@powerduck/openapi-request 0.2.2

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.
@@ -0,0 +1 @@
1
+ "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={};((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(s,{DescriptorDecodeError:()=>Te,DescriptorShapeError:()=>Le,GrpcAdapter:()=>yr,GrpcDependencyBrokenError:()=>h,GrpcDependencyMissingError:()=>p,LABEL_NAMES:()=>He,LOADER_OPTIONS:()=>lt,ReflectionProtocolError:()=>Q,ReflectionUnavailableError:()=>H,TYPE_NAMES:()=>Xe,buildCatalog:()=>wt,buildCredentials:()=>S,buildCredentialsAsync:()=>T,buildCredentialsChecked:()=>E,buildCredentialsCheckedAsync:()=>k,buildMessageTemplate:()=>zt,decodeFileDescriptorProto:()=>Re,decodeFileDescriptorSet:()=>Be,deriveIncludeDirsDetailed:()=>I,describeFromCatalog:()=>lr,describeMethod:()=>cr,discover:()=>ur,discoverFromCatalog:()=>dr,enumName:()=>et,fetchDescriptorSet:()=>ge,fetchFullDescriptorSet:()=>ye,grpcCall:()=>At,isGrpcAvailable:()=>w,isMapEntry:()=>it,listServices:()=>he,listServicesDetailed:()=>pe,loadGrpc:()=>v,readEnumValueNames:()=>at,readFields:()=>rt,readMethods:()=>ct,readNestedTypes:()=>st,readOneofNames:()=>ot,requireCapability:()=>b,resolveMethod:()=>Tt,scanProtoFiles:()=>F,serializeDescriptorSet:()=>fe}),module.exports=(e=s,((e,s,i,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of n(s))o.call(e,c)||c===i||t(e,c,{get:()=>s[c],enumerable:!(a=r(s,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var i,a,c=require("module"),l=require("fs"),d=require("path"),u={},f={grpc:"@grpc/grpc-js",protoLoader:"@grpc/proto-loader"},p=class extends Error{missing;constructor(e,t){super(`gRPC support requires optional peer dependencies that are not installed: ${e.join(", ")}.\n npm i ${e.join(" ")}`,{cause:t}),this.name="GrpcDependencyMissingError",this.missing=e}},h=class extends Error{packageName;constructor(e,t,r){super(`gRPC dependency "${e}" is installed but unusable: ${t}`,{cause:r}),this.name="GrpcDependencyBrokenError",this.packageName=e}};async function m(e,t){let r;try{r=await(import(e))}catch(t){if(function(e,t){const r=e,n="string"==typeof r?.code?r.code:"";if("ERR_MODULE_NOT_FOUND"!==n&&"MODULE_NOT_FOUND"!==n)return!1;const o="string"==typeof r?.message?r.message:"";return o.includes(`'${t}'`)||o.includes(`"${t}"`)||o.includes(t)}(t,e))throw new p([e],t);throw new h(e,t instanceof Error?`it threw while loading — ${t.message}`:String(t),t)}return function(e,t,r){const n=[e,e?.default];for(const e of n)if(e&&"object"==typeof e&&t in e)return e;throw new h(r,`its module namespace has no "${t}" export, so the installed version is not the package this library expects.`)}(r,t,e)}function g(e,t,r){for(const[n,o]of Object.entries(r)){const r=e[n],s=null===r?"null":typeof r;if(s!==o)throw new h(t,`expected "${n}" to be a ${o}, found ${s}. The installed package is not the one this library supports.`)}}function y(e){try{const t=(0,c.createRequire)(u.url);let r=(0,d.dirname)(t.resolve(e));for(let t=0;t<8;t++){try{const t=(0,l.readFileSync)((0,d.join)(r,"package.json"),"utf8"),n=JSON.parse(t);if(n.name===e&&"string"==typeof n.version)return n.version}catch{}const t=(0,d.dirname)(r);if(t===r)break;r=t}}catch{}}async function v(){return a||(i||(i=async function(){const e=await Promise.allSettled([m(f.grpc,"Client"),m(f.protoLoader,"load")]),t=[];for(const r of e)"rejected"===r.status&&r.reason instanceof p&&t.push(...r.reason.missing);if(t.length>0){const r=e.find(e=>"rejected"===e.status&&e.reason instanceof p);throw new p(t,"rejected"===r?.status?r.reason:void 0)}for(const t of e)if("rejected"===t.status)throw t.reason;const r=e[0].value,n=e[1].value;return g(r,f.grpc,{Client:"function",Metadata:"function",credentials:"object"}),g(n,f.protoLoader,{load:"function"}),{grpc:r,protoLoader:n,capabilities:{descriptorSetFromBuffer:"function"==typeof n.loadFileDescriptorSetFromBuffer,grpcVersion:y(f.grpc),protoLoaderVersion:y(f.protoLoader)}}}().then(e=>(a=e,e),e=>{throw i=void 0,e})),i)}async function w(){try{return await v(),!0}catch{return!1}}function b(e,t){switch(t){case"descriptorSetFromBuffer":{if(e.capabilities.descriptorSetFromBuffer)return;const t=e.capabilities.protoLoaderVersion?` (found ${e.capabilities.protoLoaderVersion})`:"";throw new h(f.protoLoader,`server reflection requires @grpc/proto-loader >= 0.7.0${t}; loadFileDescriptorSetFromBuffer is missing.`)}case"grpcVersion":case"protoLoaderVersion":throw new TypeError(`"${t}" is diagnostic information, not a capability; it cannot be required.`);default:throw new TypeError(`unknown gRPC capability: ${String(t)}`)}}function $(e,t){if(null==e)return null;if(Buffer.isBuffer(e))return e;if(e instanceof Uint8Array)return Buffer.from(e);if("string"==typeof e)throw new TypeError(`tls.${t} must be PEM bytes, not a string. A file path is not accepted — read it first, e.g. await readFile(path). Passing a path would fail later during the handshake with an unrelated error.`);throw new TypeError(`tls.${t} must be a Buffer or Uint8Array of PEM bytes; received ${typeof e}.`)}function E(e,{grpc:t}){const r=[],n=e.tls;if(void 0===n||!1===n)return{credentials:t.credentials.createInsecure(),mode:"insecure",warnings:r};if(!0===n)return{credentials:t.credentials.createSsl(),mode:"tls-system-roots",warnings:r};const o=$(n.rootCerts,"rootCerts"),s=$(n.privateKey,"privateKey"),i=$(n.certChain,"certChain");if(null===s!=(null===i))throw new Error(`mutual TLS requires both tls.privateKey and tls.certChain; only ${s?"privateKey":"certChain"} was provided.`);const a=null!==s?"mtls":null!==o?"tls-custom-roots":"tls-system-roots";return n.skipHostnameVerification?(r.push("skipHostnameVerification is on: the server certificate chain is still verified, but its hostname is not checked against the address. This permits connecting to an impostor holding any trusted certificate. Use it for local debugging only."),{credentials:t.credentials.createSsl(o,s,i,{checkServerIdentity:()=>{}}),mode:a,warnings:r}):{credentials:t.credentials.createSsl(o,s,i),mode:a,warnings:r}}function S(e,t){return E(e,t).credentials}async function T(e){return S(e,await v())}async function k(e){return E(e,await v())}var D=require("fs/promises"),P=require("path"),_=["node_modules",".git","dist","build","out",".venv"],x=5e3,O=40;function M(e){return e.toLowerCase().endsWith(".proto")}function j(e,t){const r=t?.code;switch(r){case"ENOENT":return`proto path does not exist: ${e}`;case"EACCES":case"EPERM":return`proto path is not readable (permission denied): ${e}`;case"ENOTDIR":return`a component of the proto path is not a directory: ${e}`;case"ELOOP":return`proto path contains a symlink loop: ${e}`;case"ENAMETOOLONG":return`proto path is too long: ${e}`;default:return`proto path could not be read: ${e}`+(r?` (${r})`:"")+(t instanceof Error?` — ${t.message}`:"")}}async function N(e){try{const t=await(0,D.stat)(e);return t.isDirectory()?"dir":t.isFile()?"file":"other"}catch{return"error"}}async function F(e){!function(e){if(!e||"object"!=typeof e)throw new TypeError("scanProtoFiles requires an options object.");if(!Array.isArray(e.paths))throw new TypeError(`protoPaths must be an array of strings; received ${typeof e.paths}. A single path must still be wrapped in an array, or it is iterated one character at a time.`);if(e.paths.forEach((e,t)=>{if("string"!=typeof e||0===e.length)throw new TypeError(`protoPaths[${t}] must be a non-empty string; received ${void 0===e?"undefined":typeof e}.`)}),0===e.paths.length)throw new Error("protoPaths is empty; nothing to load.");if(void 0!==e.ignoreDirs){if(!Array.isArray(e.ignoreDirs))throw new TypeError(`ignoreDirs must be an array of directory names; received ${typeof e.ignoreDirs}.`);e.ignoreDirs.forEach((e,t)=>{if("string"!=typeof e)throw new TypeError(`ignoreDirs[${t}] must be a string; received ${typeof e}.`);if(e.includes("/")||e.includes("\\"))throw new TypeError(`ignoreDirs[${t}] ("${e}") looks like a path, but ignoreDirs matches single directory names only; a path never matches and would be silently ignored.`)})}if(void 0!==e.maxFiles&&(!Number.isInteger(e.maxFiles)||e.maxFiles<1))throw new TypeError(`maxFiles must be a positive integer; received ${String(e.maxFiles)}. A cap of 0 would collect nothing and report it as an empty proto tree.`);if(void 0!==e.followSymlinks&&"boolean"!=typeof e.followSymlinks)throw new TypeError(`followSymlinks must be a boolean; received ${typeof e.followSymlinks}.`)}(e);const t=new Set(e.ignoreDirs??_),r=e.maxFiles??x,n=new Set,o=[],s=[],i=[],a=new Set,c=new Map;let l=!1,d=0;const u=e=>{i.length>=O?d++:i.push(e)},f=async(t,o)=>{if(!n.has(t))if(n.size>=r)l||(l=!0,u(`stopped after ${r} .proto files; pass maxFiles or a narrower protoPaths if the tree really is this large. The file set is truncated, so symbols may be missing.`));else{if(o||e.followSymlinks){let e;try{e=await(0,D.realpath)(t)}catch(e){return void u(j(t,e))}const r=c.get(e);if(void 0!==r)return void(r!==t&&u(`skipped ${t}: it is the same file as ${r} (both resolve to ${e}). Loading it twice would be reported as a duplicate symbol definition.`));c.set(e,t)}n.add(t)}},p=async(r,n)=>{let o,s;try{o=await(0,D.realpath)(r)}catch(e){return void u(j(r,e))}if(a.has(o))n&&u(`skipped ${r}: it resolves to ${o}, which was already scanned.`);else{a.add(o);try{s=await(0,D.readdir)(r,{withFileTypes:!0})}catch(e){return void u(j(r,e))}for(const o of s){if(l)return;const s=(0,P.join)(r,o.name);if(o.isSymbolicLink()){if(!e.followSymlinks){u(`skipped symlink ${s} (followSymlinks is off). If your proto tree links to shared definitions, enable followSymlinks or add the target to protoPaths.`);continue}let r;try{r=await(0,D.stat)(s)}catch(e){u(j(s,e));continue}r.isDirectory()?t.has(o.name)||await p(s,!0):r.isFile()&&M(o.name)&&await f((0,P.resolve)(s),!0);continue}if(o.isDirectory()){t.has(o.name)||await p(s,n);continue}if(o.isFile()){M(o.name)&&await f((0,P.resolve)(s),n);continue}if(o.isFIFO()||o.isSocket()||o.isBlockDevice()||o.isCharacterDevice())continue;const i=await N(s);"dir"===i?t.has(o.name)||await p(s,n):"file"===i?M(o.name)&&await f((0,P.resolve)(s),n):"error"===i&&M(o.name)&&u(`could not determine the type of ${s}; it was skipped even though its name suggests a proto file.`)}}};for(const t of e.paths){const e=(0,P.resolve)(t);let r;try{r=await(0,D.stat)(e)}catch(e){throw new Error(j(t,e),{cause:e})}if(r.isFile()){if(!M(e))throw new Error(`not a .proto file: ${t}. protoPaths accepts .proto files and directories containing them.`);await f(e,!1),s.includes(e)||s.push(e)}else{if(!r.isDirectory())throw new Error(`proto path is neither a file nor a directory: ${t}`);o.includes(e)||o.push(e),await p(e,!1)}}if(d>0&&i.push(`${d} further scan note(s) were suppressed; the ones above are representative.`),0===n.size){const r=i.length?` Some entries were skipped: ${i[0]}`:` Checked for *.proto, skipping ${[...t].join(", ")}.`;throw new Error(`no .proto files found under: ${e.paths.join(", ")}.${r}`)}return{files:[...n].sort(),rootDirs:o,fileRoots:s,notes:i}}function A(e,t){const r=t.endsWith(P.sep)?t:t+P.sep;return e===t||e.startsWith(r)}function I(e){const t=[],r=new Set;for(const t of e.rootDirs)r.add(t);for(const t of e.fileRoots)r.add((0,P.dirname)(t));const n=[...r],o=[];for(const t of e.files){const e=(0,P.dirname)(t);n.some(t=>A(e,t))||(r.has(e)||(r.add(e),o.push(e)))}return o.length>0&&t.push(`${o.length} directory(ies) outside the given protoPaths were added as include roots so their imports resolve: ${o.slice(0,3).join(", ")}${o.length>3?", …":""}. Imports are therefore resolved more loosely than protoc would; pass includeDirs explicitly for exact behaviour.`),{includeDirs:[...r].sort(),notes:t}}function C(e){return e instanceof Error?e.message:String(e)}var q=0,R=2,B=[1,128,16384,2097152,268435456,34359738368,4398046511104,562949953421312,72057594037927940,0x8000000000000000],L=class{constructor(e,t=0){this.buf=e,this.pos=t}buf;pos;get eof(){return this.pos>=this.buf.length}varint(){let e,t=0,r=0;do{if(this.pos>=this.buf.length)throw new Error(`truncated varint at offset ${this.pos}`);if(r>=B.length)throw new Error("varint longer than 10 bytes");e=this.buf[this.pos++],t+=(127&e)*B[r++]}while(128&e);if(!Number.isSafeInteger(t))throw new Error("varint exceeds Number.MAX_SAFE_INTEGER");return t}bytes(){return Buffer.from(this.view())}view(){const e=this.varint(),t=this.pos+e;if(t>this.buf.length)throw new Error(`length-delimited field runs past end of buffer (need ${e} bytes at ${this.pos}, have ${this.buf.length-this.pos})`);const r=this.buf.subarray(this.pos,t);return this.pos=t,r}string(){return this.view().toString("utf8")}skip(e){switch(e){case q:return void this.varint();case 1:return void this.advance(8);case R:return void this.view();case 5:return void this.advance(4);default:throw new Error(`unsupported wire type ${e} at offset ${this.pos}`)}}advance(e){const t=this.pos+e;if(t>this.buf.length)throw new Error("fixed-width field runs past end of buffer");this.pos=t}};function U(e,t){const r=new L(e);for(;!r.eof;){const e=r.varint(),n=Math.floor(e/8),o=7&e;if(0===n)throw new Error("field number 0 is not valid");const s=r.pos;if(t(n,o,r)){if(r.pos===s)throw new Error(`decoder claimed field ${n} (wire ${o}) without consuming it`)}else r.skip(o)}}function Y(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`cannot encode ${e} as an unsigned varint`);const t=[];let r=e;for(;r>127;)t.push(r%128|128),r=Math.floor(r/128);return t.push(r),Buffer.from(t)}function z(e,t){return Y(8*e+t)}function V(e,t){return Buffer.concat([z(e,R),Y(t.length),t])}function G(e,t){return V(e,Buffer.from(t,"utf8"))}function W(e){return"list"===e?"the service list":e.slice(e.indexOf(":")+1)}function K(e){let t,r={kind:"other",field:0};return U(e,(e,n,o)=>{if(n!==R)return!1;switch(e){case 2:return t=function(e){let t;return U(e,(e,r,n)=>r===R&&(3===e?(t=`file:${n.string()}`,!0):4===e?(t=`sym:${n.string()}`,!0):7===e&&(n.view(),t="list",!0))),t}(o.view()),!0;case 4:{const e=[];return U(o.view(),(t,r,n)=>1===t&&r===R&&(e.push(n.bytes()),!0)),r={kind:"files",descriptors:e},!0}case 6:{const e=[];return U(o.view(),(t,r,n)=>1===t&&r===R&&(U(n.view(),(t,r,n)=>1===t&&r===R&&(e.push(n.string()),!0)),!0)),r={kind:"services",services:e},!0}case 7:{let e=2,t="";return U(o.view(),(r,n,o)=>1===r&&n===q?(e=o.varint(),!0):2===r&&n===R&&(t=o.string(),!0)),r={kind:"error",code:e,message:t},!0}case 5:return o.view(),r={kind:"other",field:5},!0;default:return!1}}),{answers:t,body:r}}function X(e){let t="";const r=[];return U(e,(e,n,o)=>n===R&&(1===e?(t=o.string(),!0):3===e&&(r.push(o.string()),!0))),{name:t,dependencies:r}}var H=class extends Error{address;versionsTried;constructor(e,t,r){super(`server at ${e} answered but does not implement the gRPC reflection service (${t.join(" and ")} both reported UNIMPLEMENTED/NOT_FOUND). Register the reflection service on the server, or pass protoPaths instead.`,{cause:r}),this.name="ReflectionUnavailableError",this.address=e,this.versionsTried=t}},J=class extends Error{address;code;constructor(e,t,r){super(`could not complete the reflection handshake with ${e}`+(void 0!==t?` (gRPC status ${t})`:"")+`: ${r}. This is a connectivity or transport failure, not a missing reflection service — nothing was reached that could answer.`),this.name="ReflectionTransportError",this.address=e,this.code=t}},Q=class extends Error{detail;constructor(e,t){super(t?`${e} (${t})`:e),this.name="ReflectionProtocolError",this.detail=t}},Z={v1:"/grpc.reflection.v1.ServerReflection/ServerReflectionInfo",v1alpha:"/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo"},ee=5e3,te=2e3,re=33554432,ne=12,oe=5;function se(e){return"object"==typeof e&&null!==e&&!0===e.versionMissing}function ie(e){const t=e?.code;return"number"==typeof t?t:void 0}function ae(e,t,r){if(void 0!==t&&("number"!=typeof t||!Number.isFinite(t)||t<r))throw new RangeError(`${e} must be a finite number >= ${r}; received ${"number"==typeof t?t:typeof t}.`)}function ce(e){if("string"!=typeof e.address||""===e.address)throw new TypeError("reflection requires a non-empty address.");if(ae("timeoutMs",e.timeoutMs,1),ae("maxFiles",e.maxFiles,1),ae("maxBytes",e.maxBytes,1),void 0!==e.version&&"v1"!==e.version&&"v1alpha"!==e.version)throw new TypeError(`reflectionVersion must be "v1" or "v1alpha"; received ${String(e.version)}.`)}async function le(e,t){const r=e.version?[e.version]:["v1","v1alpha"];let n;for(const[o,s]of r.entries())try{const n=await de(e,t,s);return o>0&&n.notes.unshift(`reflection ${r[0]} was unimplemented; used ${s}.`),n}catch(e){if(!se(e))throw e;n=e.cause}throw new H(e.address,r,n)}function de(e,t,r){const n=e.timeoutMs??ee,o=e.maxFiles??te,s=e.maxBytes??re,i=e.host??"";return v().then(({grpc:a})=>{const c=function(e,t){const r=new e.Metadata;for(const[e,n]of Object.entries(t??{})){const t=Array.isArray(n)?n:[n];for(const n of t){if("string"!=typeof n&&!Buffer.isBuffer(n))throw new TypeError(`reflection metadata["${e}"] must be a string, a Buffer, or an array of those; received ${null===n?"null":typeof n}.`);try{r.add(e,n)}catch(t){throw new TypeError(`reflection metadata key "${e}" was rejected by grpc-js: ${C(t)}. Keys must match [0-9a-z_.-]+, and only keys ending in "-bin" may carry Buffers.`)}}}return r}(a,e.metadata);let l,d;try{l=new a.Client(e.address,e.credentials,e.channelOptions)}catch(t){throw new J(e.address,void 0,`the channel could not be created: ${C(t)}. Expected host:port`)}try{d=l.makeBidiStreamRequest(Z[r],e=>e,e=>e,c,{deadline:new Date(Date.now()+n)})}catch(t){try{l.close()}catch{}throw new J(e.address,ie(t),C(t))}return new Promise((a,c)=>{const u=new Map,f=[],p=new Map,h=new Set;let m,g="symbols"!==t.kind,y=0,v=!1,w=!1,b=!1;const $=()=>{if(0===p.size)return;const e=[...p.keys()].slice(0,5).join(", ");return`still awaiting ${p.size} reply(ies): ${e}${p.size>5?", …":""}`},E=setTimeout(()=>{T(new Q(`reflection session at ${e.address} did not complete within ${n}ms`,$()))},n+250);E.unref?.();const S=()=>{clearTimeout(E);try{d.cancel()}catch{}try{l.close()}catch{}};function T(e){v||(v=!0,S(),c(e))}function k(t){T(b?new Q(`the reflection stream at ${e.address} failed after the server had already answered, so ${r} is served here; ${u.size} file(s) were discarded`,C(t)):{versionMissing:!0,cause:t})}function D(){if(!v){v=!0,clearTimeout(E);try{d.end()}catch{}try{l.close()}catch{}a({services:"symbols"===t.kind?void 0:m??[],descriptors:u,version:r,notes:f})}}const P=(t,r)=>{if(!v&&!h.has(t))if(h.size>=o)T(new Q(`reflection closure exceeded maxFiles=${o}`,`while requesting ${W(t)}`));else{h.add(t),p.set(t,{key:t,primary:r});try{d.write(function(e,t){const r=[];return t&&r.push(G(1,t)),"list"===e?r.push(G(7,"*")):e.startsWith("file:")?r.push(G(3,e.slice(5))):r.push(G(4,e.slice(4))),Buffer.concat(r)}(t,i))}catch(r){T(new J(e.address,ie(r),`writing the request for ${W(t)} failed: ${C(r)}`))}}};if(d.on("data",e=>{if(v)return;let r;try{r=K(e)}catch(e){return b=!0,void T(new Q("malformed ServerReflectionResponse",C(e)))}b=!0;const n=(e=>{if(void 0!==e&&p.has(e)){const t=p.get(e);return p.delete(e),t}w||(w=!0,f.push(void 0===e?"server omitted original_request; replies were paired by arrival order.":`server echoed an unrequested original_request (${e}); replies were paired by arrival order.`));const t=p.keys().next();if(t.done)return;const r=p.get(t.value);return p.delete(t.value),r})(r.answers);switch(r.body.kind){case"error":{const{code:e,message:t}=r.body,o=`code ${e}: ${t||"(no message)"}`;if(!n||n.primary)return void T(new Q(`reflection request for ${n?W(n.key):"(unknown)"} failed`,o));f.push(`server could not supply ${W(n.key)} — ${o}. The descriptor set may be incomplete.`);break}case"files":if(0===r.body.descriptors.length&&n?.primary&&f.push(`server returned an empty file set for ${W(n.key)}.`),(e=>{for(const t of e){if(v)return;if(y+=t.length,y>s)return void T(new Q(`reflection payload exceeded maxBytes=${s}`,`after ${u.size} file(s)`));let e;try{e=X(t)}catch(e){return void T(new Q("server returned a FileDescriptorProto that could not be parsed",C(e)))}if(e.name){if(!u.has(e.name)){u.set(e.name,t);for(const t of e.dependencies)if(u.has(t)||P(`file:${t}`,!1),v)return}}else f.push("server returned a FileDescriptorProto with no name; it was skipped.")}})(r.body.descriptors),v)return;break;case"services":if(m=r.body.services,g=!1,"list_then_symbols"===t.kind){const e=m.filter(e=>!e.startsWith("grpc.reflection."));for(const t of e)if(P(`sym:${t}`,!0),v)return}break;case"other":f.push(`ignored an unexpected reflection response variant (field ${r.body.field}) for ${n?W(n.key):"(unknown request)"}.`)}0!==p.size||g||D()}),d.on("error",t=>{if(v)return;const r=ie(t);r!==ne&&r!==oe?T(new J(e.address,r,C(t))):k(t)}),d.on("status",t=>{if(v)return;const r=t;if(0!==r.code){const t=`${r.code} ${r.details??""}`.trim();return r.code===ne||r.code===oe?void k(Object.assign(new Error(`reflection stream ended: ${t}`),{code:r.code,details:r.details})):void T(new J(e.address,r.code,r.details||"the stream ended with a non-OK status"))}p.size>0||g?T(new Q("server closed the reflection stream before answering everything",$()??"the service list was requested but never returned")):D()}),d.on("end",()=>{v||0!==p.size||g||D()}),"symbols"===t.kind){for(const e of t.symbols)if(P(`sym:${e}`,!0),v)return}else P("list",!0)})})}function ue(e){const t=new Map;for(const[r,n]of e){let o;try{o=X(n)}catch{t.set(r,[]);continue}t.set(r,o.dependencies.filter(t=>e.has(t)))}const r=[],n=[],o=new Map,s=e=>{const i=o.get(e);if("done"!==i)if("visiting"!==i){o.set(e,"visiting");for(const r of t.get(e)??[])s(r);o.set(e,"done"),r.push(e)}else n.includes(e)||n.push(e)};for(const t of[...e.keys()].sort())s(t);return{ordered:r,cycles:n}}function fe(e){const{ordered:t}=ue(e);return Buffer.concat(t.map(t=>V(1,e.get(t))))}async function pe(e){ce(e);const t=await le(e,{kind:"list"});return{services:(t.services??[]).filter(e=>!e.startsWith("grpc.reflection.")).sort(),version:t.version,notes:t.notes}}async function he(e){return(await pe(e)).services}function me(e,t){if(0===e.descriptors.size)throw new Q(`reflection returned no file descriptors for ${t}`,e.notes.join(" ")||void 0);const{ordered:r,cycles:n}=ue(e.descriptors),o=[...e.notes];return n.length>0&&o.push(`${n.length} file(s) take part in an import cycle, which protoc cannot produce: ${n.slice(0,5).join(", ")}`+(n.length>5?", …":"")+". They were emitted once each; the descriptor set may not load."),{descriptorSet:Buffer.concat(r.map(t=>V(1,e.descriptors.get(t)))),files:r,version:e.version,notes:o}}async function ge(e){if(ce(e),!Array.isArray(e.symbols)||0===e.symbols.length)throw new TypeError("fetchDescriptorSet requires a non-empty array of symbol names.");const t=e.symbols.findIndex(e=>"string"!=typeof e||""===e);if(-1!==t)throw new TypeError(`symbols[${t}] is not a non-empty string (got ${typeof e.symbols[t]}).`);return me(await le(e,{kind:"symbols",symbols:e.symbols}),e.symbols.join(", "))}async function ye(e){ce(e);const t=await le(e,{kind:"list_then_symbols"}),r=(t.services??[]).filter(e=>!e.startsWith("grpc.reflection.")).sort();return 0===r.length?{services:r,descriptorSet:Buffer.alloc(0),files:[],version:t.version,notes:[...t.notes,`reflection is available at ${e.address} but the server advertises no services other than reflection itself.`]}:{services:r,...me(t,r.join(", "))}}var ve=0,we=1,be=2,$e=3,Ee=4,Se=5,Te=class extends Error{constructor(e){super(`descriptor decode failed: ${e}`),this.name="DescriptorDecodeError"}};function ke(e){let t=0n,r=0n;for(;;){if(e.pos>=e.end)throw new Te("truncated varint");const n=e.buf[e.pos++];if(t|=BigInt(127&n)<<r,!(128&n))return t;if(r+=7n,r>70n)throw new Te("varint too long")}}function De(e,t,r){switch(t){case ve:return void ke(e);case we:return void Pe(e,8);case Se:return void Pe(e,4);case be:return void Pe(e,Number(ke(e)));case $e:if(r>32)throw new Te("group nesting too deep");for(;;){if(e.pos>=e.end)throw new Te("unterminated group");const t=7&Number(ke(e));if(t===Ee)return;De(e,t,r+1)}default:throw new Te(`unsupported wire type ${t}`)}}function Pe(e,t){if(t<0||e.pos+t>e.end)throw new Te("length exceeds buffer");e.pos+=t}function _e(e){const t={buf:e,pos:0,end:e.length},r=new Map;for(;t.pos<t.end;){const n=Number(ke(t)),o=n>>>3,s=7&n;if(0===o)throw new Te("field number 0 is invalid");let i;if(s===ve)i={wireType:s,varint:ke(t)};else if(s===be){const r=Number(ke(t));if(r<0||t.pos+r>t.end)throw new Te("length-delimited field overruns");i={wireType:s,bytes:e.subarray(t.pos,t.pos+r)},t.pos+=r}else{const r=t.pos;De(t,s,0),i={wireType:s,bytes:e.subarray(r,t.pos)}}const a=r.get(o);a?a.push(i):r.set(o,[i])}return r}var xe=new TextDecoder("utf-8",{fatal:!0});function Oe(e,t){const r=e.get(t)?.at(-1);if(r?.bytes)try{return xe.decode(r.bytes)}catch{throw new Te(`field ${t} is not valid UTF-8`)}}function Me(e,t){const r=e.get(t)?.at(-1);if(void 0===r?.varint)return;const n=r.varint;return Number(n>0x7fffffffn?BigInt.asIntN(32,n):n)}function je(e,t){const r=e.get(t)?.at(-1);return void 0!==r?.varint&&0n!==r.varint}function Ne(e,t){const r=e.get(t);return r?r.map(e=>{if(!e.bytes)throw new Te(`field ${t} was expected to be length-delimited`);return e.bytes}):[]}function Fe(e,t){if(void 0===e||""===e)throw new Te(`${t} is missing or empty`);return e}function Ae(e){const t=_e(e),r=Me(t,4),n=Me(t,5);if(void 0===r)throw new Te("FieldDescriptorProto.label is missing");if(void 0===n)throw new Te("FieldDescriptorProto.type is missing");return{name:Fe(Oe(t,1),"FieldDescriptorProto.name"),number:Me(t,3)??0,label:r,type:n,type_name:Oe(t,6),json_name:Oe(t,10),oneof_index:Me(t,9),proto3_optional:je(t,17)}}function Ie(e){const t=_e(e);return{name:Fe(Oe(t,1),"EnumDescriptorProto.name"),value:Ne(t,2).map(e=>{const t=_e(e);return{name:Fe(Oe(t,1),"EnumValueDescriptorProto.name"),number:Me(t,2)??0}})}}function Ce(e,t=0){if(t>64)throw new Te("message nesting too deep");const r=_e(e),n=Ne(r,7).at(-1);const o=n?_e(n):void 0;return{name:Fe(Oe(r,1),"DescriptorProto.name"),field:Ne(r,2).map(Ae),nested_type:Ne(r,3).map(e=>Ce(e,t+1)),enum_type:Ne(r,4).map(Ie),oneof_decl:Ne(r,8).map(e=>({name:Fe(Oe(_e(e),1),"OneofDescriptorProto.name")})),options:{map_entry:!!o&&je(o,7)}}}function qe(e){const t=_e(e);return{name:Fe(Oe(t,1),"ServiceDescriptorProto.name"),method:Ne(t,2).map(e=>{const t=_e(e);return{name:Fe(Oe(t,1),"MethodDescriptorProto.name"),input_type:Fe(Oe(t,2),"MethodDescriptorProto.input_type"),output_type:Fe(Oe(t,3),"MethodDescriptorProto.output_type"),client_streaming:je(t,5),server_streaming:je(t,6)}})}}function Re(e){const t=_e(e);return{name:Oe(t,1),package:Oe(t,2),syntax:Oe(t,12),dependency:Ne(t,3).map(e=>function(e,t){try{return xe.decode(e)}catch{throw new Te(`${t} is not valid UTF-8`)}}(e,"FileDescriptorProto.dependency")),message_type:Ne(t,4).map(e=>Ce(e)),enum_type:Ne(t,5).map(Ie),service:Ne(t,6).map(qe)}}function Be(e){const t=_e(e),r=Ne(t,1),n=[...t.keys()].filter(e=>1!==e);if(n.length>0)throw new Te(`expected a FileDescriptorSet but the message also carries field(s) ${n.sort((e,t)=>e-t).join(", ")}. These bytes are most likely a bare FileDescriptorProto; decode it with decodeFileDescriptorProto instead.`);return 0===r.length?[]:r.map(Re)}var Le=class extends Error{expected;observedKeys;constructor(e,t,r){const n=t&&"object"==typeof t?Object.keys(t).sort():[],o=n.length?n.slice(0,24).join(", "):"(none)";super(`descriptor shape mismatch: expected ${e}, got ${Ue(t)} with keys [${o}]`+(n.length>24?` ...+${n.length-24} more`:"")+(r?`. ${r}`:"")),this.name="DescriptorShapeError",this.expected=e,this.observedKeys=n}};function Ue(e){if(null===e)return"null";if(Array.isArray(e))return`array(${e.length})`;const t=typeof e;return"object"===t?e.constructor?.name??"object":t}function Ye(e,t,r){if(!e||"object"!=typeof e)return;const n=e;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:t!==r&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:void 0}function ze(e,t,r){if(!e||"object"!=typeof e)return!1;const n=e;return Object.prototype.hasOwnProperty.call(n,t)||t!==r&&Object.prototype.hasOwnProperty.call(n,r)}function Ve(e,t,r,n){if(!ze(e,t,r))return[];const o=Ye(e,t,r);if(void 0===o)return[];if(null===o||!Array.isArray(o))throw new Le(`${n}.${r} to be a repeated field`,e,`field "${r}" is ${Ue(o)}.`);return o}function Ge(e,t,r,n){const o=Ye(e,t,r);if("string"!=typeof o||0===o.length)throw new Le(`${n}.${r} to be a non-empty string`,e,`got ${Ue(o)}.`);return o}function We(e,t,r,n){const o=Ye(e,t,r),s="string"==typeof o&&""!==o.trim()?Number(o):o;if("number"!=typeof s||!Number.isFinite(s))throw new Le(`${n}.${r} to be a number`,e,`got ${Ue(o)}.`);return s}function Ke(e,t,r){const n=Ye(e,t,r);return!0===n||1===n||"true"===n}var Xe={1:"TYPE_DOUBLE",2:"TYPE_FLOAT",3:"TYPE_INT64",4:"TYPE_UINT64",5:"TYPE_INT32",6:"TYPE_FIXED64",7:"TYPE_FIXED32",8:"TYPE_BOOL",9:"TYPE_STRING",10:"TYPE_GROUP",11:"TYPE_MESSAGE",12:"TYPE_BYTES",13:"TYPE_UINT32",14:"TYPE_ENUM",15:"TYPE_SFIXED32",16:"TYPE_SFIXED64",17:"TYPE_SINT32",18:"TYPE_SINT64"},He={1:"LABEL_OPTIONAL",2:"LABEL_REQUIRED",3:"LABEL_REPEATED"},Je=new Set(Object.values(Xe)),Qe=new Set(Object.values(He));function Ze(e,t,r,n,o){if("string"==typeof e){if(r.has(e))return e;throw new Le(`${n}.${o} to be a known enum name`,e,`"${e}" is not one of [${[...r].join(", ")}].`)}if("number"==typeof e){const r=t[e];if(r)return r;throw new Le(`${n}.${o} to be a known enum number`,e,`${e} has no mapping; the descriptor may use a newer protobuf revision.`)}throw new Le(`${n}.${o} to be present`,e,`got ${Ue(e)}.`)}function et(e,t){return"string"==typeof e?e:"number"==typeof e?t[e]:void 0}function tt(e){return!(!e||"object"!=typeof e)&&Object.values(e).some(e=>{const t=e;return!!t&&"object"==typeof t&&"string"==typeof t.path&&"function"==typeof t.requestSerialize})}function rt(e){nt(e);return Ve(e,"field","field","DescriptorProto").map((e,t)=>{const r=`FieldDescriptorProto[${t}]`,n=Ye(e,"typeName","type_name"),o=Ye(e,"jsonName","json_name"),s=Ye(e,"oneofIndex","oneof_index"),i=Ze(Ye(e,"type","type"),Xe,Je,r,"type");if(("TYPE_MESSAGE"===i||"TYPE_ENUM"===i||"TYPE_GROUP"===i)&&"string"!=typeof n)throw new Le(`${r}.type_name to be present for ${i}`,e,`a ${i} field cannot be resolved without its type name.`);return{name:Ge(e,"name","name",r),number:We(e,"number","number",r),type:i,label:Ze(Ye(e,"label","label"),He,Qe,r,"label"),typeName:"string"==typeof n&&n?n:void 0,jsonName:"string"==typeof o&&o?o:void 0,oneofIndex:"number"==typeof s&&Number.isFinite(s)?s:void 0,proto3Optional:Ke(e,"proto3Optional","proto3_optional")}})}function nt(e){var t;if(!(t=e)||"object"!=typeof t||!ze(t,"name","name")||ze(t,"method","method")||ze(t,"value","value")||tt(t))throw new Le("a DescriptorProto (message descriptor)",e,tt(e)?"this looks like a proto-loader runtime object, not a descriptor proto. Descriptor protos come from loadFileDescriptorSetFromBuffer or from reflection.":"the descriptor source did not produce descriptor protos.")}function ot(e){nt(e);return Ve(e,"oneofDecl","oneof_decl","DescriptorProto").map((e,t)=>Ge(e,"name","name",`OneofDescriptorProto[${t}]`))}function st(e){return nt(e),Ve(e,"nestedType","nested_type","DescriptorProto")}function it(e){if(!e||"object"!=typeof e)return!1;return Ke(Ye(e,"options","options"),"mapEntry","map_entry")}function at(e){if(!((t=e)&&"object"==typeof t&&ze(t,"name","name")&&ze(t,"value","value")))throw new Le("an EnumDescriptorProto",e,"the descriptor source did not produce enum descriptors.");var t;return Ve(e,"value","value","EnumDescriptorProto").map((e,t)=>Ge(e,"name","name",`EnumValueDescriptorProto[${t}]`))}function ct(e){if(!((t=e)&&"object"==typeof t&&ze(t,"name","name")&&ze(t,"method","method")))throw new Le("a ServiceDescriptorProto",e,tt(e)?"this is a proto-loader runtime service object (entries carry `path` and `requestSerialize`), which contains no method descriptors. Load a FileDescriptorSet or use reflection to obtain them.":"the descriptor source did not produce service descriptors.");var t;return Ve(e,"method","method","ServiceDescriptorProto").map((e,t)=>{const r=`MethodDescriptorProto[${t}]`;return{name:Ge(e,"name","name",r),inputType:Ge(e,"inputType","input_type",r),outputType:Ge(e,"outputType","output_type",r),clientStreaming:Ke(e,"clientStreaming","client_streaming"),serverStreaming:Ke(e,"serverStreaming","server_streaming")}})}var lt={keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0};function dt(e,t){return e?`${e}.${t}`:t}function ut(e,t,r){if(""===r)return;const n=t=>e.symbols.has(t)||e.mapEntries.has(t);if(r.startsWith(".")){const e=r.slice(1);return n(e)?e:void 0}let o=t;for(;;){const e=o?`${o}.${r}`:r;if(n(e))return e;if(""===o)return;const t=o.lastIndexOf(".");o=-1===t?"":o.slice(0,t)}}function ft(e,t,r){const n=Ye(e,t,r);return Array.isArray(n)?n:[]}function pt(e,t,r,n,o){e.notes.push(`duplicate definition of ${t} "${r}" (${n} and ${o}); the first one was kept.`)}function ht(e,t,r,n){const o=String(Ye(n,"name","name")??"");if(!o)return void e.notes.push(`${t}: a message with no name was skipped.`);const s=dt(r,o);if(it(n))e.mapEntries.add(s);else{const r=e.symbols.get(s);r?pt(e,"message",s,r.file,t):e.symbols.set(s,{kind:"message",type:n,file:t})}for(const r of ft(n,"nestedType","nested_type"))ht(e,t,s,r);for(const r of ft(n,"enumType","enum_type"))mt(e,t,s,r)}function mt(e,t,r,n){const o=String(Ye(n,"name","name")??"");if(!o)return void e.notes.push(`${t}: an enum with no name was skipped.`);const s=dt(r,o),i=e.symbols.get(s);i?pt(e,"enum",s,i.file,t):e.symbols.set(s,{kind:"enum",type:n,file:t})}function gt(e,t){const r=Ye(t,"name","name"),n="string"==typeof r&&""!==r?r:`(unnamed #${++e.unnamedSeq})`,o=String(Ye(t,"package","package")??"");for(const r of ft(t,"messageType","message_type"))ht(e,n,o,r);for(const r of ft(t,"enumType","enum_type"))mt(e,n,o,r);for(const r of ft(t,"service","service")){const t=String(Ye(r,"name","name")??"");if(!t){e.notes.push(`${n}: a service with no name was skipped.`);continue}const s=dt(o,t),i=e.symbols.get(s);i?"service"===i.kind?pt(e,"service",s,i.file,n):e.notes.push(`"${s}" is declared both as a service (${n}) and as a ${i.kind} (${i.file}); the ${i.kind} was kept and the service is not callable through this catalog.`):(e.symbols.set(s,{kind:"service",type:r,file:n}),e.serviceDescriptors.set(s,r))}}function yt(e){return null!==e&&"object"==typeof e&&"string"==typeof e.path}function vt(e,t,r,n){if(0===t.length)return void n.push(r?"the descriptors attached by @grpc/proto-loader carry no file names, so symbols cannot be attributed to the .proto they were declared in. This affects diagnostics only.":"no descriptor file names were recovered, so symbols cannot be attributed to their .proto files. This affects diagnostics only.");const o=e.filter(e=>!(e=>{const r=e.split("\\").join("/");return t.some(e=>r===e||r.endsWith(`/${e}`))})(e));0!==o.length&&(o.length!==e.length?n.push(`${o.length} of ${e.length} scanned .proto file(s) are not represented in the decoded descriptors, so nothing they declare is in the symbol table: ${o.join(", ")}.`):n.push(`descriptor file names do not correspond to the .proto paths that were scanned (descriptors report ${t.slice(0,3).join(", ")}${t.length>3?", …":""}), so symbols cannot be attributed to the file that declared them. This is how protobufjs-generated descriptors name files and affects diagnostics only — the symbol table itself is unaffected.`))}async function wt(e){!function(e){if(!0===e.reflection)return;const t=e.protoPaths;if(null==t)throw new Error("a gRPC endpoint needs a descriptor source: either set reflection: true, or pass protoPaths: string[] pointing at your .proto files or directories. Neither was provided.");if(!Array.isArray(t))throw new TypeError(`protoPaths must be an array of paths; received ${"string"==typeof t?`the string "${t}" — wrap it: ["${t}"]`:typeof t}.`);if(0===t.length)throw new Error("protoPaths is empty. Pass at least one .proto file or directory, or set reflection: true to obtain descriptors from the server.");const r=t.findIndex(e=>"string"!=typeof e||""===e);if(-1!==r)throw new TypeError(`protoPaths[${r}] is not a non-empty string (got ${typeof t[r]}).`);const n=e.includeDirs;if(null!=n&&!Array.isArray(n))throw new TypeError(`includeDirs must be an array of directories; received ${"string"==typeof n?`the string "${n}" — wrap it: ["${n}"]`:typeof n}.`)}(e);const t=await v(),{protoLoader:r}=t,n=[];let o,s,i,a;if(!0===e.reflection){b(t,"descriptorSetFromBuffer");const{credentials:c,mode:l,warnings:d}=E(e,t);n.push(...d);const u=await ye({address:e.address,credentials:c,metadata:e.metadata,timeoutMs:e.reflectionTimeoutMs??5e3,channelOptions:e.channelOptions,version:e.reflectionVersion,host:e.reflectionHost,maxFiles:e.maxReflectionFiles,maxBytes:e.maxReflectionBytes});if(n.push(...u.notes),0===u.services.length)throw new Error(`reflection is available at ${e.address} (${u.version}) but no services are registered on it. Either the server registered only the reflection service itself, or the services you expect were never added to it.`);o=r.loadFileDescriptorSetFromBuffer(u.descriptorSet,lt);try{s=Be(u.descriptorSet)}catch(t){if(!(t instanceof Te))throw t;throw new Error(`reflection at ${e.address} returned ${u.descriptorSet.length} byte(s) that could not be decoded as a FileDescriptorSet: ${t.message}. The server may be answering the reflection method with a non-standard payload.`)}if(0===s.length)throw new Error(`reflection at ${e.address} reported ${u.services.length} service(s) but its descriptor set decoded to zero files, so nothing can be described.`);i="reflection",a=u.files,n.push(`reflection (${u.version}, ${l}) returned ${u.services.length} service(s) across ${u.files.length} file(s).`)}else{const t=e.protoPaths,c=await F({paths:t,ignoreDirs:e.ignoreDirs,followSymlinks:e.followSymlinks,maxFiles:e.maxProtoFiles});let l;if(n.push(...c.notes),a=c.files,Array.isArray(e.includeDirs)&&e.includeDirs.length>0)l=e.includeDirs;else{const e=I(c);l=e.includeDirs,n.push(...e.notes)}o=await r.load(c.files,{...lt,includeDirs:l});const d=function(e){const t=new Set,r=[];let n=!1,o=0;const s=e=>{const s=e?.fileDescriptorProtos;if(!Array.isArray(s))return!1;n=!0,o++;for(const e of s){if(!(Buffer.isBuffer(e)||e instanceof Uint8Array))continue;const n=Buffer.isBuffer(e)?e:Buffer.from(e),o=n.toString("base64");t.has(o)||(t.add(o),r.push(n))}return!0};for(const t of Object.values(e))if(t&&"object"==typeof t&&!s(t))for(const e of Object.values(t))e&&"object"==typeof e&&s(e);return{buffers:r,found:n,carriers:o}}(o);if(!d.found)throw new Error(`@grpc/proto-loader did not attach fileDescriptorProtos to any of the ${Object.keys(o).length} entries it produced, so no method or field metadata can be read. Upgrade to @grpc/proto-loader >= 0.6.0.`);if(0===d.buffers.length)throw new Error(`@grpc/proto-loader attached fileDescriptorProtos to ${d.carriers} entry/entries, but none of them contained descriptor bytes. The loader output cannot be interpreted; this is a version incompatibility rather than a problem with your protos.`);s=function(e,t){const r=[],n=[];for(const t of e)try{r.push(Re(t))}catch(e){n.push(e instanceof Error?e.message:String(e))}if(n.length>0&&0===r.length)throw new Error(`none of the ${e.length} FileDescriptorProto(s) attached by @grpc/proto-loader could be decoded, so no method or field metadata is available. First failure: ${n[0]}`);return n.length>0&&t.push(`${n.length} of ${e.length} FileDescriptorProto(s) could not be decoded and their symbols are unavailable. First failure: ${n[0]}`),r}(d.buffers,n),i="proto",c.files.length>1&&n.push(`merged ${c.files.length} .proto file(s) from ${t.length} path(s).`)}const c={symbols:new Map,serviceDescriptors:new Map,mapEntries:new Set,notes:n,unnamedSeq:0};for(const e of s)gt(c,e);const{symbols:l,serviceDescriptors:d,mapEntries:u}=c,f=s.map(e=>{const t=Ye(e,"name","name");return"string"==typeof t&&""!==t?t:void 0}),p=f.length>0&&f.every(e=>void 0===e),h=[...new Set(f.filter(e=>void 0!==e))].sort();"proto"===i&&a&&vt(a,h,p,n),function(e){const t={symbols:e.symbols,mapEntries:e.mapEntries},r=new Map,n=(e,t)=>{const n=r.get(e)??[];n.includes(t)||n.push(t),r.set(e,n)},o=(e,r,s)=>{for(const o of ft(s,"field","field")){const s=Ye(o,"typeName","type_name");"string"==typeof s&&""!==s&&void 0===ut(t,e,s)&&n(s,r)}for(const t of ft(s,"nestedType","nested_type")){const n=String(Ye(t,"name","name")??"");n&&o(`${e}.${n}`,r,t)}};for(const[t,r]of e.symbols)"message"===r.kind&&o(t,t,r.type);for(const[r,o]of e.serviceDescriptors)for(const e of ft(o,"method","method"))for(const[o,s]of[["inputType","input_type"],["outputType","output_type"]]){const i=Ye(e,o,s);"string"==typeof i&&""!==i&&void 0===ut(t,r,i)&&n(i,r)}if(0===r.size)return;const s=[...r.keys()].sort().slice(0,12),i=[...new Set([...r.values()].flat())].sort();e.notes.push(`${r.size} type reference(s) do not resolve against the symbol table: ${s.join(", ")}`+(r.size>s.length?" ...+"+(r.size-s.length):"")+`. Request templates for the messages using them will be incomplete. Referenced from: ${i.slice(0,6).join(", ")}`+(i.length>6?" ...+"+(i.length-6):"")+".")}(c);const m=[...d.keys()].sort(),g=function(e,t){const r=[],n=[];for(const[t,o]of Object.entries(e)){if(!o||"object"!=typeof o)continue;if("fileDescriptorProtos"in o)continue;const e=Object.values(o);0!==e.length?e.every(yt)&&r.push(t):n.push(t)}return n.length>0&&t.push(`${n.length} service(s) declare no methods and cannot be called: ${n.sort().join(", ")}.`),r.sort()}(o,n);return function(e,t,r){const n=new Set(e),o=new Set(t),s=e.filter(e=>!o.has(e)),i=t.filter(e=>!n.has(e));s.length>0&&r.push(`${s.length} service(s) are described but not invocable (no codecs were generated): ${s.join(", ")}.`),i.length>0&&r.push(`${i.length} service(s) are invocable but have no descriptor, so no request template can be generated: ${i.join(", ")}.`)}(m,g,n),0===m.length&&0===g.length&&n.push("proto"===i?`the ${a?.length??0} .proto file(s) loaded declare no services.`:"reflection returned descriptors that declare no services."),{catalog:{source:i,symbols:l,services:m,invocableServices:g,serviceDescriptors:d,notes:n,files:a,descriptorFiles:h,mapEntries:u,descriptorFilesUnnamed:p},packageDefinition:o}}function bt(e,t){return e&&t?"bidi_streaming":e?"client_streaming":t?"server_streaming":"unary"}function $t(e,t,r,n,o){const s=(i=r).startsWith(".")?i.slice(1):i;var i;let a;try{a=function(e){if("string"==typeof e)return e||void 0;const t=e?.name;return"string"==typeof t&&t?t:void 0}(ut(e,t,r))}catch(e){return o.push(`resolving the ${n} type "${r}" failed: ${e instanceof Error?e.message:String(e)}. The name is reported as written.`),s}return a||(o.push(r.startsWith(".")?`the ${n} type "${s}" is not in the symbol table; the descriptor closure is incomplete. The name is reported as written.`:`the ${n} type "${r}" is a relative reference that could not be resolved in scope "${t||"(root)"}"; it is reported as written and is therefore not fully qualified.`),s)}function Et(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.path&&t.path.length>0&&"boolean"==typeof t.requestStream&&"boolean"==typeof t.responseStream&&"function"==typeof t.requestSerialize&&"function"==typeof t.responseDeserialize}function St(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}async function Tt(e,t){if(function(e){const t=["address","service","method"];for(const r of t){const t=e[r];if("string"!=typeof t||0===t.length)throw new TypeError(`GrpcTarget.${r} must be a non-empty string; received ${void 0===t?"undefined":typeof t}.`)}}(e),t&&(!t.catalog||!t.packageDefinition))throw new TypeError("ResolveMethodOptions requires both catalog and packageDefinition, from the same buildCatalog call.");const{catalog:r,packageDefinition:n}=t??await wt(e),o=[...r.notes],s=Object.prototype.hasOwnProperty.call(n,e.service)?n[e.service]:void 0;if(!s||"object"!=typeof s){const t=new Set([...r.invocableServices,...r.services]),n=r.services.includes(e.service)?" It exists in the descriptor but no codecs were generated for it, so it cannot be called.":` Available: ${[...t].sort().join(", ")||"(none)"}`;throw new Error(`service "${e.service}" is not invocable (source: ${r.source}).${n}`)}const i=function(e){const t=new Map,r=new Set;for(const n of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(!Et(o))continue;const s=St(o.path);r.has(s)||(t.set(s,o),n===s&&r.add(s))}return t}(s),a=[...i.keys()],c=function(e,t){if(e.includes(t))return{name:t,exact:!0};const r=t.toLowerCase(),n=e.filter(e=>e.toLowerCase()===r);return 1===n.length?{name:n[0],exact:!1}:void 0}(a,e.method);if(!c){const t=a.filter(t=>t.toLowerCase()===e.method.toLowerCase()).length>1;throw new Error(t?`method "${e.method}" is ambiguous on ${e.service}; several methods differ only in case. Use the exact name.`:`method "${e.method}" not found on ${e.service}. Available: ${[...a].sort().join(", ")||"(none)"}`)}c.exact||o.push(`method matched case-insensitively: requested "${e.method}", using "${c.name}".`);const l=i.get(c.name),d=l.requestStream,u=l.responseStream,f=function(e,t,r){const n=e.serviceDescriptors.get(t);if(void 0!==n)try{return ct(n)}catch(e){if(!(e instanceof Le))throw e;return void r.push(`the descriptor for ${t} is unreadable, so message type names are unavailable and no request template can be generated; the call itself is unaffected: ${e.message}`)}else r.push(`no descriptor for ${t} in the ${e.source} catalog; the call can still be made but request templates and message type names are unavailable.`)}(r,e.service,o);let p;if(f&&(p=f.find(e=>e.name===c.name),p||o.push(`method "${c.name}" is invocable but absent from the ${e.service} descriptor; message type names are unavailable.`)),p&&(p.clientStreaming!==d||p.serverStreaming!==u))throw new Error(`descriptor and runtime disagree on the streaming kind of ${e.service}/${c.name}: descriptor says ${bt(p.clientStreaming,p.serverStreaming)}, runtime says ${bt(d,u)}. Refusing to dial, because either choice would misuse the stream. The descriptor source is likely stale or mixed — reload the proto tree, or clear cached reflection data.`);const h=`/${e.service}/${c.name}`;l.path!==h&&o.push(`the method path reported by the loader (${l.path}) differs from the expected ${h}; the loader's path is used.`);const m=function(e){const t=e.lastIndexOf(".");return t>0?e.slice(0,t):""}(e.service),g=p?$t(r,m,p.inputType,"request",o):void 0,y=p?$t(r,m,p.outputType,"response",o):void 0;return{name:c.name,kind:bt(d,u),path:l.path,requestStream:d,responseStream:u,serialize:e=>l.requestSerialize(e),deserialize:e=>l.responseDeserialize(e),inputType:g,outputType:y,source:r.source,notes:o}}var kt={0:"OK",1:"CANCELLED",2:"UNKNOWN",3:"INVALID_ARGUMENT",4:"DEADLINE_EXCEEDED",5:"NOT_FOUND",6:"ALREADY_EXISTS",7:"PERMISSION_DENIED",8:"RESOURCE_EXHAUSTED",9:"FAILED_PRECONDITION",10:"ABORTED",11:"OUT_OF_RANGE",12:"UNIMPLEMENTED",13:"INTERNAL",14:"UNAVAILABLE",15:"DATA_LOSS",16:"UNAUTHENTICATED"},Dt=0,Pt=1,_t=2,xt=3,Ot=200;function Mt(e,t){return{code:e,codeName:kt[e]??`CODE_${e}`,details:t}}function jt(e){const t=e;if("function"!=typeof t?.toJSON)return{};const r={};for(const[e,n]of Object.entries(t.toJSON())){const t=Array.isArray(n)?n:[n];r[e]=t.map(e=>Buffer.isBuffer(e)?e.toString("base64"):String(e))}return r}var Nt=new Set(["max_messages","idle_timeout","max_session","aborted"]);function Ft(e,t){if(void 0!==t&&("number"!=typeof t||!Number.isFinite(t)||t<0))throw new RangeError(`${e} must be a finite number of milliseconds >= 0; received ${"number"==typeof t?t:typeof t}.`)}async function At(e,t={},r){const n=Date.now(),o=function(e){if(void 0===e)return[];if(!Array.isArray(e))throw new TypeError(`options.messages must be an array of request payloads; received ${null===e?"null":typeof e}. A single message still goes in an array.`);return e}(t.messages);if(function(e,t){if(void 0!==t&&(!Number.isInteger(t)||t<0))throw new RangeError(`${e} must be a non-negative integer; received ${"number"==typeof t?t:typeof t}. A fractional limit can never be reached by a message count.`)}("maxMessages",t.maxMessages),Ft("idleTimeoutMs",t.idleTimeoutMs),Ft("maxSessionMs",t.maxSessionMs),Ft("sendIntervalMs",t.sendIntervalMs),Ft("deadlineMs",e.deadlineMs),void 0!==t.signal&&null!==t.signal){const e=t.signal;if("function"!=typeof e.addEventListener||"boolean"!=typeof e.aborted)throw new TypeError("options.signal must be an AbortSignal (pass controller.signal, not the controller).")}if(void 0!==t.onEvent&&"function"!=typeof t.onEvent)throw new TypeError(`options.onEvent must be a function; received ${typeof t.onEvent}.`);const s=await v(),{grpc:i}=s,a=r??await(async()=>{const t=await wt(e);return{catalog:t.catalog,packageDefinition:t.packageDefinition,includeSourceNotes:!1}})(),c=await Tt(e,{catalog:a.catalog,packageDefinition:a.packageDefinition}),l=new Set(a.catalog.notes),d=a.includeSourceNotes?[...c.notes]:c.notes.filter(e=>!l.has(e)),u=[],f=[];let p,h,m,g,y,w,b=0,$=!1;if(!c.requestStream&&o.length>1&&d.push(`${c.kind} accepts a single request message; ${o.length-1} extra message(s) were ignored.`),c.requestStream||0!==o.length||d.push(`${c.kind} requires a request message and none was given; an empty message was sent, which on the wire means "all defaults".`),t.keepWriteOpen&&"bidi_streaming"!==c.kind&&d.push(`keepWriteOpen only applies to bidi_streaming; ignored for ${c.kind}.`),void 0===t.sendIntervalMs||c.requestStream||d.push(`sendIntervalMs paces the outbound stream and has no effect on ${c.kind}, which sends exactly one message.`),t.keepWriteOpen&&"bidi_streaming"===c.kind){const r=void 0!==t.maxSessionMs||void 0!==t.idleTimeoutMs||void 0!==t.maxMessages||Boolean(t.signal);r||void 0!==e.deadlineMs?r||d.push(`keepWriteOpen is bounded only by deadlineMs (${e.deadlineMs}ms); since the write side is never half-closed, the call will end in DEADLINE_EXCEEDED unless the server closes the stream first. Set maxMessages, idleTimeoutMs, or maxSessionMs for a clean stop.`):d.push("keepWriteOpen is set with no limit and no deadline; the call can only end when the server closes the stream.")}const S=E(e,s);d.push(...S.warnings);const T=function(e,t){const r=new e.Metadata;for(const[e,n]of Object.entries(t??{})){const t=Array.isArray(n)?n:[n];for(const n of t){if("string"!=typeof n&&!Buffer.isBuffer(n))throw new TypeError(`metadata["${e}"] must be a string, a Buffer, or an array of those; received ${null===n?"null":typeof n}. Binary values require a key ending in "-bin".`);try{r.add(e,n)}catch(t){throw new TypeError(`metadata key "${e}" was rejected by grpc-js: ${t instanceof Error?t.message:String(t)}. Keys must match [0-9a-z_.-]+, and only keys ending in "-bin" may carry Buffers.`)}}}return r}(i,e.metadata);let k;try{k=new i.Client(e.address,S.credentials,e.channelOptions)}catch(t){throw new Error(`could not create a channel to "${e.address}": ${t instanceof Error?t.message:String(t)}. Expected host:port.`)}const D={};return void 0!==e.deadlineMs&&(D.deadline=new Date(Date.now()+e.deadlineMs)),await new Promise(e=>{let r,n,s,i,a,l,v=!1,E=!1,S=!1,P=!1;const _=e=>{if(v)return;const r={...e,seq:b++,at:Date.now()};if(u.push(r),t.onEvent)try{t.onEvent(r)}catch{}},x=(e,t)=>{E||(E=!0,m=e,g=t)},O=e=>{S||$||(S=!0,h=e)},M=o=>{if(!v){o&&($=!0,p=o,Nt.has(o)&&x(Mt(Pt,`call stopped by the client (${o}); the server never reported a status`),"synthesized")),P&&!E&&(x(Mt(Dt),"synthesized"),d.push(`the response was received but the server's status did not arrive within ${Ot}ms; OK was inferred from the successful response and no trailing metadata is available.`)),P=!1,v=!0,clearTimeout(r),clearTimeout(n),clearTimeout(s),clearTimeout(i),l&&t.signal&&t.signal.removeEventListener("abort",l);try{a?.cancel()}catch{}try{k.close()}catch{}e()}},j=()=>{v||void 0!==t.idleTimeoutMs&&(clearTimeout(r),r=setTimeout(()=>M("idle_timeout"),t.idleTimeoutMs))},N=e=>{v||(f.push(e),_({direction:"inbound",payload:e}),j(),void 0!==t.maxMessages&&f.length>=t.maxMessages&&M("max_messages"))},F=()=>{v||E?M():(P=!0,clearTimeout(r),i=setTimeout(()=>M(),Ot))},A=e=>{const t=e,r=Mt(t.code??_t,t.details??t.message),n=void 0===t.code?"client":"server";x(r,n),O(t.message??String(e)),_({direction:"status",status:r,statusOrigin:n}),M()},I=(e,t,r)=>{const n=Mt(e,t);x(n,"client"),O(r instanceof Error?r.message:String(r)),_({direction:"status",status:n,statusOrigin:"client"}),M()};if(0===t.maxMessages)return d.push("maxMessages is 0, so the call is stopped before any response is read."),void M("max_messages");if(void 0!==t.maxSessionMs&&(n=setTimeout(()=>M("max_session"),t.maxSessionMs)),t.signal){if(t.signal.aborted)return void M("aborted");l=()=>M("aborted"),t.signal.addEventListener("abort",l,{once:!0})}const C=e=>c.serialize(e),q=e=>c.deserialize(e),R=(e,t)=>{try{return c.serialize(e),!0}catch(e){return I(xt,`request message #${t} does not match ${c.inputType??"the request type"}`,e),!1}},B=e=>{e.on("metadata",e=>{y=jt(e),_({direction:"meta",metadata:y})}),e.on("status",e=>{const t=e;w=jt(t.metadata);const r=Mt(t.code,t.details);x(r,"server"),_({direction:"status",status:r,statusOrigin:"server",metadata:w}),(c.responseStream||P)&&M()})},L=e=>{let r=0;const n=()=>{if(v)return;if(r>=o.length){if(!(!0===t.keepWriteOpen&&"bidi_streaming"===c.kind))try{e.end?.()}catch{}return}const i=r,a=o[r++];if(R(a,i)){try{e.write?.(a),_({direction:"outbound",payload:a}),j()}catch(e){return void I(_t,`write of message #${i} failed`,e)}t.sendIntervalMs?s=setTimeout(n,t.sendIntervalMs):n()}};n()};try{if("unary"===c.kind||"server_streaming"===c.kind){const e=o[0]??{};if(!R(e,0))return;_({direction:"outbound",payload:e}),"unary"===c.kind?(a=k.makeUnaryRequest(c.path,C,q,e,T,D,(e,t)=>{e?A(e):(N(t),F())}),B(a),a.on("error",A)):(a=k.makeServerStreamRequest(c.path,C,q,e,T,D),B(a),a.on("data",e=>N(e)),a.on("error",A),a.on("end",()=>{x(Mt(Dt),"synthesized"),M()}))}else"client_streaming"===c.kind?(a=k.makeClientStreamRequest(c.path,C,q,T,D,(e,t)=>{e?A(e):(N(t),F())}),B(a),a.on("error",A),L(a)):(a=k.makeBidiStreamRequest(c.path,C,q,T,D),B(a),a.on("data",e=>N(e)),a.on("error",A),a.on("end",()=>{x(Mt(Dt),"synthesized"),M()}),L(a))}catch(e){return void I(_t,"call setup failed",e)}j()}),{protocol:"grpc",kind:c.kind,target:e,events:u,messages:f,initialMetadata:y,status:m,statusOrigin:g,trailers:w,truncated:$,truncatedReason:p,error:h,warnings:d,durationMs:Date.now()-n}}var It=Symbol("omit"),Ct={TYPE_DOUBLE:0,TYPE_FLOAT:0,TYPE_INT32:0,TYPE_UINT32:0,TYPE_SINT32:0,TYPE_FIXED32:0,TYPE_SFIXED32:0,TYPE_BOOL:!1,TYPE_STRING:"",TYPE_BYTES:"",TYPE_INT64:"0",TYPE_UINT64:"0",TYPE_SINT64:"0",TYPE_FIXED64:"0",TYPE_SFIXED64:"0"},qt={"google.protobuf.Timestamp":"1970-01-01T00:00:00Z","google.protobuf.Duration":"0s","google.protobuf.Empty":{},"google.protobuf.StringValue":"","google.protobuf.BoolValue":!1,"google.protobuf.Int32Value":0,"google.protobuf.Int64Value":"0","google.protobuf.UInt32Value":0,"google.protobuf.UInt64Value":"0","google.protobuf.DoubleValue":0,"google.protobuf.FloatValue":0,"google.protobuf.BytesValue":"","google.protobuf.FieldMask":"","google.protobuf.Struct":{},"google.protobuf.ListValue":[]},Rt=new Set(["google.protobuf.Value","google.protobuf.Any"]);function Bt(e){return e.startsWith(".")?e.slice(1):e}function Lt(e,t){return e?`${e}.${t}`:t}var Ut=!0===lt.keepCase?"declared":"json";function Yt(e){return"declared"===Ut?e.name:e.jsonName??e.name.replace(/_([a-z0-9])/g,(e,t)=>t.toUpperCase())}function zt(e,t,r={}){const n={catalog:e,maxDepth:r.maxDepth??4,seedCollections:!1!==r.seedCollections,fillExplicitOptional:!0===r.fillExplicitOptional,fillMessageFields:!1!==r.fillMessageFields,keyOf:Yt,oneofs:[],enums:[],collections:[],presence:[],warnings:[],stack:[],hintDepth:0},o=Bt(t),s=Kt(n,"",t)??o;let i={};try{i=Qt(n,s,"",0)??{}}catch(e){if(!(e instanceof Le))throw e;n.warnings.push(`template generation stopped: ${e.message}. The request must be composed by hand.`)}return{message:s,example:i,keyStyle:Ut,oneofs:n.oneofs,enums:n.enums,collections:n.collections,presence:n.presence,warnings:n.warnings}}function Vt(e){return 0===e.hintDepth}function Gt(e,t){Vt(e)&&e.warnings.push(t)}function Wt(e,t){e.hintDepth++;try{return t()}finally{e.hintDepth--}}function Kt(e,t,r){const n=ut(e.catalog,t,r);if(void 0!==n)return"message"===e.catalog.symbols.get(n)?.kind?n:void 0}function Xt(e,t){const r=e.catalog.symbols.get(t);return"message"===r?.kind?r.type:void 0}function Ht(e,t,r){return r.typeName?ut(e.catalog,t,r.typeName)??Bt(r.typeName):r.type}function Jt(e,t){return 1===t.length&&("LABEL_REPEATED"!==t[0].label&&(void 0===e||e===`_${t[0].name}`))}function Qt(e,t,r,n){if(n>e.maxDepth)return Gt(e,`recursion depth ${e.maxDepth} reached at "${r||"(root)"}" (${t}); the value is an empty message, which on the wire means "set with all defaults" — remove the key to leave it unset.`),{};if(e.stack.includes(t))return Gt(e,`cyclic reference to ${t} at "${r}"; the value is an empty message, which on the wire means "set with all defaults".`),{};const o=Xt(e,t);if(!o)return Gt(e,`message "${t}" is not in the symbol table (referenced at "${r||"(root)"}"); left as an empty object. The descriptor closure is incomplete — the catalog notes say which references failed.`),{};e.stack.push(t);try{const s=rt(o),i=ot(o),a={},c=new Map;for(const e of s){if(void 0===e.oneofIndex)continue;const t=c.get(e.oneofIndex)??[];t.push(e),c.set(e.oneofIndex,t)}const l=new Map,d=new Set;for(const[r,n]of c){if(n.every(e=>e.proto3Optional)||Jt(i[r],n))for(const e of n)d.add(e.name);else{const o=n.filter(e=>e.proto3Optional);if(o.length>0){Gt(e,`oneof "${i[r]??r}" in ${t} mixes ${o.length} explicit-presence member(s) with ${n.length-o.length} plain one(s), which protoc does not produce. All of them are treated as optional fields and left unset; set at most one by hand.`);for(const e of n)d.add(e.name)}else l.set(r,n)}}const u=new Set;for(const o of s){const s=e.keyOf(o),c=Lt(r,o.name);if(void 0!==o.oneofIndex&&l.has(o.oneofIndex)){if(u.has(o.oneofIndex))continue;u.add(o.oneofIndex);const s=l.get(o.oneofIndex),c=s[0],d=Zt(e,t,c,Lt(r,c.name),n),f={};d!==It&&(f[e.keyOf(c)]=d),Wt(e,()=>{for(const o of s.slice(1)){const s=Zt(e,t,o,Lt(r,o.name),n);s!==It&&(f[e.keyOf(o)]=s)}}),Vt(e)&&e.oneofs.push({at:r,oneof:i[o.oneofIndex]??`oneof_${o.oneofIndex}`,branches:s.map(e=>e.name),chosen:c.name,branchValues:f}),d!==It&&(a[e.keyOf(c)]=d);continue}if(o.proto3Optional||d.has(o.name)){const r=Wt(e,()=>Zt(e,t,o,c,n));Vt(e)&&e.presence.push({at:c,reason:"proto3_optional",presentInExample:e.fillExplicitOptional,valueIfSet:r===It?void 0:r}),e.fillExplicitOptional&&r!==It&&(a[s]=r);continue}const f=Zt(e,t,o,c,n);f!==It&&(a[s]=f)}return a}finally{e.stack.pop()}}function Zt(e,t,r,n,o){const s="LABEL_REPEATED"===r.label;if(s&&"TYPE_MESSAGE"===r.type&&r.typeName){const s=function(e,t,r){const n=Xt(e,t);if(!n)return;const o=Bt(r),s=o.slice(o.lastIndexOf(".")+1);try{for(const e of st(n)){if(String(Ye(e,"name","name")??"")!==s)continue;if(!it(e))continue;const t=rt(e),r=t.find(e=>"key"===e.name),n=t.find(e=>"value"===e.name);if(r&&n)return{keyType:r.type,valueField:n}}}catch(e){if(!(e instanceof Le))throw e;return}}(e,t,r.typeName);if(s){if(Vt(e)&&e.collections.push({at:n,kind:"map",of:Ht(e,t,s.valueField),keyOf:s.keyType}),!e.seedCollections)return{};const r="TYPE_STRING"===s.keyType?"key":"0",i=er(e,t,s.valueField,`${n}.${r}`,o);return i===It?{}:{[r]:i}}Gt(e,`"${n}" is a repeated ${Bt(r.typeName)} that could not be read as a map entry; treating it as a repeated message field.`)}if(s){if(Vt(e)&&e.collections.push({at:n,kind:"repeated",of:Ht(e,t,r)}),!e.seedCollections)return[];const s=er(e,t,r,`${n}[0]`,o);return s===It?[]:[s]}return er(e,t,r,n,o)}function er(e,t,r,n,o){if("TYPE_ENUM"===r.type){const o=r.typeName,s=function(e,t,r){const n=ut(e.catalog,t,r);if(void 0!==n)return"enum"===e.catalog.symbols.get(n)?.kind?n:void 0}(e,t,o),i=s??Bt(o);let a=[];if(void 0!==s){const t=function(e,t){const r=e.catalog.symbols.get(t);return"enum"===r?.kind?r.type:void 0}(e,s);try{a=at(t)}catch(t){if(!(t instanceof Le))throw t;Gt(e,`enum "${i}" at "${n}" is unreadable: ${t.message}`)}}return 0===a.length?(Gt(e,void 0===s?`enum "${i}" at "${n}" does not resolve from scope "${t}"; the example uses an empty string, which the server will reject. The catalog notes list the failed references.`:`enum "${i}" at "${n}" declares no values; the example uses an empty string, which the server will reject.`),""):(Vt(e)&&e.enums.push({at:n,enum:i,values:a}),a[0])}if("TYPE_MESSAGE"===r.type||"TYPE_GROUP"===r.type){const s=r.typeName,i=Bt(s),a=Kt(e,t,s),c=a??i;if("google.protobuf.Any"===c||"google.protobuf.Any"===i)return Gt(e,`"${n}" is google.protobuf.Any; its payload is passed through unmodified and is not validated against the descriptor. Editing support is not available in this version.`),{"@type":"",value:{}};if(Rt.has(c)||Rt.has(i))return Gt(e,`"${n}" is ${c}, whose JSON form is any JSON value; no example can be generated without guessing. Supply it by hand.`),{};if(c in qt)return qt[c];if(i in qt)return qt[i];if(void 0===a)return Gt(e,`message "${i}" at "${n}" does not resolve from scope "${t}"; left as an empty object, which on the wire means "set with all defaults". The catalog notes list the failed references.`),Vt(e)&&e.presence.push({at:n,reason:"message",presentInExample:e.fillMessageFields,valueIfSet:{}}),e.fillMessageFields?{}:It;const l=Qt(e,a,n,o+1)??{};return Vt(e)&&e.presence.push({at:n,reason:"message",presentInExample:e.fillMessageFields,valueIfSet:l}),e.fillMessageFields?l:It}return r.type in Ct?Ct[r.type]:(Gt(e,`unhandled field type ${r.type} at "${n}"; the example uses null, which will not serialise.`),null)}var tr=(e,t)=>e.name<t.name?-1:e.name>t.name?1:0;function rr(e,t){return e&&t?"bidi_streaming":e?"client_streaming":t?"server_streaming":"unary"}function nr(e){return e.startsWith(".")?e.slice(1):e}function or(e){const t=e.lastIndexOf(".");return-1===t?"":e.slice(0,t)}function sr(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function ir(e,t){const r=new Map,n=e[t];if(!n||"object"!=typeof n)return r;for(const[e,t]of Object.entries(n)){const n=t;if(!n||"object"!=typeof n||"string"!=typeof n.path)continue;const o={key:e,path:n.path,requestStream:!0===n.requestStream,responseStream:!0===n.responseStream,hasCodecs:"function"==typeof n.requestSerialize&&"function"==typeof n.responseDeserialize},s=sr(o.path),i=r.get(s);i&&i.key===s||r.set(s,o)}return r}function ar(e,t,r){const n=e.serviceDescriptors.get(t);if(void 0!==n)try{return ct(n)}catch(e){return void r.push(`descriptor for ${t} is unreadable, so request templates and type names are unavailable for it: ${e instanceof Error?e.message:String(e)}`)}}async function cr(e,t,r,n={}){const{catalog:o,packageDefinition:s}=await wt(e);return lr(o,s,t,r,n)}function lr(e,t,r,n,o={}){if(!(e.serviceDescriptors.has(r)||e.invocableServices.includes(r))){const t=[...new Set([...e.services,...e.invocableServices])].sort();throw new Error(`service "${r}" not found (source: ${e.source}). Available: ${t.join(", ")||"(none)"}`)}const s=[...e.notes],i=ar(e,r,s),a=ir(t,r);let c=i?.find(e=>e.name===n);if(!c&&i){const e=i.filter(e=>e.name.toLowerCase()===n.toLowerCase());if(1===e.length)s.push(`method matched case-insensitively: requested "${n}", using "${e[0].name}".`),c=e[0];else if(e.length>1)throw new Error(`method "${n}" is ambiguous on ${r}: ${e.map(e=>e.name).sort().join(", ")}. Use the exact declared name.`)}if(!c)throw function(e,t,r,n,o){const s=(n??[]).map(e=>e.name).sort(),i=[...o.keys()].sort();if(void 0===n)return new Error(`cannot describe "${e}/${t}": no readable descriptor for ${e} (source: ${r}), so no method metadata is available. The method may still be callable — the runtime view lists ${i.join(", ")||"(none)"}.`);const a=i.filter(e=>!s.includes(e));return o.has(t)?new Error(`method "${t}" is callable on ${e} but missing from its descriptor (source: ${r}), so no request template can be built. Described: ${s.join(", ")||"(none)"}.`+(a.length?` Also undescribed: ${a.filter(e=>e!==t).join(", ")||"(none)"}.`:"")):new Error(`method "${t}" not found on ${e} (source: ${r}). Described: ${s.join(", ")||"(none)"}`+(a.length?`; callable but undescribed: ${a.join(", ")}`:"")+".")}(r,n,e.source,i,a);const l=a.get(c.name),d={name:c.name,path:l?.path??`/${r}/${c.name}`,kind:rr(c.clientStreaming,c.serverStreaming),inputType:nr(c.inputType),outputType:nr(c.outputType),requestStream:c.clientStreaming,responseStream:c.serverStreaming,invocable:!0===l?.hasCodecs};d.invocable||s.push(`${r}/${c.name} can be described but not called: the loaded definition has no codecs for it.`);const u={maxDepth:o.maxDepth,seedCollections:o.seedCollections,fillExplicitOptional:o.fillExplicitOptional,fillMessageFields:o.fillMessageFields};let f,p;if(void 0===d.inputType)s.push(`the request type of ${r}/${d.name} is unknown, so no template can be built.`);else try{f=zt(e,d.inputType,u)}catch(e){if(!(e instanceof Le))throw e;s.push(`request template unavailable: ${e.message}`)}if(o.includeResponse)if(void 0===d.outputType)s.push(`the response type of ${r}/${d.name} is unknown, so its shape is unavailable.`);else try{p=zt(e,d.outputType,u)}catch(e){if(!(e instanceof Le))throw e;s.push(`response shape unavailable: ${e.message}`)}return{...d,service:r,request:f,response:p,notes:s}}function dr(e,t,r){const n=[...t.notes],o=[...new Set([...t.services,...t.invocableServices])].sort().map(e=>function(e,t,r,n){const o=[],s=new Set;for(const i of t??[]){s.add(i.name);const t=r.get(i.name);if(t){const r=rr(i.clientStreaming,i.serverStreaming),o=rr(t.requestStream,t.responseStream);r!==o&&n.push(`streaming flags disagree for ${e}/${i.name}: descriptor says ${r}, runtime says ${o}. Calls to this method will be refused.`)}o.push({name:i.name,path:t?.path??`/${e}/${i.name}`,kind:rr(i.clientStreaming,i.serverStreaming),inputType:nr(i.inputType),outputType:nr(i.outputType),requestStream:i.clientStreaming,responseStream:i.serverStreaming,invocable:!0===t?.hasCodecs})}const i=[];for(const[e,t]of r)s.has(e)||(i.push(e),o.push({name:e,path:t.path,kind:rr(t.requestStream,t.responseStream),inputType:void 0,outputType:void 0,requestStream:t.requestStream,responseStream:t.responseStream,invocable:t.hasCodecs}));i.length&&n.push(`${e}: ${i.sort().join(", ")} ${1===i.length?"is":"are"} callable but absent from the descriptor; no request template can be generated for ${1===i.length?"it":"them"}.`);const a=o.filter(e=>!e.invocable).map(e=>e.name);return a.length&&t&&n.push(`${e}: ${a.sort().join(", ")} ${1===a.length?"is":"are"} declared but not invocable; the loaded definition has no codecs for ${1===a.length?"it":"them"}.`),o.sort(tr),{name:e,package:or(e),methods:o,views:t&&r.size>0?"both":t?"descriptor_only":"runtime_only"}}(e,ar(t,e,n),ir(r,e),n));return{address:e.address,source:t.source,services:o,files:t.files,notes:n}}async function ur(e){const{catalog:t,packageDefinition:r}=await wt(e);return dr(e,t,r)}function fr(e){return void 0!==e&&!1!==e&&(!0===e?"system":{roots:e.rootCerts?.length??0,key:e.privateKey?.length??0,chain:e.certChain?.length??0,skipHostname:!0===e.skipHostnameVerification})}function pr(e){return Array.isArray(e)?[...e].filter(e=>"string"==typeof e).sort():[]}function hr(e){return!0===e.reflection?JSON.stringify({kind:"reflection",address:e.address,version:e.reflectionVersion??null,host:e.reflectionHost??null,tls:fr(e.tls)}):JSON.stringify({kind:"proto",address:e.address,protoPaths:pr(e.protoPaths),includeDirs:pr(e.includeDirs),ignoreDirs:pr(e.ignoreDirs),followSymlinks:!0===e.followSymlinks,tls:fr(e.tls)})}function mr(e){return"string"==typeof e&&e.length>0}function gr(e){if(!e||"object"!=typeof e)return!1;const t=e;return!!mr(t.address)&&(!0===t.reflection||Array.isArray(t.protoPaths)&&t.protoPaths.length>0&&t.protoPaths.every(mr))}var yr=class{protocol="grpc";catalogTtlMs;maxCachedCatalogs;catalogs=new Map;building=new Map;constructor(e={}){const t=e.catalogTtlMs??3e4;if(!Number.isFinite(t)||t<0)throw new RangeError(`catalogTtlMs must be a finite number >= 0; received ${t}.`);const r=e.maxCachedCatalogs??32;if(!Number.isInteger(r)||r<1)throw new RangeError(`maxCachedCatalogs must be an integer >= 1; received ${r}.`);this.catalogTtlMs=t,this.maxCachedCatalogs=r}supports(e){if(!gr(e))return!1;const t=e;return mr(t.service)&&mr(t.method)}assertSupported(e){if(!this.supports(e))throw new Error("not a usable gRPC target: address, service and method are required, plus either protoPaths (a non-empty array of files or directories) or reflection: true.");return e}assertEndpoint(e){if(!gr(e))throw new Error("not a usable gRPC endpoint: address is required, plus either protoPaths (a non-empty array of files or directories) or reflection: true.");return e}async catalogFor(e){const t=hr(e);if(this.catalogTtlMs>0){const e=this.catalogs.get(t);if(e&&Date.now()-e.at<=this.catalogTtlMs)return this.catalogs.delete(t),this.catalogs.set(t,e),e;e&&this.catalogs.delete(t)}const r=this.building.get(t);if(r)return r;const n=wt(e).then(({catalog:e,packageDefinition:r})=>{const n={catalog:e,packageDefinition:r,at:Date.now()};return this.catalogTtlMs>0&&(this.catalogs.set(t,n),this.evict()),n}).finally(()=>{this.building.delete(t)});return this.building.set(t,n),n}evict(){for(;this.catalogs.size>this.maxCachedCatalogs;){const e=this.catalogs.keys().next();if(e.done)return;this.catalogs.delete(e.value)}}invalidate(e){if(!e)return this.catalogs.clear(),void this.building.clear();const t=hr(e);this.catalogs.delete(t),this.building.delete(t)}async sourceNotes(e){const t=this.assertEndpoint(e),{catalog:r}=await this.catalogFor(t);return[...r.notes]}async plan(e){const t=this.assertSupported(e),{catalog:r,packageDefinition:n}=await this.catalogFor(t),o=await Tt(t,{catalog:r,packageDefinition:n}),s=(new Set(r.notes),[...o.notes,'the exported collection is not a valid Postman v2.1.0 document: gRPC has no standard representation there, so method is written as "GRPC" and the invocation details live under protocolProfileBehavior. Import support depends on the client.',"only address, service, method and metadata survive the export. Message payloads, stream pacing, deadlines and truncation limits do not.","gRPC results cannot be written back into an OpenAPI document; writeBack is ignored for protocol=grpc.",...vr(t)]);return{streaming:o.requestStream||o.responseStream,warnings:s,environment:{baseUrl:t.address},collection:wr(t,o)}}async run(e,t){const r=this.assertSupported(e),{catalog:n,packageDefinition:o}=await this.catalogFor(r);return At(r,t??{},{catalog:n,packageDefinition:o,includeSourceNotes:!1})}async discover(e){const t=this.assertEndpoint(e),{catalog:r,packageDefinition:n}=await this.catalogFor(t);return dr(t,r,n)}async describeMethod(e,t,r,n={}){const o=this.assertEndpoint(e);if(!mr(t)||!mr(r))throw new TypeError("describeMethod needs a non-empty service and method name.");const{catalog:s,packageDefinition:i}=await this.catalogFor(o);return lr(s,i,t,r,{includeResponse:!0,...n})}};function vr(e){const t=e.tls;if(void 0===t||!1===t||!0===t)return[];const r=[];return(t.privateKey||t.certChain)&&r.push("the client certificate"),t.rootCerts&&r.push("the custom CA bundle"),t.skipHostnameVerification&&r.push("skipHostnameVerification, which the importing client will not honour"),0===r.length?[]:[`the export records only that TLS is enabled; ${r.join(" and ")} will be absent, so the imported request will not connect as configured.`]}function wr(e,t){const r=`${e.service}/${t.name}`;return{info:{name:r,schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},item:[{name:r,request:{method:"GRPC",url:{raw:`grpc://${e.address}${t.path}`},description:`kind=${t.kind} source=${t.source}`,header:Object.entries(e.metadata??{}).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).map(t=>({key:e,value:Buffer.isBuffer(t)?t.toString("base64"):String(t)})))},protocolProfileBehavior:{grpc:{service:e.service,methodName:t.name,methodType:t.kind,url:e.address,tls:void 0!==e.tls&&!1!==e.tls}}}]}}
@@ -0,0 +1,61 @@
1
+ export { B as BuildTemplateOptions, C as Catalog, E as CollectProtoOptions, F as CollectionHint, H as CredentialsBuildResult, I as DecodedEnum, J as DecodedField, K as DecodedFile, M as DecodedMessage, N as DecodedMethod, O as DecodedService, P as DescribeOptions, a as DescriptorDecodeError, Q as DescriptorSetResult, d as DiscoveredMethod, e as DiscoveredService, D as DiscoveryResult, S as EnumHint, T as FullDescriptorSetResult, G as GrpcAdapter, U as GrpcAdapterOptions, V as GrpcCapabilities, b as GrpcDependencyBrokenError, c as GrpcDependencyMissingError, W as GrpcPlan, X as IncludeDirsResult, L as LOADER_OPTIONS, Y as ListServicesResult, Z as LoadedGrpc, _ as MessageTemplate, $ as MethodDetail, a0 as OneofHint, a1 as PresenceHint, a2 as ProtoScanResult, a3 as ReflectionOp, a4 as ReflectionOutcome, R as ReflectionProtocolError, a5 as ReflectionSessionOptions, f as ReflectionUnavailableError, a6 as ReflectionVersion, a7 as ResolveMethodOptions, a8 as ResolvedMethod, a9 as SymbolEntry, aa as SymbolKind, g as buildCatalog, h as buildCredentials, i as buildCredentialsAsync, j as buildCredentialsChecked, k as buildCredentialsCheckedAsync, l as buildMessageTemplate, m as decodeFileDescriptorProto, n as decodeFileDescriptorSet, o as deriveIncludeDirsDetailed, ab as describeFromCatalog, ac as describeMethod, p as discover, ad as discoverFromCatalog, q as fetchDescriptorSet, r as fetchFullDescriptorSet, s as grpcCall, t as isGrpcAvailable, u as listServices, v as listServicesDetailed, w as loadGrpc, x as requireCapability, y as resolveMethod, z as scanProtoFiles, A as serializeDescriptorSet } from '../../credentials-Cl0G4KpE.cjs';
2
+ export { r as GrpcCredentialsOptions, s as GrpcDescriptorSource, d as GrpcEndpoint, u as GrpcEvent, v as GrpcEventDirection, y as GrpcMessageEvent, z as GrpcMetadataEvent, B as GrpcMetadataInput, F as GrpcMetadataOutput, H as GrpcMethodKind, I as GrpcProtoFileSource, K as GrpcReflectionSource, L as GrpcResult, N as GrpcSendOptions, Q as GrpcStatus, R as GrpcStatusEvent, T as GrpcStatusOrigin, G as GrpcTarget, U as GrpcTlsOptions, V as GrpcTruncatedReason } from '../../types-C9ifzKqk.cjs';
3
+ import '@grpc/grpc-js';
4
+ import '@grpc/proto-loader';
5
+
6
+ /**
7
+ * Descriptor field access.
8
+ *
9
+ * proto-loader and the reflection path both surface descriptors as
10
+ * protobufjs `toObject()` output, where key casing (camelCase vs snake_case)
11
+ * and enum representation (numeric vs string) are not guaranteed across
12
+ * versions. Every read goes through these helpers.
13
+ *
14
+ * Design rule: these helpers NEVER substitute a default for a shape they did
15
+ * not understand. A missing container throws `DescriptorShapeError`; a missing
16
+ * scalar throws too. Defaulting is what previously let an entire descriptor
17
+ * source degrade to "every service has zero methods" without a single warning.
18
+ *
19
+ * The only tolerated absence is a genuinely optional descriptor field
20
+ * (`type_name`, `json_name`, `oneof_index`), which is modelled as `undefined`.
21
+ */
22
+ /** Raised when a descriptor object does not have the shape we require. */
23
+ declare class DescriptorShapeError extends Error {
24
+ readonly expected: string;
25
+ readonly observedKeys: string[];
26
+ constructor(expected: string, observed: unknown, hint?: string);
27
+ }
28
+ declare const TYPE_NAMES: Record<number, string>;
29
+ declare const LABEL_NAMES: Record<number, string>;
30
+ /** Best-effort enum name for diagnostics only. Never feeds behaviour. */
31
+ declare function enumName(value: unknown, table: Record<number, string>): string | undefined;
32
+ interface FieldDescriptor {
33
+ name: string;
34
+ number: number;
35
+ /** TYPE_* */
36
+ type: string;
37
+ /** LABEL_* */
38
+ label: string;
39
+ /** Fully-qualified with a leading dot, e.g. ".demo.common.Meta" */
40
+ typeName?: string;
41
+ jsonName?: string;
42
+ oneofIndex?: number;
43
+ /** True only for `optional` in proto3 (explicit presence). */
44
+ proto3Optional: boolean;
45
+ }
46
+ declare function readFields(messageType: unknown): FieldDescriptor[];
47
+ declare function readOneofNames(messageType: unknown): string[];
48
+ declare function readNestedTypes(messageType: unknown): unknown[];
49
+ declare function isMapEntry(messageType: unknown): boolean;
50
+ declare function readEnumValueNames(enumType: unknown): string[];
51
+ interface MethodDescriptor {
52
+ name: string;
53
+ /** Fully-qualified with a leading dot. */
54
+ inputType: string;
55
+ outputType: string;
56
+ clientStreaming: boolean;
57
+ serverStreaming: boolean;
58
+ }
59
+ declare function readMethods(serviceType: unknown): MethodDescriptor[];
60
+
61
+ export { DescriptorShapeError, type FieldDescriptor, LABEL_NAMES, type MethodDescriptor, TYPE_NAMES, enumName, isMapEntry, readEnumValueNames, readFields, readMethods, readNestedTypes, readOneofNames };
@@ -0,0 +1,61 @@
1
+ export { B as BuildTemplateOptions, C as Catalog, E as CollectProtoOptions, F as CollectionHint, H as CredentialsBuildResult, I as DecodedEnum, J as DecodedField, K as DecodedFile, M as DecodedMessage, N as DecodedMethod, O as DecodedService, P as DescribeOptions, a as DescriptorDecodeError, Q as DescriptorSetResult, d as DiscoveredMethod, e as DiscoveredService, D as DiscoveryResult, S as EnumHint, T as FullDescriptorSetResult, G as GrpcAdapter, U as GrpcAdapterOptions, V as GrpcCapabilities, b as GrpcDependencyBrokenError, c as GrpcDependencyMissingError, W as GrpcPlan, X as IncludeDirsResult, L as LOADER_OPTIONS, Y as ListServicesResult, Z as LoadedGrpc, _ as MessageTemplate, $ as MethodDetail, a0 as OneofHint, a1 as PresenceHint, a2 as ProtoScanResult, a3 as ReflectionOp, a4 as ReflectionOutcome, R as ReflectionProtocolError, a5 as ReflectionSessionOptions, f as ReflectionUnavailableError, a6 as ReflectionVersion, a7 as ResolveMethodOptions, a8 as ResolvedMethod, a9 as SymbolEntry, aa as SymbolKind, g as buildCatalog, h as buildCredentials, i as buildCredentialsAsync, j as buildCredentialsChecked, k as buildCredentialsCheckedAsync, l as buildMessageTemplate, m as decodeFileDescriptorProto, n as decodeFileDescriptorSet, o as deriveIncludeDirsDetailed, ab as describeFromCatalog, ac as describeMethod, p as discover, ad as discoverFromCatalog, q as fetchDescriptorSet, r as fetchFullDescriptorSet, s as grpcCall, t as isGrpcAvailable, u as listServices, v as listServicesDetailed, w as loadGrpc, x as requireCapability, y as resolveMethod, z as scanProtoFiles, A as serializeDescriptorSet } from '../../credentials-rqEKODvf.js';
2
+ export { r as GrpcCredentialsOptions, s as GrpcDescriptorSource, d as GrpcEndpoint, u as GrpcEvent, v as GrpcEventDirection, y as GrpcMessageEvent, z as GrpcMetadataEvent, B as GrpcMetadataInput, F as GrpcMetadataOutput, H as GrpcMethodKind, I as GrpcProtoFileSource, K as GrpcReflectionSource, L as GrpcResult, N as GrpcSendOptions, Q as GrpcStatus, R as GrpcStatusEvent, T as GrpcStatusOrigin, G as GrpcTarget, U as GrpcTlsOptions, V as GrpcTruncatedReason } from '../../types-C9ifzKqk.js';
3
+ import '@grpc/grpc-js';
4
+ import '@grpc/proto-loader';
5
+
6
+ /**
7
+ * Descriptor field access.
8
+ *
9
+ * proto-loader and the reflection path both surface descriptors as
10
+ * protobufjs `toObject()` output, where key casing (camelCase vs snake_case)
11
+ * and enum representation (numeric vs string) are not guaranteed across
12
+ * versions. Every read goes through these helpers.
13
+ *
14
+ * Design rule: these helpers NEVER substitute a default for a shape they did
15
+ * not understand. A missing container throws `DescriptorShapeError`; a missing
16
+ * scalar throws too. Defaulting is what previously let an entire descriptor
17
+ * source degrade to "every service has zero methods" without a single warning.
18
+ *
19
+ * The only tolerated absence is a genuinely optional descriptor field
20
+ * (`type_name`, `json_name`, `oneof_index`), which is modelled as `undefined`.
21
+ */
22
+ /** Raised when a descriptor object does not have the shape we require. */
23
+ declare class DescriptorShapeError extends Error {
24
+ readonly expected: string;
25
+ readonly observedKeys: string[];
26
+ constructor(expected: string, observed: unknown, hint?: string);
27
+ }
28
+ declare const TYPE_NAMES: Record<number, string>;
29
+ declare const LABEL_NAMES: Record<number, string>;
30
+ /** Best-effort enum name for diagnostics only. Never feeds behaviour. */
31
+ declare function enumName(value: unknown, table: Record<number, string>): string | undefined;
32
+ interface FieldDescriptor {
33
+ name: string;
34
+ number: number;
35
+ /** TYPE_* */
36
+ type: string;
37
+ /** LABEL_* */
38
+ label: string;
39
+ /** Fully-qualified with a leading dot, e.g. ".demo.common.Meta" */
40
+ typeName?: string;
41
+ jsonName?: string;
42
+ oneofIndex?: number;
43
+ /** True only for `optional` in proto3 (explicit presence). */
44
+ proto3Optional: boolean;
45
+ }
46
+ declare function readFields(messageType: unknown): FieldDescriptor[];
47
+ declare function readOneofNames(messageType: unknown): string[];
48
+ declare function readNestedTypes(messageType: unknown): unknown[];
49
+ declare function isMapEntry(messageType: unknown): boolean;
50
+ declare function readEnumValueNames(enumType: unknown): string[];
51
+ interface MethodDescriptor {
52
+ name: string;
53
+ /** Fully-qualified with a leading dot. */
54
+ inputType: string;
55
+ outputType: string;
56
+ clientStreaming: boolean;
57
+ serverStreaming: boolean;
58
+ }
59
+ declare function readMethods(serviceType: unknown): MethodDescriptor[];
60
+
61
+ export { DescriptorShapeError, type FieldDescriptor, LABEL_NAMES, type MethodDescriptor, TYPE_NAMES, enumName, isMapEntry, readEnumValueNames, readFields, readMethods, readNestedTypes, readOneofNames };
@@ -0,0 +1 @@
1
+ import{createRequire as e}from"module";import{readFileSync as t}from"fs";import{dirname as r,join as n}from"path";var o,s,i="@grpc/grpc-js",a="@grpc/proto-loader",c=class extends Error{missing;constructor(e,t){super(`gRPC support requires optional peer dependencies that are not installed: ${e.join(", ")}.\n npm i ${e.join(" ")}`,{cause:t}),this.name="GrpcDependencyMissingError",this.missing=e}},l=class extends Error{packageName;constructor(e,t,r){super(`gRPC dependency "${e}" is installed but unusable: ${t}`,{cause:r}),this.name="GrpcDependencyBrokenError",this.packageName=e}};async function u(e,t){let r;try{r=await(import(e))}catch(t){if(function(e,t){const r=e,n="string"==typeof r?.code?r.code:"";if("ERR_MODULE_NOT_FOUND"!==n&&"MODULE_NOT_FOUND"!==n)return!1;const o="string"==typeof r?.message?r.message:"";return o.includes(`'${t}'`)||o.includes(`"${t}"`)||o.includes(t)}(t,e))throw new c([e],t);throw new l(e,t instanceof Error?`it threw while loading — ${t.message}`:String(t),t)}return function(e,t,r){const n=[e,e?.default];for(const e of n)if(e&&"object"==typeof e&&t in e)return e;throw new l(r,`its module namespace has no "${t}" export, so the installed version is not the package this library expects.`)}(r,t,e)}function d(e,t,r){for(const[n,o]of Object.entries(r)){const r=e[n],s=null===r?"null":typeof r;if(s!==o)throw new l(t,`expected "${n}" to be a ${o}, found ${s}. The installed package is not the one this library supports.`)}}function f(o){try{const s=e(import.meta.url);let i=r(s.resolve(o));for(let e=0;e<8;e++){try{const e=t(n(i,"package.json"),"utf8"),r=JSON.parse(e);if(r.name===o&&"string"==typeof r.version)return r.version}catch{}const e=r(i);if(e===i)break;i=e}}catch{}}async function p(){return s||(o||(o=async function(){const e=await Promise.allSettled([u(i,"Client"),u(a,"load")]),t=[];for(const r of e)"rejected"===r.status&&r.reason instanceof c&&t.push(...r.reason.missing);if(t.length>0){const r=e.find(e=>"rejected"===e.status&&e.reason instanceof c);throw new c(t,"rejected"===r?.status?r.reason:void 0)}for(const t of e)if("rejected"===t.status)throw t.reason;const r=e[0].value,n=e[1].value;return d(r,i,{Client:"function",Metadata:"function",credentials:"object"}),d(n,a,{load:"function"}),{grpc:r,protoLoader:n,capabilities:{descriptorSetFromBuffer:"function"==typeof n.loadFileDescriptorSetFromBuffer,grpcVersion:f(i),protoLoaderVersion:f(a)}}}().then(e=>(s=e,e),e=>{throw o=void 0,e})),o)}async function h(){try{return await p(),!0}catch{return!1}}function m(e,t){switch(t){case"descriptorSetFromBuffer":{if(e.capabilities.descriptorSetFromBuffer)return;const t=e.capabilities.protoLoaderVersion?` (found ${e.capabilities.protoLoaderVersion})`:"";throw new l(a,`server reflection requires @grpc/proto-loader >= 0.7.0${t}; loadFileDescriptorSetFromBuffer is missing.`)}case"grpcVersion":case"protoLoaderVersion":throw new TypeError(`"${t}" is diagnostic information, not a capability; it cannot be required.`);default:throw new TypeError(`unknown gRPC capability: ${String(t)}`)}}function g(e,t){if(null==e)return null;if(Buffer.isBuffer(e))return e;if(e instanceof Uint8Array)return Buffer.from(e);if("string"==typeof e)throw new TypeError(`tls.${t} must be PEM bytes, not a string. A file path is not accepted — read it first, e.g. await readFile(path). Passing a path would fail later during the handshake with an unrelated error.`);throw new TypeError(`tls.${t} must be a Buffer or Uint8Array of PEM bytes; received ${typeof e}.`)}function y(e,{grpc:t}){const r=[],n=e.tls;if(void 0===n||!1===n)return{credentials:t.credentials.createInsecure(),mode:"insecure",warnings:r};if(!0===n)return{credentials:t.credentials.createSsl(),mode:"tls-system-roots",warnings:r};const o=g(n.rootCerts,"rootCerts"),s=g(n.privateKey,"privateKey"),i=g(n.certChain,"certChain");if(null===s!=(null===i))throw new Error(`mutual TLS requires both tls.privateKey and tls.certChain; only ${s?"privateKey":"certChain"} was provided.`);const a=null!==s?"mtls":null!==o?"tls-custom-roots":"tls-system-roots";return n.skipHostnameVerification?(r.push("skipHostnameVerification is on: the server certificate chain is still verified, but its hostname is not checked against the address. This permits connecting to an impostor holding any trusted certificate. Use it for local debugging only."),{credentials:t.credentials.createSsl(o,s,i,{checkServerIdentity:()=>{}}),mode:a,warnings:r}):{credentials:t.credentials.createSsl(o,s,i),mode:a,warnings:r}}function w(e,t){return y(e,t).credentials}async function v(e){return w(e,await p())}async function b(e){return y(e,await p())}import{readdir as $,realpath as E,stat as S}from"fs/promises";import{dirname as T,join as k,resolve as D,sep as P}from"path";var x=["node_modules",".git","dist","build","out",".venv"];function _(e){return e.toLowerCase().endsWith(".proto")}function O(e,t){const r=t?.code;switch(r){case"ENOENT":return`proto path does not exist: ${e}`;case"EACCES":case"EPERM":return`proto path is not readable (permission denied): ${e}`;case"ENOTDIR":return`a component of the proto path is not a directory: ${e}`;case"ELOOP":return`proto path contains a symlink loop: ${e}`;case"ENAMETOOLONG":return`proto path is too long: ${e}`;default:return`proto path could not be read: ${e}`+(r?` (${r})`:"")+(t instanceof Error?` — ${t.message}`:"")}}async function j(e){try{const t=await S(e);return t.isDirectory()?"dir":t.isFile()?"file":"other"}catch{return"error"}}async function M(e){!function(e){if(!e||"object"!=typeof e)throw new TypeError("scanProtoFiles requires an options object.");if(!Array.isArray(e.paths))throw new TypeError(`protoPaths must be an array of strings; received ${typeof e.paths}. A single path must still be wrapped in an array, or it is iterated one character at a time.`);if(e.paths.forEach((e,t)=>{if("string"!=typeof e||0===e.length)throw new TypeError(`protoPaths[${t}] must be a non-empty string; received ${void 0===e?"undefined":typeof e}.`)}),0===e.paths.length)throw new Error("protoPaths is empty; nothing to load.");if(void 0!==e.ignoreDirs){if(!Array.isArray(e.ignoreDirs))throw new TypeError(`ignoreDirs must be an array of directory names; received ${typeof e.ignoreDirs}.`);e.ignoreDirs.forEach((e,t)=>{if("string"!=typeof e)throw new TypeError(`ignoreDirs[${t}] must be a string; received ${typeof e}.`);if(e.includes("/")||e.includes("\\"))throw new TypeError(`ignoreDirs[${t}] ("${e}") looks like a path, but ignoreDirs matches single directory names only; a path never matches and would be silently ignored.`)})}if(void 0!==e.maxFiles&&(!Number.isInteger(e.maxFiles)||e.maxFiles<1))throw new TypeError(`maxFiles must be a positive integer; received ${String(e.maxFiles)}. A cap of 0 would collect nothing and report it as an empty proto tree.`);if(void 0!==e.followSymlinks&&"boolean"!=typeof e.followSymlinks)throw new TypeError(`followSymlinks must be a boolean; received ${typeof e.followSymlinks}.`)}(e);const t=new Set(e.ignoreDirs??x),r=e.maxFiles??5e3,n=new Set,o=[],s=[],i=[],a=new Set,c=new Map;let l=!1,u=0;const d=e=>{i.length>=40?u++:i.push(e)},f=async(t,o)=>{if(!n.has(t))if(n.size>=r)l||(l=!0,d(`stopped after ${r} .proto files; pass maxFiles or a narrower protoPaths if the tree really is this large. The file set is truncated, so symbols may be missing.`));else{if(o||e.followSymlinks){let e;try{e=await E(t)}catch(e){return void d(O(t,e))}const r=c.get(e);if(void 0!==r)return void(r!==t&&d(`skipped ${t}: it is the same file as ${r} (both resolve to ${e}). Loading it twice would be reported as a duplicate symbol definition.`));c.set(e,t)}n.add(t)}},p=async(r,n)=>{let o,s;try{o=await E(r)}catch(e){return void d(O(r,e))}if(a.has(o))n&&d(`skipped ${r}: it resolves to ${o}, which was already scanned.`);else{a.add(o);try{s=await $(r,{withFileTypes:!0})}catch(e){return void d(O(r,e))}for(const o of s){if(l)return;const s=k(r,o.name);if(o.isSymbolicLink()){if(!e.followSymlinks){d(`skipped symlink ${s} (followSymlinks is off). If your proto tree links to shared definitions, enable followSymlinks or add the target to protoPaths.`);continue}let r;try{r=await S(s)}catch(e){d(O(s,e));continue}r.isDirectory()?t.has(o.name)||await p(s,!0):r.isFile()&&_(o.name)&&await f(D(s),!0);continue}if(o.isDirectory()){t.has(o.name)||await p(s,n);continue}if(o.isFile()){_(o.name)&&await f(D(s),n);continue}if(o.isFIFO()||o.isSocket()||o.isBlockDevice()||o.isCharacterDevice())continue;const i=await j(s);"dir"===i?t.has(o.name)||await p(s,n):"file"===i?_(o.name)&&await f(D(s),n):"error"===i&&_(o.name)&&d(`could not determine the type of ${s}; it was skipped even though its name suggests a proto file.`)}}};for(const t of e.paths){const e=D(t);let r;try{r=await S(e)}catch(e){throw new Error(O(t,e),{cause:e})}if(r.isFile()){if(!_(e))throw new Error(`not a .proto file: ${t}. protoPaths accepts .proto files and directories containing them.`);await f(e,!1),s.includes(e)||s.push(e)}else{if(!r.isDirectory())throw new Error(`proto path is neither a file nor a directory: ${t}`);o.includes(e)||o.push(e),await p(e,!1)}}if(u>0&&i.push(`${u} further scan note(s) were suppressed; the ones above are representative.`),0===n.size){const r=i.length?` Some entries were skipped: ${i[0]}`:` Checked for *.proto, skipping ${[...t].join(", ")}.`;throw new Error(`no .proto files found under: ${e.paths.join(", ")}.${r}`)}return{files:[...n].sort(),rootDirs:o,fileRoots:s,notes:i}}function N(e,t){const r=t.endsWith(P)?t:t+P;return e===t||e.startsWith(r)}function F(e){const t=[],r=new Set;for(const t of e.rootDirs)r.add(t);for(const t of e.fileRoots)r.add(T(t));const n=[...r],o=[];for(const t of e.files){const e=T(t);n.some(t=>N(e,t))||(r.has(e)||(r.add(e),o.push(e)))}return o.length>0&&t.push(`${o.length} directory(ies) outside the given protoPaths were added as include roots so their imports resolve: ${o.slice(0,3).join(", ")}${o.length>3?", …":""}. Imports are therefore resolved more loosely than protoc would; pass includeDirs explicitly for exact behaviour.`),{includeDirs:[...r].sort(),notes:t}}function I(e){return e instanceof Error?e.message:String(e)}var A=[1,128,16384,2097152,268435456,34359738368,4398046511104,562949953421312,72057594037927940,0x8000000000000000],C=class{constructor(e,t=0){this.buf=e,this.pos=t}buf;pos;get eof(){return this.pos>=this.buf.length}varint(){let e,t=0,r=0;do{if(this.pos>=this.buf.length)throw new Error(`truncated varint at offset ${this.pos}`);if(r>=A.length)throw new Error("varint longer than 10 bytes");e=this.buf[this.pos++],t+=(127&e)*A[r++]}while(128&e);if(!Number.isSafeInteger(t))throw new Error("varint exceeds Number.MAX_SAFE_INTEGER");return t}bytes(){return Buffer.from(this.view())}view(){const e=this.varint(),t=this.pos+e;if(t>this.buf.length)throw new Error(`length-delimited field runs past end of buffer (need ${e} bytes at ${this.pos}, have ${this.buf.length-this.pos})`);const r=this.buf.subarray(this.pos,t);return this.pos=t,r}string(){return this.view().toString("utf8")}skip(e){switch(e){case 0:return void this.varint();case 1:return void this.advance(8);case 2:return void this.view();case 5:return void this.advance(4);default:throw new Error(`unsupported wire type ${e} at offset ${this.pos}`)}}advance(e){const t=this.pos+e;if(t>this.buf.length)throw new Error("fixed-width field runs past end of buffer");this.pos=t}};function q(e,t){const r=new C(e);for(;!r.eof;){const e=r.varint(),n=Math.floor(e/8),o=7&e;if(0===n)throw new Error("field number 0 is not valid");const s=r.pos;if(t(n,o,r)){if(r.pos===s)throw new Error(`decoder claimed field ${n} (wire ${o}) without consuming it`)}else r.skip(o)}}function B(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`cannot encode ${e} as an unsigned varint`);const t=[];let r=e;for(;r>127;)t.push(r%128|128),r=Math.floor(r/128);return t.push(r),Buffer.from(t)}function R(e,t){return B(8*e+t)}function L(e,t){return Buffer.concat([R(e,2),B(t.length),t])}function U(e,t){return L(e,Buffer.from(t,"utf8"))}function Y(e){return"list"===e?"the service list":e.slice(e.indexOf(":")+1)}function z(e){let t,r={kind:"other",field:0};return q(e,(e,n,o)=>{if(2!==n)return!1;switch(e){case 2:return t=function(e){let t;return q(e,(e,r,n)=>2===r&&(3===e?(t=`file:${n.string()}`,!0):4===e?(t=`sym:${n.string()}`,!0):7===e&&(n.view(),t="list",!0))),t}(o.view()),!0;case 4:{const e=[];return q(o.view(),(t,r,n)=>1===t&&2===r&&(e.push(n.bytes()),!0)),r={kind:"files",descriptors:e},!0}case 6:{const e=[];return q(o.view(),(t,r,n)=>1===t&&2===r&&(q(n.view(),(t,r,n)=>1===t&&2===r&&(e.push(n.string()),!0)),!0)),r={kind:"services",services:e},!0}case 7:{let e=2,t="";return q(o.view(),(r,n,o)=>1===r&&0===n?(e=o.varint(),!0):2===r&&2===n&&(t=o.string(),!0)),r={kind:"error",code:e,message:t},!0}case 5:return o.view(),r={kind:"other",field:5},!0;default:return!1}}),{answers:t,body:r}}function V(e){let t="";const r=[];return q(e,(e,n,o)=>2===n&&(1===e?(t=o.string(),!0):3===e&&(r.push(o.string()),!0))),{name:t,dependencies:r}}var W=class extends Error{address;versionsTried;constructor(e,t,r){super(`server at ${e} answered but does not implement the gRPC reflection service (${t.join(" and ")} both reported UNIMPLEMENTED/NOT_FOUND). Register the reflection service on the server, or pass protoPaths instead.`,{cause:r}),this.name="ReflectionUnavailableError",this.address=e,this.versionsTried=t}},G=class extends Error{address;code;constructor(e,t,r){super(`could not complete the reflection handshake with ${e}`+(void 0!==t?` (gRPC status ${t})`:"")+`: ${r}. This is a connectivity or transport failure, not a missing reflection service — nothing was reached that could answer.`),this.name="ReflectionTransportError",this.address=e,this.code=t}},K=class extends Error{detail;constructor(e,t){super(t?`${e} (${t})`:e),this.name="ReflectionProtocolError",this.detail=t}},X={v1:"/grpc.reflection.v1.ServerReflection/ServerReflectionInfo",v1alpha:"/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo"};function H(e){return"object"==typeof e&&null!==e&&!0===e.versionMissing}function J(e){const t=e?.code;return"number"==typeof t?t:void 0}function Q(e,t,r){if(void 0!==t&&("number"!=typeof t||!Number.isFinite(t)||t<r))throw new RangeError(`${e} must be a finite number >= ${r}; received ${"number"==typeof t?t:typeof t}.`)}function Z(e){if("string"!=typeof e.address||""===e.address)throw new TypeError("reflection requires a non-empty address.");if(Q("timeoutMs",e.timeoutMs,1),Q("maxFiles",e.maxFiles,1),Q("maxBytes",e.maxBytes,1),void 0!==e.version&&"v1"!==e.version&&"v1alpha"!==e.version)throw new TypeError(`reflectionVersion must be "v1" or "v1alpha"; received ${String(e.version)}.`)}async function ee(e,t){const r=e.version?[e.version]:["v1","v1alpha"];let n;for(const[o,s]of r.entries())try{const n=await te(e,t,s);return o>0&&n.notes.unshift(`reflection ${r[0]} was unimplemented; used ${s}.`),n}catch(e){if(!H(e))throw e;n=e.cause}throw new W(e.address,r,n)}function te(e,t,r){const n=e.timeoutMs??5e3,o=e.maxFiles??2e3,s=e.maxBytes??33554432,i=e.host??"";return p().then(({grpc:a})=>{const c=function(e,t){const r=new e.Metadata;for(const[e,n]of Object.entries(t??{})){const t=Array.isArray(n)?n:[n];for(const n of t){if("string"!=typeof n&&!Buffer.isBuffer(n))throw new TypeError(`reflection metadata["${e}"] must be a string, a Buffer, or an array of those; received ${null===n?"null":typeof n}.`);try{r.add(e,n)}catch(t){throw new TypeError(`reflection metadata key "${e}" was rejected by grpc-js: ${I(t)}. Keys must match [0-9a-z_.-]+, and only keys ending in "-bin" may carry Buffers.`)}}}return r}(a,e.metadata);let l,u;try{l=new a.Client(e.address,e.credentials,e.channelOptions)}catch(t){throw new G(e.address,void 0,`the channel could not be created: ${I(t)}. Expected host:port`)}try{u=l.makeBidiStreamRequest(X[r],e=>e,e=>e,c,{deadline:new Date(Date.now()+n)})}catch(t){try{l.close()}catch{}throw new G(e.address,J(t),I(t))}return new Promise((a,c)=>{const d=new Map,f=[],p=new Map,h=new Set;let m,g="symbols"!==t.kind,y=0,w=!1,v=!1,b=!1;const $=()=>{if(0===p.size)return;const e=[...p.keys()].slice(0,5).join(", ");return`still awaiting ${p.size} reply(ies): ${e}${p.size>5?", …":""}`},E=setTimeout(()=>{T(new K(`reflection session at ${e.address} did not complete within ${n}ms`,$()))},n+250);E.unref?.();const S=()=>{clearTimeout(E);try{u.cancel()}catch{}try{l.close()}catch{}};function T(e){w||(w=!0,S(),c(e))}function k(t){T(b?new K(`the reflection stream at ${e.address} failed after the server had already answered, so ${r} is served here; ${d.size} file(s) were discarded`,I(t)):{versionMissing:!0,cause:t})}function D(){if(!w){w=!0,clearTimeout(E);try{u.end()}catch{}try{l.close()}catch{}a({services:"symbols"===t.kind?void 0:m??[],descriptors:d,version:r,notes:f})}}const P=(t,r)=>{if(!w&&!h.has(t))if(h.size>=o)T(new K(`reflection closure exceeded maxFiles=${o}`,`while requesting ${Y(t)}`));else{h.add(t),p.set(t,{key:t,primary:r});try{u.write(function(e,t){const r=[];return t&&r.push(U(1,t)),"list"===e?r.push(U(7,"*")):e.startsWith("file:")?r.push(U(3,e.slice(5))):r.push(U(4,e.slice(4))),Buffer.concat(r)}(t,i))}catch(r){T(new G(e.address,J(r),`writing the request for ${Y(t)} failed: ${I(r)}`))}}};if(u.on("data",e=>{if(w)return;let r;try{r=z(e)}catch(e){return b=!0,void T(new K("malformed ServerReflectionResponse",I(e)))}b=!0;const n=(e=>{if(void 0!==e&&p.has(e)){const t=p.get(e);return p.delete(e),t}v||(v=!0,f.push(void 0===e?"server omitted original_request; replies were paired by arrival order.":`server echoed an unrequested original_request (${e}); replies were paired by arrival order.`));const t=p.keys().next();if(t.done)return;const r=p.get(t.value);return p.delete(t.value),r})(r.answers);switch(r.body.kind){case"error":{const{code:e,message:t}=r.body,o=`code ${e}: ${t||"(no message)"}`;if(!n||n.primary)return void T(new K(`reflection request for ${n?Y(n.key):"(unknown)"} failed`,o));f.push(`server could not supply ${Y(n.key)} — ${o}. The descriptor set may be incomplete.`);break}case"files":if(0===r.body.descriptors.length&&n?.primary&&f.push(`server returned an empty file set for ${Y(n.key)}.`),(e=>{for(const t of e){if(w)return;if(y+=t.length,y>s)return void T(new K(`reflection payload exceeded maxBytes=${s}`,`after ${d.size} file(s)`));let e;try{e=V(t)}catch(e){return void T(new K("server returned a FileDescriptorProto that could not be parsed",I(e)))}if(e.name){if(!d.has(e.name)){d.set(e.name,t);for(const t of e.dependencies)if(d.has(t)||P(`file:${t}`,!1),w)return}}else f.push("server returned a FileDescriptorProto with no name; it was skipped.")}})(r.body.descriptors),w)return;break;case"services":if(m=r.body.services,g=!1,"list_then_symbols"===t.kind){const e=m.filter(e=>!e.startsWith("grpc.reflection."));for(const t of e)if(P(`sym:${t}`,!0),w)return}break;case"other":f.push(`ignored an unexpected reflection response variant (field ${r.body.field}) for ${n?Y(n.key):"(unknown request)"}.`)}0!==p.size||g||D()}),u.on("error",t=>{if(w)return;const r=J(t);12!==r&&5!==r?T(new G(e.address,r,I(t))):k(t)}),u.on("status",t=>{if(w)return;const r=t;if(0!==r.code){const t=`${r.code} ${r.details??""}`.trim();return 12===r.code||5===r.code?void k(Object.assign(new Error(`reflection stream ended: ${t}`),{code:r.code,details:r.details})):void T(new G(e.address,r.code,r.details||"the stream ended with a non-OK status"))}p.size>0||g?T(new K("server closed the reflection stream before answering everything",$()??"the service list was requested but never returned")):D()}),u.on("end",()=>{w||0!==p.size||g||D()}),"symbols"===t.kind){for(const e of t.symbols)if(P(`sym:${e}`,!0),w)return}else P("list",!0)})})}function re(e){const t=new Map;for(const[r,n]of e){let o;try{o=V(n)}catch{t.set(r,[]);continue}t.set(r,o.dependencies.filter(t=>e.has(t)))}const r=[],n=[],o=new Map,s=e=>{const i=o.get(e);if("done"!==i)if("visiting"!==i){o.set(e,"visiting");for(const r of t.get(e)??[])s(r);o.set(e,"done"),r.push(e)}else n.includes(e)||n.push(e)};for(const t of[...e.keys()].sort())s(t);return{ordered:r,cycles:n}}function ne(e){const{ordered:t}=re(e);return Buffer.concat(t.map(t=>L(1,e.get(t))))}async function oe(e){Z(e);const t=await ee(e,{kind:"list"});return{services:(t.services??[]).filter(e=>!e.startsWith("grpc.reflection.")).sort(),version:t.version,notes:t.notes}}async function se(e){return(await oe(e)).services}function ie(e,t){if(0===e.descriptors.size)throw new K(`reflection returned no file descriptors for ${t}`,e.notes.join(" ")||void 0);const{ordered:r,cycles:n}=re(e.descriptors),o=[...e.notes];return n.length>0&&o.push(`${n.length} file(s) take part in an import cycle, which protoc cannot produce: ${n.slice(0,5).join(", ")}`+(n.length>5?", …":"")+". They were emitted once each; the descriptor set may not load."),{descriptorSet:Buffer.concat(r.map(t=>L(1,e.descriptors.get(t)))),files:r,version:e.version,notes:o}}async function ae(e){if(Z(e),!Array.isArray(e.symbols)||0===e.symbols.length)throw new TypeError("fetchDescriptorSet requires a non-empty array of symbol names.");const t=e.symbols.findIndex(e=>"string"!=typeof e||""===e);if(-1!==t)throw new TypeError(`symbols[${t}] is not a non-empty string (got ${typeof e.symbols[t]}).`);return ie(await ee(e,{kind:"symbols",symbols:e.symbols}),e.symbols.join(", "))}async function ce(e){Z(e);const t=await ee(e,{kind:"list_then_symbols"}),r=(t.services??[]).filter(e=>!e.startsWith("grpc.reflection.")).sort();return 0===r.length?{services:r,descriptorSet:Buffer.alloc(0),files:[],version:t.version,notes:[...t.notes,`reflection is available at ${e.address} but the server advertises no services other than reflection itself.`]}:{services:r,...ie(t,r.join(", "))}}var le=class extends Error{constructor(e){super(`descriptor decode failed: ${e}`),this.name="DescriptorDecodeError"}};function ue(e){let t=0n,r=0n;for(;;){if(e.pos>=e.end)throw new le("truncated varint");const n=e.buf[e.pos++];if(t|=BigInt(127&n)<<r,!(128&n))return t;if(r+=7n,r>70n)throw new le("varint too long")}}function de(e,t,r){switch(t){case 0:return void ue(e);case 1:return void fe(e,8);case 5:return void fe(e,4);case 2:return void fe(e,Number(ue(e)));case 3:if(r>32)throw new le("group nesting too deep");for(;;){if(e.pos>=e.end)throw new le("unterminated group");const t=7&Number(ue(e));if(4===t)return;de(e,t,r+1)}default:throw new le(`unsupported wire type ${t}`)}}function fe(e,t){if(t<0||e.pos+t>e.end)throw new le("length exceeds buffer");e.pos+=t}function pe(e){const t={buf:e,pos:0,end:e.length},r=new Map;for(;t.pos<t.end;){const n=Number(ue(t)),o=n>>>3,s=7&n;if(0===o)throw new le("field number 0 is invalid");let i;if(0===s)i={wireType:s,varint:ue(t)};else if(2===s){const r=Number(ue(t));if(r<0||t.pos+r>t.end)throw new le("length-delimited field overruns");i={wireType:s,bytes:e.subarray(t.pos,t.pos+r)},t.pos+=r}else{const r=t.pos;de(t,s,0),i={wireType:s,bytes:e.subarray(r,t.pos)}}const a=r.get(o);a?a.push(i):r.set(o,[i])}return r}var he=new TextDecoder("utf-8",{fatal:!0});function me(e,t){const r=e.get(t)?.at(-1);if(r?.bytes)try{return he.decode(r.bytes)}catch{throw new le(`field ${t} is not valid UTF-8`)}}function ge(e,t){const r=e.get(t)?.at(-1);if(void 0===r?.varint)return;const n=r.varint;return Number(n>0x7fffffffn?BigInt.asIntN(32,n):n)}function ye(e,t){const r=e.get(t)?.at(-1);return void 0!==r?.varint&&0n!==r.varint}function we(e,t){const r=e.get(t);return r?r.map(e=>{if(!e.bytes)throw new le(`field ${t} was expected to be length-delimited`);return e.bytes}):[]}function ve(e,t){if(void 0===e||""===e)throw new le(`${t} is missing or empty`);return e}function be(e){const t=pe(e),r=ge(t,4),n=ge(t,5);if(void 0===r)throw new le("FieldDescriptorProto.label is missing");if(void 0===n)throw new le("FieldDescriptorProto.type is missing");return{name:ve(me(t,1),"FieldDescriptorProto.name"),number:ge(t,3)??0,label:r,type:n,type_name:me(t,6),json_name:me(t,10),oneof_index:ge(t,9),proto3_optional:ye(t,17)}}function $e(e){const t=pe(e);return{name:ve(me(t,1),"EnumDescriptorProto.name"),value:we(t,2).map(e=>{const t=pe(e);return{name:ve(me(t,1),"EnumValueDescriptorProto.name"),number:ge(t,2)??0}})}}function Ee(e,t=0){if(t>64)throw new le("message nesting too deep");const r=pe(e),n=we(r,7).at(-1);const o=n?pe(n):void 0;return{name:ve(me(r,1),"DescriptorProto.name"),field:we(r,2).map(be),nested_type:we(r,3).map(e=>Ee(e,t+1)),enum_type:we(r,4).map($e),oneof_decl:we(r,8).map(e=>({name:ve(me(pe(e),1),"OneofDescriptorProto.name")})),options:{map_entry:!!o&&ye(o,7)}}}function Se(e){const t=pe(e);return{name:ve(me(t,1),"ServiceDescriptorProto.name"),method:we(t,2).map(e=>{const t=pe(e);return{name:ve(me(t,1),"MethodDescriptorProto.name"),input_type:ve(me(t,2),"MethodDescriptorProto.input_type"),output_type:ve(me(t,3),"MethodDescriptorProto.output_type"),client_streaming:ye(t,5),server_streaming:ye(t,6)}})}}function Te(e){const t=pe(e);return{name:me(t,1),package:me(t,2),syntax:me(t,12),dependency:we(t,3).map(e=>function(e,t){try{return he.decode(e)}catch{throw new le(`${t} is not valid UTF-8`)}}(e,"FileDescriptorProto.dependency")),message_type:we(t,4).map(e=>Ee(e)),enum_type:we(t,5).map($e),service:we(t,6).map(Se)}}function ke(e){const t=pe(e),r=we(t,1),n=[...t.keys()].filter(e=>1!==e);if(n.length>0)throw new le(`expected a FileDescriptorSet but the message also carries field(s) ${n.sort((e,t)=>e-t).join(", ")}. These bytes are most likely a bare FileDescriptorProto; decode it with decodeFileDescriptorProto instead.`);return 0===r.length?[]:r.map(Te)}var De=class extends Error{expected;observedKeys;constructor(e,t,r){const n=t&&"object"==typeof t?Object.keys(t).sort():[],o=n.length?n.slice(0,24).join(", "):"(none)";super(`descriptor shape mismatch: expected ${e}, got ${Pe(t)} with keys [${o}]`+(n.length>24?` ...+${n.length-24} more`:"")+(r?`. ${r}`:"")),this.name="DescriptorShapeError",this.expected=e,this.observedKeys=n}};function Pe(e){if(null===e)return"null";if(Array.isArray(e))return`array(${e.length})`;const t=typeof e;return"object"===t?e.constructor?.name??"object":t}function xe(e,t,r){if(!e||"object"!=typeof e)return;const n=e;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:t!==r&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:void 0}function _e(e,t,r){if(!e||"object"!=typeof e)return!1;const n=e;return Object.prototype.hasOwnProperty.call(n,t)||t!==r&&Object.prototype.hasOwnProperty.call(n,r)}function Oe(e,t,r,n){if(!_e(e,t,r))return[];const o=xe(e,t,r);if(void 0===o)return[];if(null===o||!Array.isArray(o))throw new De(`${n}.${r} to be a repeated field`,e,`field "${r}" is ${Pe(o)}.`);return o}function je(e,t,r,n){const o=xe(e,t,r);if("string"!=typeof o||0===o.length)throw new De(`${n}.${r} to be a non-empty string`,e,`got ${Pe(o)}.`);return o}function Me(e,t,r,n){const o=xe(e,t,r),s="string"==typeof o&&""!==o.trim()?Number(o):o;if("number"!=typeof s||!Number.isFinite(s))throw new De(`${n}.${r} to be a number`,e,`got ${Pe(o)}.`);return s}function Ne(e,t,r){const n=xe(e,t,r);return!0===n||1===n||"true"===n}var Fe={1:"TYPE_DOUBLE",2:"TYPE_FLOAT",3:"TYPE_INT64",4:"TYPE_UINT64",5:"TYPE_INT32",6:"TYPE_FIXED64",7:"TYPE_FIXED32",8:"TYPE_BOOL",9:"TYPE_STRING",10:"TYPE_GROUP",11:"TYPE_MESSAGE",12:"TYPE_BYTES",13:"TYPE_UINT32",14:"TYPE_ENUM",15:"TYPE_SFIXED32",16:"TYPE_SFIXED64",17:"TYPE_SINT32",18:"TYPE_SINT64"},Ie={1:"LABEL_OPTIONAL",2:"LABEL_REQUIRED",3:"LABEL_REPEATED"},Ae=new Set(Object.values(Fe)),Ce=new Set(Object.values(Ie));function qe(e,t,r,n,o){if("string"==typeof e){if(r.has(e))return e;throw new De(`${n}.${o} to be a known enum name`,e,`"${e}" is not one of [${[...r].join(", ")}].`)}if("number"==typeof e){const r=t[e];if(r)return r;throw new De(`${n}.${o} to be a known enum number`,e,`${e} has no mapping; the descriptor may use a newer protobuf revision.`)}throw new De(`${n}.${o} to be present`,e,`got ${Pe(e)}.`)}function Be(e,t){return"string"==typeof e?e:"number"==typeof e?t[e]:void 0}function Re(e){return!(!e||"object"!=typeof e)&&Object.values(e).some(e=>{const t=e;return!!t&&"object"==typeof t&&"string"==typeof t.path&&"function"==typeof t.requestSerialize})}function Le(e){Ue(e);return Oe(e,"field","field","DescriptorProto").map((e,t)=>{const r=`FieldDescriptorProto[${t}]`,n=xe(e,"typeName","type_name"),o=xe(e,"jsonName","json_name"),s=xe(e,"oneofIndex","oneof_index"),i=qe(xe(e,"type","type"),Fe,Ae,r,"type");if(("TYPE_MESSAGE"===i||"TYPE_ENUM"===i||"TYPE_GROUP"===i)&&"string"!=typeof n)throw new De(`${r}.type_name to be present for ${i}`,e,`a ${i} field cannot be resolved without its type name.`);return{name:je(e,"name","name",r),number:Me(e,"number","number",r),type:i,label:qe(xe(e,"label","label"),Ie,Ce,r,"label"),typeName:"string"==typeof n&&n?n:void 0,jsonName:"string"==typeof o&&o?o:void 0,oneofIndex:"number"==typeof s&&Number.isFinite(s)?s:void 0,proto3Optional:Ne(e,"proto3Optional","proto3_optional")}})}function Ue(e){var t;if(!(t=e)||"object"!=typeof t||!_e(t,"name","name")||_e(t,"method","method")||_e(t,"value","value")||Re(t))throw new De("a DescriptorProto (message descriptor)",e,Re(e)?"this looks like a proto-loader runtime object, not a descriptor proto. Descriptor protos come from loadFileDescriptorSetFromBuffer or from reflection.":"the descriptor source did not produce descriptor protos.")}function Ye(e){Ue(e);return Oe(e,"oneofDecl","oneof_decl","DescriptorProto").map((e,t)=>je(e,"name","name",`OneofDescriptorProto[${t}]`))}function ze(e){return Ue(e),Oe(e,"nestedType","nested_type","DescriptorProto")}function Ve(e){if(!e||"object"!=typeof e)return!1;return Ne(xe(e,"options","options"),"mapEntry","map_entry")}function We(e){if(!((t=e)&&"object"==typeof t&&_e(t,"name","name")&&_e(t,"value","value")))throw new De("an EnumDescriptorProto",e,"the descriptor source did not produce enum descriptors.");var t;return Oe(e,"value","value","EnumDescriptorProto").map((e,t)=>je(e,"name","name",`EnumValueDescriptorProto[${t}]`))}function Ge(e){if(!((t=e)&&"object"==typeof t&&_e(t,"name","name")&&_e(t,"method","method")))throw new De("a ServiceDescriptorProto",e,Re(e)?"this is a proto-loader runtime service object (entries carry `path` and `requestSerialize`), which contains no method descriptors. Load a FileDescriptorSet or use reflection to obtain them.":"the descriptor source did not produce service descriptors.");var t;return Oe(e,"method","method","ServiceDescriptorProto").map((e,t)=>{const r=`MethodDescriptorProto[${t}]`;return{name:je(e,"name","name",r),inputType:je(e,"inputType","input_type",r),outputType:je(e,"outputType","output_type",r),clientStreaming:Ne(e,"clientStreaming","client_streaming"),serverStreaming:Ne(e,"serverStreaming","server_streaming")}})}var Ke={keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0};function Xe(e,t){return e?`${e}.${t}`:t}function He(e,t,r){if(""===r)return;const n=t=>e.symbols.has(t)||e.mapEntries.has(t);if(r.startsWith(".")){const e=r.slice(1);return n(e)?e:void 0}let o=t;for(;;){const e=o?`${o}.${r}`:r;if(n(e))return e;if(""===o)return;const t=o.lastIndexOf(".");o=-1===t?"":o.slice(0,t)}}function Je(e,t,r){const n=xe(e,t,r);return Array.isArray(n)?n:[]}function Qe(e,t,r,n,o){e.notes.push(`duplicate definition of ${t} "${r}" (${n} and ${o}); the first one was kept.`)}function Ze(e,t,r,n){const o=String(xe(n,"name","name")??"");if(!o)return void e.notes.push(`${t}: a message with no name was skipped.`);const s=Xe(r,o);if(Ve(n))e.mapEntries.add(s);else{const r=e.symbols.get(s);r?Qe(e,"message",s,r.file,t):e.symbols.set(s,{kind:"message",type:n,file:t})}for(const r of Je(n,"nestedType","nested_type"))Ze(e,t,s,r);for(const r of Je(n,"enumType","enum_type"))et(e,t,s,r)}function et(e,t,r,n){const o=String(xe(n,"name","name")??"");if(!o)return void e.notes.push(`${t}: an enum with no name was skipped.`);const s=Xe(r,o),i=e.symbols.get(s);i?Qe(e,"enum",s,i.file,t):e.symbols.set(s,{kind:"enum",type:n,file:t})}function tt(e,t){const r=xe(t,"name","name"),n="string"==typeof r&&""!==r?r:`(unnamed #${++e.unnamedSeq})`,o=String(xe(t,"package","package")??"");for(const r of Je(t,"messageType","message_type"))Ze(e,n,o,r);for(const r of Je(t,"enumType","enum_type"))et(e,n,o,r);for(const r of Je(t,"service","service")){const t=String(xe(r,"name","name")??"");if(!t){e.notes.push(`${n}: a service with no name was skipped.`);continue}const s=Xe(o,t),i=e.symbols.get(s);i?"service"===i.kind?Qe(e,"service",s,i.file,n):e.notes.push(`"${s}" is declared both as a service (${n}) and as a ${i.kind} (${i.file}); the ${i.kind} was kept and the service is not callable through this catalog.`):(e.symbols.set(s,{kind:"service",type:r,file:n}),e.serviceDescriptors.set(s,r))}}function rt(e){return null!==e&&"object"==typeof e&&"string"==typeof e.path}function nt(e,t,r,n){if(0===t.length)return void n.push(r?"the descriptors attached by @grpc/proto-loader carry no file names, so symbols cannot be attributed to the .proto they were declared in. This affects diagnostics only.":"no descriptor file names were recovered, so symbols cannot be attributed to their .proto files. This affects diagnostics only.");const o=e.filter(e=>!(e=>{const r=e.split("\\").join("/");return t.some(e=>r===e||r.endsWith(`/${e}`))})(e));0!==o.length&&(o.length!==e.length?n.push(`${o.length} of ${e.length} scanned .proto file(s) are not represented in the decoded descriptors, so nothing they declare is in the symbol table: ${o.join(", ")}.`):n.push(`descriptor file names do not correspond to the .proto paths that were scanned (descriptors report ${t.slice(0,3).join(", ")}${t.length>3?", …":""}), so symbols cannot be attributed to the file that declared them. This is how protobufjs-generated descriptors name files and affects diagnostics only — the symbol table itself is unaffected.`))}async function ot(e){!function(e){if(!0===e.reflection)return;const t=e.protoPaths;if(null==t)throw new Error("a gRPC endpoint needs a descriptor source: either set reflection: true, or pass protoPaths: string[] pointing at your .proto files or directories. Neither was provided.");if(!Array.isArray(t))throw new TypeError(`protoPaths must be an array of paths; received ${"string"==typeof t?`the string "${t}" — wrap it: ["${t}"]`:typeof t}.`);if(0===t.length)throw new Error("protoPaths is empty. Pass at least one .proto file or directory, or set reflection: true to obtain descriptors from the server.");const r=t.findIndex(e=>"string"!=typeof e||""===e);if(-1!==r)throw new TypeError(`protoPaths[${r}] is not a non-empty string (got ${typeof t[r]}).`);const n=e.includeDirs;if(null!=n&&!Array.isArray(n))throw new TypeError(`includeDirs must be an array of directories; received ${"string"==typeof n?`the string "${n}" — wrap it: ["${n}"]`:typeof n}.`)}(e);const t=await p(),{protoLoader:r}=t,n=[];let o,s,i,a;if(!0===e.reflection){m(t,"descriptorSetFromBuffer");const{credentials:c,mode:l,warnings:u}=y(e,t);n.push(...u);const d=await ce({address:e.address,credentials:c,metadata:e.metadata,timeoutMs:e.reflectionTimeoutMs??5e3,channelOptions:e.channelOptions,version:e.reflectionVersion,host:e.reflectionHost,maxFiles:e.maxReflectionFiles,maxBytes:e.maxReflectionBytes});if(n.push(...d.notes),0===d.services.length)throw new Error(`reflection is available at ${e.address} (${d.version}) but no services are registered on it. Either the server registered only the reflection service itself, or the services you expect were never added to it.`);o=r.loadFileDescriptorSetFromBuffer(d.descriptorSet,Ke);try{s=ke(d.descriptorSet)}catch(t){if(!(t instanceof le))throw t;throw new Error(`reflection at ${e.address} returned ${d.descriptorSet.length} byte(s) that could not be decoded as a FileDescriptorSet: ${t.message}. The server may be answering the reflection method with a non-standard payload.`)}if(0===s.length)throw new Error(`reflection at ${e.address} reported ${d.services.length} service(s) but its descriptor set decoded to zero files, so nothing can be described.`);i="reflection",a=d.files,n.push(`reflection (${d.version}, ${l}) returned ${d.services.length} service(s) across ${d.files.length} file(s).`)}else{const t=e.protoPaths,c=await M({paths:t,ignoreDirs:e.ignoreDirs,followSymlinks:e.followSymlinks,maxFiles:e.maxProtoFiles});let l;if(n.push(...c.notes),a=c.files,Array.isArray(e.includeDirs)&&e.includeDirs.length>0)l=e.includeDirs;else{const e=F(c);l=e.includeDirs,n.push(...e.notes)}o=await r.load(c.files,{...Ke,includeDirs:l});const u=function(e){const t=new Set,r=[];let n=!1,o=0;const s=e=>{const s=e?.fileDescriptorProtos;if(!Array.isArray(s))return!1;n=!0,o++;for(const e of s){if(!(Buffer.isBuffer(e)||e instanceof Uint8Array))continue;const n=Buffer.isBuffer(e)?e:Buffer.from(e),o=n.toString("base64");t.has(o)||(t.add(o),r.push(n))}return!0};for(const t of Object.values(e))if(t&&"object"==typeof t&&!s(t))for(const e of Object.values(t))e&&"object"==typeof e&&s(e);return{buffers:r,found:n,carriers:o}}(o);if(!u.found)throw new Error(`@grpc/proto-loader did not attach fileDescriptorProtos to any of the ${Object.keys(o).length} entries it produced, so no method or field metadata can be read. Upgrade to @grpc/proto-loader >= 0.6.0.`);if(0===u.buffers.length)throw new Error(`@grpc/proto-loader attached fileDescriptorProtos to ${u.carriers} entry/entries, but none of them contained descriptor bytes. The loader output cannot be interpreted; this is a version incompatibility rather than a problem with your protos.`);s=function(e,t){const r=[],n=[];for(const t of e)try{r.push(Te(t))}catch(e){n.push(e instanceof Error?e.message:String(e))}if(n.length>0&&0===r.length)throw new Error(`none of the ${e.length} FileDescriptorProto(s) attached by @grpc/proto-loader could be decoded, so no method or field metadata is available. First failure: ${n[0]}`);return n.length>0&&t.push(`${n.length} of ${e.length} FileDescriptorProto(s) could not be decoded and their symbols are unavailable. First failure: ${n[0]}`),r}(u.buffers,n),i="proto",c.files.length>1&&n.push(`merged ${c.files.length} .proto file(s) from ${t.length} path(s).`)}const c={symbols:new Map,serviceDescriptors:new Map,mapEntries:new Set,notes:n,unnamedSeq:0};for(const e of s)tt(c,e);const{symbols:l,serviceDescriptors:u,mapEntries:d}=c,f=s.map(e=>{const t=xe(e,"name","name");return"string"==typeof t&&""!==t?t:void 0}),h=f.length>0&&f.every(e=>void 0===e),g=[...new Set(f.filter(e=>void 0!==e))].sort();"proto"===i&&a&&nt(a,g,h,n),function(e){const t={symbols:e.symbols,mapEntries:e.mapEntries},r=new Map,n=(e,t)=>{const n=r.get(e)??[];n.includes(t)||n.push(t),r.set(e,n)},o=(e,r,s)=>{for(const o of Je(s,"field","field")){const s=xe(o,"typeName","type_name");"string"==typeof s&&""!==s&&void 0===He(t,e,s)&&n(s,r)}for(const t of Je(s,"nestedType","nested_type")){const n=String(xe(t,"name","name")??"");n&&o(`${e}.${n}`,r,t)}};for(const[t,r]of e.symbols)"message"===r.kind&&o(t,t,r.type);for(const[r,o]of e.serviceDescriptors)for(const e of Je(o,"method","method"))for(const[o,s]of[["inputType","input_type"],["outputType","output_type"]]){const i=xe(e,o,s);"string"==typeof i&&""!==i&&void 0===He(t,r,i)&&n(i,r)}if(0===r.size)return;const s=[...r.keys()].sort().slice(0,12),i=[...new Set([...r.values()].flat())].sort();e.notes.push(`${r.size} type reference(s) do not resolve against the symbol table: ${s.join(", ")}`+(r.size>s.length?" ...+"+(r.size-s.length):"")+`. Request templates for the messages using them will be incomplete. Referenced from: ${i.slice(0,6).join(", ")}`+(i.length>6?" ...+"+(i.length-6):"")+".")}(c);const w=[...u.keys()].sort(),v=function(e,t){const r=[],n=[];for(const[t,o]of Object.entries(e)){if(!o||"object"!=typeof o)continue;if("fileDescriptorProtos"in o)continue;const e=Object.values(o);0!==e.length?e.every(rt)&&r.push(t):n.push(t)}return n.length>0&&t.push(`${n.length} service(s) declare no methods and cannot be called: ${n.sort().join(", ")}.`),r.sort()}(o,n);return function(e,t,r){const n=new Set(e),o=new Set(t),s=e.filter(e=>!o.has(e)),i=t.filter(e=>!n.has(e));s.length>0&&r.push(`${s.length} service(s) are described but not invocable (no codecs were generated): ${s.join(", ")}.`),i.length>0&&r.push(`${i.length} service(s) are invocable but have no descriptor, so no request template can be generated: ${i.join(", ")}.`)}(w,v,n),0===w.length&&0===v.length&&n.push("proto"===i?`the ${a?.length??0} .proto file(s) loaded declare no services.`:"reflection returned descriptors that declare no services."),{catalog:{source:i,symbols:l,services:w,invocableServices:v,serviceDescriptors:u,notes:n,files:a,descriptorFiles:g,mapEntries:d,descriptorFilesUnnamed:h},packageDefinition:o}}function st(e,t){return e&&t?"bidi_streaming":e?"client_streaming":t?"server_streaming":"unary"}function it(e,t,r,n,o){const s=(i=r).startsWith(".")?i.slice(1):i;var i;let a;try{a=function(e){if("string"==typeof e)return e||void 0;const t=e?.name;return"string"==typeof t&&t?t:void 0}(He(e,t,r))}catch(e){return o.push(`resolving the ${n} type "${r}" failed: ${e instanceof Error?e.message:String(e)}. The name is reported as written.`),s}return a||(o.push(r.startsWith(".")?`the ${n} type "${s}" is not in the symbol table; the descriptor closure is incomplete. The name is reported as written.`:`the ${n} type "${r}" is a relative reference that could not be resolved in scope "${t||"(root)"}"; it is reported as written and is therefore not fully qualified.`),s)}function at(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.path&&t.path.length>0&&"boolean"==typeof t.requestStream&&"boolean"==typeof t.responseStream&&"function"==typeof t.requestSerialize&&"function"==typeof t.responseDeserialize}function ct(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}async function lt(e,t){if(function(e){const t=["address","service","method"];for(const r of t){const t=e[r];if("string"!=typeof t||0===t.length)throw new TypeError(`GrpcTarget.${r} must be a non-empty string; received ${void 0===t?"undefined":typeof t}.`)}}(e),t&&(!t.catalog||!t.packageDefinition))throw new TypeError("ResolveMethodOptions requires both catalog and packageDefinition, from the same buildCatalog call.");const{catalog:r,packageDefinition:n}=t??await ot(e),o=[...r.notes],s=Object.prototype.hasOwnProperty.call(n,e.service)?n[e.service]:void 0;if(!s||"object"!=typeof s){const t=new Set([...r.invocableServices,...r.services]),n=r.services.includes(e.service)?" It exists in the descriptor but no codecs were generated for it, so it cannot be called.":` Available: ${[...t].sort().join(", ")||"(none)"}`;throw new Error(`service "${e.service}" is not invocable (source: ${r.source}).${n}`)}const i=function(e){const t=new Map,r=new Set;for(const n of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(!at(o))continue;const s=ct(o.path);r.has(s)||(t.set(s,o),n===s&&r.add(s))}return t}(s),a=[...i.keys()],c=function(e,t){if(e.includes(t))return{name:t,exact:!0};const r=t.toLowerCase(),n=e.filter(e=>e.toLowerCase()===r);return 1===n.length?{name:n[0],exact:!1}:void 0}(a,e.method);if(!c){const t=a.filter(t=>t.toLowerCase()===e.method.toLowerCase()).length>1;throw new Error(t?`method "${e.method}" is ambiguous on ${e.service}; several methods differ only in case. Use the exact name.`:`method "${e.method}" not found on ${e.service}. Available: ${[...a].sort().join(", ")||"(none)"}`)}c.exact||o.push(`method matched case-insensitively: requested "${e.method}", using "${c.name}".`);const l=i.get(c.name),u=l.requestStream,d=l.responseStream,f=function(e,t,r){const n=e.serviceDescriptors.get(t);if(void 0!==n)try{return Ge(n)}catch(e){if(!(e instanceof De))throw e;return void r.push(`the descriptor for ${t} is unreadable, so message type names are unavailable and no request template can be generated; the call itself is unaffected: ${e.message}`)}else r.push(`no descriptor for ${t} in the ${e.source} catalog; the call can still be made but request templates and message type names are unavailable.`)}(r,e.service,o);let p;if(f&&(p=f.find(e=>e.name===c.name),p||o.push(`method "${c.name}" is invocable but absent from the ${e.service} descriptor; message type names are unavailable.`)),p&&(p.clientStreaming!==u||p.serverStreaming!==d))throw new Error(`descriptor and runtime disagree on the streaming kind of ${e.service}/${c.name}: descriptor says ${st(p.clientStreaming,p.serverStreaming)}, runtime says ${st(u,d)}. Refusing to dial, because either choice would misuse the stream. The descriptor source is likely stale or mixed — reload the proto tree, or clear cached reflection data.`);const h=`/${e.service}/${c.name}`;l.path!==h&&o.push(`the method path reported by the loader (${l.path}) differs from the expected ${h}; the loader's path is used.`);const m=function(e){const t=e.lastIndexOf(".");return t>0?e.slice(0,t):""}(e.service),g=p?it(r,m,p.inputType,"request",o):void 0,y=p?it(r,m,p.outputType,"response",o):void 0;return{name:c.name,kind:st(u,d),path:l.path,requestStream:u,responseStream:d,serialize:e=>l.requestSerialize(e),deserialize:e=>l.responseDeserialize(e),inputType:g,outputType:y,source:r.source,notes:o}}var ut={0:"OK",1:"CANCELLED",2:"UNKNOWN",3:"INVALID_ARGUMENT",4:"DEADLINE_EXCEEDED",5:"NOT_FOUND",6:"ALREADY_EXISTS",7:"PERMISSION_DENIED",8:"RESOURCE_EXHAUSTED",9:"FAILED_PRECONDITION",10:"ABORTED",11:"OUT_OF_RANGE",12:"UNIMPLEMENTED",13:"INTERNAL",14:"UNAVAILABLE",15:"DATA_LOSS",16:"UNAUTHENTICATED"};function dt(e,t){return{code:e,codeName:ut[e]??`CODE_${e}`,details:t}}function ft(e){const t=e;if("function"!=typeof t?.toJSON)return{};const r={};for(const[e,n]of Object.entries(t.toJSON())){const t=Array.isArray(n)?n:[n];r[e]=t.map(e=>Buffer.isBuffer(e)?e.toString("base64"):String(e))}return r}var pt=new Set(["max_messages","idle_timeout","max_session","aborted"]);function ht(e,t){if(void 0!==t&&("number"!=typeof t||!Number.isFinite(t)||t<0))throw new RangeError(`${e} must be a finite number of milliseconds >= 0; received ${"number"==typeof t?t:typeof t}.`)}async function mt(e,t={},r){const n=Date.now(),o=function(e){if(void 0===e)return[];if(!Array.isArray(e))throw new TypeError(`options.messages must be an array of request payloads; received ${null===e?"null":typeof e}. A single message still goes in an array.`);return e}(t.messages);if(function(e,t){if(void 0!==t&&(!Number.isInteger(t)||t<0))throw new RangeError(`${e} must be a non-negative integer; received ${"number"==typeof t?t:typeof t}. A fractional limit can never be reached by a message count.`)}("maxMessages",t.maxMessages),ht("idleTimeoutMs",t.idleTimeoutMs),ht("maxSessionMs",t.maxSessionMs),ht("sendIntervalMs",t.sendIntervalMs),ht("deadlineMs",e.deadlineMs),void 0!==t.signal&&null!==t.signal){const e=t.signal;if("function"!=typeof e.addEventListener||"boolean"!=typeof e.aborted)throw new TypeError("options.signal must be an AbortSignal (pass controller.signal, not the controller).")}if(void 0!==t.onEvent&&"function"!=typeof t.onEvent)throw new TypeError(`options.onEvent must be a function; received ${typeof t.onEvent}.`);const s=await p(),{grpc:i}=s,a=r??await(async()=>{const t=await ot(e);return{catalog:t.catalog,packageDefinition:t.packageDefinition,includeSourceNotes:!1}})(),c=await lt(e,{catalog:a.catalog,packageDefinition:a.packageDefinition}),l=new Set(a.catalog.notes),u=a.includeSourceNotes?[...c.notes]:c.notes.filter(e=>!l.has(e)),d=[],f=[];let h,m,g,w,v,b,$=0,E=!1;if(!c.requestStream&&o.length>1&&u.push(`${c.kind} accepts a single request message; ${o.length-1} extra message(s) were ignored.`),c.requestStream||0!==o.length||u.push(`${c.kind} requires a request message and none was given; an empty message was sent, which on the wire means "all defaults".`),t.keepWriteOpen&&"bidi_streaming"!==c.kind&&u.push(`keepWriteOpen only applies to bidi_streaming; ignored for ${c.kind}.`),void 0===t.sendIntervalMs||c.requestStream||u.push(`sendIntervalMs paces the outbound stream and has no effect on ${c.kind}, which sends exactly one message.`),t.keepWriteOpen&&"bidi_streaming"===c.kind){const r=void 0!==t.maxSessionMs||void 0!==t.idleTimeoutMs||void 0!==t.maxMessages||Boolean(t.signal);r||void 0!==e.deadlineMs?r||u.push(`keepWriteOpen is bounded only by deadlineMs (${e.deadlineMs}ms); since the write side is never half-closed, the call will end in DEADLINE_EXCEEDED unless the server closes the stream first. Set maxMessages, idleTimeoutMs, or maxSessionMs for a clean stop.`):u.push("keepWriteOpen is set with no limit and no deadline; the call can only end when the server closes the stream.")}const S=y(e,s);u.push(...S.warnings);const T=function(e,t){const r=new e.Metadata;for(const[e,n]of Object.entries(t??{})){const t=Array.isArray(n)?n:[n];for(const n of t){if("string"!=typeof n&&!Buffer.isBuffer(n))throw new TypeError(`metadata["${e}"] must be a string, a Buffer, or an array of those; received ${null===n?"null":typeof n}. Binary values require a key ending in "-bin".`);try{r.add(e,n)}catch(t){throw new TypeError(`metadata key "${e}" was rejected by grpc-js: ${t instanceof Error?t.message:String(t)}. Keys must match [0-9a-z_.-]+, and only keys ending in "-bin" may carry Buffers.`)}}}return r}(i,e.metadata);let k;try{k=new i.Client(e.address,S.credentials,e.channelOptions)}catch(t){throw new Error(`could not create a channel to "${e.address}": ${t instanceof Error?t.message:String(t)}. Expected host:port.`)}const D={};return void 0!==e.deadlineMs&&(D.deadline=new Date(Date.now()+e.deadlineMs)),await new Promise(e=>{let r,n,s,i,a,l,p=!1,y=!1,S=!1,P=!1;const x=e=>{if(p)return;const r={...e,seq:$++,at:Date.now()};if(d.push(r),t.onEvent)try{t.onEvent(r)}catch{}},_=(e,t)=>{y||(y=!0,g=e,w=t)},O=e=>{S||E||(S=!0,m=e)},j=o=>{if(!p){o&&(E=!0,h=o,pt.has(o)&&_(dt(1,`call stopped by the client (${o}); the server never reported a status`),"synthesized")),P&&!y&&(_(dt(0),"synthesized"),u.push("the response was received but the server's status did not arrive within 200ms; OK was inferred from the successful response and no trailing metadata is available.")),P=!1,p=!0,clearTimeout(r),clearTimeout(n),clearTimeout(s),clearTimeout(i),l&&t.signal&&t.signal.removeEventListener("abort",l);try{a?.cancel()}catch{}try{k.close()}catch{}e()}},M=()=>{p||void 0!==t.idleTimeoutMs&&(clearTimeout(r),r=setTimeout(()=>j("idle_timeout"),t.idleTimeoutMs))},N=e=>{p||(f.push(e),x({direction:"inbound",payload:e}),M(),void 0!==t.maxMessages&&f.length>=t.maxMessages&&j("max_messages"))},F=()=>{p||y?j():(P=!0,clearTimeout(r),i=setTimeout(()=>j(),200))},I=e=>{const t=e,r=dt(t.code??2,t.details??t.message),n=void 0===t.code?"client":"server";_(r,n),O(t.message??String(e)),x({direction:"status",status:r,statusOrigin:n}),j()},A=(e,t,r)=>{const n=dt(e,t);_(n,"client"),O(r instanceof Error?r.message:String(r)),x({direction:"status",status:n,statusOrigin:"client"}),j()};if(0===t.maxMessages)return u.push("maxMessages is 0, so the call is stopped before any response is read."),void j("max_messages");if(void 0!==t.maxSessionMs&&(n=setTimeout(()=>j("max_session"),t.maxSessionMs)),t.signal){if(t.signal.aborted)return void j("aborted");l=()=>j("aborted"),t.signal.addEventListener("abort",l,{once:!0})}const C=e=>c.serialize(e),q=e=>c.deserialize(e),B=(e,t)=>{try{return c.serialize(e),!0}catch(e){return A(3,`request message #${t} does not match ${c.inputType??"the request type"}`,e),!1}},R=e=>{e.on("metadata",e=>{v=ft(e),x({direction:"meta",metadata:v})}),e.on("status",e=>{const t=e;b=ft(t.metadata);const r=dt(t.code,t.details);_(r,"server"),x({direction:"status",status:r,statusOrigin:"server",metadata:b}),(c.responseStream||P)&&j()})},L=e=>{let r=0;const n=()=>{if(p)return;if(r>=o.length){if(!(!0===t.keepWriteOpen&&"bidi_streaming"===c.kind))try{e.end?.()}catch{}return}const i=r,a=o[r++];if(B(a,i)){try{e.write?.(a),x({direction:"outbound",payload:a}),M()}catch(e){return void A(2,`write of message #${i} failed`,e)}t.sendIntervalMs?s=setTimeout(n,t.sendIntervalMs):n()}};n()};try{if("unary"===c.kind||"server_streaming"===c.kind){const e=o[0]??{};if(!B(e,0))return;x({direction:"outbound",payload:e}),"unary"===c.kind?(a=k.makeUnaryRequest(c.path,C,q,e,T,D,(e,t)=>{e?I(e):(N(t),F())}),R(a),a.on("error",I)):(a=k.makeServerStreamRequest(c.path,C,q,e,T,D),R(a),a.on("data",e=>N(e)),a.on("error",I),a.on("end",()=>{_(dt(0),"synthesized"),j()}))}else"client_streaming"===c.kind?(a=k.makeClientStreamRequest(c.path,C,q,T,D,(e,t)=>{e?I(e):(N(t),F())}),R(a),a.on("error",I),L(a)):(a=k.makeBidiStreamRequest(c.path,C,q,T,D),R(a),a.on("data",e=>N(e)),a.on("error",I),a.on("end",()=>{_(dt(0),"synthesized"),j()}),L(a))}catch(e){return void A(2,"call setup failed",e)}M()}),{protocol:"grpc",kind:c.kind,target:e,events:d,messages:f,initialMetadata:v,status:g,statusOrigin:w,trailers:b,truncated:E,truncatedReason:h,error:m,warnings:u,durationMs:Date.now()-n}}var gt=Symbol("omit"),yt={TYPE_DOUBLE:0,TYPE_FLOAT:0,TYPE_INT32:0,TYPE_UINT32:0,TYPE_SINT32:0,TYPE_FIXED32:0,TYPE_SFIXED32:0,TYPE_BOOL:!1,TYPE_STRING:"",TYPE_BYTES:"",TYPE_INT64:"0",TYPE_UINT64:"0",TYPE_SINT64:"0",TYPE_FIXED64:"0",TYPE_SFIXED64:"0"},wt={"google.protobuf.Timestamp":"1970-01-01T00:00:00Z","google.protobuf.Duration":"0s","google.protobuf.Empty":{},"google.protobuf.StringValue":"","google.protobuf.BoolValue":!1,"google.protobuf.Int32Value":0,"google.protobuf.Int64Value":"0","google.protobuf.UInt32Value":0,"google.protobuf.UInt64Value":"0","google.protobuf.DoubleValue":0,"google.protobuf.FloatValue":0,"google.protobuf.BytesValue":"","google.protobuf.FieldMask":"","google.protobuf.Struct":{},"google.protobuf.ListValue":[]},vt=new Set(["google.protobuf.Value","google.protobuf.Any"]);function bt(e){return e.startsWith(".")?e.slice(1):e}function $t(e,t){return e?`${e}.${t}`:t}var Et=!0===Ke.keepCase?"declared":"json";function St(e){return"declared"===Et?e.name:e.jsonName??e.name.replace(/_([a-z0-9])/g,(e,t)=>t.toUpperCase())}function Tt(e,t,r={}){const n={catalog:e,maxDepth:r.maxDepth??4,seedCollections:!1!==r.seedCollections,fillExplicitOptional:!0===r.fillExplicitOptional,fillMessageFields:!1!==r.fillMessageFields,keyOf:St,oneofs:[],enums:[],collections:[],presence:[],warnings:[],stack:[],hintDepth:0},o=bt(t),s=xt(n,"",t)??o;let i={};try{i=Mt(n,s,"",0)??{}}catch(e){if(!(e instanceof De))throw e;n.warnings.push(`template generation stopped: ${e.message}. The request must be composed by hand.`)}return{message:s,example:i,keyStyle:Et,oneofs:n.oneofs,enums:n.enums,collections:n.collections,presence:n.presence,warnings:n.warnings}}function kt(e){return 0===e.hintDepth}function Dt(e,t){kt(e)&&e.warnings.push(t)}function Pt(e,t){e.hintDepth++;try{return t()}finally{e.hintDepth--}}function xt(e,t,r){const n=He(e.catalog,t,r);if(void 0!==n)return"message"===e.catalog.symbols.get(n)?.kind?n:void 0}function _t(e,t){const r=e.catalog.symbols.get(t);return"message"===r?.kind?r.type:void 0}function Ot(e,t,r){return r.typeName?He(e.catalog,t,r.typeName)??bt(r.typeName):r.type}function jt(e,t){return 1===t.length&&("LABEL_REPEATED"!==t[0].label&&(void 0===e||e===`_${t[0].name}`))}function Mt(e,t,r,n){if(n>e.maxDepth)return Dt(e,`recursion depth ${e.maxDepth} reached at "${r||"(root)"}" (${t}); the value is an empty message, which on the wire means "set with all defaults" — remove the key to leave it unset.`),{};if(e.stack.includes(t))return Dt(e,`cyclic reference to ${t} at "${r}"; the value is an empty message, which on the wire means "set with all defaults".`),{};const o=_t(e,t);if(!o)return Dt(e,`message "${t}" is not in the symbol table (referenced at "${r||"(root)"}"); left as an empty object. The descriptor closure is incomplete — the catalog notes say which references failed.`),{};e.stack.push(t);try{const s=Le(o),i=Ye(o),a={},c=new Map;for(const e of s){if(void 0===e.oneofIndex)continue;const t=c.get(e.oneofIndex)??[];t.push(e),c.set(e.oneofIndex,t)}const l=new Map,u=new Set;for(const[r,n]of c){if(n.every(e=>e.proto3Optional)||jt(i[r],n))for(const e of n)u.add(e.name);else{const o=n.filter(e=>e.proto3Optional);if(o.length>0){Dt(e,`oneof "${i[r]??r}" in ${t} mixes ${o.length} explicit-presence member(s) with ${n.length-o.length} plain one(s), which protoc does not produce. All of them are treated as optional fields and left unset; set at most one by hand.`);for(const e of n)u.add(e.name)}else l.set(r,n)}}const d=new Set;for(const o of s){const s=e.keyOf(o),c=$t(r,o.name);if(void 0!==o.oneofIndex&&l.has(o.oneofIndex)){if(d.has(o.oneofIndex))continue;d.add(o.oneofIndex);const s=l.get(o.oneofIndex),c=s[0],u=Nt(e,t,c,$t(r,c.name),n),f={};u!==gt&&(f[e.keyOf(c)]=u),Pt(e,()=>{for(const o of s.slice(1)){const s=Nt(e,t,o,$t(r,o.name),n);s!==gt&&(f[e.keyOf(o)]=s)}}),kt(e)&&e.oneofs.push({at:r,oneof:i[o.oneofIndex]??`oneof_${o.oneofIndex}`,branches:s.map(e=>e.name),chosen:c.name,branchValues:f}),u!==gt&&(a[e.keyOf(c)]=u);continue}if(o.proto3Optional||u.has(o.name)){const r=Pt(e,()=>Nt(e,t,o,c,n));kt(e)&&e.presence.push({at:c,reason:"proto3_optional",presentInExample:e.fillExplicitOptional,valueIfSet:r===gt?void 0:r}),e.fillExplicitOptional&&r!==gt&&(a[s]=r);continue}const f=Nt(e,t,o,c,n);f!==gt&&(a[s]=f)}return a}finally{e.stack.pop()}}function Nt(e,t,r,n,o){const s="LABEL_REPEATED"===r.label;if(s&&"TYPE_MESSAGE"===r.type&&r.typeName){const s=function(e,t,r){const n=_t(e,t);if(!n)return;const o=bt(r),s=o.slice(o.lastIndexOf(".")+1);try{for(const e of ze(n)){if(String(xe(e,"name","name")??"")!==s)continue;if(!Ve(e))continue;const t=Le(e),r=t.find(e=>"key"===e.name),n=t.find(e=>"value"===e.name);if(r&&n)return{keyType:r.type,valueField:n}}}catch(e){if(!(e instanceof De))throw e;return}}(e,t,r.typeName);if(s){if(kt(e)&&e.collections.push({at:n,kind:"map",of:Ot(e,t,s.valueField),keyOf:s.keyType}),!e.seedCollections)return{};const r="TYPE_STRING"===s.keyType?"key":"0",i=Ft(e,t,s.valueField,`${n}.${r}`,o);return i===gt?{}:{[r]:i}}Dt(e,`"${n}" is a repeated ${bt(r.typeName)} that could not be read as a map entry; treating it as a repeated message field.`)}if(s){if(kt(e)&&e.collections.push({at:n,kind:"repeated",of:Ot(e,t,r)}),!e.seedCollections)return[];const s=Ft(e,t,r,`${n}[0]`,o);return s===gt?[]:[s]}return Ft(e,t,r,n,o)}function Ft(e,t,r,n,o){if("TYPE_ENUM"===r.type){const o=r.typeName,s=function(e,t,r){const n=He(e.catalog,t,r);if(void 0!==n)return"enum"===e.catalog.symbols.get(n)?.kind?n:void 0}(e,t,o),i=s??bt(o);let a=[];if(void 0!==s){const t=function(e,t){const r=e.catalog.symbols.get(t);return"enum"===r?.kind?r.type:void 0}(e,s);try{a=We(t)}catch(t){if(!(t instanceof De))throw t;Dt(e,`enum "${i}" at "${n}" is unreadable: ${t.message}`)}}return 0===a.length?(Dt(e,void 0===s?`enum "${i}" at "${n}" does not resolve from scope "${t}"; the example uses an empty string, which the server will reject. The catalog notes list the failed references.`:`enum "${i}" at "${n}" declares no values; the example uses an empty string, which the server will reject.`),""):(kt(e)&&e.enums.push({at:n,enum:i,values:a}),a[0])}if("TYPE_MESSAGE"===r.type||"TYPE_GROUP"===r.type){const s=r.typeName,i=bt(s),a=xt(e,t,s),c=a??i;if("google.protobuf.Any"===c||"google.protobuf.Any"===i)return Dt(e,`"${n}" is google.protobuf.Any; its payload is passed through unmodified and is not validated against the descriptor. Editing support is not available in this version.`),{"@type":"",value:{}};if(vt.has(c)||vt.has(i))return Dt(e,`"${n}" is ${c}, whose JSON form is any JSON value; no example can be generated without guessing. Supply it by hand.`),{};if(c in wt)return wt[c];if(i in wt)return wt[i];if(void 0===a)return Dt(e,`message "${i}" at "${n}" does not resolve from scope "${t}"; left as an empty object, which on the wire means "set with all defaults". The catalog notes list the failed references.`),kt(e)&&e.presence.push({at:n,reason:"message",presentInExample:e.fillMessageFields,valueIfSet:{}}),e.fillMessageFields?{}:gt;const l=Mt(e,a,n,o+1)??{};return kt(e)&&e.presence.push({at:n,reason:"message",presentInExample:e.fillMessageFields,valueIfSet:l}),e.fillMessageFields?l:gt}return r.type in yt?yt[r.type]:(Dt(e,`unhandled field type ${r.type} at "${n}"; the example uses null, which will not serialise.`),null)}var It=(e,t)=>e.name<t.name?-1:e.name>t.name?1:0;function At(e,t){return e&&t?"bidi_streaming":e?"client_streaming":t?"server_streaming":"unary"}function Ct(e){return e.startsWith(".")?e.slice(1):e}function qt(e){const t=e.lastIndexOf(".");return-1===t?"":e.slice(0,t)}function Bt(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Rt(e,t){const r=new Map,n=e[t];if(!n||"object"!=typeof n)return r;for(const[e,t]of Object.entries(n)){const n=t;if(!n||"object"!=typeof n||"string"!=typeof n.path)continue;const o={key:e,path:n.path,requestStream:!0===n.requestStream,responseStream:!0===n.responseStream,hasCodecs:"function"==typeof n.requestSerialize&&"function"==typeof n.responseDeserialize},s=Bt(o.path),i=r.get(s);i&&i.key===s||r.set(s,o)}return r}function Lt(e,t,r){const n=e.serviceDescriptors.get(t);if(void 0!==n)try{return Ge(n)}catch(e){return void r.push(`descriptor for ${t} is unreadable, so request templates and type names are unavailable for it: ${e instanceof Error?e.message:String(e)}`)}}async function Ut(e,t,r,n={}){const{catalog:o,packageDefinition:s}=await ot(e);return Yt(o,s,t,r,n)}function Yt(e,t,r,n,o={}){if(!(e.serviceDescriptors.has(r)||e.invocableServices.includes(r))){const t=[...new Set([...e.services,...e.invocableServices])].sort();throw new Error(`service "${r}" not found (source: ${e.source}). Available: ${t.join(", ")||"(none)"}`)}const s=[...e.notes],i=Lt(e,r,s),a=Rt(t,r);let c=i?.find(e=>e.name===n);if(!c&&i){const e=i.filter(e=>e.name.toLowerCase()===n.toLowerCase());if(1===e.length)s.push(`method matched case-insensitively: requested "${n}", using "${e[0].name}".`),c=e[0];else if(e.length>1)throw new Error(`method "${n}" is ambiguous on ${r}: ${e.map(e=>e.name).sort().join(", ")}. Use the exact declared name.`)}if(!c)throw function(e,t,r,n,o){const s=(n??[]).map(e=>e.name).sort(),i=[...o.keys()].sort();if(void 0===n)return new Error(`cannot describe "${e}/${t}": no readable descriptor for ${e} (source: ${r}), so no method metadata is available. The method may still be callable — the runtime view lists ${i.join(", ")||"(none)"}.`);const a=i.filter(e=>!s.includes(e));return o.has(t)?new Error(`method "${t}" is callable on ${e} but missing from its descriptor (source: ${r}), so no request template can be built. Described: ${s.join(", ")||"(none)"}.`+(a.length?` Also undescribed: ${a.filter(e=>e!==t).join(", ")||"(none)"}.`:"")):new Error(`method "${t}" not found on ${e} (source: ${r}). Described: ${s.join(", ")||"(none)"}`+(a.length?`; callable but undescribed: ${a.join(", ")}`:"")+".")}(r,n,e.source,i,a);const l=a.get(c.name),u={name:c.name,path:l?.path??`/${r}/${c.name}`,kind:At(c.clientStreaming,c.serverStreaming),inputType:Ct(c.inputType),outputType:Ct(c.outputType),requestStream:c.clientStreaming,responseStream:c.serverStreaming,invocable:!0===l?.hasCodecs};u.invocable||s.push(`${r}/${c.name} can be described but not called: the loaded definition has no codecs for it.`);const d={maxDepth:o.maxDepth,seedCollections:o.seedCollections,fillExplicitOptional:o.fillExplicitOptional,fillMessageFields:o.fillMessageFields};let f,p;if(void 0===u.inputType)s.push(`the request type of ${r}/${u.name} is unknown, so no template can be built.`);else try{f=Tt(e,u.inputType,d)}catch(e){if(!(e instanceof De))throw e;s.push(`request template unavailable: ${e.message}`)}if(o.includeResponse)if(void 0===u.outputType)s.push(`the response type of ${r}/${u.name} is unknown, so its shape is unavailable.`);else try{p=Tt(e,u.outputType,d)}catch(e){if(!(e instanceof De))throw e;s.push(`response shape unavailable: ${e.message}`)}return{...u,service:r,request:f,response:p,notes:s}}function zt(e,t,r){const n=[...t.notes],o=[...new Set([...t.services,...t.invocableServices])].sort().map(e=>function(e,t,r,n){const o=[],s=new Set;for(const i of t??[]){s.add(i.name);const t=r.get(i.name);if(t){const r=At(i.clientStreaming,i.serverStreaming),o=At(t.requestStream,t.responseStream);r!==o&&n.push(`streaming flags disagree for ${e}/${i.name}: descriptor says ${r}, runtime says ${o}. Calls to this method will be refused.`)}o.push({name:i.name,path:t?.path??`/${e}/${i.name}`,kind:At(i.clientStreaming,i.serverStreaming),inputType:Ct(i.inputType),outputType:Ct(i.outputType),requestStream:i.clientStreaming,responseStream:i.serverStreaming,invocable:!0===t?.hasCodecs})}const i=[];for(const[e,t]of r)s.has(e)||(i.push(e),o.push({name:e,path:t.path,kind:At(t.requestStream,t.responseStream),inputType:void 0,outputType:void 0,requestStream:t.requestStream,responseStream:t.responseStream,invocable:t.hasCodecs}));i.length&&n.push(`${e}: ${i.sort().join(", ")} ${1===i.length?"is":"are"} callable but absent from the descriptor; no request template can be generated for ${1===i.length?"it":"them"}.`);const a=o.filter(e=>!e.invocable).map(e=>e.name);return a.length&&t&&n.push(`${e}: ${a.sort().join(", ")} ${1===a.length?"is":"are"} declared but not invocable; the loaded definition has no codecs for ${1===a.length?"it":"them"}.`),o.sort(It),{name:e,package:qt(e),methods:o,views:t&&r.size>0?"both":t?"descriptor_only":"runtime_only"}}(e,Lt(t,e,n),Rt(r,e),n));return{address:e.address,source:t.source,services:o,files:t.files,notes:n}}async function Vt(e){const{catalog:t,packageDefinition:r}=await ot(e);return zt(e,t,r)}function Wt(e){return void 0!==e&&!1!==e&&(!0===e?"system":{roots:e.rootCerts?.length??0,key:e.privateKey?.length??0,chain:e.certChain?.length??0,skipHostname:!0===e.skipHostnameVerification})}function Gt(e){return Array.isArray(e)?[...e].filter(e=>"string"==typeof e).sort():[]}function Kt(e){return!0===e.reflection?JSON.stringify({kind:"reflection",address:e.address,version:e.reflectionVersion??null,host:e.reflectionHost??null,tls:Wt(e.tls)}):JSON.stringify({kind:"proto",address:e.address,protoPaths:Gt(e.protoPaths),includeDirs:Gt(e.includeDirs),ignoreDirs:Gt(e.ignoreDirs),followSymlinks:!0===e.followSymlinks,tls:Wt(e.tls)})}function Xt(e){return"string"==typeof e&&e.length>0}function Ht(e){if(!e||"object"!=typeof e)return!1;const t=e;return!!Xt(t.address)&&(!0===t.reflection||Array.isArray(t.protoPaths)&&t.protoPaths.length>0&&t.protoPaths.every(Xt))}var Jt=class{protocol="grpc";catalogTtlMs;maxCachedCatalogs;catalogs=new Map;building=new Map;constructor(e={}){const t=e.catalogTtlMs??3e4;if(!Number.isFinite(t)||t<0)throw new RangeError(`catalogTtlMs must be a finite number >= 0; received ${t}.`);const r=e.maxCachedCatalogs??32;if(!Number.isInteger(r)||r<1)throw new RangeError(`maxCachedCatalogs must be an integer >= 1; received ${r}.`);this.catalogTtlMs=t,this.maxCachedCatalogs=r}supports(e){if(!Ht(e))return!1;const t=e;return Xt(t.service)&&Xt(t.method)}assertSupported(e){if(!this.supports(e))throw new Error("not a usable gRPC target: address, service and method are required, plus either protoPaths (a non-empty array of files or directories) or reflection: true.");return e}assertEndpoint(e){if(!Ht(e))throw new Error("not a usable gRPC endpoint: address is required, plus either protoPaths (a non-empty array of files or directories) or reflection: true.");return e}async catalogFor(e){const t=Kt(e);if(this.catalogTtlMs>0){const e=this.catalogs.get(t);if(e&&Date.now()-e.at<=this.catalogTtlMs)return this.catalogs.delete(t),this.catalogs.set(t,e),e;e&&this.catalogs.delete(t)}const r=this.building.get(t);if(r)return r;const n=ot(e).then(({catalog:e,packageDefinition:r})=>{const n={catalog:e,packageDefinition:r,at:Date.now()};return this.catalogTtlMs>0&&(this.catalogs.set(t,n),this.evict()),n}).finally(()=>{this.building.delete(t)});return this.building.set(t,n),n}evict(){for(;this.catalogs.size>this.maxCachedCatalogs;){const e=this.catalogs.keys().next();if(e.done)return;this.catalogs.delete(e.value)}}invalidate(e){if(!e)return this.catalogs.clear(),void this.building.clear();const t=Kt(e);this.catalogs.delete(t),this.building.delete(t)}async sourceNotes(e){const t=this.assertEndpoint(e),{catalog:r}=await this.catalogFor(t);return[...r.notes]}async plan(e){const t=this.assertSupported(e),{catalog:r,packageDefinition:n}=await this.catalogFor(t),o=await lt(t,{catalog:r,packageDefinition:n}),s=(new Set(r.notes),[...o.notes,'the exported collection is not a valid Postman v2.1.0 document: gRPC has no standard representation there, so method is written as "GRPC" and the invocation details live under protocolProfileBehavior. Import support depends on the client.',"only address, service, method and metadata survive the export. Message payloads, stream pacing, deadlines and truncation limits do not.","gRPC results cannot be written back into an OpenAPI document; writeBack is ignored for protocol=grpc.",...Qt(t)]);return{streaming:o.requestStream||o.responseStream,warnings:s,environment:{baseUrl:t.address},collection:Zt(t,o)}}async run(e,t){const r=this.assertSupported(e),{catalog:n,packageDefinition:o}=await this.catalogFor(r);return mt(r,t??{},{catalog:n,packageDefinition:o,includeSourceNotes:!1})}async discover(e){const t=this.assertEndpoint(e),{catalog:r,packageDefinition:n}=await this.catalogFor(t);return zt(t,r,n)}async describeMethod(e,t,r,n={}){const o=this.assertEndpoint(e);if(!Xt(t)||!Xt(r))throw new TypeError("describeMethod needs a non-empty service and method name.");const{catalog:s,packageDefinition:i}=await this.catalogFor(o);return Yt(s,i,t,r,{includeResponse:!0,...n})}};function Qt(e){const t=e.tls;if(void 0===t||!1===t||!0===t)return[];const r=[];return(t.privateKey||t.certChain)&&r.push("the client certificate"),t.rootCerts&&r.push("the custom CA bundle"),t.skipHostnameVerification&&r.push("skipHostnameVerification, which the importing client will not honour"),0===r.length?[]:[`the export records only that TLS is enabled; ${r.join(" and ")} will be absent, so the imported request will not connect as configured.`]}function Zt(e,t){const r=`${e.service}/${t.name}`;return{info:{name:r,schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},item:[{name:r,request:{method:"GRPC",url:{raw:`grpc://${e.address}${t.path}`},description:`kind=${t.kind} source=${t.source}`,header:Object.entries(e.metadata??{}).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).map(t=>({key:e,value:Buffer.isBuffer(t)?t.toString("base64"):String(t)})))},protocolProfileBehavior:{grpc:{service:e.service,methodName:t.name,methodType:t.kind,url:e.address,tls:void 0!==e.tls&&!1!==e.tls}}}]}}export{le as DescriptorDecodeError,De as DescriptorShapeError,Jt as GrpcAdapter,l as GrpcDependencyBrokenError,c as GrpcDependencyMissingError,Ie as LABEL_NAMES,Ke as LOADER_OPTIONS,K as ReflectionProtocolError,W as ReflectionUnavailableError,Fe as TYPE_NAMES,ot as buildCatalog,w as buildCredentials,v as buildCredentialsAsync,y as buildCredentialsChecked,b as buildCredentialsCheckedAsync,Tt as buildMessageTemplate,Te as decodeFileDescriptorProto,ke as decodeFileDescriptorSet,F as deriveIncludeDirsDetailed,Yt as describeFromCatalog,Ut as describeMethod,Vt as discover,zt as discoverFromCatalog,Be as enumName,ae as fetchDescriptorSet,ce as fetchFullDescriptorSet,mt as grpcCall,h as isGrpcAvailable,Ve as isMapEntry,se as listServices,oe as listServicesDetailed,p as loadGrpc,We as readEnumValueNames,Le as readFields,Ge as readMethods,ze as readNestedTypes,Ye as readOneofNames,m as requireCapability,lt as resolveMethod,M as scanProtoFiles,ne as serializeDescriptorSet};