@influxdata/influxdb3-client 0.1.0 → 0.2.0-nightly.843

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