New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@influxdata/influxdb3-client-browser

Package Overview
Dependencies
Maintainers
11
Versions
380
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@influxdata/influxdb3-client-browser - npm Package Compare versions

Comparing version 0.3.0-nightly.2049 to 0.3.0-nightly.2105

12

dist/index.browser.js

@@ -6,9 +6,9 @@ (function (global, factory) {

})(this, (function (exports) {
"use strict";var influxdb=(()=>{var he=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var Gt=Object.prototype.hasOwnProperty;var H=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Xt=(n,e)=>{for(var t in e)he(n,t,{get:e[t],enumerable:!0})},Zt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ht(e))!Gt.call(n,i)&&i!==t&&he(n,i,{get:()=>e[i],enumerable:!(r=Kt(e,i))||r.enumerable});return n};var Yt=n=>Zt(he({},"__esModule",{value:!0}),n);var yr={};Xt(yr,{AbortError:()=>v,DEFAULT_ConnectionOptions:()=>zt,DEFAULT_WriteOptions:()=>be,HttpError:()=>E,IllegalArgumentError:()=>B,InfluxDBClient:()=>K,Log:()=>D,Point:()=>L,RequestTimedOutError:()=>de,collectAll:()=>ut,consoleLogger:()=>Qe,convertTime:()=>Oe,convertTimeToNanos:()=>xe,createTextDecoderCombiner:()=>ge,currentTime:()=>ot,dateToProtocolTimestamp:()=>at,escape:()=>C,setLogger:()=>Qt,useProcessHrtime:()=>st,writableDataToLineProtocol:()=>ke});var B=class n extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,n.prototype)}},E=class n extends Error{constructor(t,r,i,s,o){super();this.statusCode=t;this.statusMessage=r;this.body=i;this.contentType=s;if(Object.setPrototypeOf(this,n.prototype),o)this.message=o;else if(i){if(s!=null&&s.startsWith("application/json"))try{this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code}catch(a){}this.message||(this.message=`${t} ${r} : ${i}`)}else this.message=`${t} ${r}`;this.name="HttpError"}},de=class n extends Error{constructor(){super(),Object.setPrototypeOf(this,n.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},v=class n extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,n.prototype),this.message="Response aborted"}};function ge(){let n=new TextDecoder("utf-8");return{concat(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r},copy(e,t,r){let i=new Uint8Array(r-t);return i.set(e.subarray(t,r)),i},toUtf8String(e,t,r){return n.decode(e.subarray(t,r))}}}var zt={timeout:1e4},be={precision:"ns",gzipThreshold:1e3};var Qe={error(n,e){console.error(`ERROR: ${n}`,e||"")},warn(n,e){console.warn(`WARN: ${n}`,e||"")}},G=Qe,D={error(n,e){G.error(n,e)},warn(n,e){G.warn(n,e)}};function Qt(n){let e=G;return G=n,e}function ye(n,e){return function(t){let r="",i=0,s=0;for(;s<t.length;){let o=n.indexOf(t[s]);o>=0&&(r+=t.substring(i,s),r+=e[o],i=s+1),s++}return i==0?t:(i<t.length&&(r+=t.substring(i,t.length)),r)}}function er(n,e){let t=ye(n,e);return r=>`"${t(r)}"`}var C={measurement:ye(`,
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:er('"\\',['\\"',"\\\\"]),tag:ye(`, =
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var it="000000000";function st(n){return!1}st(!0);var et=Date.now(),we=0;function Te(){{let n=Date.now();n!==et?(et=n,we=0):we++;let e=String(we);return String(n)+it.substr(0,6-e.length)+e}}function tt(){return String(Date.now())+it.substr(0,3)}function rt(){return String(Date.now())}function nt(){return String(Math.floor(Date.now()/1e3))}var ot={s:nt,ms:rt,us:tt,ns:Te,seconds:nt,millis:rt,micros:tt,nanos:Te},at={s:n=>`${Math.floor(n.getTime()/1e3)}`,ms:n=>`${n.getTime()}`,us:n=>`${n.getTime()}000`,ns:n=>`${n.getTime()}000000`};function xe(n){return n===void 0?Te():typeof n=="string"?n.length>0?n:void 0:n instanceof Date?`${n.getTime()}000000`:String(typeof n=="number"?Math.floor(n):n)}var Oe=(n,e="ns")=>n===void 0?ot[e]():typeof n=="string"?n.length>0?n:void 0:n instanceof Date?at[e](n):String(typeof n=="number"?Math.floor(n):n);var L=class n{constructor(e){this._tags={};this.fields={};e&&(this._name=e)}measurement(e){return this._name=e,this}tag(e,t){return this._tags[e]=t,this}booleanField(e,t){return this.fields[e]=t?"T":"F",this}intField(e,t){let r;if(typeof t=="number"?r=t:r=parseInt(String(t)),isNaN(r)||r<=-9223372036854776e3||r>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${t}'!`);return this.fields[e]=`${Math.floor(r)}i`,this}uintField(e,t){if(typeof t=="number"){if(isNaN(t)||t<0||t>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${e}' out of range: ${t}`);this.fields[e]=`${Math.floor(t)}u`}else{let r=String(t);for(let i=0;i<r.length;i++){let s=r.charCodeAt(i);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${i}: ${t}`)}if(r.length>20||r.length===20&&r.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${r}`);this.fields[e]=`${r}u`}return this}floatField(e,t){let r;if(typeof t=="number"?r=t:r=parseFloat(t),!isFinite(r))throw new Error(`invalid float value for field '${e}': '${t}'!`);return this.fields[e]=String(r),this}stringField(e,t){return t!=null&&(typeof t!="string"&&(t=String(t)),this.fields[e]=C.quoted(t)),this}timestamp(e){return this._time=e,this}toLineProtocol(e){if(!this._name)return;let t="";if(Object.keys(this.fields).sort().forEach(o=>{if(o){let a=this.fields[o];t.length>0&&(t+=","),t+=`${C.tag(o)}=${a}`}}),t.length===0)return;let r="",i=this._tags;Object.keys(i).sort().forEach(o=>{if(o){let a=i[o];a&&(r+=",",r+=`${C.tag(o)}=${C.tag(a)}`)}});let s=this._time;return e?typeof e=="string"?s=Oe(s,e):s=e(s):s=xe(s),`${C.measurement(this._name)}${r} ${t}${s!==void 0?` ${s}`:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}static fromRecord(e){let{measurement:t,fields:r,tags:i,timestamp:s}=e;if(!t)throw new Error("measurement must be defined on the Point record!");if(!r)throw new Error("fields must be defined on the Point record!");let o=new n(t);s!==void 0&&o.timestamp(s);for(let[a,f]of Object.entries(r))if(typeof f=="number")o.floatField(a,f);else if(typeof f=="string")o.stringField(a,f);else throw new Error(`unsuported type of field ${a}: ${typeof f}`);if(i)for(let[a,f]of Object.entries(i))if(typeof f=="string")o.tag(a,f);else throw new Error(`tag has to be string ${a}: ${typeof f}`);return o}};var Ie=n=>{throw n},ft=n=>n!==void 0,lt=n=>n instanceof Array||n instanceof Object&&typeof n.length=="number"&&(n.length===0||Object.getOwnPropertyNames(n).some(e=>e==="0")),ct=n=>{let e=new Uint8Array(4);return e[0]=n>>0,e[1]=n>>8,e[2]=n>>16,e[3]=n>>24,e},ut=async n=>{let e=[];for await(let t of n)e.push(t);return e};var ke=n=>{let e=lt(n)&&typeof n!="string"?Array.from(n):[n];if(e.length===0)return[];let t=typeof e[0]=="string",r=e[0]instanceof L;return t?e:(r?e:e.map(L.fromRecord)).map(i=>i.toLineProtocol()).filter(ft)};function Ne(n={}){let e=0,t={next:r=>{if(e===0&&n.next&&r!==null&&r!==void 0)return n.next(r)},error:r=>{e===0&&(e=1,n.error&&n.error(r))},complete:()=>{e===0&&(e=2,n.complete&&n.complete())},responseStarted:(r,i)=>{n.responseStarted&&n.responseStarted(r,i)}};return n.useCancellable&&(t.useCancellable=n.useCancellable.bind(n)),n.useResume&&(t.useResume=n.useResume.bind(n)),t}function pt(n){let e={};return n.headers.forEach((t,r)=>{let i=e[r];i===void 0?e[r]=t:Array.isArray(i)?i.push(t):e[r]=[i,t]}),e}var W=class{constructor(e){this._connectionOptions=e;this.chunkCombiner=ge();this.requestDecorator=function(){};this._defaultHeaders={"content-type":"application/json; charset=utf-8",...e.headers},this._connectionOptions.token&&(this._defaultHeaders.Authorization=`Token ${this._connectionOptions.token}`),this._url=String(this._connectionOptions.host),this._url.endsWith("/")&&(this._url=this._url.substring(0,this._url.length-1)),this._url.endsWith("/api/v2")&&(this._url=this._url.substring(0,this._url.length-7),D.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this._url} !`))}send(e,t,r,i){let s=Ne(i),o=!1,a=r.signal,f,c=()=>{},u=c;if(i&&i.useCancellable){let p=new AbortController;a||(a=p.signal,r={...r,signal:a}),a.addEventListener("abort",()=>{u()}),i.useCancellable({cancel(){o=!0,p.abort()},isCancelled(){return o||a.aborted}})}this._fetch(e,t,r).then(async p=>{if(i!=null&&i.responseStarted&&s.responseStarted(pt(p),p.status),await this._throwOnErrorResponse(p),p.body){let m=p.body.getReader(),d;do{if(f&&await f,o)break;if(d=await m.read(),s.next(d.value)===!1){let b=s.useResume;if(!b){let k="Unable to pause, useResume is not configured!";return await m.cancel(k),Promise.reject(new Error(k))}f=new Promise(k=>{u=()=>{k(),f=void 0,u=c},b(u)})}}while(!d.done)}else if(p.arrayBuffer){let m=await p.arrayBuffer();s.next(new Uint8Array(m))}else{let m=await p.text();s.next(new TextEncoder().encode(m))}}).catch(p=>{o||s.error(p)}).finally(()=>s.complete())}async _throwOnErrorResponse(e){if(e.status>=300){let t="";try{if(t=await e.text(),!t){let r=e.headers.get("x-influxdb-error");r&&(t=r)}}catch(r){throw D.warn("Unable to receive error body",r),new E(e.status,e.statusText,void 0,e.headers.get("content-type"))}throw new E(e.status,e.statusText,t,e.headers.get("content-type"))}}async*iterate(e,t,r){var s;let i=await this._fetch(e,t,r);if(await this._throwOnErrorResponse(i),i.body){let o=i.body.getReader();for(;;){let{value:a,done:f}=await o.read();if(f)break;if((s=r.signal)!=null&&s.aborted)throw await i.body.cancel(),new v;yield a}}else if(i.arrayBuffer){let o=await i.arrayBuffer();yield new Uint8Array(o)}else{let o=await i.text();yield new TextEncoder().encode(o)}}async request(e,t,r,i){var c,u;let s=await this._fetch(e,t,r),{headers:o}=s,a=o.get("content-type")||"";i&&i(pt(s),s.status),await this._throwOnErrorResponse(s);let f=(u=(c=r.headers)==null?void 0:c.accept)!=null?u:a;if(f.includes("json"))return await s.json();if(f.includes("text")||f.startsWith("application/csv"))return await s.text()}_fetch(e,t,r){let{method:i,headers:s,...o}=r,a=`${this._url}${e}`,f={method:i,body:i==="GET"||i==="HEAD"?void 0:typeof t=="string"?t:JSON.stringify(t),headers:{...this._defaultHeaders,...s},credentials:"omit",...this._connectionOptions.transportOptions,...o};return this.requestDecorator(f,r,a),fetch(a,f)}};var mt=H("@protobuf-ts/grpcweb-transport"),ht=({host:n})=>new mt.GrpcWebFetchTransport({baseUrl:n});var tr={writeTransport:n=>new W(n),queryTransport:ht},M=tr;var $=class{constructor(e){this._options=e;this._closed=!1;var t;this._transport=(t=this._options.transport)!=null?t:M.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_createWritePath(e,t,r){let i=[`bucket=${encodeURIComponent(e)}`,`precision=${t.precision}`];r&&i.push(`org=${encodeURIComponent(r)}`);let s=t==null?void 0:t.consistency;return s&&i.push(`consistency=${encodeURIComponent(s)}`),`/api/v2/write?${i.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,f=new Promise((d,b)=>{o=d,a=b}),c,u={responseStarted(d,b){c=b},error(d){if(d instanceof E&&d.json&&typeof d.json.error=="string"&&d.json.error.includes("hinted handoff queue not empty")){D.warn(`Write to InfluxDB returns: ${d.json.error}`),c=204,u.complete();return}D.error("Write to InfluxDB failed.",d),a(d)},complete(){if(c==204||c==null)o();else{let d=`204 HTTP response status code expected, but ${c} returned`,b=new E(c,d,void 0,"0");b.message=d,u.error(b)}}},p={...be,...i},m={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...i==null?void 0:i.headers},gzipThreshold:p.gzipThreshold};return this._transport.send(this._createWritePath(t,p,r),e.join(`
`),m,u),f}async close(){this._closed=!0}};var $t=H("apache-arrow");var Vt=H("@protobuf-ts/runtime-rpc");function _(n){let e=typeof n;if(e=="object"){if(Array.isArray(n))return"array";if(n===null)return"null"}return e}function Ee(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}var F="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),X=[];for(let n=0;n<F.length;n++)X[F[n].charCodeAt(0)]=n;X["-".charCodeAt(0)]=F.indexOf("+");X["_".charCodeAt(0)]=F.indexOf("/");function dt(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=X[n.charCodeAt(a)],s===void 0)switch(n[a]){case"=":i=0;case`
`: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 gt(n){let e="",t=0,r,i=0;for(let s=0;s<n.length;s++)switch(r=n[s],t){case 0:e+=F[r>>2],i=(r&3)<<4,t=1;break;case 1:e+=F[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=F[i|r>>6],e+=F[r&63],t=0;break}return t&&(e+=F[i],e+="=",t==1&&(e+="=")),e}var P;(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])})(P||(P={}));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 bt(){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))return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,!(t&128))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))return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function Y(n,e,t){for(let s=0;s<28;s=s+7){let o=n>>>s,a=!(!(o>>>7)&&e==0),f=(a?o|128:o)&255;if(t.push(f),!a)return}let r=n>>>28&15|(e&7)<<4,i=!!(e>>3);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),f=(a?o|128:o)&255;if(t.push(f),!a)return}t.push(e>>>31&1)}}var Z=65536*65536;function Fe(n){let e=n[0]=="-";e&&(n=n.slice(1));let t=1e6,r=0,i=0;function s(o,a){let f=Number(n.slice(o,a));i*=t,r=r*t+f,r>=Z&&(i=i+(r/Z|0),r=r%Z)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,r,i]}function z(n,e){if(e>>>0<=2097151)return""+(Z*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,f=1e7;s>=f&&(o+=Math.floor(s/f),s%=f),o>=f&&(a+=Math.floor(o/f),o%=f);function c(u,p){let m=u?String(u):"";return p?"0000000".slice(m.length)+m:m}return c(a,0)+c(o,a)+c(s,1)}function Re(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 yt(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var y;function rr(){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}rr();function wt(n){if(!n)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Tt=/^-?[0-9]+$/,ee=4294967296,Q=2147483648,te=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*ee+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},x=class n extends te{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(),!Tt.test(e))throw new Error("string is no integer");let[t,r,i]=Fe(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/ee)}throw new Error("unknown value "+typeof e)}toString(){return y?this.toBigInt().toString():z(this.lo,this.hi)}toBigInt(){return wt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigUint64(0,!0)}};x.ZERO=new x(0,0);var g=class n extends te{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(),!Tt.test(e))throw new Error("string is no integer");let[t,r,i]=Fe(e);if(t){if(i>Q||i==Q&&r!=0)throw new Error("signed long too small")}else if(i>=Q)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/ee):new n(-e,-e/ee).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&Q)!==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"-"+z(e.lo,e.hi)}return z(this.lo,this.hi)}toBigInt(){return wt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigInt64(0,!0)}};g.ZERO=new g(0,0);var xt={readUnknownField:!0,readerFactory:n=>new Ae(n)};function Ot(n){return n?Object.assign(Object.assign({},xt),n):xt}var Ae=class{constructor(e,t){this.varint64=bt,this.uint32=yt,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 g(...this.varint64())}uint64(){return new x(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,new g(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 x(this.sfixed32(),this.sfixed32())}sfixed64(){return new g(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 h(n,e){if(!n)throw new Error(e)}var nr=34028234663852886e22,ir=-34028234663852886e22,sr=4294967295,or=2147483647,ar=-2147483648;function A(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>or||n<ar)throw new Error("invalid int 32: "+n)}function U(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>sr||n<0)throw new Error("invalid uint 32: "+n)}function V(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>nr||n<ir))throw new Error("invalid float 32: "+n)}var It={writeUnknownFields:!0,writerFactory:()=>new Se};function kt(n){return n?Object.assign(Object.assign({},It),n):It}var Se=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(U(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return A(e),Re(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){V(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){U(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){A(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return A(e),e=(e<<1^e>>31)>>>0,Re(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=g.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=x.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=g.from(e);return Y(t.lo,t.hi,this.buf),this}sint64(e){let t=g.from(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return Y(i,s,this.buf),this}uint64(e){let t=x.from(e);return Y(t.lo,t.hi,this.buf),this}};var Nt={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Et={ignoreUnknownFields:!1};function Ft(n){return n?Object.assign(Object.assign({},Et),n):Et}function Rt(n){return n?Object.assign(Object.assign({},Nt),n):Nt}var At=Symbol.for("protobuf-ts/message-type");function De(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 l;(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"})(l||(l={}));var O;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING",n[n.NUMBER=2]="NUMBER"})(O||(O={}));var J;(function(n){n[n.NO=0]="NO",n[n.PACKED=1]="PACKED",n[n.UNPACKED=2]="UNPACKED"})(J||(J={}));function St(n){var e,t,r,i;return n.localName=(e=n.localName)!==null&&e!==void 0?e:De(n.name),n.jsonName=(t=n.jsonName)!==null&&t!==void 0?t:De(n.name),n.repeat=(r=n.repeat)!==null&&r!==void 0?r:J.NO,n.opt=(i=n.opt)!==null&&i!==void 0?i:n.repeat||n.oneof?!1:n.kind=="message",n}function Dt(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 re=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(!Dt(a))return!1;if(a.oneofKind===void 0)continue;let f=this.fields.find(c=>c.localName===a.oneofKind);if(!f||!this.field(a[a.oneofKind],f,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,l.INT32,i):this.scalar(e,l.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),l.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 l.UINT64:case l.FIXED64:case l.INT64:case l.SFIXED64:case l.SINT64:switch(r){case O.BIGINT:return i=="bigint";case O.NUMBER:return i=="number"&&!isNaN(e);default:return i=="string"}case l.BOOL:return i=="boolean";case l.STRING:return i=="string";case l.BYTES:return e instanceof Uint8Array;case l.DOUBLE:case l.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 l.INT32:case l.FIXED32:case l.SFIXED32:case l.SINT32:case l.UINT32:return this.scalars(i.slice(0,r).map(s=>parseInt(s)),t,r);case l.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,O.STRING)}}};function I(n,e){switch(e){case O.BIGINT:return n.toBigInt();case O.NUMBER:return n.toNumber();default:return n.toString()}}var ne=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=_(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 f=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:f}}else c=t;if(a.kind=="map"){if(o===null)continue;this.assert(Ee(o),a.name,o);let u=c[f];for(let[p,m]of Object.entries(o)){this.assert(m!==null,a.name+" map value",null);let d;switch(a.V.kind){case"message":d=a.V.T().internalJsonRead(m,r);break;case"enum":if(d=this.enum(a.V.T(),m,a.name,r.ignoreUnknownFields),d===!1)continue;break;case"scalar":d=this.scalar(m,a.V.T,a.V.L,a.name);break}this.assert(d!==void 0,a.name+" map value",m);let b=p;a.K==l.BOOL&&(b=b=="true"?!0:b=="false"?!1:b),b=this.scalar(b,a.K,O.STRING,a.name).toString(),u[b]=d}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let u=c[f];for(let p of o){this.assert(p!==null,a.name,null);let m;switch(a.kind){case"message":m=a.T().internalJsonRead(p,r);break;case"enum":if(m=this.enum(a.T(),p,a.name,r.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(p,a.T,a.L,a.name);break}this.assert(m!==void 0,a.name,o),u.push(m)}}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[f]=a.T().internalJsonRead(o,r,c[f]);break;case"enum":let u=this.enum(a.T(),o,a.name,r.ignoreUnknownFields);if(u===!1)continue;c[f]=u;break;case"scalar":c[f]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,r,i){if(e[0]=="google.protobuf.NullValue"&&h(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 h(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:(h(typeof o=="number",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} has no value for "${t}".`),o)}h(!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 l.DOUBLE:case l.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==l.FLOAT&&V(o),o;case l.INT32:case l.FIXED32:case l.SFIXED32:case l.SINT32:case l.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==l.UINT32?U(a):A(a),a;case l.INT64:case l.SFIXED64:case l.SINT64:if(e===null)return I(g.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return I(g.from(e),r);case l.FIXED64:case l.UINT64:if(e===null)return I(x.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return I(x.from(e),r);case l.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case l.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(f){f="invalid UTF8";break}return e;case l.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return dt(e)}}catch(o){s=o.message}this.assert(!1,i+(s?" - "+s:""),e)}};var ie=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,f=this.field(s,o[s.localName],a);h(f!==void 0),r[t.useProtoFieldName?s.name:s.jsonName]=f}return r}field(e,t,r){let i;if(e.kind=="map"){h(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[f,c]of Object.entries(t)){let u=this.scalar(e.V.T,c,e.name,!1,!0);h(u!==void 0),s[f.toString()]=u}break;case"message":let o=e.V.T();for(let[f,c]of Object.entries(t)){let u=this.message(o,c,e.name,r);h(u!==void 0),s[f.toString()]=u}break;case"enum":let a=e.V.T();for(let[f,c]of Object.entries(t)){h(c===void 0||typeof c=="number");let u=this.enum(a,c,e.name,!1,!0,r.enumAsInteger);h(u!==void 0),s[f.toString()]=u}break}(r.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){h(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let f=0;f<t.length;f++){let c=this.scalar(e.T,t[f],e.name,e.opt,!0);h(c!==void 0),s.push(c)}break;case"enum":let o=e.T();for(let f=0;f<t.length;f++){h(t[f]===void 0||typeof t[f]=="number");let c=this.enum(o,t[f],e.name,e.opt,!0,r.enumAsInteger);h(c!==void 0),s.push(c)}break;case"message":let a=e.T();for(let f=0;f<t.length;f++){let c=this.message(a,t[f],e.name,r);h(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){h(i);return}if(!(t===0&&!s&&!i))return h(typeof t=="number"),h(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){h(i);return}let o=s||i;switch(e){case l.INT32:case l.SFIXED32:case l.SINT32:return t===0?o?0:void 0:(A(t),t);case l.FIXED32:case l.UINT32:return t===0?o?0:void 0:(U(t),t);case l.FLOAT:V(t);case l.DOUBLE:return t===0?o?0:void 0:(h(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case l.STRING:return t===""?o?"":void 0:(h(typeof t=="string"),t);case l.BOOL:return t===!1?o?!1:void 0:(h(typeof t=="boolean"),t);case l.UINT64:case l.FIXED64:h(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=x.from(t);return a.isZero()&&!o?void 0:a.toString();case l.INT64:case l.SFIXED64:case l.SINT64:h(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let f=g.from(t);return f.isZero()&&!o?void 0:f.toString();case l.BYTES:return h(t instanceof Uint8Array),t.byteLength?gt(t):o?"":void 0}}};function q(n,e=O.STRING){switch(n){case l.BOOL:return!1;case l.UINT64:case l.FIXED64:return I(x.ZERO,e);case l.INT64:case l.SFIXED64:case l.SINT64:return I(g.ZERO,e);case l.DOUBLE:case l.FLOAT:return 0;case l.BYTES:return new Uint8Array(0);case l.STRING:return"";default:return 0}}var se=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(),f=this.fieldNoToField.get(o);if(!f){let m=r.readUnknownField;if(m=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let d=e.skip(a);m!==!1&&(m===!0?P.onRead:m)(this.info.typeName,t,o,a,d);continue}let c=t,u=f.repeat,p=f.localName;switch(f.oneof&&(c=c[f.oneof],c.oneofKind!==p&&(c=t[f.oneof]={oneofKind:p})),f.kind){case"scalar":case"enum":let m=f.kind=="enum"?l.INT32:f.T,d=f.kind=="scalar"?f.L:void 0;if(u){let S=c[p];if(a==T.LengthDelimited&&m!=l.STRING&&m!=l.BYTES){let R=e.uint32()+e.pos;for(;e.pos<R;)S.push(this.scalar(e,m,d))}else S.push(this.scalar(e,m,d))}else c[p]=this.scalar(e,m,d);break;case"message":if(u){let S=c[p],R=f.T().internalBinaryRead(e,e.uint32(),r);S.push(R)}else c[p]=f.T().internalBinaryRead(e,e.uint32(),r,c[p]);break;case"map":let[b,k]=this.mapEntry(f,e,r);c[p][b]=k;break}}}mapEntry(e,t,r){let i=t.uint32(),s=t.pos+i,o,a;for(;t.pos<s;){let[f,c]=t.tag();switch(f){case 1:e.K==l.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,O.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 ${f} (wire type ${c}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let f=q(e.K);o=e.K==l.BOOL?f.toString():f}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 l.INT32:return e.int32();case l.STRING:return e.string();case l.BOOL:return e.bool();case l.DOUBLE:return e.double();case l.FLOAT:return e.float();case l.INT64:return I(e.int64(),r);case l.UINT64:return I(e.uint64(),r);case l.FIXED64:return I(e.fixed64(),r);case l.FIXED32:return e.fixed32();case l.BYTES:return e.bytes();case l.UINT32:return e.uint32();case l.SFIXED32:return e.sfixed32();case l.SFIXED64:return I(e.sfixed64(),r);case l.SINT32:return e.sint32();case l.SINT64:return I(e.sint64(),r)}}};var oe=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,f=s.repeat,c=s.localName;if(s.oneof){let u=e[s.oneof];if(u.oneofKind!==c)continue;o=u[c],a=!0}else o=e[c],a=!1;switch(s.kind){case"scalar":case"enum":let u=s.kind=="enum"?l.INT32:s.T;if(f)if(h(Array.isArray(o)),f==J.PACKED)this.packed(t,u,s.no,o);else for(let p of o)this.scalar(t,u,s.no,p,!0);else o===void 0?h(s.opt):this.scalar(t,u,s.no,o,a||s.opt);break;case"message":if(f){h(Array.isArray(o));for(let p of o)this.message(t,r,s.T(),s.no,p)}else this.message(t,r,s.T(),s.no,o);break;case"map":h(typeof o=="object"&&o!==null);for(let[p,m]of Object.entries(o))this.mapEntry(t,r,s,p,m);break}}let i=r.writeUnknownFields;i!==!1&&(i===!0?P.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 l.INT32:case l.FIXED32:case l.UINT32:case l.SFIXED32:case l.SINT32:o=Number.parseInt(i);break;case l.BOOL:h(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,l.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,f]=this.scalarInfo(t,i);(!f||s)&&(e.tag(r,o),e[a](i))}packed(e,t,r,i){if(!i.length)return;h(t!==l.BYTES&&t!==l.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 l.INT32:i="int32";break;case l.STRING:o=s||!t.length,r=T.LengthDelimited,i="string";break;case l.BOOL:o=t===!1,i="bool";break;case l.UINT32:i="uint32";break;case l.DOUBLE:r=T.Bit64,i="double";break;case l.FLOAT:r=T.Bit32,i="float";break;case l.INT64:o=s||g.from(t).isZero(),i="int64";break;case l.UINT64:o=s||x.from(t).isZero(),i="uint64";break;case l.FIXED64:o=s||x.from(t).isZero(),r=T.Bit64,i="fixed64";break;case l.BYTES:o=s||!t.byteLength,r=T.LengthDelimited,i="bytes";break;case l.FIXED32:r=T.Bit32,i="fixed32";break;case l.SFIXED32:r=T.Bit32,i="sfixed32";break;case l.SFIXED64:o=s||g.from(t).isZero(),r=T.Bit64,i="sfixed64";break;case l.SINT32:i="sint32";break;case l.SINT64:o=s||g.from(t).isZero(),i="sint64";break}return[r,i,s||o]}};function Ct(n){let e={};Object.defineProperty(e,At,{enumerable:!1,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 ae(n,e,t){let r,i=t,s;for(let o of n.fields){let a=o.localName;if(o.oneof){let f=i[o.oneof];if((f==null?void 0:f.oneofKind)==null)continue;if(r=f[a],s=e[o.oneof],s.oneofKind=f.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 f=o.T();if(o.repeat)for(let c=0;c<r.length;c++)s[a][c]=f.create(r[c]);else s[a]===void 0?s[a]=f.create(r):f.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 u of Object.keys(r))s[a][u]=c.create(r[u]);break}break}}}function Bt(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"?l.INT32:r.T;if(!(r.repeat?_t(a,s,o):Lt(a,s,o)))return!1;break;case"map":if(!(r.V.kind=="message"?Ut(r.V.T(),fe(s),fe(o)):_t(r.V.kind=="enum"?l.INT32:r.V.T,fe(s),fe(o))))return!1;break;case"message":let f=r.T();if(!(r.repeat?Ut(f,s,o):f.equals(s,o)))return!1;break}}return!0}var fe=Object.values;function Lt(n,e,t){if(e===t)return!0;if(n!==l.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 _t(n,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Lt(n,e[r],t[r]))return!1;return!0}function Ut(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 w=class{constructor(e,t,r){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(St),this.options=r!=null?r:{},this.refTypeCheck=new re(this),this.refJsonReader=new ne(this),this.refJsonWriter=new ie(this),this.refBinReader=new se(this),this.refBinWriter=new oe(this)}create(e){let t=Ct(this);return e!==void 0&&ae(this,t,e),t}clone(e){let t=this.create();return ae(this,t,e),t}equals(e,t){return Bt(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){ae(this,e,t)}fromBinary(e,t){let r=Ot(t);return this.internalBinaryRead(r.readerFactory(e),e.byteLength,r)}fromJson(e,t){return this.internalJsonRead(e,Ft(t))}fromJsonString(e,t){let r=JSON.parse(e);return this.fromJson(r,t)}toJson(e,t){return this.internalJsonWrite(e,Rt(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=kt(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 ${_(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 Ce=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=g.from(Math.floor(t/1e3)).toBigInt(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(g.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),r=e.getTime();return t.seconds=g.from(Math.floor(r/1e3)).toBigInt(),t.nanos=r%1e3*1e6,t}internalJsonWrite(e,t){let r=g.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 "+_(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=g.from(s/1e3).toBigInt(),r.nanos=0,i[7]&&(r.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),r}},Pt=new Ce;var vt=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.PATH=1]="PATH",r[r.CMD=2]="CMD",r))(vt||{}),Wt=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.CANCELLED=1]="CANCELLED",i[i.CANCELLING=2]="CANCELLING",i[i.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",i))(Wt||{}),_e=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}])}},fr=new _e,Ue=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}])}},lr=new Ue,Be=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}])}},Li=new Be,Le=class extends w{constructor(){super("arrow.flight.protocol.Empty",[])}},cr=new Le,Pe=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}])}},ur=new Pe,Ve=class extends w{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},pr=new Ve,ve=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}])}},mr=new ve,We=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>He}])}},Pi=new We,Me=class extends w{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>Mt}])}},Vi=new Me,$e=class extends w{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},hr=new $e,Je=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Wt,"CANCEL_STATUS_"]}])}},vi=new Je,qe=class extends w{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},dr=new qe,je=class extends w{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",vt]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},ce=new je,Ke=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:()=>ce},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>Mt},{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}])}},He=new Ke,Ge=class extends w{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>ue},{no:2,name:"location",kind:"message",repeat:1,T:()=>gr},{no:3,name:"expiration_time",kind:"message",T:()=>Pt}])}},Mt=new Ge,Xe=class extends w{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},gr=new Xe,Ze=class extends w{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},ue=new Ze,Ye=class extends w{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>ce},{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}])}},le=new Ye,ze=class extends w{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},br=new ze,pe=new Vt.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:fr,O:lr},{name:"ListFlights",serverStreaming:!0,options:{},I:pr,O:He},{name:"GetFlightInfo",options:{},I:ce,O:He},{name:"GetSchema",options:{},I:ce,O:dr},{name:"DoGet",serverStreaming:!0,options:{},I:ue,O:le},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:le,O:br},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:le,O:le},{name:"DoAction",serverStreaming:!0,options:{},I:mr,O:hr},{name:"ListActions",serverStreaming:!0,options:{},I:cr,O:ur}]);var N=H("@protobuf-ts/runtime-rpc"),me=class{constructor(e){this._transport=e;this.typeName=pe.typeName;this.methods=pe.methods;this.options=pe.options}handshake(e){let t=this.methods[0],r=this._transport.mergeOptions(e);return(0,N.stackIntercept)("duplex",this._transport,t,r)}listFlights(e,t){let r=this.methods[1],i=this._transport.mergeOptions(t);return(0,N.stackIntercept)("serverStreaming",this._transport,r,i,e)}getFlightInfo(e,t){let r=this.methods[2],i=this._transport.mergeOptions(t);return(0,N.stackIntercept)("unary",this._transport,r,i,e)}getSchema(e,t){let r=this.methods[3],i=this._transport.mergeOptions(t);return(0,N.stackIntercept)("unary",this._transport,r,i,e)}doGet(e,t){let r=this.methods[4],i=this._transport.mergeOptions(t);return(0,N.stackIntercept)("serverStreaming",this._transport,r,i,e)}doPut(e){let t=this.methods[5],r=this._transport.mergeOptions(e);return(0,N.stackIntercept)("duplex",this._transport,t,r)}doExchange(e){let t=this.methods[6],r=this._transport.mergeOptions(e);return(0,N.stackIntercept)("duplex",this._transport,t,r)}doAction(e,t){let r=this.methods[7],i=this._transport.mergeOptions(t);return(0,N.stackIntercept)("serverStreaming",this._transport,r,i,e)}listActions(e,t){let r=this.methods[8],i=this._transport.mergeOptions(t);return(0,N.stackIntercept)("serverStreaming",this._transport,r,i,e)}};var j=class{constructor(e){this._options=e;this._closed=!1;this._transport=M.queryTransport(this._options),this._flightClient=new me(this._transport)}async*query(e,t,r){var d;if(this._closed)throw new Error("queryApi: already closed!");let i=this._flightClient,s={database:t,sql_query:e,query_type:r},o=ue.create({ticket:new TextEncoder().encode(JSON.stringify(s))}),a={},f=this._options.token;f&&(a.authorization=`Bearer ${f}`);let c={meta:a},u=i.doGet(o,c),p=async function*(){for await(let b of u.responses)yield ct(b.dataHeader.length),yield b.dataHeader,yield b.dataBody}(),m=await $t.RecordBatchReader.from(p);for await(let b of m)for(let k=0;k<b.numRows;k++){let S={};for(let R=0;R<b.numCols;R++){let qt=b.schema.fields[R].name,jt=(d=b.getChildAt(R))==null?void 0:d.get(k);S[qt]=jt}yield S}}async close(){var e,t;this._closed=!0,(t=(e=this._transport).close)==null||t.call(e)}};var Jt=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
`,K=class{constructor(e){this._mergeWriteOptions=e=>({...this._options.writeOptions,...e});if(e==null)throw new B("No configuration specified!");this._options=e;let t=this._options.host;if(typeof t!="string")throw new B("No host specified!");t.endsWith("/")&&(this._options.host=t.substring(0,t.length-1)),this._queryApi=new j(this._options),this._writeApi=new $(this._options)}async write(e,t,r,i){var s;await this._writeApi.doWrite(ke(e),(s=t!=null?t:this._options.database)!=null?s:Ie(new Error(Jt)),r,this._mergeWriteOptions(i))}query(e,t,r="sql"){var i;return this._queryApi.query(e,(i=t!=null?t:this._options.database)!=null?i:Ie(new Error(Jt)),r)}async close(){await this._writeApi.close(),await this._queryApi.close()}};return Yt(yr);})();
"use strict";var influxdb=(()=>{var ye=Object.defineProperty;var Gt=Object.getOwnPropertyDescriptor;var Kt=Object.getOwnPropertyNames;var Ht=Object.prototype.hasOwnProperty;var K=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Xt=(n,e)=>{for(var t in e)ye(n,t,{get:e[t],enumerable:!0})},Zt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Kt(e))!Ht.call(n,i)&&i!==t&&ye(n,i,{get:()=>e[i],enumerable:!(r=Gt(e,i))||r.enumerable});return n};var Qt=n=>Zt(ye({},"__esModule",{value:!0}),n);var Tr={};Xt(Tr,{AbortError:()=>V,DEFAULT_ConnectionOptions:()=>Yt,DEFAULT_WriteOptions:()=>xe,GetFieldTypeMissmatchError:()=>Z,HttpError:()=>N,IllegalArgumentError:()=>U,InfluxDBClient:()=>G,Log:()=>A,Point:()=>v,PointValues:()=>R,RequestTimedOutError:()=>we,collectAll:()=>dt,consoleLogger:()=>nt,convertTime:()=>Ne,convertTimeToNanos:()=>ke,createTextDecoderCombiner:()=>Te,currentTime:()=>ft,dateToProtocolTimestamp:()=>ct,escape:()=>D,setLogger:()=>zt,useProcessHrtime:()=>ut,writableDataToLineProtocol:()=>Ee});var U=class n extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,n.prototype)}},N=class n extends Error{constructor(t,r,i,s,o){super();this.statusCode=t;this.statusMessage=r;this.body=i;this.contentType=s;if(Object.setPrototypeOf(this,n.prototype),o)this.message=o;else if(i){if(s!=null&&s.startsWith("application/json"))try{this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code}catch(a){}this.message||(this.message=`${t} ${r} : ${i}`)}else this.message=`${t} ${r}`;this.name="HttpError"}},we=class n extends Error{constructor(){super(),Object.setPrototypeOf(this,n.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},V=class n extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,n.prototype),this.message="Response aborted"}};function Te(){let n=new TextDecoder("utf-8");return{concat(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r},copy(e,t,r){let i=new Uint8Array(r-t);return i.set(e.subarray(t,r)),i},toUtf8String(e,t,r){return n.decode(e.subarray(t,r))}}}var Yt={timeout:1e4},xe={precision:"ns",gzipThreshold:1e3};var nt={error(n,e){console.error(`ERROR: ${n}`,e||"")},warn(n,e){console.warn(`WARN: ${n}`,e||"")}},H=nt,A={error(n,e){H.error(n,e)},warn(n,e){H.warn(n,e)}};function zt(n){let e=H;return H=n,e}function Fe(n,e){return function(t){let r="",i=0,s=0;for(;s<t.length;){let o=n.indexOf(t[s]);o>=0&&(r+=t.substring(i,s),r+=e[o],i=s+1),s++}return i==0?t:(i<t.length&&(r+=t.substring(i,t.length)),r)}}function er(n,e){let t=Fe(n,e);return r=>`"${t(r)}"`}var D={measurement:Fe(`,
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:er('"\\',['\\"',"\\\\"]),tag:Fe(`, =
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var lt="000000000";function ut(n){return!1}ut(!0);var it=Date.now(),Ie=0;function Oe(){{let n=Date.now();n!==it?(it=n,Ie=0):Ie++;let e=String(Ie);return String(n)+lt.substr(0,6-e.length)+e}}function st(){return String(Date.now())+lt.substr(0,3)}function ot(){return String(Date.now())}function at(){return String(Math.floor(Date.now()/1e3))}var ft={s:at,ms:ot,us:st,ns:Oe,seconds:at,millis:ot,micros:st,nanos:Oe},ct={s:n=>`${Math.floor(n.getTime()/1e3)}`,ms:n=>`${n.getTime()}`,us:n=>`${n.getTime()}000`,ns:n=>`${n.getTime()}000000`};function ke(n){return n===void 0?Oe():typeof n=="string"?n.length>0?n:void 0:n instanceof Date?`${n.getTime()}000000`:String(typeof n=="number"?Math.floor(n):n)}var Ne=(n,e="ns")=>n===void 0?ft[e]():typeof n=="string"?n.length>0?n:void 0:n instanceof Date?ct[e](n):String(typeof n=="number"?Math.floor(n):n);var X=n=>{throw n},pt=n=>n!==void 0,mt=n=>n instanceof Array||n instanceof Object&&typeof n.length=="number"&&(n.length===0||Object.getOwnPropertyNames(n).some(e=>e==="0")),ht=n=>{let e=new Uint8Array(4);return e[0]=n>>0,e[1]=n>>8,e[2]=n>>16,e[3]=n>>24,e},dt=async n=>{let e=[];for await(let t of n)e.push(t);return e};var Ee=n=>{let e=mt(n)&&typeof n!="string"?Array.from(n):[n];return e.length===0?[]:typeof e[0]=="string"?e:e.map(r=>r.toLineProtocol()).filter(pt)};var tr=n=>typeof n=="number"?"float":typeof n=="string"?"string":typeof n=="boolean"?"boolean":void 0,Z=class n extends Error{constructor(e,t,r){super(`field ${e} of type ${r} doesn't match expected type ${t}!`),this.name="GetFieldTypeMissmatchError",Object.setPrototypeOf(this,n.prototype)}},R=class n{constructor(){this._tags={};this._fields={}}getMeasurement(){return this._name}setMeasurement(e){return this._name=e,this}getTimestamp(){return this._time}setTimestamp(e){return this._time=e,this}getTag(e){return this._tags[e]}setTag(e,t){return this._tags[e]=t,this}removeTag(e){return delete this._tags[e],this}getTagNames(){return Object.keys(this._tags)}getFloatField(e){return this.getField(e,"float")}setFloatField(e,t){let r;if(typeof t=="number"?r=t:r=parseFloat(t),!isFinite(r))throw new Error(`invalid float value for field '${e}': '${t}'!`);return this._fields[e]=["float",r],this}getIntegerField(e){return this.getField(e,"integer")}setIntegerField(e,t){let r;if(typeof t=="number"?r=t:r=parseInt(String(t)),isNaN(r)||r<=-9223372036854776e3||r>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${t}'!`);return this._fields[e]=["integer",Math.floor(r)],this}getUintegerField(e){return this.getField(e,"uinteger")}setUintegerField(e,t){if(typeof t=="number"){if(isNaN(t)||t<0||t>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${e}' out of range: ${t}`);this._fields[e]=["uinteger",Math.floor(t)]}else{let r=String(t);for(let i=0;i<r.length;i++){let s=r.charCodeAt(i);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${i}: ${t}`)}if(r.length>20||r.length===20&&r.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${r}`);this._fields[e]=["uinteger",+r]}return this}getStringField(e){return this.getField(e,"string")}setStringField(e,t){return t!=null&&(typeof t!="string"&&(t=String(t)),this._fields[e]=["string",t]),this}getBooleanField(e){return this.getField(e,"boolean")}setBooleanField(e,t){return this._fields[e]=["boolean",!!t],this}getField(e,t){let r=this._fields[e];if(!r)return;let[i,s]=r;if(t!==void 0&&t!==i)throw new Z(e,t,i);return s}getFieldType(e){let t=this._fields[e];if(t)return t[0]}setField(e,t,r){switch(r!=null?r:tr(t)){case"string":return this.setStringField(e,t);case"boolean":return this.setBooleanField(e,t);case"float":return this.setFloatField(e,t);case"integer":return this.setIntegerField(e,t);case"uinteger":return this.setUintegerField(e,t);case void 0:return this;default:throw new Error(`invalid field type for field '${e}': type -> ${r}, value -> ${t}!`)}}setFields(e){for(let[t,r]of Object.entries(e))this.setField(t,r);return this}removeField(e){return delete this._fields[e],this}getFieldNames(){return Object.keys(this._fields)}hasFields(){return this.getFieldNames().length>0}copy(){let e=new n;return e._name=this._name,e._time=this._time,e._tags=Object.fromEntries(Object.entries(this._tags)),e._fields=Object.fromEntries(Object.entries(this._fields).map(t=>[...t])),e}asPoint(e){return v.fromValues(e?this.setMeasurement(e):this)}};var rr=(n,e)=>{switch(n){case"string":return D.quoted(e);case"boolean":return e?"T":"F";case"float":return`${e}`;case"integer":return`${e}i`;case"uinteger":return`${e}u`}},v=class n{constructor(e){e instanceof R?this._values=e:this._values=new R,typeof e=="string"&&this._values.setMeasurement(e)}static measurement(e){return new n(e)}static fromValues(e){if(!e.getMeasurement()||e.getMeasurement()==="")throw new Error("Cannot convert values to point without measurement set!");return new n(e)}getMeasurement(){return this._values.getMeasurement()}setMeasurement(e){return e!==""&&this._values.setMeasurement(e),this}getTimestamp(){return this._values.getTimestamp()}setTimestamp(e){return this._values.setTimestamp(e),this}getTag(e){return this._values.getTag(e)}setTag(e,t){return this._values.setTag(e,t),this}removeTag(e){return this._values.removeTag(e),this}getTagNames(){return this._values.getTagNames()}getFloatField(e){return this._values.getFloatField(e)}setFloatField(e,t){return this._values.setFloatField(e,t),this}getIntegerField(e){return this._values.getIntegerField(e)}setIntegerField(e,t){return this._values.setIntegerField(e,t),this}getUintegerField(e){return this._values.getUintegerField(e)}setUintegerField(e,t){return this._values.setUintegerField(e,t),this}getStringField(e){return this._values.getStringField(e)}setStringField(e,t){return this._values.setStringField(e,t),this}getBooleanField(e){return this._values.getBooleanField(e)}setBooleanField(e,t){return this._values.setBooleanField(e,t),this}getField(e,t){return this._values.getField(e,t)}getFieldType(e){return this._values.getFieldType(e)}setField(e,t,r){return this._values.setField(e,t,r),this}setFields(e){return this._values.setFields(e),this}removeField(e){return this._values.removeField(e),this}getFieldNames(){return this._values.getFieldNames()}hasFields(){return this._values.hasFields()}copy(){return new n(this._values.copy())}toLineProtocol(e){if(!this._values.getMeasurement())return;let t="";if(this._values.getFieldNames().sort().forEach(o=>{if(o){let a=this._values.getFieldType(o),l=this._values.getField(o);if(a===void 0||l===void 0)return;let f=rr(a,l);t.length>0&&(t+=","),t+=`${D.tag(o)}=${f}`}}),t.length===0)return;let r="";this._values.getTagNames().sort().forEach(o=>{if(o){let a=this._values.getTag(o);a&&(r+=",",r+=`${D.tag(o)}=${D.tag(a)}`)}});let s=this._values.getTimestamp();return e?typeof e=="string"?s=Ne(s,e):s=e(s):s=ke(s),`${D.measurement(this.getMeasurement())}${r} ${t}${s!==void 0?` ${s}`:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}};function Re(n={}){let e=0,t={next:r=>{if(e===0&&n.next&&r!==null&&r!==void 0)return n.next(r)},error:r=>{e===0&&(e=1,n.error&&n.error(r))},complete:()=>{e===0&&(e=2,n.complete&&n.complete())},responseStarted:(r,i)=>{n.responseStarted&&n.responseStarted(r,i)}};return n.useCancellable&&(t.useCancellable=n.useCancellable.bind(n)),n.useResume&&(t.useResume=n.useResume.bind(n)),t}function gt(n){let e={};return n.headers.forEach((t,r)=>{let i=e[r];i===void 0?e[r]=t:Array.isArray(i)?i.push(t):e[r]=[i,t]}),e}var M=class{constructor(e){this._connectionOptions=e;this.chunkCombiner=Te();this.requestDecorator=function(){};this._defaultHeaders={"content-type":"application/json; charset=utf-8",...e.headers},this._connectionOptions.token&&(this._defaultHeaders.Authorization=`Token ${this._connectionOptions.token}`),this._url=String(this._connectionOptions.host),this._url.endsWith("/")&&(this._url=this._url.substring(0,this._url.length-1)),this._url.endsWith("/api/v2")&&(this._url=this._url.substring(0,this._url.length-7),A.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this._url} !`))}send(e,t,r,i){let s=Re(i),o=!1,a=r.signal,l,f=()=>{},c=f;if(i&&i.useCancellable){let p=new AbortController;a||(a=p.signal,r={...r,signal:a}),a.addEventListener("abort",()=>{c()}),i.useCancellable({cancel(){o=!0,p.abort()},isCancelled(){return o||a.aborted}})}this._fetch(e,t,r).then(async p=>{if(i!=null&&i.responseStarted&&s.responseStarted(gt(p),p.status),await this._throwOnErrorResponse(p),p.body){let m=p.body.getReader(),h;do{if(l&&await l,o)break;if(h=await m.read(),s.next(h.value)===!1){let T=s.useResume;if(!T){let O="Unable to pause, useResume is not configured!";return await m.cancel(O),Promise.reject(new Error(O))}l=new Promise(O=>{c=()=>{O(),l=void 0,c=f},T(c)})}}while(!h.done)}else if(p.arrayBuffer){let m=await p.arrayBuffer();s.next(new Uint8Array(m))}else{let m=await p.text();s.next(new TextEncoder().encode(m))}}).catch(p=>{o||s.error(p)}).finally(()=>s.complete())}async _throwOnErrorResponse(e){if(e.status>=300){let t="";try{if(t=await e.text(),!t){let r=e.headers.get("x-influxdb-error");r&&(t=r)}}catch(r){throw A.warn("Unable to receive error body",r),new N(e.status,e.statusText,void 0,e.headers.get("content-type"))}throw new N(e.status,e.statusText,t,e.headers.get("content-type"))}}async*iterate(e,t,r){var s;let i=await this._fetch(e,t,r);if(await this._throwOnErrorResponse(i),i.body){let o=i.body.getReader();for(;;){let{value:a,done:l}=await o.read();if(l)break;if((s=r.signal)!=null&&s.aborted)throw await i.body.cancel(),new V;yield a}}else if(i.arrayBuffer){let o=await i.arrayBuffer();yield new Uint8Array(o)}else{let o=await i.text();yield new TextEncoder().encode(o)}}async request(e,t,r,i){var f,c;let s=await this._fetch(e,t,r),{headers:o}=s,a=o.get("content-type")||"";i&&i(gt(s),s.status),await this._throwOnErrorResponse(s);let l=(c=(f=r.headers)==null?void 0:f.accept)!=null?c:a;if(l.includes("json"))return await s.json();if(l.includes("text")||l.startsWith("application/csv"))return await s.text()}_fetch(e,t,r){let{method:i,headers:s,...o}=r,a=`${this._url}${e}`,l={method:i,body:i==="GET"||i==="HEAD"?void 0:typeof t=="string"?t:JSON.stringify(t),headers:{...this._defaultHeaders,...s},credentials:"omit",...this._connectionOptions.transportOptions,...o};return this.requestDecorator(l,r,a),fetch(a,l)}};var bt=K("@protobuf-ts/grpcweb-transport"),yt=({host:n})=>new bt.GrpcWebFetchTransport({baseUrl:n});var nr={writeTransport:n=>new M(n),queryTransport:yt},W=nr;var q=class{constructor(e){this._options=e;this._closed=!1;var t;this._transport=(t=this._options.transport)!=null?t:W.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_createWritePath(e,t,r){let i=[`bucket=${encodeURIComponent(e)}`,`precision=${t.precision}`];r&&i.push(`org=${encodeURIComponent(r)}`);let s=t==null?void 0:t.consistency;return s&&i.push(`consistency=${encodeURIComponent(s)}`),`/api/v2/write?${i.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,T)=>{o=h,a=T}),f,c={responseStarted(h,T){f=T},error(h){if(h instanceof N&&h.json&&typeof h.json.error=="string"&&h.json.error.includes("hinted handoff queue not empty")){A.warn(`Write to InfluxDB returns: ${h.json.error}`),f=204,c.complete();return}A.error("Write to InfluxDB failed.",h),a(h)},complete(){if(f==204||f==null)o();else{let h=`204 HTTP response status code expected, but ${f} returned`,T=new N(f,h,void 0,"0");T.message=h,c.error(T)}}},p={...xe,...i},m={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...i==null?void 0:i.headers},gzipThreshold:p.gzipThreshold};return this._transport.send(this._createWritePath(t,p,r),e.join(`
`),m,c),l}async close(){this._closed=!0}};var ge=K("apache-arrow");var qt=K("@protobuf-ts/runtime-rpc");function C(n){let e=typeof n;if(e=="object"){if(Array.isArray(n))return"array";if(n===null)return"null"}return e}function Se(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}var E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Q=[];for(let n=0;n<E.length;n++)Q[E[n].charCodeAt(0)]=n;Q["-".charCodeAt(0)]=E.indexOf("+");Q["_".charCodeAt(0)]=E.indexOf("/");function wt(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=Q[n.charCodeAt(a)],s===void 0)switch(n[a]){case"=":i=0;case`
`: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 Tt(n){let e="",t=0,r,i=0;for(let s=0;s<n.length;s++)switch(r=n[s],t){case 0:e+=E[r>>2],i=(r&3)<<4,t=1;break;case 1:e+=E[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=E[i|r>>6],e+=E[r&63],t=0;break}return t&&(e+=E[i],e+="=",t==1&&(e+="=")),e}var B;(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])})(B||(B={}));var w;(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"})(w||(w={}));function xt(){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))return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,!(t&128))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))return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function z(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);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 Y=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>=Y&&(i=i+(r/Y|0),r=r%Y)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,r,i]}function ee(n,e){if(e>>>0<=2097151)return""+(Y*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 f(c,p){let m=c?String(c):"";return p?"0000000".slice(m.length)+m:m}return f(a,0)+f(o,a)+f(s,1)}function Ae(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 Ft(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var b;function ir(){let n=new DataView(new ArrayBuffer(8));b=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}ir();function It(n){if(!n)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Ot=/^-?[0-9]+$/,re=4294967296,te=2147483648,ne=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*re+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},x=class n extends ne{static from(e){if(b)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=b.C(e);case"number":if(e===0)return this.ZERO;e=b.C(e);case"bigint":if(!e)return this.ZERO;if(e<b.UMIN)throw new Error("signed value for ulong");if(e>b.UMAX)throw new Error("ulong too large");return b.V.setBigUint64(0,e,!0),new n(b.V.getInt32(0,!0),b.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ot.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/re)}throw new Error("unknown value "+typeof e)}toString(){return b?this.toBigInt().toString():ee(this.lo,this.hi)}toBigInt(){return It(b),b.V.setInt32(0,this.lo,!0),b.V.setInt32(4,this.hi,!0),b.V.getBigUint64(0,!0)}};x.ZERO=new x(0,0);var g=class n extends ne{static from(e){if(b)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=b.C(e);case"number":if(e===0)return this.ZERO;e=b.C(e);case"bigint":if(!e)return this.ZERO;if(e<b.MIN)throw new Error("signed long too small");if(e>b.MAX)throw new Error("signed long too large");return b.V.setBigInt64(0,e,!0),new n(b.V.getInt32(0,!0),b.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ot.test(e))throw new Error("string is no integer");let[t,r,i]=_e(e);if(t){if(i>te||i==te&&r!=0)throw new Error("signed long too small")}else if(i>=te)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/re):new n(-e,-e/re).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&te)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new n(t,e)}toString(){if(b)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ee(e.lo,e.hi)}return ee(this.lo,this.hi)}toBigInt(){return It(b),b.V.setInt32(0,this.lo,!0),b.V.setInt32(4,this.hi,!0),b.V.getBigInt64(0,!0)}};g.ZERO=new g(0,0);var kt={readUnknownField:!0,readerFactory:n=>new De(n)};function Nt(n){return n?Object.assign(Object.assign({},kt),n):kt}var De=class{constructor(e,t){this.varint64=xt,this.uint32=Ft,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 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 r=this.uint32();this.pos+=r;break;case w.StartGroup:let i;for(;(i=this.tag()[1])!==w.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 g(...this.varint64())}uint64(){return new x(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,new g(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 x(this.sfixed32(),this.sfixed32())}sfixed64(){return new g(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 d(n,e){if(!n)throw new Error(e)}var sr=34028234663852886e22,or=-34028234663852886e22,ar=4294967295,lr=2147483647,ur=-2147483648;function S(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>lr||n<ur)throw new Error("invalid int 32: "+n)}function P(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>ar||n<0)throw new Error("invalid uint 32: "+n)}function L(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>sr||n<or))throw new Error("invalid float 32: "+n)}var Et={writeUnknownFields:!0,writerFactory:()=>new Ce};function Rt(n){return n?Object.assign(Object.assign({},Et),n):Et}var Ce=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(P(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return S(e),Ae(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){L(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){P(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){S(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return S(e),e=(e<<1^e>>31)>>>0,Ae(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=g.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=x.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=g.from(e);return z(t.lo,t.hi,this.buf),this}sint64(e){let t=g.from(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return z(i,s,this.buf),this}uint64(e){let t=x.from(e);return z(t.lo,t.hi,this.buf),this}};var St={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},_t={ignoreUnknownFields:!1};function At(n){return n?Object.assign(Object.assign({},_t),n):_t}function Dt(n){return n?Object.assign(Object.assign({},St),n):St}var Ct=Symbol.for("protobuf-ts/message-type");function Pe(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 F;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING",n[n.NUMBER=2]="NUMBER"})(F||(F={}));var $;(function(n){n[n.NO=0]="NO",n[n.PACKED=1]="PACKED",n[n.UNPACKED=2]="UNPACKED"})($||($={}));function Pt(n){var e,t,r,i;return n.localName=(e=n.localName)!==null&&e!==void 0?e:Pe(n.name),n.jsonName=(t=n.jsonName)!==null&&t!==void 0?t:Pe(n.name),n.repeat=(r=n.repeat)!==null&&r!==void 0?r:$.NO,n.opt=(i=n.opt)!==null&&i!==void 0?i:n.repeat||n.oneof?!1:n.kind=="message",n}function Ut(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 ie=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(!Ut(a))return!1;if(a.oneofKind===void 0)continue;let l=this.fields.find(f=>f.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 F.BIGINT:return i=="bigint";case F.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,F.STRING)}}};function I(n,e){switch(e){case F.BIGINT:return n.toBigInt();case F.NUMBER:return n.toNumber();default:return n.toString()}}var se=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=C(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,f;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),f=t[a.oneof]={oneofKind:l}}else f=t;if(a.kind=="map"){if(o===null)continue;this.assert(Se(o),a.name,o);let c=f[l];for(let[p,m]of Object.entries(o)){this.assert(m!==null,a.name+" map value",null);let h;switch(a.V.kind){case"message":h=a.V.T().internalJsonRead(m,r);break;case"enum":if(h=this.enum(a.V.T(),m,a.name,r.ignoreUnknownFields),h===!1)continue;break;case"scalar":h=this.scalar(m,a.V.T,a.V.L,a.name);break}this.assert(h!==void 0,a.name+" map value",m);let T=p;a.K==u.BOOL&&(T=T=="true"?!0:T=="false"?!1:T),T=this.scalar(T,a.K,F.STRING,a.name).toString(),c[T]=h}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let c=f[l];for(let p of o){this.assert(p!==null,a.name,null);let m;switch(a.kind){case"message":m=a.T().internalJsonRead(p,r);break;case"enum":if(m=this.enum(a.T(),p,a.name,r.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(p,a.T,a.L,a.name);break}this.assert(m!==void 0,a.name,o),c.push(m)}}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}f[l]=a.T().internalJsonRead(o,r,f[l]);break;case"enum":let c=this.enum(a.T(),o,a.name,r.ignoreUnknownFields);if(c===!1)continue;f[l]=c;break;case"scalar":f[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,r,i){if(e[0]=="google.protobuf.NullValue"&&d(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 d(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:(d(typeof o=="number",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} has no value for "${t}".`),o)}d(!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&&L(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?P(a):S(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return I(g.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return I(g.from(e),r);case u.FIXED64:case u.UINT64:if(e===null)return I(x.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return I(x.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 wt(e)}}catch(o){s=o.message}this.assert(!1,i+(s?" - "+s:""),e)}};var oe=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 f=this.field(s,i[s.localName],t);f!==void 0&&(r[t.useProtoFieldName?s.name:s.jsonName]=f);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);d(l!==void 0),r[t.useProtoFieldName?s.name:s.jsonName]=l}return r}field(e,t,r){let i;if(e.kind=="map"){d(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[l,f]of Object.entries(t)){let c=this.scalar(e.V.T,f,e.name,!1,!0);d(c!==void 0),s[l.toString()]=c}break;case"message":let o=e.V.T();for(let[l,f]of Object.entries(t)){let c=this.message(o,f,e.name,r);d(c!==void 0),s[l.toString()]=c}break;case"enum":let a=e.V.T();for(let[l,f]of Object.entries(t)){d(f===void 0||typeof f=="number");let c=this.enum(a,f,e.name,!1,!0,r.enumAsInteger);d(c!==void 0),s[l.toString()]=c}break}(r.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){d(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){let f=this.scalar(e.T,t[l],e.name,e.opt,!0);d(f!==void 0),s.push(f)}break;case"enum":let o=e.T();for(let l=0;l<t.length;l++){d(t[l]===void 0||typeof t[l]=="number");let f=this.enum(o,t[l],e.name,e.opt,!0,r.enumAsInteger);d(f!==void 0),s.push(f)}break;case"message":let a=e.T();for(let l=0;l<t.length;l++){let f=this.message(a,t[l],e.name,r);d(f!==void 0),s.push(f)}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){d(i);return}if(!(t===0&&!s&&!i))return d(typeof t=="number"),d(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){d(i);return}let o=s||i;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(S(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(P(t),t);case u.FLOAT:L(t);case u.DOUBLE:return t===0?o?0:void 0:(d(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:(d(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(d(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:d(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=x.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:d(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=g.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return d(t instanceof Uint8Array),t.byteLength?Tt(t):o?"":void 0}}};function J(n,e=F.STRING){switch(n){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return I(x.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return I(g.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 ae=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 m=r.readUnknownField;if(m=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let h=e.skip(a);m!==!1&&(m===!0?B.onRead:m)(this.info.typeName,t,o,a,h);continue}let f=t,c=l.repeat,p=l.localName;switch(l.oneof&&(f=f[l.oneof],f.oneofKind!==p&&(f=t[l.oneof]={oneofKind:p})),l.kind){case"scalar":case"enum":let m=l.kind=="enum"?u.INT32:l.T,h=l.kind=="scalar"?l.L:void 0;if(c){let _=f[p];if(a==w.LengthDelimited&&m!=u.STRING&&m!=u.BYTES){let be=e.uint32()+e.pos;for(;e.pos<be;)_.push(this.scalar(e,m,h))}else _.push(this.scalar(e,m,h))}else f[p]=this.scalar(e,m,h);break;case"message":if(c){let _=f[p],be=l.T().internalBinaryRead(e,e.uint32(),r);_.push(be)}else f[p]=l.T().internalBinaryRead(e,e.uint32(),r,f[p]);break;case"map":let[T,O]=this.mapEntry(l,e,r);f[p][T]=O;break}}}mapEntry(e,t,r){let i=t.uint32(),s=t.pos+i,o,a;for(;t.pos<s;){let[l,f]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,F.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 ${f}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let l=J(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=J(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 I(e.int64(),r);case u.UINT64:return I(e.uint64(),r);case u.FIXED64:return I(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 I(e.sfixed64(),r);case u.SINT32:return e.sint32();case u.SINT64:return I(e.sint64(),r)}}};var le=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,f=s.localName;if(s.oneof){let c=e[s.oneof];if(c.oneofKind!==f)continue;o=c[f],a=!0}else o=e[f],a=!1;switch(s.kind){case"scalar":case"enum":let c=s.kind=="enum"?u.INT32:s.T;if(l)if(d(Array.isArray(o)),l==$.PACKED)this.packed(t,c,s.no,o);else for(let p of o)this.scalar(t,c,s.no,p,!0);else o===void 0?d(s.opt):this.scalar(t,c,s.no,o,a||s.opt);break;case"message":if(l){d(Array.isArray(o));for(let p of o)this.message(t,r,s.T(),s.no,p)}else this.message(t,r,s.T(),s.no,o);break;case"map":d(typeof o=="object"&&o!==null);for(let[p,m]of Object.entries(o))this.mapEntry(t,r,s,p,m);break}}let i=r.writeUnknownFields;i!==!1&&(i===!0?B.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,r,i,s){e.tag(r.no,w.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:d(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,w.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;d(t!==u.BYTES&&t!==u.STRING),e.tag(r,w.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=w.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=w.LengthDelimited,i="string";break;case u.BOOL:o=t===!1,i="bool";break;case u.UINT32:i="uint32";break;case u.DOUBLE:r=w.Bit64,i="double";break;case u.FLOAT:r=w.Bit32,i="float";break;case u.INT64:o=s||g.from(t).isZero(),i="int64";break;case u.UINT64:o=s||x.from(t).isZero(),i="uint64";break;case u.FIXED64:o=s||x.from(t).isZero(),r=w.Bit64,i="fixed64";break;case u.BYTES:o=s||!t.byteLength,r=w.LengthDelimited,i="bytes";break;case u.FIXED32:r=w.Bit32,i="fixed32";break;case u.SFIXED32:r=w.Bit32,i="sfixed32";break;case u.SFIXED64:o=s||g.from(t).isZero(),r=w.Bit64,i="sfixed64";break;case u.SINT32:i="sint32";break;case u.SINT64:o=s||g.from(t).isZero(),i="sint64";break}return[r,i,s||o]}};function Bt(n){let e={};Object.defineProperty(e,Ct,{enumerable:!1,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]=J(t.T,t.L);break;case"enum":e[r]=0;break;case"map":e[r]={};break}}return e}function ue(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 f=0;f<r.length;f++)s[a][f]=r[f];else s[a]=r;break;case"message":let l=o.T();if(o.repeat)for(let f=0;f<r.length;f++)s[a][f]=l.create(r[f]);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 f=o.V.T();for(let c of Object.keys(r))s[a][c]=f.create(r[c]);break}break}}}function vt(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?Lt(a,s,o):Mt(a,s,o)))return!1;break;case"map":if(!(r.V.kind=="message"?Vt(r.V.T(),fe(s),fe(o)):Lt(r.V.kind=="enum"?u.INT32:r.V.T,fe(s),fe(o))))return!1;break;case"message":let l=r.T();if(!(r.repeat?Vt(l,s,o):l.equals(s,o)))return!1;break}}return!0}var fe=Object.values;function Mt(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 Lt(n,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Mt(n,e[r],t[r]))return!1;return!0}function Vt(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 y=class{constructor(e,t,r){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Pt),this.options=r!=null?r:{},this.refTypeCheck=new ie(this),this.refJsonReader=new se(this),this.refJsonWriter=new oe(this),this.refBinReader=new ae(this),this.refBinWriter=new le(this)}create(e){let t=Bt(this);return e!==void 0&&ue(this,t,e),t}clone(e){let t=this.create();return ue(this,t,e),t}equals(e,t){return vt(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){ue(this,e,t)}fromBinary(e,t){let r=Nt(t);return this.internalBinaryRead(r.readerFactory(e),e.byteLength,r)}fromJson(e,t){return this.internalJsonRead(e,At(t))}fromJsonString(e,t){let r=JSON.parse(e);return this.fromJson(r,t)}toJson(e,t){return this.internalJsonWrite(e,Dt(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=Rt(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 ${C(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 Ue=class extends y{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=g.from(Math.floor(t/1e3)).toBigInt(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(g.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),r=e.getTime();return t.seconds=g.from(Math.floor(r/1e3)).toBigInt(),t.nanos=r%1e3*1e6,t}internalJsonWrite(e,t){let r=g.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 "+C(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=g.from(s/1e3).toBigInt(),r.nanos=0,i[7]&&(r.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),r}},Wt=new Ue;var $t=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.PATH=1]="PATH",r[r.CMD=2]="CMD",r))($t||{}),Jt=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.CANCELLED=1]="CANCELLED",i[i.CANCELLING=2]="CANCELLING",i[i.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",i))(Jt||{}),Be=class extends y{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}])}},fr=new Be,Le=class extends y{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}])}},cr=new Le,Ve=class extends y{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},Mi=new Ve,ve=class extends y{constructor(){super("arrow.flight.protocol.Empty",[])}},pr=new ve,Me=class extends y{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},mr=new Me,We=class extends y{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},hr=new We,qe=class extends y{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},dr=new qe,$e=class extends y{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Ze}])}},Wi=new $e,Je=class extends y{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>jt}])}},qi=new Je,je=class extends y{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},gr=new je,Ge=class extends y{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Jt,"CANCEL_STATUS_"]}])}},$i=new Ge,Ke=class extends y{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},br=new Ke,He=class extends y{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",$t]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},pe=new He,Xe=class extends y{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>pe},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>jt},{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}])}},Ze=new Xe,Qe=class extends y{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>me},{no:2,name:"location",kind:"message",repeat:1,T:()=>yr},{no:3,name:"expiration_time",kind:"message",T:()=>Wt}])}},jt=new Qe,Ye=class extends y{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},yr=new Ye,ze=class extends y{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},me=new ze,et=class extends y{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>pe},{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}])}},ce=new et,tt=class extends y{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},wr=new tt,he=new qt.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:fr,O:cr},{name:"ListFlights",serverStreaming:!0,options:{},I:hr,O:Ze},{name:"GetFlightInfo",options:{},I:pe,O:Ze},{name:"GetSchema",options:{},I:pe,O:br},{name:"DoGet",serverStreaming:!0,options:{},I:me,O:ce},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:ce,O:wr},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:ce,O:ce},{name:"DoAction",serverStreaming:!0,options:{},I:dr,O:gr},{name:"ListActions",serverStreaming:!0,options:{},I:pr,O:mr}]);var k=K("@protobuf-ts/runtime-rpc"),de=class{constructor(e){this._transport=e;this.typeName=he.typeName;this.methods=he.methods;this.options=he.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)}getSchema(e,t){let r=this.methods[3],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,r,i,e)}doGet(e,t){let r=this.methods[4],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}doPut(e){let t=this.methods[5],r=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,r)}doExchange(e){let t=this.methods[6],r=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,r)}doAction(e,t){let r=this.methods[7],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}listActions(e,t){let r=this.methods[8],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}};var j=class{constructor(e){this._options=e;this._closed=!1;this._transport=W.queryTransport(this._options),this._flightClient=new de(this._transport)}async*_queryRawBatches(e,t,r){if(this._closed)throw new Error("queryApi: already closed!");let i=this._flightClient,s={database:t,sql_query:e,query_type:r},o=me.create({ticket:new TextEncoder().encode(JSON.stringify(s))}),a={},l=this._options.token;l&&(a.authorization=`Bearer ${l}`);let f={meta:a},c=i.doGet(o,f),p=async function*(){for await(let h of c.responses)yield ht(h.dataHeader.length),yield h.dataHeader,yield h.dataBody}();yield*await ge.RecordBatchReader.from(p)}async*query(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={};for(let f=0;f<o.numCols;f++){let c=o.schema.fields[f].name,p=(s=o.getChildAt(f))==null?void 0:s.get(a);l[c]=p}yield l}}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 R;for(let f=0;f<o.numCols;f++){let c=o.schema.fields[f],p=c.name,m=(s=o.getChildAt(f))==null?void 0:s.get(a),h=c.typeId,T=c.metadata.get("iox::column::type");if(m==null)continue;if((p==="measurement"||p=="iox::measurement")&&typeof m=="string"){l.setMeasurement(m);continue}if(!T){p==="time"&&h===ge.Type.Timestamp?l.setTimestamp(m):l.setField(p,m);continue}let[,,O,_]=T.split("::");O==="field"?_&&m!==void 0&&m!==null&&l.setField(p,m,_):O==="tag"?l.setTag(p,m):O==="timestamp"&&l.setTimestamp(m)}yield l}}async close(){var e,t;this._closed=!0,(t=(e=this._transport).close)==null||t.call(e)}};var rt=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
`,G=class{constructor(e){this._mergeWriteOptions=e=>({...this._options.writeOptions,...e});if(e==null)throw new U("No configuration specified!");this._options=e;let t=this._options.host;if(typeof t!="string")throw new U("No host specified!");t.endsWith("/")&&(this._options.host=t.substring(0,t.length-1)),this._queryApi=new j(this._options),this._writeApi=new q(this._options)}async write(e,t,r,i){var s;await this._writeApi.doWrite(Ee(e),(s=t!=null?t:this._options.database)!=null?s:X(new Error(rt)),r,this._mergeWriteOptions(i))}query(e,t,r="sql"){var i;return this._queryApi.query(e,(i=t!=null?t:this._options.database)!=null?i:X(new Error(rt)),r)}queryPoints(e,t,r="sql"){var i;return this._queryApi.queryPoints(e,(i=t!=null?t:this._options.database)!=null?i:X(new Error(rt)),r)}async close(){await this._writeApi.close(),await this._queryApi.close()}};return Qt(Tr);})();
Object.defineProperty(exports, '__esModule', { value: true });Object.assign(exports, influxdb);}));
//# sourceMappingURL=index.browser.js.map

@@ -324,25 +324,24 @@ /** IllegalArgumentError is thrown when illegal argument is supplied. */

type PointRecord = {
measurement: string;
fields: Record<string, number | string>;
tags?: Record<string, string>;
timestamp?: string | number | Date;
};
type PointFieldType = 'float' | 'integer' | 'uinteger' | 'string' | 'boolean';
declare class GetFieldTypeMissmatchError extends Error {
constructor(fieldName: string, expectedType: PointFieldType, actualType: PointFieldType);
}
/**
* Point defines values of a single measurement.
*/
declare class Point {
declare class PointValues {
private _name;
private _time;
private _tags;
private _time;
/** escaped field values */
fields: {
[key: string]: string;
};
private _fields;
/**
* Create a new Point with specified a measurement name.
* Create an empty PointValues.
*/
constructor();
/**
* Get measurement name. Can be undefined if not set.
*
* @param measurementName - the measurement name
* @returns measurement name or undefined
*/
constructor(measurementName?: string);
getMeasurement(): string | undefined;
/**

@@ -354,5 +353,37 @@ * Sets point's measurement.

*/
measurement(name: string): Point;
setMeasurement(name: string): PointValues;
/**
* Adds a tag. The caller has to ensure that both name and value are not empty
* Get timestamp. Can be undefined if not set.
*
* @returns timestamp or undefined
*/
getTimestamp(): Date | number | string | undefined;
/**
* Sets point timestamp. Timestamp can be specified as a Date (preferred), number, string
* or an undefined value. An undefined value instructs to assign a local timestamp using
* the client's clock. An empty string can be used to let the server assign
* the timestamp. A number value represents time as a count of time units since epoch, the
* exact time unit then depends on the {@link InfluxDBClient.write | precision} of the API
* that writes the point.
*
* Beware that the current time in nanoseconds can't precisely fit into a JS number,
* which can hold at most 2^53 integer number. Nanosecond precision numbers are thus supplied as
* a (base-10) string. An application can also use ES2020 BigInt to represent nanoseconds,
* BigInt's `toString()` returns the required high-precision string.
*
* Note that InfluxDB requires the timestamp to fit into int64 data type.
*
* @param value - point time
* @returns this
*/
setTimestamp(value: Date | number | string | undefined): PointValues;
/**
* Gets value of tag with given name. Returns undefined if tag not found.
*
* @param name - tag name
* @returns tag value or undefined
*/
getTag(name: string): string | undefined;
/**
* Sets a tag. The caller has to ensure that both name and value are not empty
* and do not end with backslash.

@@ -364,15 +395,49 @@ *

*/
tag(name: string, value: string): Point;
setTag(name: string, value: string): PointValues;
/**
* Adds a boolean field.
* Removes a tag with the specified name if it exists; otherwise, it does nothing.
*
* @param field - field name
* @param name - The name of the tag to be removed.
* @returns this
*/
removeTag(name: string): PointValues;
/**
* Gets an array of tag names.
*
* @returns An array of tag names.
*/
getTagNames(): string[];
/**
* Gets the float field value associated with the specified name.
* Throws if actual type of field with given name is not float.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match float type.
* @returns The float field value or undefined.
*/
getFloatField(name: string): number | undefined;
/**
* Sets a number field.
*
* @param name - field name
* @param value - field value
* @returns this
* @throws NaN/Infinity/-Infinity is supplied
*/
booleanField(name: string, value: boolean | any): Point;
setFloatField(name: string, value: number | any): PointValues;
/**
* Adds an integer field.
* Gets the integer field value associated with the specified name.
* Throws if actual type of field with given name is not integer.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match integer type.
* @returns The integer field value or undefined.
*/
getIntegerField(name: string): number | undefined;
/**
* Sets an integer field.
*
* @param name - field name
* @param value - field value

@@ -382,7 +447,17 @@ * @returns this

*/
intField(name: string, value: number | any): Point;
setIntegerField(name: string, value: number | any): PointValues;
/**
* Adds an unsigned integer field.
* Gets the uint field value associated with the specified name.
* Throws if actual type of field with given name is not uint.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match uint type.
* @returns The uint field value or undefined.
*/
getUintegerField(name: string): number | undefined;
/**
* Sets an unsigned integer field.
*
* @param name - field name
* @param value - field value

@@ -392,21 +467,193 @@ * @returns this

*/
uintField(name: string, value: number | any): Point;
setUintegerField(name: string, value: number | any): PointValues;
/**
* Adds a number field.
* Gets the string field value associated with the specified name.
* Throws if actual type of field with given name is not string.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match string type.
* @returns The string field value or undefined.
*/
getStringField(name: string): string | undefined;
/**
* Sets a string field.
*
* @param name - field name
* @param value - field value
* @returns this
* @throws NaN/Infinity/-Infinity is supplied
*/
floatField(name: string, value: number | any): Point;
setStringField(name: string, value: string | any): PointValues;
/**
* Adds a string field.
* Gets the boolean field value associated with the specified name.
* Throws if actual type of field with given name is not boolean.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match boolean type.
* @returns The boolean field value or undefined.
*/
getBooleanField(name: string): boolean | undefined;
/**
* Sets a boolean field.
*
* @param name - field name
* @param value - field value
* @returns this
*/
stringField(name: string, value: string | any): Point;
setBooleanField(name: string, value: boolean | any): PointValues;
/**
* Get field of numeric type.
* Throws if actual type of field with given name is not given numeric type.
* If the field is not present, returns undefined.
*
* @param name - field name
* @param type - field numeric type
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match provided numeric type.
* @returns this
*/
getField(name: string, type: 'float' | 'integer' | 'uinteger'): number | undefined;
/**
* Get field of string type.
* Throws if actual type of field with given name is not string.
* If the field is not present, returns undefined.
*
* @param name - field name
* @param type - field string type
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match provided 'string' type.
* @returns this
*/
getField(name: string, type: 'string'): string | undefined;
/**
* Get field of boolean type.
* Throws if actual type of field with given name is not boolean.
* If the field is not present, returns undefined.
*
* @param name - field name
* @param type - field boolean type
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match provided 'boolean' type.
* @returns this
*/
getField(name: string, type: 'boolean'): boolean | undefined;
/**
* Get field without type check.
* If the field is not present, returns undefined.
*
* @param name - field name
* @returns this
*/
getField(name: string): number | string | boolean | undefined;
/**
* Gets the type of field with given name, if it exists.
* If the field is not present, returns undefined.
*
* @param name - field name
* @returns The field type or undefined.
*/
getFieldType(name: string): PointFieldType | undefined;
/**
* Sets field based on provided type.
*
* @param name - field name
* @param value - field value
* @param type - field type
* @returns this
*/
setField(name: string, value: any, type?: PointFieldType): PointValues;
/**
* Add fields according to their type. All numeric type is considered float
*
* @param fields - name-value map
* @returns this
*/
setFields(fields: {
[key: string]: number | boolean | string;
}): PointValues;
/**
* Removes a field with the specified name if it exists; otherwise, it does nothing.
*
* @param name - The name of the field to be removed.
* @returns this
*/
removeField(name: string): PointValues;
/**
* Gets an array of field names associated with this object.
*
* @returns An array of field names.
*/
getFieldNames(): string[];
/**
* Checks if this object has any fields.
*
* @returns true if fields are present, false otherwise.
*/
hasFields(): boolean;
/**
* Creates a copy of this object.
*
* @returns A new instance with same values.
*/
copy(): PointValues;
/**
* Creates new Point with this as values.
*
* @returns Point from this values.
*/
asPoint(measurement?: string): Point;
}
/**
* Point defines values of a single measurement.
*/
declare class Point {
private readonly _values;
/**
* Create a new Point with specified a measurement name.
*
* @param measurementName - the measurement name
*/
private constructor();
/**
* Create a new Point with given values.
* After creating Point, it's values shouldn't be modified directly by PointValues object.
*
* @param values - point values
*/
private constructor();
/**
* Creates new Point with given measurement.
*
* @param name - measurement name
* @returns new Point
*/
static measurement(name: string): Point;
/**
* Creates new point from PointValues object.
* Can throw error if measurement missing.
*
* @param values - point values object with measurement
* @throws missing measurement
* @returns new point from values
*/
static fromValues(values: PointValues): Point;
/**
* Get measurement name.
*
* @returns measurement name
*/
getMeasurement(): string;
/**
* Sets point's measurement.
*
* @param name - measurement name
* @returns this
*/
setMeasurement(name: string): Point;
/**
* Get timestamp. Can be undefined if not set.
*
* @returns timestamp or undefined
*/
getTimestamp(): Date | number | string | undefined;
/**
* Sets point timestamp. Timestamp can be specified as a Date (preferred), number, string

@@ -429,6 +676,213 @@ * or an undefined value. An undefined value instructs to assign a local timestamp using

*/
timestamp(value: Date | number | string | undefined): Point;
setTimestamp(value: Date | number | string | undefined): Point;
/**
* Gets value of tag with given name. Returns undefined if tag not found.
*
* @param name - tag name
* @returns tag value or undefined
*/
getTag(name: string): string | undefined;
/**
* Sets a tag. The caller has to ensure that both name and value are not empty
* and do not end with backslash.
*
* @param name - tag name
* @param value - tag value
* @returns this
*/
setTag(name: string, value: string): Point;
/**
* Removes a tag with the specified name if it exists; otherwise, it does nothing.
*
* @param name - The name of the tag to be removed.
* @returns this
*/
removeTag(name: string): Point;
/**
* Gets an array of tag names.
*
* @returns An array of tag names.
*/
getTagNames(): string[];
/**
* Gets the float field value associated with the specified name.
* Throws if actual type of field with given name is not float.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match float type.
* @returns The float field value or undefined.
*/
getFloatField(name: string): number | undefined;
/**
* Sets a number field.
*
* @param name - field name
* @param value - field value
* @returns this
* @throws NaN/Infinity/-Infinity is supplied
*/
setFloatField(name: string, value: number | any): Point;
/**
* Gets the integer field value associated with the specified name.
* Throws if actual type of field with given name is not integer.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match integer type.
* @returns The integer field value or undefined.
*/
getIntegerField(name: string): number | undefined;
/**
* Sets an integer field.
*
* @param name - field name
* @param value - field value
* @returns this
* @throws NaN or out of int64 range value is supplied
*/
setIntegerField(name: string, value: number | any): Point;
/**
* Gets the uint field value associated with the specified name.
* Throws if actual type of field with given name is not uint.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match uint type.
* @returns The uint field value or undefined.
*/
getUintegerField(name: string): number | undefined;
/**
* Sets an unsigned integer field.
*
* @param name - field name
* @param value - field value
* @returns this
* @throws NaN out of range value is supplied
*/
setUintegerField(name: string, value: number | any): Point;
/**
* Gets the string field value associated with the specified name.
* Throws if actual type of field with given name is not string.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match string type.
* @returns The string field value or undefined.
*/
getStringField(name: string): string | undefined;
/**
* Sets a string field.
*
* @param name - field name
* @param value - field value
* @returns this
*/
setStringField(name: string, value: string | any): Point;
/**
* Gets the boolean field value associated with the specified name.
* Throws if actual type of field with given name is not boolean.
* If the field is not present, returns undefined.
*
* @param name - field name
* @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match boolean type.
* @returns The boolean field value or undefined.
*/
getBooleanField(name: string): boolean | undefined;
/**
* Sets a boolean field.
*
* @param name - field name
* @param value - field value
* @returns this
*/
setBooleanField(name: string, value: boolean | any): Point;
/**
* Get field of numeric type.
*
* @param name - field name
* @param type - field numeric type
* @throws Field type doesn't match actual type
* @returns this
*/
getField(name: string, type: 'float' | 'integer' | 'uinteger'): number | undefined;
/**
* Get field of string type.
*
* @param name - field name
* @param type - field string type
* @throws Field type doesn't match actual type
* @returns this
*/
getField(name: string, type: 'string'): string | undefined;
/**
* Get field of boolean type.
*
* @param name - field name
* @param type - field boolean type
* @throws Field type doesn't match actual type
* @returns this
*/
getField(name: string, type: 'boolean'): boolean | undefined;
/**
* Get field without type check.
*
* @param name - field name
* @returns this
*/
getField(name: string): number | string | boolean | undefined;
/**
* Gets the type of field with given name, if it exists.
* If the field is not present, returns undefined.
*
* @param name - field name
* @returns The field type or undefined.
*/
getFieldType(name: string): PointFieldType | undefined;
/**
* Sets field based on provided type.
*
* @param name - field name
* @param value - field value
* @param type - field type
* @returns this
*/
setField(name: string, value: any, type?: PointFieldType): Point;
/**
* Add fields according to their type. All numeric type is considered float
*
* @param fields - name-value map
* @returns this
*/
setFields(fields: {
[key: string]: number | boolean | string;
}): Point;
/**
* Removes a field with the specified name if it exists; otherwise, it does nothing.
*
* @param name - The name of the field to be removed.
* @returns this
*/
removeField(name: string): Point;
/**
* Gets an array of field names associated with this object.
*
* @returns An array of field names.
*/
getFieldNames(): string[];
/**
* Checks if this object has any fields.
*
* @returns true if fields are present, false otherwise.
*/
hasFields(): boolean;
/**
* Creates a copy of this object.
*
* @returns A new instance with same values.
*/
copy(): Point;
/**
* Creates an InfluxDB protocol line out of this instance.
* @param settings - settings control serialization of a point timestamp and can also add default tags,
* @param convertTimePrecision - settings control serialization of a point timestamp and can also add default tags,
* nanosecond timestamp precision is used when no `settings` or no `settings.convertTime` is supplied.

@@ -439,13 +893,4 @@ * @returns an InfluxDB protocol line out of this instance

toString(): string;
static fromRecord(record: PointRecord): Point;
}
/** Prevents confusion with the ArrayLike type. Use with PointRecord */
type NotArrayLike<T> = T & {
length?: string;
};
/** Prevents confusion with the PointRecord type. */
type NotPointRecord<T> = T & {
measurement?: void;
};
/**

@@ -458,8 +903,4 @@ * The `WritableData` type represents different types of data that can be written.

* - `string`: Represents lines of the [Line Protocol](https://bit.ly/2QL99fu).
*
* - `PointRecord`: Represents an anonymous object. Note that a single `PointRecord`
* should not have a property of name length, as it could be misinterpreted as ArrayLike.
* If unsure, encapsulate your record in an array, i.e. [record].
*/
type WritableData = NotPointRecord<ArrayLike<string> | ArrayLike<Point> | ArrayLike<PointRecord>> | NotArrayLike<PointRecord> | string | Point;
type WritableData = ArrayLike<string> | ArrayLike<Point> | string | Point;
declare const writableDataToLineProtocol: (data: WritableData) => string[];

@@ -482,7 +923,34 @@

private _mergeWriteOptions;
/**
* Write data into specified database.
* @param data - data to write
* @param database - database to write into
* @param org - organization to write into
* @param writeOptions - write options
*/
write(data: WritableData, database?: string, org?: string, writeOptions?: Partial<WriteOptions>): Promise<void>;
/**
* Execute a query and return the results as an async generator.
*
* @param query - The query string.
* @param database - The name of the database to query.
* @param queryType - The type of query (default: 'sql').
* @returns An async generator that yields maps of string keys to any values.
*/
query(query: string, database?: string, queryType?: QueryType): AsyncGenerator<Record<string, any>, void, void>;
/**
* Execute a query and return the results as an async generator.
*
* @param query - The query string.
* @param database - The name of the database to query.
* @param queryType - The type of query (default: 'sql').
* @returns An async generator that yields PointValues object.
*/
queryPoints(query: string, database?: string, queryType?: QueryType): AsyncGenerator<PointValues, void, void>;
/**
* Closes the client and all its resources (connections, ...)
*/
close(): Promise<void>;
}
export { AbortError, Cancellable, ChunkCombiner, ClientOptions, CommunicationObserver, ConnectionOptions, DEFAULT_ConnectionOptions, DEFAULT_WriteOptions, HttpHeaders as Headers, HttpError, HttpHeaders, IllegalArgumentError, InfluxDBClient, Log, Logger, NotArrayLike, NotPointRecord, Point, PointRecord, QueryType, RequestTimedOutError, ResponseStartedFn, SendOptions, TimeConverter, Transport, WritableData, WriteOptions, WritePrecision, collectAll, consoleLogger, convertTime, convertTimeToNanos, createTextDecoderCombiner, currentTime, dateToProtocolTimestamp, escape, setLogger, useProcessHrtime, writableDataToLineProtocol };
export { AbortError, Cancellable, ChunkCombiner, ClientOptions, CommunicationObserver, ConnectionOptions, DEFAULT_ConnectionOptions, DEFAULT_WriteOptions, GetFieldTypeMissmatchError, HttpHeaders as Headers, HttpError, HttpHeaders, IllegalArgumentError, InfluxDBClient, Log, Logger, Point, PointFieldType, PointValues, QueryType, RequestTimedOutError, ResponseStartedFn, SendOptions, TimeConverter, Transport, WritableData, WriteOptions, WritePrecision, collectAll, consoleLogger, convertTime, convertTimeToNanos, createTextDecoderCombiner, currentTime, dateToProtocolTimestamp, escape, setLogger, useProcessHrtime, writableDataToLineProtocol };

@@ -1,7 +0,7 @@

"use strict";var fr=Object.create;var X=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var cr=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,pr=Object.prototype.hasOwnProperty;var mr=(r,e)=>{for(var t in e)X(r,t,{get:e[t],enumerable:!0})},st=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of cr(e))!pr.call(r,i)&&i!==t&&X(r,i,{get:()=>e[i],enumerable:!(n=lr(e,i))||n.enumerable});return r};var Z=(r,e,t)=>(t=r!=null?fr(ur(r)):{},st(e||!r||!r.__esModule?X(t,"default",{value:r,enumerable:!0}):t,r)),hr=r=>st(X({},"__esModule",{value:!0}),r);var Pr={};mr(Pr,{AbortError:()=>D,DEFAULT_ConnectionOptions:()=>we,DEFAULT_WriteOptions:()=>xe,HttpError:()=>R,IllegalArgumentError:()=>L,InfluxDBClient:()=>G,Log:()=>P,Point:()=>V,RequestTimedOutError:()=>B,collectAll:()=>wt,consoleLogger:()=>at,convertTime:()=>Ee,convertTimeToNanos:()=>Ne,createTextDecoderCombiner:()=>dr,currentTime:()=>ht,dateToProtocolTimestamp:()=>dt,escape:()=>_,setLogger:()=>gr,useProcessHrtime:()=>mt,writableDataToLineProtocol:()=>Re});module.exports=hr(Pr);var L=class r extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,r.prototype)}},R=class r extends Error{constructor(t,n,i,o,s){super();this.statusCode=t;this.statusMessage=n;this.body=i;this.contentType=o;if(Object.setPrototypeOf(this,r.prototype),s)this.message=s;else if(i){if(o!=null&&o.startsWith("application/json"))try{this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code}catch(a){}this.message||(this.message=`${t} ${n} : ${i}`)}else this.message=`${t} ${n}`;this.name="HttpError"}},B=class r extends Error{constructor(){super(),Object.setPrototypeOf(this,r.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},D=class r extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,r.prototype),this.message="Response aborted"}};function dr(){let r=new TextDecoder("utf-8");return{concat(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n},copy(e,t,n){let i=new Uint8Array(n-t);return i.set(e.subarray(t,n)),i},toUtf8String(e,t,n){return r.decode(e.subarray(t,n))}}}var we={timeout:1e4},xe={precision:"ns",gzipThreshold:1e3};var at={error(r,e){console.error(`ERROR: ${r}`,e||"")},warn(r,e){console.warn(`WARN: ${r}`,e||"")}},H=at,P={error(r,e){H.error(r,e)},warn(r,e){H.warn(r,e)}};function gr(r){let e=H;return H=r,e}function Te(r,e){return function(t){let n="",i=0,o=0;for(;o<t.length;){let s=r.indexOf(t[o]);s>=0&&(n+=t.substring(i,o),n+=e[s],i=o+1),o++}return i==0?t:(i<t.length&&(n+=t.substring(i,t.length)),n)}}function br(r,e){let t=Te(r,e);return n=>`"${t(n)}"`}var _={measurement:Te(`,
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:br('"\\',['\\"',"\\\\"]),tag:Te(`, =
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var Y="000000000",ke=!1;function mt(r){return ke=r&&process&&typeof process.hrtime=="function"}mt(!0);var ft,z,lt=Date.now(),Ie=0;function Oe(){if(ke){let r=process.hrtime(),e=Date.now();z?(r[0]=r[0]-z[0],r[1]=r[1]-z[1],r[1]<0&&(r[0]-=1,r[1]+=1e9),e=ft+r[0]*1e3+Math.floor(r[1]/1e6)):(z=r,ft=e);let t=String(r[1]%1e6);return String(e)+Y.substr(0,6-t.length)+t}else{let r=Date.now();r!==lt?(lt=r,Ie=0):Ie++;let e=String(Ie);return String(r)+Y.substr(0,6-e.length)+e}}function ct(){if(ke){let r=process.hrtime(),e=String(Math.trunc(r[1]/1e3)%1e3);return String(Date.now())+Y.substr(0,3-e.length)+e}else return String(Date.now())+Y.substr(0,3)}function ut(){return String(Date.now())}function pt(){return String(Math.floor(Date.now()/1e3))}var ht={s:pt,ms:ut,us:ct,ns:Oe,seconds:pt,millis:ut,micros:ct,nanos:Oe},dt={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function Ne(r){return r===void 0?Oe():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var Ee=(r,e="ns")=>r===void 0?ht[e]():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?dt[e](r):String(typeof r=="number"?Math.floor(r):r);var V=class r{constructor(e){this._tags={};this.fields={};e&&(this._name=e)}measurement(e){return this._name=e,this}tag(e,t){return this._tags[e]=t,this}booleanField(e,t){return this.fields[e]=t?"T":"F",this}intField(e,t){let n;if(typeof t=="number"?n=t:n=parseInt(String(t)),isNaN(n)||n<=-9223372036854776e3||n>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${t}'!`);return this.fields[e]=`${Math.floor(n)}i`,this}uintField(e,t){if(typeof t=="number"){if(isNaN(t)||t<0||t>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${e}' out of range: ${t}`);this.fields[e]=`${Math.floor(t)}u`}else{let n=String(t);for(let i=0;i<n.length;i++){let o=n.charCodeAt(i);if(o<48||o>57)throw new Error(`uint value has an unsupported character at pos ${i}: ${t}`)}if(n.length>20||n.length===20&&n.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${n}`);this.fields[e]=`${n}u`}return this}floatField(e,t){let n;if(typeof t=="number"?n=t:n=parseFloat(t),!isFinite(n))throw new Error(`invalid float value for field '${e}': '${t}'!`);return this.fields[e]=String(n),this}stringField(e,t){return t!=null&&(typeof t!="string"&&(t=String(t)),this.fields[e]=_.quoted(t)),this}timestamp(e){return this._time=e,this}toLineProtocol(e){if(!this._name)return;let t="";if(Object.keys(this.fields).sort().forEach(s=>{if(s){let a=this.fields[s];t.length>0&&(t+=","),t+=`${_.tag(s)}=${a}`}}),t.length===0)return;let n="",i=this._tags;Object.keys(i).sort().forEach(s=>{if(s){let a=i[s];a&&(n+=",",n+=`${_.tag(s)}=${_.tag(a)}`)}});let o=this._time;return e?typeof e=="string"?o=Ee(o,e):o=e(o):o=Ne(o),`${_.measurement(this._name)}${n} ${t}${o!==void 0?` ${o}`:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}static fromRecord(e){let{measurement:t,fields:n,tags:i,timestamp:o}=e;if(!t)throw new Error("measurement must be defined on the Point record!");if(!n)throw new Error("fields must be defined on the Point record!");let s=new r(t);o!==void 0&&s.timestamp(o);for(let[a,f]of Object.entries(n))if(typeof f=="number")s.floatField(a,f);else if(typeof f=="string")s.stringField(a,f);else throw new Error(`unsuported type of field ${a}: ${typeof f}`);if(i)for(let[a,f]of Object.entries(i))if(typeof f=="string")s.tag(a,f);else throw new Error(`tag has to be string ${a}: ${typeof f}`);return s}};var Fe=r=>{throw r},gt=r=>r!==void 0,bt=r=>r instanceof Array||r instanceof Object&&typeof r.length=="number"&&(r.length===0||Object.getOwnPropertyNames(r).some(e=>e==="0")),yt=r=>{let e=new Uint8Array(4);return e[0]=r>>0,e[1]=r>>8,e[2]=r>>16,e[3]=r>>24,e},wt=async r=>{let e=[];for await(let t of r)e.push(t);return e};var Re=r=>{let e=bt(r)&&typeof r!="string"?Array.from(r):[r];if(e.length===0)return[];let t=typeof e[0]=="string",n=e[0]instanceof V;return t?e:(n?e:e.map(V.fromRecord)).map(i=>i.toLineProtocol()).filter(gt)};var Ae=require("url"),Tt=Z(require("http")),It=Z(require("https")),Q=require("buffer");var M=Z(require("zlib"));function Se(r={}){let e=0,t={next:n=>{if(e===0&&r.next&&n!==null&&n!==void 0)return r.next(n)},error:n=>{e===0&&(e=1,r.error&&r.error(n))},complete:()=>{e===0&&(e=2,r.complete&&r.complete())},responseStarted:(n,i)=>{r.responseStarted&&r.responseStarted(n,i)}};return r.useCancellable&&(t.useCancellable=r.useCancellable.bind(r)),r.useResume&&(t.useResume=r.useResume.bind(r)),t}var xt="0.3.0.nightly";var Ot=require("stream");var yr={flush:M.default.constants.Z_SYNC_FLUSH,finishFlush:M.default.constants.Z_SYNC_FLUSH},wr=Q.Buffer.allocUnsafe(0),De=class{constructor(){this._cancelled=!1}cancel(){this._cancelled=!0,this.resume&&(this.resume(),this.resume=void 0)}isCancelled(){return this._cancelled}},_e=class{constructor(e){var f,c,u,p,m,h,b;let{host:t,proxyUrl:n,token:i,transportOptions:o,...s}=e,a=(0,Ae.parse)(n||t);if(this._token=i,this._defaultOptions={...we,...s,...o,port:a.port,protocol:a.protocol,hostname:a.hostname},this._contextPath=n?t:(f=a.path)!=null?f:"",this._contextPath.endsWith("/")&&(this._contextPath=this._contextPath.substring(0,this._contextPath.length-1)),Object.keys(this._defaultOptions).forEach(E=>this._defaultOptions[E]===void 0&&delete this._defaultOptions[E]),this._contextPath.endsWith("/api/v2")&&(P.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${a.protocol}//${a.hostname}:${a.port} !`),this._contextPath=""),a.protocol==="http:")this._requestApi=(p=(u=(c=this._defaultOptions["follow-redirects"])==null?void 0:c.http)==null?void 0:u.request)!=null?p:Tt.request;else if(a.protocol==="https:")this._requestApi=(b=(h=(m=this._defaultOptions["follow-redirects"])==null?void 0:m.https)==null?void 0:h.request)!=null?b:It.request;else throw new Error(`Unsupported protocol "${a.protocol} in URL: "${e.host}"`);this._headers={"User-Agent":`influxdb-client-js/${xt}`,...e.headers},n&&(this._headers.Host=(0,Ae.parse)(t).host)}send(e,t,n,i){let o=new De;i&&i.useCancellable&&i.useCancellable(o),this._createRequestMessage(e,t,n,s=>{this._request(s,o,i)},s=>(i==null?void 0:i.error)&&i.error(s))}request(e,t,n,i){t?typeof t!="string"&&(t=JSON.stringify(t)):t="";let o=wr,s,a;return new Promise((f,c)=>{this.send(e,t,n,{responseStarted(u,p){i&&i(u,p),s=String(u["content-type"]),a=p},next:u=>{o=Q.Buffer.concat([o,u])},complete:()=>{var p,m;let u=(m=(p=n.headers)==null?void 0:p.accept)!=null?m:s;try{a===204&&f(void 0),u.includes("json")?o.length?f(JSON.parse(o.toString("utf8"))):f(void 0):u.includes("text")||u.startsWith("application/csv")?f(o.toString("utf8")):f(o)}catch(h){c(h)}},error:u=>{c(u)}})})}async*iterate(e,t,n){var u;let i,o;function s(p){i=p,o(p)}let a=await new Promise((p,m)=>{o=m,this._createRequestMessage(e,t,n,p,s)});(u=a.signal)!=null&&u.addEventListener&&a.signal.addEventListener("abort",()=>{s(new D)});let f=await new Promise((p,m)=>{o=m;let h=this._requestApi(a,p);h.on("timeout",()=>s(new B)),h.on("error",s),h.write(a.body),h.end()}),c=await new Promise((p,m)=>{o=m,this._prepareResponse(f,p,s)});for await(let p of c){if(i)throw i;yield p}}_createRequestMessage(e,t,n,i,o){let s=Q.Buffer.from(t,"utf-8"),a={"content-type":"application/json; charset=utf-8",...this._headers};this._token&&(a.authorization=`Token ${this._token}`);let f={...this._defaultOptions,path:this._contextPath+e,method:n.method,headers:{...a,...n.headers}};if(n.signal&&(f.signal=n.signal),n.gzipThreshold!==void 0&&n.gzipThreshold<s.length){M.default.gzip(s,(c,u)=>{if(c)return o(c);f.headers["content-encoding"]="gzip",f.body=u,i(f)});return}f.body=s,f.headers["content-length"]=f.body.length,i(f)}_prepareResponse(e,t,n){var a;e.on("aborted",()=>{n(new D)}),e.on("error",n);let i=(a=e.statusCode)!=null?a:600,o=e.headers["content-encoding"],s;if(o==="gzip"?(s=M.default.createGunzip(yr),s=(0,Ot.pipeline)(e,s,f=>f&&n(f))):s=e,i>=300){let f="",c=String(e.headers["content-type"]).startsWith("application/json");s.on("data",u=>{f+=u.toString(),!c&&f.length>1e3&&(f=f.slice(0,1e3),e.resume())}),s.on("end",()=>{f===""&&e.headers["x-influxdb-error"]&&(f=e.headers["x-influxdb-error"].toString()),n(new R(i,e.statusMessage,f,e.headers["retry-after"],e.headers["content-type"]))})}else t(s)}_request(e,t,n){var s;let i=Se(n);if(t.isCancelled()){i.complete();return}(s=e.signal)!=null&&s.addEventListener&&e.signal.addEventListener("abort",()=>{i.error(new D)});let o=this._requestApi(e,a=>{if(t.isCancelled()){a.resume(),i.complete();return}i.responseStarted(a.headers,a.statusCode),this._prepareResponse(a,f=>{f.on("data",c=>{if(t.isCancelled())a.resume();else if(i.next(c)===!1){if(!i.useResume){i.error(new Error("Unable to pause, useResume is not configured!")),a.resume();return}a.pause();let u=()=>{a.resume()};t.resume=u,i.useResume(u)}}),f.on("end",i.complete)},i.error)});typeof o.setTimeout=="function"&&e.timeout&&o.setTimeout(e.timeout),o.on("timeout",()=>{i.error(new B)}),o.on("error",a=>{i.error(a)}),e.body&&o.write(e.body),o.end()}},kt=_e;var Rt=require("@protobuf-ts/grpc-transport");var Nt="http://",Et="https://",Ft=r=>{r=r.replace(/\/$/,"");let e;return r.startsWith(Nt)?(r=r.slice(Nt.length),e=!1,r.includes(":")||(r=`${r}:80`)):r.startsWith(Et)&&(r=r.slice(Et.length),e=!0,r.includes(":")||(r=`${r}:443`)),{url:r,safe:e}};var St=Z(require("@grpc/grpc-js")),At=({host:r})=>{let{url:e,safe:t}=Ft(r),n=St.credentials[t==null||t?"createSsl":"createInsecure"]();return new Rt.GrpcTransport({host:e,channelCredentials:n})};var xr={writeTransport:r=>new kt(r),queryTransport:At},$=xr;var q=class{constructor(e){this._options=e;this._closed=!1;var t;this._transport=(t=this._options.transport)!=null?t:$.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_createWritePath(e,t,n){let i=[`bucket=${encodeURIComponent(e)}`,`precision=${t.precision}`];n&&i.push(`org=${encodeURIComponent(n)}`);let o=t==null?void 0:t.consistency;return o&&i.push(`consistency=${encodeURIComponent(o)}`),`/api/v2/write?${i.join("&")}`}doWrite(e,t,n,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 s,a,f=new Promise((h,b)=>{s=h,a=b}),c,u={responseStarted(h,b){c=b},error(h){if(h instanceof R&&h.json&&typeof h.json.error=="string"&&h.json.error.includes("hinted handoff queue not empty")){P.warn(`Write to InfluxDB returns: ${h.json.error}`),c=204,u.complete();return}P.error("Write to InfluxDB failed.",h),a(h)},complete(){if(c==204||c==null)s();else{let h=`204 HTTP response status code expected, but ${c} returned`,b=new R(c,h,void 0,"0");b.message=h,u.error(b)}}},p={...xe,...i},m={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...i==null?void 0:i.headers},gzipThreshold:p.gzipThreshold};return this._transport.send(this._createWritePath(t,p,n),e.join(`
`),m,u),f}async close(){this._closed=!0}};var ir=require("apache-arrow");var er=require("@protobuf-ts/runtime-rpc");function C(r){let e=typeof r;if(e=="object"){if(Array.isArray(r))return"array";if(r===null)return"null"}return e}function Ce(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}var N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ee=[];for(let r=0;r<N.length;r++)ee[N[r].charCodeAt(0)]=r;ee["-".charCodeAt(0)]=N.indexOf("+");ee["_".charCodeAt(0)]=N.indexOf("/");function Dt(r){let e=r.length*3/4;r[r.length-2]=="="?e-=2:r[r.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,i=0,o,s=0;for(let a=0;a<r.length;a++){if(o=ee[r.charCodeAt(a)],o===void 0)switch(r[a]){case"=":i=0;case`
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:s=o,i=1;break;case 1:t[n++]=s<<2|(o&48)>>4,s=o,i=2;break;case 2:t[n++]=(s&15)<<4|(o&60)>>2,s=o,i=3;break;case 3:t[n++]=(s&3)<<6|o,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function _t(r){let e="",t=0,n,i=0;for(let o=0;o<r.length;o++)switch(n=r[o],t){case 0:e+=N[n>>2],i=(n&3)<<4,t=1;break;case 1:e+=N[i|n>>4],i=(n&15)<<2,t=2;break;case 2:e+=N[i|n>>6],e+=N[n&63],t=0;break}return t&&(e+=N[i],e+="=",t==1&&(e+="=")),e}var v;(function(r){r.symbol=Symbol.for("protobuf-ts/unknown"),r.onRead=(t,n,i,o,s)=>{(e(n)?n[r.symbol]:n[r.symbol]=[]).push({no:i,wireType:o,data:s})},r.onWrite=(t,n,i)=>{for(let{no:o,wireType:s,data:a}of r.list(n))i.tag(o,s).raw(a)},r.list=(t,n)=>{if(e(t)){let i=t[r.symbol];return n?i.filter(o=>o.no==n):i}return[]},r.last=(t,n)=>r.list(t,n).slice(-1)[0];let e=t=>t&&Array.isArray(t[r.symbol])})(v||(v={}));var x;(function(r){r[r.Varint=0]="Varint",r[r.Bit64=1]="Bit64",r[r.LengthDelimited=2]="LengthDelimited",r[r.StartGroup=3]="StartGroup",r[r.EndGroup=4]="EndGroup",r[r.Bit32=5]="Bit32"})(x||(x={}));function Ct(){let r=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(r|=(i&127)<<n,!(i&128))return this.assertBounds(),[r,e]}let t=this.buf[this.pos++];if(r|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[r,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,!(i&128))return this.assertBounds(),[r,e]}throw new Error("invalid varint")}function re(r,e,t){for(let o=0;o<28;o=o+7){let s=r>>>o,a=!(!(s>>>7)&&e==0),f=(a?s|128:s)&255;if(t.push(f),!a)return}let n=r>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?n|128:n)&255),!!i){for(let o=3;o<31;o=o+7){let s=e>>>o,a=!!(s>>>7),f=(a?s|128:s)&255;if(t.push(f),!a)return}t.push(e>>>31&1)}}var te=65536*65536;function Ue(r){let e=r[0]=="-";e&&(r=r.slice(1));let t=1e6,n=0,i=0;function o(s,a){let f=Number(r.slice(s,a));i*=t,n=n*t+f,n>=te&&(i=i+(n/te|0),n=n%te)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),[e,n,i]}function ne(r,e){if(e>>>0<=2097151)return""+(te*e+(r>>>0));let t=r&16777215,n=(r>>>24|e<<8)>>>0&16777215,i=e>>16&65535,o=t+n*6777216+i*6710656,s=n+i*8147497,a=i*2,f=1e7;o>=f&&(s+=Math.floor(o/f),o%=f),s>=f&&(a+=Math.floor(s/f),s%=f);function c(u,p){let m=u?String(u):"";return p?"0000000".slice(m.length)+m:m}return c(a,0)+c(s,a)+c(o,1)}function Le(r,e){if(r>=0){for(;r>127;)e.push(r&127|128),r=r>>>7;e.push(r)}else{for(let t=0;t<9;t++)e.push(r&127|128),r=r>>7;e.push(1)}}function Ut(){let r=this.buf[this.pos++],e=r&127;if(!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<7,!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<14,!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<21,!(r&128))return this.assertBounds(),e;r=this.buf[this.pos++],e|=(r&15)<<28;for(let t=5;r&128&&t<10;t++)r=this.buf[this.pos++];if(r&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var y;function Tr(){let r=new DataView(new ArrayBuffer(8));y=globalThis.BigInt!==void 0&&typeof r.getBigInt64=="function"&&typeof r.getBigUint64=="function"&&typeof r.setBigInt64=="function"&&typeof r.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:r}:void 0}Tr();function Lt(r){if(!r)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Bt=/^-?[0-9]+$/,oe=4294967296,ie=2147483648,se=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*oe+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},T=class r extends se{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 r(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(),!Bt.test(e))throw new Error("string is no integer");let[t,n,i]=Ue(e);if(t)throw new Error("signed value for ulong");return new r(n,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 r(e,e/oe)}throw new Error("unknown value "+typeof e)}toString(){return y?this.toBigInt().toString():ne(this.lo,this.hi)}toBigInt(){return Lt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigUint64(0,!0)}};T.ZERO=new T(0,0);var g=class r extends se{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 r(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(),!Bt.test(e))throw new Error("string is no integer");let[t,n,i]=Ue(e);if(t){if(i>ie||i==ie&&n!=0)throw new Error("signed long too small")}else if(i>=ie)throw new Error("signed long too large");let o=new r(n,i);return t?o.negate():o;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new r(e,e/oe):new r(-e,-e/oe).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&ie)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new r(t,e)}toString(){if(y)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ne(e.lo,e.hi)}return ne(this.lo,this.hi)}toBigInt(){return Lt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigInt64(0,!0)}};g.ZERO=new g(0,0);var Pt={readUnknownField:!0,readerFactory:r=>new Be(r)};function Vt(r){return r?Object.assign(Object.assign({},Pt),r):Pt}var Be=class{constructor(e,t){this.varint64=Ct,this.uint32=Ut,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,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case x.Varint:for(;this.buf[this.pos++]&128;);break;case x.Bit64:this.pos+=4;case x.Bit32:this.pos+=4;break;case x.LengthDelimited:let n=this.uint32();this.pos+=n;break;case x.StartGroup:let i;for(;(i=this.tag()[1])!==x.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 g(...this.varint64())}uint64(){return new T(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new g(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 T(this.sfixed32(),this.sfixed32())}sfixed64(){return new g(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 d(r,e){if(!r)throw new Error(e)}var Ir=34028234663852886e22,Or=-34028234663852886e22,kr=4294967295,Nr=2147483647,Er=-2147483648;function S(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>Nr||r<Er)throw new Error("invalid int 32: "+r)}function U(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>kr||r<0)throw new Error("invalid uint 32: "+r)}function W(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>Ir||r<Or))throw new Error("invalid float 32: "+r)}var vt={writeUnknownFields:!0,writerFactory:()=>new Pe};function Wt(r){return r?Object.assign(Object.assign({},vt),r):vt}var Pe=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),n=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],n),n+=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(U(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return S(e),Le(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){U(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){S(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return S(e),e=(e<<1^e>>31)>>>0,Le(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=g.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=T.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=g.from(e);return re(t.lo,t.hi,this.buf),this}sint64(e){let t=g.from(e),n=t.hi>>31,i=t.lo<<1^n,o=(t.hi<<1|t.lo>>>31)^n;return re(i,o,this.buf),this}uint64(e){let t=T.from(e);return re(t.lo,t.hi,this.buf),this}};var Mt={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},$t={ignoreUnknownFields:!1};function qt(r){return r?Object.assign(Object.assign({},$t),r):$t}function Jt(r){return r?Object.assign(Object.assign({},Mt),r):Mt}var Kt=Symbol.for("protobuf-ts/message-type");function Ve(r){let e=!1,t=[];for(let n=0;n<r.length;n++){let i=r.charAt(n);i=="_"?e=!0:/\d/.test(i)?(t.push(i),e=!0):e?(t.push(i.toUpperCase()),e=!1):n==0?t.push(i.toLowerCase()):t.push(i)}return t.join("")}var l;(function(r){r[r.DOUBLE=1]="DOUBLE",r[r.FLOAT=2]="FLOAT",r[r.INT64=3]="INT64",r[r.UINT64=4]="UINT64",r[r.INT32=5]="INT32",r[r.FIXED64=6]="FIXED64",r[r.FIXED32=7]="FIXED32",r[r.BOOL=8]="BOOL",r[r.STRING=9]="STRING",r[r.BYTES=12]="BYTES",r[r.UINT32=13]="UINT32",r[r.SFIXED32=15]="SFIXED32",r[r.SFIXED64=16]="SFIXED64",r[r.SINT32=17]="SINT32",r[r.SINT64=18]="SINT64"})(l||(l={}));var I;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING",r[r.NUMBER=2]="NUMBER"})(I||(I={}));var J;(function(r){r[r.NO=0]="NO",r[r.PACKED=1]="PACKED",r[r.UNPACKED=2]="UNPACKED"})(J||(J={}));function jt(r){var e,t,n,i;return r.localName=(e=r.localName)!==null&&e!==void 0?e:Ve(r.name),r.jsonName=(t=r.jsonName)!==null&&t!==void 0?t:Ve(r.name),r.repeat=(n=r.repeat)!==null&&n!==void 0?n:J.NO,r.opt=(i=r.opt)!==null&&i!==void 0?i:r.repeat||r.oneof?!1:r.kind=="message",r}function Gt(r){if(typeof r!="object"||r===null||!r.hasOwnProperty("oneofKind"))return!1;switch(typeof r.oneofKind){case"string":return r[r.oneofKind]===void 0?!1:Object.keys(r).length==2;case"undefined":return Object.keys(r).length==1;default:return!1}}var ae=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;let e=[],t=[],n=[];for(let i of this.fields)if(i.oneof)n.includes(i.oneof)||(n.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(n)}}is(e,t,n=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let i=Object.keys(e),o=this.data;if(i.length<o.req.length||o.req.some(s=>!i.includes(s))||!n&&i.some(s=>!o.known.includes(s)))return!1;if(t<1)return!0;for(let s of o.oneofs){let a=e[s];if(!Gt(a))return!1;if(a.oneofKind===void 0)continue;let f=this.fields.find(c=>c.localName===a.oneofKind);if(!f||!this.field(a[a.oneofKind],f,n,t))return!1}for(let s of this.fields)if(s.oneof===void 0&&!this.field(e[s.localName],s,n,t))return!1;return!0}field(e,t,n,i){let o=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:o?this.scalars(e,t.T,i,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:o?this.scalars(e,l.INT32,i):this.scalar(e,l.INT32);case"message":return e===void 0?!0:o?this.messages(e,t.T(),n,i):this.message(e,t.T(),n,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),l.INT32,i);case"message":return this.messages(Object.values(e),t.V.T(),n,i)}break}return!0}message(e,t,n,i){return n?t.isAssignable(e,i):t.is(e,i)}messages(e,t,n,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(n){for(let o=0;o<e.length&&o<i;o++)if(!t.isAssignable(e[o],i-1))return!1}else for(let o=0;o<e.length&&o<i;o++)if(!t.is(e[o],i-1))return!1;return!0}scalar(e,t,n){let i=typeof e;switch(t){case l.UINT64:case l.FIXED64:case l.INT64:case l.SFIXED64:case l.SINT64:switch(n){case I.BIGINT:return i=="bigint";case I.NUMBER:return i=="number"&&!isNaN(e);default:return i=="string"}case l.BOOL:return i=="boolean";case l.STRING:return i=="string";case l.BYTES:return e instanceof Uint8Array;case l.DOUBLE:case l.FLOAT:return i=="number"&&!isNaN(e);default:return i=="number"&&Number.isInteger(e)}}scalars(e,t,n,i){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e)){for(let o=0;o<e.length&&o<n;o++)if(!this.scalar(e[o],t,i))return!1}return!0}mapKeys(e,t,n){let i=Object.keys(e);switch(t){case l.INT32:case l.FIXED32:case l.SFIXED32:case l.SINT32:case l.UINT32:return this.scalars(i.slice(0,n).map(o=>parseInt(o)),t,n);case l.BOOL:return this.scalars(i.slice(0,n).map(o=>o=="true"?!0:o=="false"?!1:o),t,n);default:return this.scalars(i,t,n,I.STRING)}}};function O(r,e){switch(e){case I.BIGINT:return r.toBigInt();case I.NUMBER:return r.toNumber();default:return r.toString()}}var fe=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 n of t)this.fMap[n.name]=n,this.fMap[n.jsonName]=n,this.fMap[n.localName]=n}}assert(e,t,n){if(!e){let i=C(n);throw(i=="number"||i=="boolean")&&(i=n.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();let i=[];for(let[o,s]of Object.entries(e)){let a=this.fMap[o];if(!a){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${o}`);continue}let f=a.localName,c;if(a.oneof){if(s===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:f}}else c=t;if(a.kind=="map"){if(s===null)continue;this.assert(Ce(s),a.name,s);let u=c[f];for(let[p,m]of Object.entries(s)){this.assert(m!==null,a.name+" map value",null);let h;switch(a.V.kind){case"message":h=a.V.T().internalJsonRead(m,n);break;case"enum":if(h=this.enum(a.V.T(),m,a.name,n.ignoreUnknownFields),h===!1)continue;break;case"scalar":h=this.scalar(m,a.V.T,a.V.L,a.name);break}this.assert(h!==void 0,a.name+" map value",m);let b=p;a.K==l.BOOL&&(b=b=="true"?!0:b=="false"?!1:b),b=this.scalar(b,a.K,I.STRING,a.name).toString(),u[b]=h}}else if(a.repeat){if(s===null)continue;this.assert(Array.isArray(s),a.name,s);let u=c[f];for(let p of s){this.assert(p!==null,a.name,null);let m;switch(a.kind){case"message":m=a.T().internalJsonRead(p,n);break;case"enum":if(m=this.enum(a.T(),p,a.name,n.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(p,a.T,a.L,a.name);break}this.assert(m!==void 0,a.name,s),u.push(m)}}else switch(a.kind){case"message":if(s===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}c[f]=a.T().internalJsonRead(s,n,c[f]);break;case"enum":let u=this.enum(a.T(),s,a.name,n.ignoreUnknownFields);if(u===!1)continue;c[f]=u;break;case"scalar":c[f]=this.scalar(s,a.T,a.L,a.name);break}}}enum(e,t,n,i){if(e[0]=="google.protobuf.NullValue"&&d(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return d(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let o=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(o=t.substring(e[2].length));let s=e[1][o];return typeof s=="undefined"&&i?!1:(d(typeof s=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),s)}d(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,i){let o;try{switch(t){case l.DOUBLE:case l.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===""){o="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){o="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let s=Number(e);if(Number.isNaN(s)){o="not a number";break}if(!Number.isFinite(s)){o="too large or small";break}return t==l.FLOAT&&W(s),s;case l.INT32:case l.FIXED32:case l.SFIXED32:case l.SINT32:case l.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?o="empty string":typeof e=="string"&&(e.trim().length!==e.length?o="extra whitespace":a=Number(e)),a===void 0)break;return t==l.UINT32?U(a):S(a),a;case l.INT64:case l.SFIXED64:case l.SINT64:if(e===null)return O(g.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return O(g.from(e),n);case l.FIXED64:case l.UINT64:if(e===null)return O(T.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return O(T.from(e),n);case l.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case l.STRING:if(e===null)return"";if(typeof e!="string"){o="extra whitespace";break}try{encodeURIComponent(e)}catch(f){f="invalid UTF8";break}return e;case l.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return Dt(e)}}catch(s){o=s.message}this.assert(!1,i+(o?" - "+o:""),e)}};var le=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let n={},i=e;for(let o of this.fields){if(!o.oneof){let c=this.field(o,i[o.localName],t);c!==void 0&&(n[t.useProtoFieldName?o.name:o.jsonName]=c);continue}let s=i[o.oneof];if(s.oneofKind!==o.localName)continue;let a=o.kind=="scalar"||o.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t,f=this.field(o,s[o.localName],a);d(f!==void 0),n[t.useProtoFieldName?o.name:o.jsonName]=f}return n}field(e,t,n){let i;if(e.kind=="map"){d(typeof t=="object"&&t!==null);let o={};switch(e.V.kind){case"scalar":for(let[f,c]of Object.entries(t)){let u=this.scalar(e.V.T,c,e.name,!1,!0);d(u!==void 0),o[f.toString()]=u}break;case"message":let s=e.V.T();for(let[f,c]of Object.entries(t)){let u=this.message(s,c,e.name,n);d(u!==void 0),o[f.toString()]=u}break;case"enum":let a=e.V.T();for(let[f,c]of Object.entries(t)){d(c===void 0||typeof c=="number");let u=this.enum(a,c,e.name,!1,!0,n.enumAsInteger);d(u!==void 0),o[f.toString()]=u}break}(n.emitDefaultValues||Object.keys(o).length>0)&&(i=o)}else if(e.repeat){d(Array.isArray(t));let o=[];switch(e.kind){case"scalar":for(let f=0;f<t.length;f++){let c=this.scalar(e.T,t[f],e.name,e.opt,!0);d(c!==void 0),o.push(c)}break;case"enum":let s=e.T();for(let f=0;f<t.length;f++){d(t[f]===void 0||typeof t[f]=="number");let c=this.enum(s,t[f],e.name,e.opt,!0,n.enumAsInteger);d(c!==void 0),o.push(c)}break;case"message":let a=e.T();for(let f=0;f<t.length;f++){let c=this.message(a,t[f],e.name,n);d(c!==void 0),o.push(c)}break}(n.emitDefaultValues||o.length>0||n.emitDefaultValues)&&(i=o)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,n);break}return i}enum(e,t,n,i,o,s){if(e[0]=="google.protobuf.NullValue")return!o&&!i?void 0:null;if(t===void 0){d(i);return}if(!(t===0&&!o&&!i))return d(typeof t=="number"),d(Number.isInteger(t)),s||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,n,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,n,i,o){if(t===void 0){d(i);return}let s=o||i;switch(e){case l.INT32:case l.SFIXED32:case l.SINT32:return t===0?s?0:void 0:(S(t),t);case l.FIXED32:case l.UINT32:return t===0?s?0:void 0:(U(t),t);case l.FLOAT:W(t);case l.DOUBLE:return t===0?s?0:void 0:(d(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case l.STRING:return t===""?s?"":void 0:(d(typeof t=="string"),t);case l.BOOL:return t===!1?s?!1:void 0:(d(typeof t=="boolean"),t);case l.UINT64:case l.FIXED64:d(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=T.from(t);return a.isZero()&&!s?void 0:a.toString();case l.INT64:case l.SFIXED64:case l.SINT64:d(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let f=g.from(t);return f.isZero()&&!s?void 0:f.toString();case l.BYTES:return d(t instanceof Uint8Array),t.byteLength?_t(t):s?"":void 0}}};function K(r,e=I.STRING){switch(r){case l.BOOL:return!1;case l.UINT64:case l.FIXED64:return O(T.ZERO,e);case l.INT64:case l.SFIXED64:case l.SINT64:return O(g.ZERO,e);case l.DOUBLE:case l.FLOAT:return 0;case l.BYTES:return new Uint8Array(0);case l.STRING:return"";default:return 0}}var ce=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(n=>[n.no,n]))}}read(e,t,n,i){this.prepare();let o=i===void 0?e.len:e.pos+i;for(;e.pos<o;){let[s,a]=e.tag(),f=this.fieldNoToField.get(s);if(!f){let m=n.readUnknownField;if(m=="throw")throw new Error(`Unknown field ${s} (wire type ${a}) for ${this.info.typeName}`);let h=e.skip(a);m!==!1&&(m===!0?v.onRead:m)(this.info.typeName,t,s,a,h);continue}let c=t,u=f.repeat,p=f.localName;switch(f.oneof&&(c=c[f.oneof],c.oneofKind!==p&&(c=t[f.oneof]={oneofKind:p})),f.kind){case"scalar":case"enum":let m=f.kind=="enum"?l.INT32:f.T,h=f.kind=="scalar"?f.L:void 0;if(u){let A=c[p];if(a==x.LengthDelimited&&m!=l.STRING&&m!=l.BYTES){let F=e.uint32()+e.pos;for(;e.pos<F;)A.push(this.scalar(e,m,h))}else A.push(this.scalar(e,m,h))}else c[p]=this.scalar(e,m,h);break;case"message":if(u){let A=c[p],F=f.T().internalBinaryRead(e,e.uint32(),n);A.push(F)}else c[p]=f.T().internalBinaryRead(e,e.uint32(),n,c[p]);break;case"map":let[b,E]=this.mapEntry(f,e,n);c[p][b]=E;break}}}mapEntry(e,t,n){let i=t.uint32(),o=t.pos+i,s,a;for(;t.pos<o;){let[f,c]=t.tag();switch(f){case 1:e.K==l.BOOL?s=t.bool().toString():s=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(),n);break}break;default:throw new Error(`Unknown field ${f} (wire type ${c}) in map entry for ${this.info.typeName}#${e.name}`)}}if(s===void 0){let f=K(e.K);s=e.K==l.BOOL?f.toString():f}if(a===void 0)switch(e.V.kind){case"scalar":a=K(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[s,a]}scalar(e,t,n){switch(t){case l.INT32:return e.int32();case l.STRING:return e.string();case l.BOOL:return e.bool();case l.DOUBLE:return e.double();case l.FLOAT:return e.float();case l.INT64:return O(e.int64(),n);case l.UINT64:return O(e.uint64(),n);case l.FIXED64:return O(e.fixed64(),n);case l.FIXED32:return e.fixed32();case l.BYTES:return e.bytes();case l.UINT32:return e.uint32();case l.SFIXED32:return e.sfixed32();case l.SFIXED64:return O(e.sfixed64(),n);case l.SINT32:return e.sint32();case l.SINT64:return O(e.sint64(),n)}}};var ue=class{constructor(e){this.info=e}prepare(){if(!this.fields){let e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,n)=>t.no-n.no)}}write(e,t,n){this.prepare();for(let o of this.fields){let s,a,f=o.repeat,c=o.localName;if(o.oneof){let u=e[o.oneof];if(u.oneofKind!==c)continue;s=u[c],a=!0}else s=e[c],a=!1;switch(o.kind){case"scalar":case"enum":let u=o.kind=="enum"?l.INT32:o.T;if(f)if(d(Array.isArray(s)),f==J.PACKED)this.packed(t,u,o.no,s);else for(let p of s)this.scalar(t,u,o.no,p,!0);else s===void 0?d(o.opt):this.scalar(t,u,o.no,s,a||o.opt);break;case"message":if(f){d(Array.isArray(s));for(let p of s)this.message(t,n,o.T(),o.no,p)}else this.message(t,n,o.T(),o.no,s);break;case"map":d(typeof s=="object"&&s!==null);for(let[p,m]of Object.entries(s))this.mapEntry(t,n,o,p,m);break}}let i=n.writeUnknownFields;i!==!1&&(i===!0?v.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,n,i,o){e.tag(n.no,x.LengthDelimited),e.fork();let s=i;switch(n.K){case l.INT32:case l.FIXED32:case l.UINT32:case l.SFIXED32:case l.SINT32:s=Number.parseInt(i);break;case l.BOOL:d(i=="true"||i=="false"),s=i=="true";break}switch(this.scalar(e,n.K,1,s,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,o,!0);break;case"enum":this.scalar(e,l.INT32,2,o,!0);break;case"message":this.message(e,t,n.V.T(),2,o);break}e.join()}message(e,t,n,i,o){o!==void 0&&(n.internalBinaryWrite(o,e.tag(i,x.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,i,o){let[s,a,f]=this.scalarInfo(t,i);(!f||o)&&(e.tag(n,s),e[a](i))}packed(e,t,n,i){if(!i.length)return;d(t!==l.BYTES&&t!==l.STRING),e.tag(n,x.LengthDelimited),e.fork();let[,o]=this.scalarInfo(t);for(let s=0;s<i.length;s++)e[o](i[s]);e.join()}scalarInfo(e,t){let n=x.Varint,i,o=t===void 0,s=t===0;switch(e){case l.INT32:i="int32";break;case l.STRING:s=o||!t.length,n=x.LengthDelimited,i="string";break;case l.BOOL:s=t===!1,i="bool";break;case l.UINT32:i="uint32";break;case l.DOUBLE:n=x.Bit64,i="double";break;case l.FLOAT:n=x.Bit32,i="float";break;case l.INT64:s=o||g.from(t).isZero(),i="int64";break;case l.UINT64:s=o||T.from(t).isZero(),i="uint64";break;case l.FIXED64:s=o||T.from(t).isZero(),n=x.Bit64,i="fixed64";break;case l.BYTES:s=o||!t.byteLength,n=x.LengthDelimited,i="bytes";break;case l.FIXED32:n=x.Bit32,i="fixed32";break;case l.SFIXED32:n=x.Bit32,i="sfixed32";break;case l.SFIXED64:s=o||g.from(t).isZero(),n=x.Bit64,i="sfixed64";break;case l.SINT32:i="sint32";break;case l.SINT64:s=o||g.from(t).isZero(),i="sint64";break}return[n,i,o||s]}};function Xt(r){let e={};Object.defineProperty(e,Kt,{enumerable:!1,value:r});for(let t of r.fields){let n=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[n]=[];else switch(t.kind){case"scalar":e[n]=K(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function pe(r,e,t){let n,i=t,o;for(let s of r.fields){let a=s.localName;if(s.oneof){let f=i[s.oneof];if((f==null?void 0:f.oneofKind)==null)continue;if(n=f[a],o=e[s.oneof],o.oneofKind=f.oneofKind,n==null){delete o[a];continue}}else if(n=i[a],o=e,n==null)continue;switch(s.repeat&&(o[a].length=n.length),s.kind){case"scalar":case"enum":if(s.repeat)for(let c=0;c<n.length;c++)o[a][c]=n[c];else o[a]=n;break;case"message":let f=s.T();if(s.repeat)for(let c=0;c<n.length;c++)o[a][c]=f.create(n[c]);else o[a]===void 0?o[a]=f.create(n):f.mergePartial(o[a],n);break;case"map":switch(s.V.kind){case"scalar":case"enum":Object.assign(o[a],n);break;case"message":let c=s.V.T();for(let u of Object.keys(n))o[a][u]=c.create(n[u]);break}break}}}function zt(r,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let n of r.fields){let i=n.localName,o=n.oneof?e[n.oneof][i]:e[i],s=n.oneof?t[n.oneof][i]:t[i];switch(n.kind){case"enum":case"scalar":let a=n.kind=="enum"?l.INT32:n.T;if(!(n.repeat?Zt(a,o,s):Yt(a,o,s)))return!1;break;case"map":if(!(n.V.kind=="message"?Ht(n.V.T(),me(o),me(s)):Zt(n.V.kind=="enum"?l.INT32:n.V.T,me(o),me(s))))return!1;break;case"message":let f=n.T();if(!(n.repeat?Ht(f,o,s):f.equals(o,s)))return!1;break}}return!0}var me=Object.values;function Yt(r,e,t){if(e===t)return!0;if(r!==l.BYTES)return!1;let n=e,i=t;if(n.length!==i.length)return!1;for(let o=0;o<n.length;o++)if(n[o]!=i[o])return!1;return!0}function Zt(r,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Yt(r,e[n],t[n]))return!1;return!0}function Ht(r,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r.equals(e[n],t[n]))return!1;return!0}var w=class{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(jt),this.options=n!=null?n:{},this.refTypeCheck=new ae(this),this.refJsonReader=new fe(this),this.refJsonWriter=new le(this),this.refBinReader=new ce(this),this.refBinWriter=new ue(this)}create(e){let t=Xt(this);return e!==void 0&&pe(this,t,e),t}clone(e){let t=this.create();return pe(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){pe(this,e,t)}fromBinary(e,t){let n=Vt(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,qt(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,Jt(t))}toJsonString(e,t){var n;let i=this.toJson(e,t);return JSON.stringify(i,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toBinary(e,t){let n=Wt(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let i=n!=null?n:this.create();return this.refJsonReader.read(e,i,t),i}throw new Error(`Unable to parse message ${this.typeName} from JSON ${C(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,i){let o=i!=null?i:this.create();return this.refBinReader.read(e,o,n,t),o}};var ve=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=g.from(Math.floor(t/1e3)).toBigInt(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(g.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),n=e.getTime();return t.seconds=g.from(Math.floor(n/1e3)).toBigInt(),t.nanos=n%1e3*1e6,t}internalJsonWrite(e,t){let n=g.from(e.seconds).toNumber()*1e3;if(n<Date.parse("0001-01-01T00:00:00Z")||n>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 o=(e.nanos+1e9).toString().substring(1);o.substring(3)==="000000"?i="."+o.substring(0,3)+"Z":o.substring(6)==="000"?i="."+o.substring(0,6)+"Z":i="."+o+"Z"}return new Date(n).toISOString().replace(".000Z",i)}internalJsonRead(e,t,n){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+C(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 o=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(o))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(o<Date.parse("0001-01-01T00:00:00Z")||o>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 n||(n=this.create()),n.seconds=g.from(o/1e3).toBigInt(),n.nanos=0,i[7]&&(n.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),n}},Qt=new ve;var tr=(n=>(n[n.UNKNOWN=0]="UNKNOWN",n[n.PATH=1]="PATH",n[n.CMD=2]="CMD",n))(tr||{}),rr=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.CANCELLED=1]="CANCELLED",i[i.CANCELLING=2]="CANCELLING",i[i.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",i))(rr||{}),We=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}])}},Fr=new We,Me=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}])}},Rr=new Me,$e=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}])}},no=new $e,qe=class extends w{constructor(){super("arrow.flight.protocol.Empty",[])}},Sr=new qe,Je=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}])}},Ar=new Je,Ke=class extends w{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Dr=new Ke,je=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}])}},_r=new je,Ge=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>et}])}},io=new Ge,Xe=class extends w{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>nr}])}},oo=new Xe,Ze=class extends w{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Cr=new Ze,He=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",rr,"CANCEL_STATUS_"]}])}},so=new He,ze=class extends w{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Ur=new ze,Ye=class extends w{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",tr]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},de=new Ye,Qe=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:()=>de},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>nr},{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}])}},et=new Qe,tt=class extends w{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>ge},{no:2,name:"location",kind:"message",repeat:1,T:()=>Lr},{no:3,name:"expiration_time",kind:"message",T:()=>Qt}])}},nr=new tt,rt=class extends w{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},Lr=new rt,nt=class extends w{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},ge=new nt,it=class extends w{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>de},{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}])}},he=new it,ot=class extends w{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},Br=new ot,be=new er.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Fr,O:Rr},{name:"ListFlights",serverStreaming:!0,options:{},I:Dr,O:et},{name:"GetFlightInfo",options:{},I:de,O:et},{name:"GetSchema",options:{},I:de,O:Ur},{name:"DoGet",serverStreaming:!0,options:{},I:ge,O:he},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:he,O:Br},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:he,O:he},{name:"DoAction",serverStreaming:!0,options:{},I:_r,O:Cr},{name:"ListActions",serverStreaming:!0,options:{},I:Sr,O:Ar}]);var k=require("@protobuf-ts/runtime-rpc"),ye=class{constructor(e){this._transport=e;this.typeName=be.typeName;this.methods=be.methods;this.options=be.options}handshake(e){let t=this.methods[0],n=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,n)}listFlights(e,t){let n=this.methods[1],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,n,i,e)}getFlightInfo(e,t){let n=this.methods[2],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,n,i,e)}getSchema(e,t){let n=this.methods[3],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,n,i,e)}doGet(e,t){let n=this.methods[4],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,n,i,e)}doPut(e){let t=this.methods[5],n=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,n)}doExchange(e){let t=this.methods[6],n=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,n)}doAction(e,t){let n=this.methods[7],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,n,i,e)}listActions(e,t){let n=this.methods[8],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,n,i,e)}};var j=class{constructor(e){this._options=e;this._closed=!1;this._transport=$.queryTransport(this._options),this._flightClient=new ye(this._transport)}async*query(e,t,n){var h;if(this._closed)throw new Error("queryApi: already closed!");let i=this._flightClient,o={database:t,sql_query:e,query_type:n},s=ge.create({ticket:new TextEncoder().encode(JSON.stringify(o))}),a={},f=this._options.token;f&&(a.authorization=`Bearer ${f}`);let c={meta:a},u=i.doGet(s,c),p=async function*(){for await(let b of u.responses)yield yt(b.dataHeader.length),yield b.dataHeader,yield b.dataBody}(),m=await ir.RecordBatchReader.from(p);for await(let b of m)for(let E=0;E<b.numRows;E++){let A={};for(let F=0;F<b.numCols;F++){let sr=b.schema.fields[F].name,ar=(h=b.getChildAt(F))==null?void 0:h.get(E);A[sr]=ar}yield A}}async close(){var e,t;this._closed=!0,(t=(e=this._transport).close)==null||t.call(e)}};var or=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
`,G=class{constructor(e){this._mergeWriteOptions=e=>({...this._options.writeOptions,...e});if(e==null)throw new L("No configuration specified!");this._options=e;let t=this._options.host;if(typeof t!="string")throw new L("No host specified!");t.endsWith("/")&&(this._options.host=t.substring(0,t.length-1)),this._queryApi=new j(this._options),this._writeApi=new q(this._options)}async write(e,t,n,i){var o;await this._writeApi.doWrite(Re(e),(o=t!=null?t:this._options.database)!=null?o:Fe(new Error(or)),n,this._mergeWriteOptions(i))}query(e,t,n="sql"){var i;return this._queryApi.query(e,(i=t!=null?t:this._options.database)!=null?i:Fe(new Error(or)),n)}async close(){await this._writeApi.close(),await this._queryApi.close()}};0&&(module.exports={AbortError,DEFAULT_ConnectionOptions,DEFAULT_WriteOptions,HttpError,IllegalArgumentError,InfluxDBClient,Log,Point,RequestTimedOutError,collectAll,consoleLogger,convertTime,convertTimeToNanos,createTextDecoderCombiner,currentTime,dateToProtocolTimestamp,escape,setLogger,useProcessHrtime,writableDataToLineProtocol});
"use strict";var lr=Object.create;var X=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var cr=Object.getPrototypeOf,pr=Object.prototype.hasOwnProperty;var mr=(r,e)=>{for(var t in e)X(r,t,{get:e[t],enumerable:!0})},ft=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fr(e))!pr.call(r,i)&&i!==t&&X(r,i,{get:()=>e[i],enumerable:!(n=ur(e,i))||n.enumerable});return r};var Z=(r,e,t)=>(t=r!=null?lr(cr(r)):{},ft(e||!r||!r.__esModule?X(t,"default",{value:r,enumerable:!0}):t,r)),hr=r=>ft(X({},"__esModule",{value:!0}),r);var Vr={};mr(Vr,{AbortError:()=>A,DEFAULT_ConnectionOptions:()=>Ie,DEFAULT_WriteOptions:()=>Oe,GetFieldTypeMissmatchError:()=>ee,HttpError:()=>E,IllegalArgumentError:()=>U,InfluxDBClient:()=>K,Log:()=>L,Point:()=>M,PointValues:()=>_,RequestTimedOutError:()=>B,collectAll:()=>It,consoleLogger:()=>ct,convertTime:()=>Re,convertTimeToNanos:()=>Se,createTextDecoderCombiner:()=>dr,currentTime:()=>yt,dateToProtocolTimestamp:()=>wt,escape:()=>D,setLogger:()=>gr,useProcessHrtime:()=>bt,writableDataToLineProtocol:()=>Ae});module.exports=hr(Vr);var U=class r extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,r.prototype)}},E=class r extends Error{constructor(t,n,i,s,o){super();this.statusCode=t;this.statusMessage=n;this.body=i;this.contentType=s;if(Object.setPrototypeOf(this,r.prototype),o)this.message=o;else if(i){if(s!=null&&s.startsWith("application/json"))try{this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code}catch(a){}this.message||(this.message=`${t} ${n} : ${i}`)}else this.message=`${t} ${n}`;this.name="HttpError"}},B=class r extends Error{constructor(){super(),Object.setPrototypeOf(this,r.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},A=class r extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,r.prototype),this.message="Response aborted"}};function dr(){let r=new TextDecoder("utf-8");return{concat(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n},copy(e,t,n){let i=new Uint8Array(n-t);return i.set(e.subarray(t,n)),i},toUtf8String(e,t,n){return r.decode(e.subarray(t,n))}}}var Ie={timeout:1e4},Oe={precision:"ns",gzipThreshold:1e3};var ct={error(r,e){console.error(`ERROR: ${r}`,e||"")},warn(r,e){console.warn(`WARN: ${r}`,e||"")}},H=ct,L={error(r,e){H.error(r,e)},warn(r,e){H.warn(r,e)}};function gr(r){let e=H;return H=r,e}function Ne(r,e){return function(t){let n="",i=0,s=0;for(;s<t.length;){let o=r.indexOf(t[s]);o>=0&&(n+=t.substring(i,s),n+=e[o],i=s+1),s++}return i==0?t:(i<t.length&&(n+=t.substring(i,t.length)),n)}}function br(r,e){let t=Ne(r,e);return n=>`"${t(n)}"`}var D={measurement:Ne(`,
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:br('"\\',['\\"',"\\\\"]),tag:Ne(`, =
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var Y="000000000",_e=!1;function bt(r){return _e=r&&process&&typeof process.hrtime=="function"}bt(!0);var pt,z,mt=Date.now(),ke=0;function Ee(){if(_e){let r=process.hrtime(),e=Date.now();z?(r[0]=r[0]-z[0],r[1]=r[1]-z[1],r[1]<0&&(r[0]-=1,r[1]+=1e9),e=pt+r[0]*1e3+Math.floor(r[1]/1e6)):(z=r,pt=e);let t=String(r[1]%1e6);return String(e)+Y.substr(0,6-t.length)+t}else{let r=Date.now();r!==mt?(mt=r,ke=0):ke++;let e=String(ke);return String(r)+Y.substr(0,6-e.length)+e}}function ht(){if(_e){let r=process.hrtime(),e=String(Math.trunc(r[1]/1e3)%1e3);return String(Date.now())+Y.substr(0,3-e.length)+e}else return String(Date.now())+Y.substr(0,3)}function dt(){return String(Date.now())}function gt(){return String(Math.floor(Date.now()/1e3))}var yt={s:gt,ms:dt,us:ht,ns:Ee,seconds:gt,millis:dt,micros:ht,nanos:Ee},wt={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function Se(r){return r===void 0?Ee():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var Re=(r,e="ns")=>r===void 0?yt[e]():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?wt[e](r):String(typeof r=="number"?Math.floor(r):r);var Q=r=>{throw r},Tt=r=>r!==void 0,xt=r=>r instanceof Array||r instanceof Object&&typeof r.length=="number"&&(r.length===0||Object.getOwnPropertyNames(r).some(e=>e==="0")),Ft=r=>{let e=new Uint8Array(4);return e[0]=r>>0,e[1]=r>>8,e[2]=r>>16,e[3]=r>>24,e},It=async r=>{let e=[];for await(let t of r)e.push(t);return e};var Ae=r=>{let e=xt(r)&&typeof r!="string"?Array.from(r):[r];return e.length===0?[]:typeof e[0]=="string"?e:e.map(n=>n.toLineProtocol()).filter(Tt)};var yr=r=>typeof r=="number"?"float":typeof r=="string"?"string":typeof r=="boolean"?"boolean":void 0,ee=class r extends Error{constructor(e,t,n){super(`field ${e} of type ${n} doesn't match expected type ${t}!`),this.name="GetFieldTypeMissmatchError",Object.setPrototypeOf(this,r.prototype)}},_=class r{constructor(){this._tags={};this._fields={}}getMeasurement(){return this._name}setMeasurement(e){return this._name=e,this}getTimestamp(){return this._time}setTimestamp(e){return this._time=e,this}getTag(e){return this._tags[e]}setTag(e,t){return this._tags[e]=t,this}removeTag(e){return delete this._tags[e],this}getTagNames(){return Object.keys(this._tags)}getFloatField(e){return this.getField(e,"float")}setFloatField(e,t){let n;if(typeof t=="number"?n=t:n=parseFloat(t),!isFinite(n))throw new Error(`invalid float value for field '${e}': '${t}'!`);return this._fields[e]=["float",n],this}getIntegerField(e){return this.getField(e,"integer")}setIntegerField(e,t){let n;if(typeof t=="number"?n=t:n=parseInt(String(t)),isNaN(n)||n<=-9223372036854776e3||n>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${t}'!`);return this._fields[e]=["integer",Math.floor(n)],this}getUintegerField(e){return this.getField(e,"uinteger")}setUintegerField(e,t){if(typeof t=="number"){if(isNaN(t)||t<0||t>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${e}' out of range: ${t}`);this._fields[e]=["uinteger",Math.floor(t)]}else{let n=String(t);for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${i}: ${t}`)}if(n.length>20||n.length===20&&n.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${n}`);this._fields[e]=["uinteger",+n]}return this}getStringField(e){return this.getField(e,"string")}setStringField(e,t){return t!=null&&(typeof t!="string"&&(t=String(t)),this._fields[e]=["string",t]),this}getBooleanField(e){return this.getField(e,"boolean")}setBooleanField(e,t){return this._fields[e]=["boolean",!!t],this}getField(e,t){let n=this._fields[e];if(!n)return;let[i,s]=n;if(t!==void 0&&t!==i)throw new ee(e,t,i);return s}getFieldType(e){let t=this._fields[e];if(t)return t[0]}setField(e,t,n){switch(n!=null?n:yr(t)){case"string":return this.setStringField(e,t);case"boolean":return this.setBooleanField(e,t);case"float":return this.setFloatField(e,t);case"integer":return this.setIntegerField(e,t);case"uinteger":return this.setUintegerField(e,t);case void 0:return this;default:throw new Error(`invalid field type for field '${e}': type -> ${n}, value -> ${t}!`)}}setFields(e){for(let[t,n]of Object.entries(e))this.setField(t,n);return this}removeField(e){return delete this._fields[e],this}getFieldNames(){return Object.keys(this._fields)}hasFields(){return this.getFieldNames().length>0}copy(){let e=new r;return e._name=this._name,e._time=this._time,e._tags=Object.fromEntries(Object.entries(this._tags)),e._fields=Object.fromEntries(Object.entries(this._fields).map(t=>[...t])),e}asPoint(e){return M.fromValues(e?this.setMeasurement(e):this)}};var wr=(r,e)=>{switch(r){case"string":return D.quoted(e);case"boolean":return e?"T":"F";case"float":return`${e}`;case"integer":return`${e}i`;case"uinteger":return`${e}u`}},M=class r{constructor(e){e instanceof _?this._values=e:this._values=new _,typeof e=="string"&&this._values.setMeasurement(e)}static measurement(e){return new r(e)}static fromValues(e){if(!e.getMeasurement()||e.getMeasurement()==="")throw new Error("Cannot convert values to point without measurement set!");return new r(e)}getMeasurement(){return this._values.getMeasurement()}setMeasurement(e){return e!==""&&this._values.setMeasurement(e),this}getTimestamp(){return this._values.getTimestamp()}setTimestamp(e){return this._values.setTimestamp(e),this}getTag(e){return this._values.getTag(e)}setTag(e,t){return this._values.setTag(e,t),this}removeTag(e){return this._values.removeTag(e),this}getTagNames(){return this._values.getTagNames()}getFloatField(e){return this._values.getFloatField(e)}setFloatField(e,t){return this._values.setFloatField(e,t),this}getIntegerField(e){return this._values.getIntegerField(e)}setIntegerField(e,t){return this._values.setIntegerField(e,t),this}getUintegerField(e){return this._values.getUintegerField(e)}setUintegerField(e,t){return this._values.setUintegerField(e,t),this}getStringField(e){return this._values.getStringField(e)}setStringField(e,t){return this._values.setStringField(e,t),this}getBooleanField(e){return this._values.getBooleanField(e)}setBooleanField(e,t){return this._values.setBooleanField(e,t),this}getField(e,t){return this._values.getField(e,t)}getFieldType(e){return this._values.getFieldType(e)}setField(e,t,n){return this._values.setField(e,t,n),this}setFields(e){return this._values.setFields(e),this}removeField(e){return this._values.removeField(e),this}getFieldNames(){return this._values.getFieldNames()}hasFields(){return this._values.hasFields()}copy(){return new r(this._values.copy())}toLineProtocol(e){if(!this._values.getMeasurement())return;let t="";if(this._values.getFieldNames().sort().forEach(o=>{if(o){let a=this._values.getFieldType(o),l=this._values.getField(o);if(a===void 0||l===void 0)return;let f=wr(a,l);t.length>0&&(t+=","),t+=`${D.tag(o)}=${f}`}}),t.length===0)return;let n="";this._values.getTagNames().sort().forEach(o=>{if(o){let a=this._values.getTag(o);a&&(n+=",",n+=`${D.tag(o)}=${D.tag(a)}`)}});let s=this._values.getTimestamp();return e?typeof e=="string"?s=Re(s,e):s=e(s):s=Se(s),`${D.measurement(this.getMeasurement())}${n} ${t}${s!==void 0?` ${s}`:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}};var Pe=require("url"),Nt=Z(require("http")),kt=Z(require("https")),te=require("buffer");var W=Z(require("zlib"));function De(r={}){let e=0,t={next:n=>{if(e===0&&r.next&&n!==null&&n!==void 0)return r.next(n)},error:n=>{e===0&&(e=1,r.error&&r.error(n))},complete:()=>{e===0&&(e=2,r.complete&&r.complete())},responseStarted:(n,i)=>{r.responseStarted&&r.responseStarted(n,i)}};return r.useCancellable&&(t.useCancellable=r.useCancellable.bind(r)),r.useResume&&(t.useResume=r.useResume.bind(r)),t}var Ot="0.3.0.nightly";var Et=require("stream");var Tr={flush:W.default.constants.Z_SYNC_FLUSH,finishFlush:W.default.constants.Z_SYNC_FLUSH},xr=te.Buffer.allocUnsafe(0),Ce=class{constructor(){this._cancelled=!1}cancel(){this._cancelled=!0,this.resume&&(this.resume(),this.resume=void 0)}isCancelled(){return this._cancelled}},Ue=class{constructor(e){var l,f,c,p,m,h,T;let{host:t,proxyUrl:n,token:i,transportOptions:s,...o}=e,a=(0,Pe.parse)(n||t);if(this._token=i,this._defaultOptions={...Ie,...o,...s,port:a.port,protocol:a.protocol,hostname:a.hostname},this._contextPath=n?t:(l=a.path)!=null?l:"",this._contextPath.endsWith("/")&&(this._contextPath=this._contextPath.substring(0,this._contextPath.length-1)),Object.keys(this._defaultOptions).forEach(k=>this._defaultOptions[k]===void 0&&delete this._defaultOptions[k]),this._contextPath.endsWith("/api/v2")&&(L.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${a.protocol}//${a.hostname}:${a.port} !`),this._contextPath=""),a.protocol==="http:")this._requestApi=(p=(c=(f=this._defaultOptions["follow-redirects"])==null?void 0:f.http)==null?void 0:c.request)!=null?p:Nt.request;else if(a.protocol==="https:")this._requestApi=(T=(h=(m=this._defaultOptions["follow-redirects"])==null?void 0:m.https)==null?void 0:h.request)!=null?T:kt.request;else throw new Error(`Unsupported protocol "${a.protocol} in URL: "${e.host}"`);this._headers={"User-Agent":`influxdb-client-js/${Ot}`,...e.headers},n&&(this._headers.Host=(0,Pe.parse)(t).host)}send(e,t,n,i){let s=new Ce;i&&i.useCancellable&&i.useCancellable(s),this._createRequestMessage(e,t,n,o=>{this._request(o,s,i)},o=>(i==null?void 0:i.error)&&i.error(o))}request(e,t,n,i){t?typeof t!="string"&&(t=JSON.stringify(t)):t="";let s=xr,o,a;return new Promise((l,f)=>{this.send(e,t,n,{responseStarted(c,p){i&&i(c,p),o=String(c["content-type"]),a=p},next:c=>{s=te.Buffer.concat([s,c])},complete:()=>{var p,m;let c=(m=(p=n.headers)==null?void 0:p.accept)!=null?m:o;try{a===204&&l(void 0),c.includes("json")?s.length?l(JSON.parse(s.toString("utf8"))):l(void 0):c.includes("text")||c.startsWith("application/csv")?l(s.toString("utf8")):l(s)}catch(h){f(h)}},error:c=>{f(c)}})})}async*iterate(e,t,n){var c;let i,s;function o(p){i=p,s(p)}let a=await new Promise((p,m)=>{s=m,this._createRequestMessage(e,t,n,p,o)});(c=a.signal)!=null&&c.addEventListener&&a.signal.addEventListener("abort",()=>{o(new A)});let l=await new Promise((p,m)=>{s=m;let h=this._requestApi(a,p);h.on("timeout",()=>o(new B)),h.on("error",o),h.write(a.body),h.end()}),f=await new Promise((p,m)=>{s=m,this._prepareResponse(l,p,o)});for await(let p of f){if(i)throw i;yield p}}_createRequestMessage(e,t,n,i,s){let o=te.Buffer.from(t,"utf-8"),a={"content-type":"application/json; charset=utf-8",...this._headers};this._token&&(a.authorization=`Token ${this._token}`);let l={...this._defaultOptions,path:this._contextPath+e,method:n.method,headers:{...a,...n.headers}};if(n.signal&&(l.signal=n.signal),n.gzipThreshold!==void 0&&n.gzipThreshold<o.length){W.default.gzip(o,(f,c)=>{if(f)return s(f);l.headers["content-encoding"]="gzip",l.body=c,i(l)});return}l.body=o,l.headers["content-length"]=l.body.length,i(l)}_prepareResponse(e,t,n){var a;e.on("aborted",()=>{n(new A)}),e.on("error",n);let i=(a=e.statusCode)!=null?a:600,s=e.headers["content-encoding"],o;if(s==="gzip"?(o=W.default.createGunzip(Tr),o=(0,Et.pipeline)(e,o,l=>l&&n(l))):o=e,i>=300){let l="",f=String(e.headers["content-type"]).startsWith("application/json");o.on("data",c=>{l+=c.toString(),!f&&l.length>1e3&&(l=l.slice(0,1e3),e.resume())}),o.on("end",()=>{l===""&&e.headers["x-influxdb-error"]&&(l=e.headers["x-influxdb-error"].toString()),n(new E(i,e.statusMessage,l,e.headers["retry-after"],e.headers["content-type"]))})}else t(o)}_request(e,t,n){var o;let i=De(n);if(t.isCancelled()){i.complete();return}(o=e.signal)!=null&&o.addEventListener&&e.signal.addEventListener("abort",()=>{i.error(new A)});let s=this._requestApi(e,a=>{if(t.isCancelled()){a.resume(),i.complete();return}i.responseStarted(a.headers,a.statusCode),this._prepareResponse(a,l=>{l.on("data",f=>{if(t.isCancelled())a.resume();else if(i.next(f)===!1){if(!i.useResume){i.error(new Error("Unable to pause, useResume is not configured!")),a.resume();return}a.pause();let c=()=>{a.resume()};t.resume=c,i.useResume(c)}}),l.on("end",i.complete)},i.error)});typeof s.setTimeout=="function"&&e.timeout&&s.setTimeout(e.timeout),s.on("timeout",()=>{i.error(new B)}),s.on("error",a=>{i.error(a)}),e.body&&s.write(e.body),s.end()}},_t=Ue;var Dt=require("@protobuf-ts/grpc-transport");var St="http://",Rt="https://",At=r=>{r=r.replace(/\/$/,"");let e;return r.startsWith(St)?(r=r.slice(St.length),e=!1,r.includes(":")||(r=`${r}:80`)):r.startsWith(Rt)&&(r=r.slice(Rt.length),e=!0,r.includes(":")||(r=`${r}:443`)),{url:r,safe:e}};var Pt=Z(require("@grpc/grpc-js")),Ct=({host:r})=>{let{url:e,safe:t}=At(r),n=Pt.credentials[t==null||t?"createSsl":"createInsecure"]();return new Dt.GrpcTransport({host:e,channelCredentials:n})};var Fr={writeTransport:r=>new _t(r),queryTransport:Ct},q=Fr;var $=class{constructor(e){this._options=e;this._closed=!1;var t;this._transport=(t=this._options.transport)!=null?t:q.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_createWritePath(e,t,n){let i=[`bucket=${encodeURIComponent(e)}`,`precision=${t.precision}`];n&&i.push(`org=${encodeURIComponent(n)}`);let s=t==null?void 0:t.consistency;return s&&i.push(`consistency=${encodeURIComponent(s)}`),`/api/v2/write?${i.join("&")}`}doWrite(e,t,n,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,T)=>{o=h,a=T}),f,c={responseStarted(h,T){f=T},error(h){if(h instanceof E&&h.json&&typeof h.json.error=="string"&&h.json.error.includes("hinted handoff queue not empty")){L.warn(`Write to InfluxDB returns: ${h.json.error}`),f=204,c.complete();return}L.error("Write to InfluxDB failed.",h),a(h)},complete(){if(f==204||f==null)o();else{let h=`204 HTTP response status code expected, but ${f} returned`,T=new E(f,h,void 0,"0");T.message=h,c.error(T)}}},p={...Oe,...i},m={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...i==null?void 0:i.headers},gzipThreshold:p.gzipThreshold};return this._transport.send(this._createWritePath(t,p,n),e.join(`
`),m,c),l}async close(){this._closed=!0}};var xe=require("apache-arrow");var ir=require("@protobuf-ts/runtime-rpc");function P(r){let e=typeof r;if(e=="object"){if(Array.isArray(r))return"array";if(r===null)return"null"}return e}function Be(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}var N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),re=[];for(let r=0;r<N.length;r++)re[N[r].charCodeAt(0)]=r;re["-".charCodeAt(0)]=N.indexOf("+");re["_".charCodeAt(0)]=N.indexOf("/");function Ut(r){let e=r.length*3/4;r[r.length-2]=="="?e-=2:r[r.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,i=0,s,o=0;for(let a=0;a<r.length;a++){if(s=re[r.charCodeAt(a)],s===void 0)switch(r[a]){case"=":i=0;case`
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:o=s,i=1;break;case 1:t[n++]=o<<2|(s&48)>>4,o=s,i=2;break;case 2:t[n++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[n++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function Bt(r){let e="",t=0,n,i=0;for(let s=0;s<r.length;s++)switch(n=r[s],t){case 0:e+=N[n>>2],i=(n&3)<<4,t=1;break;case 1:e+=N[i|n>>4],i=(n&15)<<2,t=2;break;case 2:e+=N[i|n>>6],e+=N[n&63],t=0;break}return t&&(e+=N[i],e+="=",t==1&&(e+="=")),e}var v;(function(r){r.symbol=Symbol.for("protobuf-ts/unknown"),r.onRead=(t,n,i,s,o)=>{(e(n)?n[r.symbol]:n[r.symbol]=[]).push({no:i,wireType:s,data:o})},r.onWrite=(t,n,i)=>{for(let{no:s,wireType:o,data:a}of r.list(n))i.tag(s,o).raw(a)},r.list=(t,n)=>{if(e(t)){let i=t[r.symbol];return n?i.filter(s=>s.no==n):i}return[]},r.last=(t,n)=>r.list(t,n).slice(-1)[0];let e=t=>t&&Array.isArray(t[r.symbol])})(v||(v={}));var w;(function(r){r[r.Varint=0]="Varint",r[r.Bit64=1]="Bit64",r[r.LengthDelimited=2]="LengthDelimited",r[r.StartGroup=3]="StartGroup",r[r.EndGroup=4]="EndGroup",r[r.Bit32=5]="Bit32"})(w||(w={}));function Lt(){let r=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(r|=(i&127)<<n,!(i&128))return this.assertBounds(),[r,e]}let t=this.buf[this.pos++];if(r|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[r,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,!(i&128))return this.assertBounds(),[r,e]}throw new Error("invalid varint")}function ie(r,e,t){for(let s=0;s<28;s=s+7){let o=r>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}let n=r>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?n|128:n)&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 ne=65536*65536;function Le(r){let e=r[0]=="-";e&&(r=r.slice(1));let t=1e6,n=0,i=0;function s(o,a){let l=Number(r.slice(o,a));i*=t,n=n*t+l,n>=ne&&(i=i+(n/ne|0),n=n%ne)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,i]}function se(r,e){if(e>>>0<=2097151)return""+(ne*e+(r>>>0));let t=r&16777215,n=(r>>>24|e<<8)>>>0&16777215,i=e>>16&65535,s=t+n*6777216+i*6710656,o=n+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 f(c,p){let m=c?String(c):"";return p?"0000000".slice(m.length)+m:m}return f(a,0)+f(o,a)+f(s,1)}function ve(r,e){if(r>=0){for(;r>127;)e.push(r&127|128),r=r>>>7;e.push(r)}else{for(let t=0;t<9;t++)e.push(r&127|128),r=r>>7;e.push(1)}}function vt(){let r=this.buf[this.pos++],e=r&127;if(!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<7,!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<14,!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<21,!(r&128))return this.assertBounds(),e;r=this.buf[this.pos++],e|=(r&15)<<28;for(let t=5;r&128&&t<10;t++)r=this.buf[this.pos++];if(r&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var b;function Ir(){let r=new DataView(new ArrayBuffer(8));b=globalThis.BigInt!==void 0&&typeof r.getBigInt64=="function"&&typeof r.getBigUint64=="function"&&typeof r.setBigInt64=="function"&&typeof r.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:r}:void 0}Ir();function Vt(r){if(!r)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Mt=/^-?[0-9]+$/,ae=4294967296,oe=2147483648,le=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*ae+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},x=class r extends le{static from(e){if(b)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=b.C(e);case"number":if(e===0)return this.ZERO;e=b.C(e);case"bigint":if(!e)return this.ZERO;if(e<b.UMIN)throw new Error("signed value for ulong");if(e>b.UMAX)throw new Error("ulong too large");return b.V.setBigUint64(0,e,!0),new r(b.V.getInt32(0,!0),b.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Mt.test(e))throw new Error("string is no integer");let[t,n,i]=Le(e);if(t)throw new Error("signed value for ulong");return new r(n,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 r(e,e/ae)}throw new Error("unknown value "+typeof e)}toString(){return b?this.toBigInt().toString():se(this.lo,this.hi)}toBigInt(){return Vt(b),b.V.setInt32(0,this.lo,!0),b.V.setInt32(4,this.hi,!0),b.V.getBigUint64(0,!0)}};x.ZERO=new x(0,0);var g=class r extends le{static from(e){if(b)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=b.C(e);case"number":if(e===0)return this.ZERO;e=b.C(e);case"bigint":if(!e)return this.ZERO;if(e<b.MIN)throw new Error("signed long too small");if(e>b.MAX)throw new Error("signed long too large");return b.V.setBigInt64(0,e,!0),new r(b.V.getInt32(0,!0),b.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Mt.test(e))throw new Error("string is no integer");let[t,n,i]=Le(e);if(t){if(i>oe||i==oe&&n!=0)throw new Error("signed long too small")}else if(i>=oe)throw new Error("signed long too large");let s=new r(n,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 r(e,e/ae):new r(-e,-e/ae).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&oe)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new r(t,e)}toString(){if(b)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+se(e.lo,e.hi)}return se(this.lo,this.hi)}toBigInt(){return Vt(b),b.V.setInt32(0,this.lo,!0),b.V.setInt32(4,this.hi,!0),b.V.getBigInt64(0,!0)}};g.ZERO=new g(0,0);var Wt={readUnknownField:!0,readerFactory:r=>new Ve(r)};function qt(r){return r?Object.assign(Object.assign({},Wt),r):Wt}var Ve=class{constructor(e,t){this.varint64=Lt,this.uint32=vt,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,n=e&7;if(t<=0||n<0||n>5)throw new 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 n=this.uint32();this.pos+=n;break;case w.StartGroup:let i;for(;(i=this.tag()[1])!==w.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 g(...this.varint64())}uint64(){return new x(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new g(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 x(this.sfixed32(),this.sfixed32())}sfixed64(){return new g(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 d(r,e){if(!r)throw new Error(e)}var Or=34028234663852886e22,Nr=-34028234663852886e22,kr=4294967295,Er=2147483647,_r=-2147483648;function S(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>Er||r<_r)throw new Error("invalid int 32: "+r)}function C(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>kr||r<0)throw new Error("invalid uint 32: "+r)}function V(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>Or||r<Nr))throw new Error("invalid float 32: "+r)}var $t={writeUnknownFields:!0,writerFactory:()=>new Me};function Jt(r){return r?Object.assign(Object.assign({},$t),r):$t}var Me=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),n=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],n),n+=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(C(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return S(e),ve(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){V(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){C(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){S(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return S(e),e=(e<<1^e>>31)>>>0,ve(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=g.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=x.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=g.from(e);return ie(t.lo,t.hi,this.buf),this}sint64(e){let t=g.from(e),n=t.hi>>31,i=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return ie(i,s,this.buf),this}uint64(e){let t=x.from(e);return ie(t.lo,t.hi,this.buf),this}};var jt={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Gt={ignoreUnknownFields:!1};function Kt(r){return r?Object.assign(Object.assign({},Gt),r):Gt}function Xt(r){return r?Object.assign(Object.assign({},jt),r):jt}var Zt=Symbol.for("protobuf-ts/message-type");function We(r){let e=!1,t=[];for(let n=0;n<r.length;n++){let i=r.charAt(n);i=="_"?e=!0:/\d/.test(i)?(t.push(i),e=!0):e?(t.push(i.toUpperCase()),e=!1):n==0?t.push(i.toLowerCase()):t.push(i)}return t.join("")}var u;(function(r){r[r.DOUBLE=1]="DOUBLE",r[r.FLOAT=2]="FLOAT",r[r.INT64=3]="INT64",r[r.UINT64=4]="UINT64",r[r.INT32=5]="INT32",r[r.FIXED64=6]="FIXED64",r[r.FIXED32=7]="FIXED32",r[r.BOOL=8]="BOOL",r[r.STRING=9]="STRING",r[r.BYTES=12]="BYTES",r[r.UINT32=13]="UINT32",r[r.SFIXED32=15]="SFIXED32",r[r.SFIXED64=16]="SFIXED64",r[r.SINT32=17]="SINT32",r[r.SINT64=18]="SINT64"})(u||(u={}));var F;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING",r[r.NUMBER=2]="NUMBER"})(F||(F={}));var J;(function(r){r[r.NO=0]="NO",r[r.PACKED=1]="PACKED",r[r.UNPACKED=2]="UNPACKED"})(J||(J={}));function Ht(r){var e,t,n,i;return r.localName=(e=r.localName)!==null&&e!==void 0?e:We(r.name),r.jsonName=(t=r.jsonName)!==null&&t!==void 0?t:We(r.name),r.repeat=(n=r.repeat)!==null&&n!==void 0?n:J.NO,r.opt=(i=r.opt)!==null&&i!==void 0?i:r.repeat||r.oneof?!1:r.kind=="message",r}function zt(r){if(typeof r!="object"||r===null||!r.hasOwnProperty("oneofKind"))return!1;switch(typeof r.oneofKind){case"string":return r[r.oneofKind]===void 0?!1:Object.keys(r).length==2;case"undefined":return Object.keys(r).length==1;default:return!1}}var ue=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;let e=[],t=[],n=[];for(let i of this.fields)if(i.oneof)n.includes(i.oneof)||(n.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(n)}}is(e,t,n=!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))||!n&&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(!zt(a))return!1;if(a.oneofKind===void 0)continue;let l=this.fields.find(f=>f.localName===a.oneofKind);if(!l||!this.field(a[a.oneofKind],l,n,t))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,n,t))return!1;return!0}field(e,t,n,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(),n,i):this.message(e,t.T(),n,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(),n,i)}break}return!0}message(e,t,n,i){return n?t.isAssignable(e,i):t.is(e,i)}messages(e,t,n,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(n){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,n){let i=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(n){case F.BIGINT:return i=="bigint";case F.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,n,i){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<n;s++)if(!this.scalar(e[s],t,i))return!1}return!0}mapKeys(e,t,n){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,n).map(s=>parseInt(s)),t,n);case u.BOOL:return this.scalars(i.slice(0,n).map(s=>s=="true"?!0:s=="false"?!1:s),t,n);default:return this.scalars(i,t,n,F.STRING)}}};function I(r,e){switch(e){case F.BIGINT:return r.toBigInt();case F.NUMBER:return r.toNumber();default:return r.toString()}}var fe=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 n of t)this.fMap[n.name]=n,this.fMap[n.jsonName]=n,this.fMap[n.localName]=n}}assert(e,t,n){if(!e){let i=P(n);throw(i=="number"||i=="boolean")&&(i=n.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();let i=[];for(let[s,o]of Object.entries(e)){let a=this.fMap[s];if(!a){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let l=a.localName,f;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),f=t[a.oneof]={oneofKind:l}}else f=t;if(a.kind=="map"){if(o===null)continue;this.assert(Be(o),a.name,o);let c=f[l];for(let[p,m]of Object.entries(o)){this.assert(m!==null,a.name+" map value",null);let h;switch(a.V.kind){case"message":h=a.V.T().internalJsonRead(m,n);break;case"enum":if(h=this.enum(a.V.T(),m,a.name,n.ignoreUnknownFields),h===!1)continue;break;case"scalar":h=this.scalar(m,a.V.T,a.V.L,a.name);break}this.assert(h!==void 0,a.name+" map value",m);let T=p;a.K==u.BOOL&&(T=T=="true"?!0:T=="false"?!1:T),T=this.scalar(T,a.K,F.STRING,a.name).toString(),c[T]=h}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let c=f[l];for(let p of o){this.assert(p!==null,a.name,null);let m;switch(a.kind){case"message":m=a.T().internalJsonRead(p,n);break;case"enum":if(m=this.enum(a.T(),p,a.name,n.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(p,a.T,a.L,a.name);break}this.assert(m!==void 0,a.name,o),c.push(m)}}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}f[l]=a.T().internalJsonRead(o,n,f[l]);break;case"enum":let c=this.enum(a.T(),o,a.name,n.ignoreUnknownFields);if(c===!1)continue;f[l]=c;break;case"scalar":f[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,n,i){if(e[0]=="google.protobuf.NullValue"&&d(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return d(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, 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:(d(typeof o=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}d(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,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&&V(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?C(a):S(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return I(g.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return I(g.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return I(x.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return I(x.from(e),n);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 ce=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let n={},i=e;for(let s of this.fields){if(!s.oneof){let f=this.field(s,i[s.localName],t);f!==void 0&&(n[t.useProtoFieldName?s.name:s.jsonName]=f);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);d(l!==void 0),n[t.useProtoFieldName?s.name:s.jsonName]=l}return n}field(e,t,n){let i;if(e.kind=="map"){d(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[l,f]of Object.entries(t)){let c=this.scalar(e.V.T,f,e.name,!1,!0);d(c!==void 0),s[l.toString()]=c}break;case"message":let o=e.V.T();for(let[l,f]of Object.entries(t)){let c=this.message(o,f,e.name,n);d(c!==void 0),s[l.toString()]=c}break;case"enum":let a=e.V.T();for(let[l,f]of Object.entries(t)){d(f===void 0||typeof f=="number");let c=this.enum(a,f,e.name,!1,!0,n.enumAsInteger);d(c!==void 0),s[l.toString()]=c}break}(n.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){d(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){let f=this.scalar(e.T,t[l],e.name,e.opt,!0);d(f!==void 0),s.push(f)}break;case"enum":let o=e.T();for(let l=0;l<t.length;l++){d(t[l]===void 0||typeof t[l]=="number");let f=this.enum(o,t[l],e.name,e.opt,!0,n.enumAsInteger);d(f!==void 0),s.push(f)}break;case"message":let a=e.T();for(let l=0;l<t.length;l++){let f=this.message(a,t[l],e.name,n);d(f!==void 0),s.push(f)}break}(n.emitDefaultValues||s.length>0||n.emitDefaultValues)&&(i=s)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,n);break}return i}enum(e,t,n,i,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!i?void 0:null;if(t===void 0){d(i);return}if(!(t===0&&!s&&!i))return d(typeof t=="number"),d(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,n,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,n,i,s){if(t===void 0){d(i);return}let o=s||i;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(S(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(C(t),t);case u.FLOAT:V(t);case u.DOUBLE:return t===0?o?0:void 0:(d(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:(d(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(d(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:d(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=x.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:d(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=g.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return d(t instanceof Uint8Array),t.byteLength?Bt(t):o?"":void 0}}};function j(r,e=F.STRING){switch(r){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return I(x.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return I(g.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 pe=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(n=>[n.no,n]))}}read(e,t,n,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 m=n.readUnknownField;if(m=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let h=e.skip(a);m!==!1&&(m===!0?v.onRead:m)(this.info.typeName,t,o,a,h);continue}let f=t,c=l.repeat,p=l.localName;switch(l.oneof&&(f=f[l.oneof],f.oneofKind!==p&&(f=t[l.oneof]={oneofKind:p})),l.kind){case"scalar":case"enum":let m=l.kind=="enum"?u.INT32:l.T,h=l.kind=="scalar"?l.L:void 0;if(c){let R=f[p];if(a==w.LengthDelimited&&m!=u.STRING&&m!=u.BYTES){let Fe=e.uint32()+e.pos;for(;e.pos<Fe;)R.push(this.scalar(e,m,h))}else R.push(this.scalar(e,m,h))}else f[p]=this.scalar(e,m,h);break;case"message":if(c){let R=f[p],Fe=l.T().internalBinaryRead(e,e.uint32(),n);R.push(Fe)}else f[p]=l.T().internalBinaryRead(e,e.uint32(),n,f[p]);break;case"map":let[T,k]=this.mapEntry(l,e,n);f[p][T]=k;break}}}mapEntry(e,t,n){let i=t.uint32(),s=t.pos+i,o,a;for(;t.pos<s;){let[l,f]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,F.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(),n);break}break;default:throw new Error(`Unknown field ${l} (wire type ${f}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let l=j(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=j(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,n){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 I(e.int64(),n);case u.UINT64:return I(e.uint64(),n);case u.FIXED64:return I(e.fixed64(),n);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 I(e.sfixed64(),n);case u.SINT32:return e.sint32();case u.SINT64:return I(e.sint64(),n)}}};var me=class{constructor(e){this.info=e}prepare(){if(!this.fields){let e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,n)=>t.no-n.no)}}write(e,t,n){this.prepare();for(let s of this.fields){let o,a,l=s.repeat,f=s.localName;if(s.oneof){let c=e[s.oneof];if(c.oneofKind!==f)continue;o=c[f],a=!0}else o=e[f],a=!1;switch(s.kind){case"scalar":case"enum":let c=s.kind=="enum"?u.INT32:s.T;if(l)if(d(Array.isArray(o)),l==J.PACKED)this.packed(t,c,s.no,o);else for(let p of o)this.scalar(t,c,s.no,p,!0);else o===void 0?d(s.opt):this.scalar(t,c,s.no,o,a||s.opt);break;case"message":if(l){d(Array.isArray(o));for(let p of o)this.message(t,n,s.T(),s.no,p)}else this.message(t,n,s.T(),s.no,o);break;case"map":d(typeof o=="object"&&o!==null);for(let[p,m]of Object.entries(o))this.mapEntry(t,n,s,p,m);break}}let i=n.writeUnknownFields;i!==!1&&(i===!0?v.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,n,i,s){e.tag(n.no,w.LengthDelimited),e.fork();let o=i;switch(n.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(i);break;case u.BOOL:d(i=="true"||i=="false"),o=i=="true";break}switch(this.scalar(e,n.K,1,o,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,n.V.T(),2,s);break}e.join()}message(e,t,n,i,s){s!==void 0&&(n.internalBinaryWrite(s,e.tag(i,w.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,i,s){let[o,a,l]=this.scalarInfo(t,i);(!l||s)&&(e.tag(n,o),e[a](i))}packed(e,t,n,i){if(!i.length)return;d(t!==u.BYTES&&t!==u.STRING),e.tag(n,w.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 n=w.Varint,i,s=t===void 0,o=t===0;switch(e){case u.INT32:i="int32";break;case u.STRING:o=s||!t.length,n=w.LengthDelimited,i="string";break;case u.BOOL:o=t===!1,i="bool";break;case u.UINT32:i="uint32";break;case u.DOUBLE:n=w.Bit64,i="double";break;case u.FLOAT:n=w.Bit32,i="float";break;case u.INT64:o=s||g.from(t).isZero(),i="int64";break;case u.UINT64:o=s||x.from(t).isZero(),i="uint64";break;case u.FIXED64:o=s||x.from(t).isZero(),n=w.Bit64,i="fixed64";break;case u.BYTES:o=s||!t.byteLength,n=w.LengthDelimited,i="bytes";break;case u.FIXED32:n=w.Bit32,i="fixed32";break;case u.SFIXED32:n=w.Bit32,i="sfixed32";break;case u.SFIXED64:o=s||g.from(t).isZero(),n=w.Bit64,i="sfixed64";break;case u.SINT32:i="sint32";break;case u.SINT64:o=s||g.from(t).isZero(),i="sint64";break}return[n,i,s||o]}};function Yt(r){let e={};Object.defineProperty(e,Zt,{enumerable:!1,value:r});for(let t of r.fields){let n=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[n]=[];else switch(t.kind){case"scalar":e[n]=j(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function he(r,e,t){let n,i=t,s;for(let o of r.fields){let a=o.localName;if(o.oneof){let l=i[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(n=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,n==null){delete s[a];continue}}else if(n=i[a],s=e,n==null)continue;switch(o.repeat&&(s[a].length=n.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let f=0;f<n.length;f++)s[a][f]=n[f];else s[a]=n;break;case"message":let l=o.T();if(o.repeat)for(let f=0;f<n.length;f++)s[a][f]=l.create(n[f]);else s[a]===void 0?s[a]=l.create(n):l.mergePartial(s[a],n);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],n);break;case"message":let f=o.V.T();for(let c of Object.keys(n))s[a][c]=f.create(n[c]);break}break}}}function tr(r,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let n of r.fields){let i=n.localName,s=n.oneof?e[n.oneof][i]:e[i],o=n.oneof?t[n.oneof][i]:t[i];switch(n.kind){case"enum":case"scalar":let a=n.kind=="enum"?u.INT32:n.T;if(!(n.repeat?Qt(a,s,o):rr(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?er(n.V.T(),de(s),de(o)):Qt(n.V.kind=="enum"?u.INT32:n.V.T,de(s),de(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?er(l,s,o):l.equals(s,o)))return!1;break}}return!0}var de=Object.values;function rr(r,e,t){if(e===t)return!0;if(r!==u.BYTES)return!1;let n=e,i=t;if(n.length!==i.length)return!1;for(let s=0;s<n.length;s++)if(n[s]!=i[s])return!1;return!0}function Qt(r,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!rr(r,e[n],t[n]))return!1;return!0}function er(r,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r.equals(e[n],t[n]))return!1;return!0}var y=class{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Ht),this.options=n!=null?n:{},this.refTypeCheck=new ue(this),this.refJsonReader=new fe(this),this.refJsonWriter=new ce(this),this.refBinReader=new pe(this),this.refBinWriter=new me(this)}create(e){let t=Yt(this);return e!==void 0&&he(this,t,e),t}clone(e){let t=this.create();return he(this,t,e),t}equals(e,t){return tr(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){he(this,e,t)}fromBinary(e,t){let n=qt(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,Kt(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,Xt(t))}toJsonString(e,t){var n;let i=this.toJson(e,t);return JSON.stringify(i,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toBinary(e,t){let n=Jt(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let i=n!=null?n:this.create();return this.refJsonReader.read(e,i,t),i}throw new Error(`Unable to parse message ${this.typeName} from JSON ${P(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,i){let s=i!=null?i:this.create();return this.refBinReader.read(e,s,n,t),s}};var qe=class extends y{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=g.from(Math.floor(t/1e3)).toBigInt(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(g.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),n=e.getTime();return t.seconds=g.from(Math.floor(n/1e3)).toBigInt(),t.nanos=n%1e3*1e6,t}internalJsonWrite(e,t){let n=g.from(e.seconds).toNumber()*1e3;if(n<Date.parse("0001-01-01T00:00:00Z")||n>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(n).toISOString().replace(".000Z",i)}internalJsonRead(e,t,n){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+P(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 n||(n=this.create()),n.seconds=g.from(s/1e3).toBigInt(),n.nanos=0,i[7]&&(n.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),n}},nr=new qe;var sr=(n=>(n[n.UNKNOWN=0]="UNKNOWN",n[n.PATH=1]="PATH",n[n.CMD=2]="CMD",n))(sr||{}),or=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.CANCELLED=1]="CANCELLED",i[i.CANCELLING=2]="CANCELLING",i[i.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",i))(or||{}),$e=class extends y{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}])}},Sr=new $e,Je=class extends y{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}])}},Rr=new Je,je=class extends y{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},as=new je,Ge=class extends y{constructor(){super("arrow.flight.protocol.Empty",[])}},Ar=new Ge,Ke=class extends y{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Dr=new Ke,Xe=class extends y{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Pr=new Xe,Ze=class extends y{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Cr=new Ze,He=class extends y{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>nt}])}},ls=new He,ze=class extends y{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>ar}])}},us=new ze,Ye=class extends y{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Ur=new Ye,Qe=class extends y{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",or,"CANCEL_STATUS_"]}])}},fs=new Qe,et=class extends y{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Br=new et,tt=class extends y{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",sr]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},be=new tt,rt=class extends y{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>be},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>ar},{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}])}},nt=new rt,it=class extends y{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>ye},{no:2,name:"location",kind:"message",repeat:1,T:()=>Lr},{no:3,name:"expiration_time",kind:"message",T:()=>nr}])}},ar=new it,st=class extends y{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},Lr=new st,ot=class extends y{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},ye=new ot,at=class extends y{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>be},{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}])}},ge=new at,lt=class extends y{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},vr=new lt,we=new ir.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Sr,O:Rr},{name:"ListFlights",serverStreaming:!0,options:{},I:Pr,O:nt},{name:"GetFlightInfo",options:{},I:be,O:nt},{name:"GetSchema",options:{},I:be,O:Br},{name:"DoGet",serverStreaming:!0,options:{},I:ye,O:ge},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:ge,O:vr},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:ge,O:ge},{name:"DoAction",serverStreaming:!0,options:{},I:Cr,O:Ur},{name:"ListActions",serverStreaming:!0,options:{},I:Ar,O:Dr}]);var O=require("@protobuf-ts/runtime-rpc"),Te=class{constructor(e){this._transport=e;this.typeName=we.typeName;this.methods=we.methods;this.options=we.options}handshake(e){let t=this.methods[0],n=this._transport.mergeOptions(e);return(0,O.stackIntercept)("duplex",this._transport,t,n)}listFlights(e,t){let n=this.methods[1],i=this._transport.mergeOptions(t);return(0,O.stackIntercept)("serverStreaming",this._transport,n,i,e)}getFlightInfo(e,t){let n=this.methods[2],i=this._transport.mergeOptions(t);return(0,O.stackIntercept)("unary",this._transport,n,i,e)}getSchema(e,t){let n=this.methods[3],i=this._transport.mergeOptions(t);return(0,O.stackIntercept)("unary",this._transport,n,i,e)}doGet(e,t){let n=this.methods[4],i=this._transport.mergeOptions(t);return(0,O.stackIntercept)("serverStreaming",this._transport,n,i,e)}doPut(e){let t=this.methods[5],n=this._transport.mergeOptions(e);return(0,O.stackIntercept)("duplex",this._transport,t,n)}doExchange(e){let t=this.methods[6],n=this._transport.mergeOptions(e);return(0,O.stackIntercept)("duplex",this._transport,t,n)}doAction(e,t){let n=this.methods[7],i=this._transport.mergeOptions(t);return(0,O.stackIntercept)("serverStreaming",this._transport,n,i,e)}listActions(e,t){let n=this.methods[8],i=this._transport.mergeOptions(t);return(0,O.stackIntercept)("serverStreaming",this._transport,n,i,e)}};var G=class{constructor(e){this._options=e;this._closed=!1;this._transport=q.queryTransport(this._options),this._flightClient=new Te(this._transport)}async*_queryRawBatches(e,t,n){if(this._closed)throw new Error("queryApi: already closed!");let i=this._flightClient,s={database:t,sql_query:e,query_type:n},o=ye.create({ticket:new TextEncoder().encode(JSON.stringify(s))}),a={},l=this._options.token;l&&(a.authorization=`Bearer ${l}`);let f={meta:a},c=i.doGet(o,f),p=async function*(){for await(let h of c.responses)yield Ft(h.dataHeader.length),yield h.dataHeader,yield h.dataBody}();yield*await xe.RecordBatchReader.from(p)}async*query(e,t,n){var s;let i=this._queryRawBatches(e,t,n);for await(let o of i)for(let a=0;a<o.numRows;a++){let l={};for(let f=0;f<o.numCols;f++){let c=o.schema.fields[f].name,p=(s=o.getChildAt(f))==null?void 0:s.get(a);l[c]=p}yield l}}async*queryPoints(e,t,n){var s;let i=this._queryRawBatches(e,t,n);for await(let o of i)for(let a=0;a<o.numRows;a++){let l=new _;for(let f=0;f<o.numCols;f++){let c=o.schema.fields[f],p=c.name,m=(s=o.getChildAt(f))==null?void 0:s.get(a),h=c.typeId,T=c.metadata.get("iox::column::type");if(m==null)continue;if((p==="measurement"||p=="iox::measurement")&&typeof m=="string"){l.setMeasurement(m);continue}if(!T){p==="time"&&h===xe.Type.Timestamp?l.setTimestamp(m):l.setField(p,m);continue}let[,,k,R]=T.split("::");k==="field"?R&&m!==void 0&&m!==null&&l.setField(p,m,R):k==="tag"?l.setTag(p,m):k==="timestamp"&&l.setTimestamp(m)}yield l}}async close(){var e,t;this._closed=!0,(t=(e=this._transport).close)==null||t.call(e)}};var ut=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
`,K=class{constructor(e){this._mergeWriteOptions=e=>({...this._options.writeOptions,...e});if(e==null)throw new U("No configuration specified!");this._options=e;let t=this._options.host;if(typeof t!="string")throw new U("No host specified!");t.endsWith("/")&&(this._options.host=t.substring(0,t.length-1)),this._queryApi=new G(this._options),this._writeApi=new $(this._options)}async write(e,t,n,i){var s;await this._writeApi.doWrite(Ae(e),(s=t!=null?t:this._options.database)!=null?s:Q(new Error(ut)),n,this._mergeWriteOptions(i))}query(e,t,n="sql"){var i;return this._queryApi.query(e,(i=t!=null?t:this._options.database)!=null?i:Q(new Error(ut)),n)}queryPoints(e,t,n="sql"){var i;return this._queryApi.queryPoints(e,(i=t!=null?t:this._options.database)!=null?i:Q(new Error(ut)),n)}async close(){await this._writeApi.close(),await this._queryApi.close()}};0&&(module.exports={AbortError,DEFAULT_ConnectionOptions,DEFAULT_WriteOptions,GetFieldTypeMissmatchError,HttpError,IllegalArgumentError,InfluxDBClient,Log,Point,PointValues,RequestTimedOutError,collectAll,consoleLogger,convertTime,convertTimeToNanos,createTextDecoderCombiner,currentTime,dateToProtocolTimestamp,escape,setLogger,useProcessHrtime,writableDataToLineProtocol});
//# sourceMappingURL=index.js.map
{
"name": "@influxdata/influxdb3-client-browser",
"version": "0.3.0-nightly.2049",
"version": "0.3.0-nightly.2105",
"description": "InfluxDB 3 client for browser",

@@ -50,7 +50,7 @@ "scripts": {

"devDependencies": {
"@influxdata/influxdb3-client": "^0.3.0-nightly.2049",
"@influxdata/influxdb3-client": "^0.3.0-nightly.2105",
"cpr": "^3.0.1",
"rimraf": "^5.0.0"
},
"gitHead": "321664d3a355369c7de88760246c039f6e9230d3"
"gitHead": "3f618e139dc74573cf7a4c145915e5f834e722f6"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc