unbake-proto 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/index.js +10 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ph0ryn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# unbake-proto
|
|
2
|
+
|
|
3
|
+
Decompile baked protobuf descriptors into human-readable `.proto` which is semantically equivalent to the original.
|
|
4
|
+
`unbake-proto` can work for all cases baked by `FileDescriptorSetSchema`
|
|
5
|
+
|
|
6
|
+
## usage
|
|
7
|
+
|
|
8
|
+
```shell
|
|
9
|
+
bun i
|
|
10
|
+
bun run unbake <input> # output to stdout
|
|
11
|
+
bun run unbake <input> [out_folder] # output to file(s)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## try
|
|
15
|
+
|
|
16
|
+
prepare your `.proto` file and then run the following commands
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
protoc --descriptor_set_out=baked.pb --include_imports original.proto
|
|
20
|
+
bun run unbake baked.pb > unbaked.proto
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
there should be no difference between `original.proto` and `unbaked.proto` !
|
|
24
|
+
|
|
25
|
+
## requirements
|
|
26
|
+
|
|
27
|
+
- Bun for the runtime; others can be used instead
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import{existsSync as Y1,mkdirSync as z1,readFileSync as q1,writeFileSync as A1}from"fs";import{dirname as Z1,join as ZH}from"path";function T(H,$){if(!(H!==null&&typeof H=="object"&&("$typeName"in H)&&typeof H.$typeName=="string"))return!1;if($===void 0)return!0;return $.typeName===H.$typeName}var q;(function(H){H[H.DOUBLE=1]="DOUBLE",H[H.FLOAT=2]="FLOAT",H[H.INT64=3]="INT64",H[H.UINT64=4]="UINT64",H[H.INT32=5]="INT32",H[H.FIXED64=6]="FIXED64",H[H.FIXED32=7]="FIXED32",H[H.BOOL=8]="BOOL",H[H.STRING=9]="STRING",H[H.BYTES=12]="BYTES",H[H.UINT32=13]="UINT32",H[H.SFIXED32=15]="SFIXED32",H[H.SFIXED64=16]="SFIXED64",H[H.SINT32=17]="SINT32",H[H.SINT64=18]="SINT64"})(q||(q={}));function n0(){let H=0,$=0;for(let K=0;K<28;K+=7){let Y=this.buf[this.pos++];if(H|=(Y&127)<<K,(Y&128)==0)return this.assertBounds(),[H,$]}let J=this.buf[this.pos++];if(H|=(J&15)<<28,$=(J&112)>>4,(J&128)==0)return this.assertBounds(),[H,$];for(let K=3;K<=31;K+=7){let Y=this.buf[this.pos++];if($|=(Y&127)<<K,(Y&128)==0)return this.assertBounds(),[H,$]}throw Error("invalid varint")}var d=4294967296;function z0(H){let $=H[0]==="-";if($)H=H.slice(1);let J=1e6,K=0,Y=0;function Q(z,A){let X=Number(H.slice(z,A));if(Y*=J,K=K*J+X,K>=d)Y=Y+(K/d|0),K=K%d}return Q(-24,-18),Q(-18,-12),Q(-12,-6),Q(-6),$?d0(K,Y):A0(K,Y)}function f0(H,$){let J=A0(H,$),K=J.hi&2147483648;if(K)J=d0(J.lo,J.hi);let Y=q0(J.lo,J.hi);return K?"-"+Y:Y}function q0(H,$){if({lo:H,hi:$}=CH(H,$),$<=2097151)return String(d*$+H);let J=H&16777215,K=(H>>>24|$<<8)&16777215,Y=$>>16&65535,Q=J+K*6777216+Y*6710656,z=K+Y*8147497,A=Y*2,X=1e7;if(Q>=X)z+=Math.floor(Q/X),Q%=X;if(z>=X)A+=Math.floor(z/X),z%=X;return A.toString()+u0(z)+u0(Q)}function CH(H,$){return{lo:H>>>0,hi:$>>>0}}function A0(H,$){return{lo:H|0,hi:$|0}}function d0(H,$){if($=~$,H)H=~H+1;else $+=1;return A0(H,$)}var u0=(H)=>{let $=String(H);return"0000000".slice($.length)+$};function Z0(H,$){if(H>=0){while(H>127)$.push(H&127|128),H=H>>>7;$.push(H)}else{for(let J=0;J<9;J++)$.push(H&127|128),H=H>>7;$.push(1)}}function p0(){let H=this.buf[this.pos++],$=H&127;if((H&128)==0)return this.assertBounds(),$;if(H=this.buf[this.pos++],$|=(H&127)<<7,(H&128)==0)return this.assertBounds(),$;if(H=this.buf[this.pos++],$|=(H&127)<<14,(H&128)==0)return this.assertBounds(),$;if(H=this.buf[this.pos++],$|=(H&127)<<21,(H&128)==0)return this.assertBounds(),$;H=this.buf[this.pos++],$|=(H&15)<<28;for(let J=5;(H&128)!==0&&J<10;J++)H=this.buf[this.pos++];if((H&128)!=0)throw Error("invalid varint");return this.assertBounds(),$>>>0}var U=UH();function UH(){let H=new DataView(new ArrayBuffer(8));if(typeof BigInt==="function"&&typeof H.getBigInt64==="function"&&typeof H.getBigUint64==="function"&&typeof H.setBigInt64==="function"&&typeof H.setBigUint64==="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let J=BigInt("-9223372036854775808"),K=BigInt("9223372036854775807"),Y=BigInt("0"),Q=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(z){let A=typeof z=="bigint"?z:BigInt(z);if(A>K||A<J)throw Error(`invalid int64: ${z}`);return A},uParse(z){let A=typeof z=="bigint"?z:BigInt(z);if(A>Q||A<Y)throw Error(`invalid uint64: ${z}`);return A},enc(z){return H.setBigInt64(0,this.parse(z),!0),{lo:H.getInt32(0,!0),hi:H.getInt32(4,!0)}},uEnc(z){return H.setBigInt64(0,this.uParse(z),!0),{lo:H.getInt32(0,!0),hi:H.getInt32(4,!0)}},dec(z,A){return H.setInt32(0,z,!0),H.setInt32(4,A,!0),H.getBigInt64(0,!0)},uDec(z,A){return H.setInt32(0,z,!0),H.setInt32(4,A,!0),H.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(J){if(typeof J!="string")J=J.toString();return s0(J),J},uParse(J){if(typeof J!="string")J=J.toString();return i0(J),J},enc(J){if(typeof J!="string")J=J.toString();return s0(J),z0(J)},uEnc(J){if(typeof J!="string")J=J.toString();return i0(J),z0(J)},dec(J,K){return f0(J,K)},uDec(J,K){return q0(J,K)}}}function s0(H){if(!/^-?[0-9]+$/.test(H))throw Error("invalid int64: "+H)}function i0(H){if(!/^[0-9]+$/.test(H))throw Error("invalid uint64: "+H)}function D(H,$){switch(H){case q.STRING:return"";case q.BOOL:return!1;case q.DOUBLE:case q.FLOAT:return 0;case q.INT64:case q.UINT64:case q.SFIXED64:case q.FIXED64:case q.SINT64:return $?"0":U.zero;case q.BYTES:return new Uint8Array(0);default:return 0}}function o0(H,$){switch(H){case q.BOOL:return $===!1;case q.STRING:return $==="";case q.BYTES:return $ instanceof Uint8Array&&!$.byteLength;default:return $==0}}var r0=2,O=Symbol.for("reflect unsafe local");function p(H,$){let J=H[$.localName].case;if(J===void 0)return J;return $.fields.find((K)=>K.localName===J)}function l0(H,$){let J=$.localName;if($.oneof)return H[$.oneof.localName].case===J;if($.presence!=r0)return H[J]!==void 0&&Object.prototype.hasOwnProperty.call(H,J);switch($.fieldKind){case"list":return H[J].length>0;case"map":return Object.keys(H[J]).length>0;case"scalar":return!o0($.scalar,H[J]);case"enum":return H[J]!==$.enum.values[0].number}throw Error("message field with implicit presence")}function x(H,$){return Object.prototype.hasOwnProperty.call(H,$)&&H[$]!==void 0}function s(H,$){if($.oneof){let J=H[$.oneof.localName];if(J.case===$.localName)return J.value;return}return H[$.localName]}function i(H,$,J){if($.oneof)H[$.oneof.localName]={case:$.localName,value:J};else H[$.localName]=J}function t0(H,$){let J=$.localName;if($.oneof){let K=$.oneof.localName;if(H[K].case===J)H[K]={case:void 0}}else if($.presence!=r0)delete H[J];else switch($.fieldKind){case"map":H[J]={};break;case"list":H[J]=[];break;case"enum":H[J]=$.enum.values[0].number;break;case"scalar":H[J]=D($.scalar,$.longAsString);break}}function N(H){return H!==null&&typeof H=="object"&&!Array.isArray(H)}function y(H,$){var J,K,Y,Q;if(N(H)&&O in H&&"add"in H&&"field"in H&&typeof H.field=="function"){if($!==void 0){let z=$,A=H.field();return z.listKind==A.listKind&&z.scalar===A.scalar&&((J=z.message)===null||J===void 0?void 0:J.typeName)===((K=A.message)===null||K===void 0?void 0:K.typeName)&&((Y=z.enum)===null||Y===void 0?void 0:Y.typeName)===((Q=A.enum)===null||Q===void 0?void 0:Q.typeName)}return!0}return!1}function m(H,$){var J,K,Y,Q;if(N(H)&&O in H&&"has"in H&&"field"in H&&typeof H.field=="function"){if($!==void 0){let z=$,A=H.field();return z.mapKey===A.mapKey&&z.mapKind==A.mapKind&&z.scalar===A.scalar&&((J=z.message)===null||J===void 0?void 0:J.typeName)===((K=A.message)===null||K===void 0?void 0:K.typeName)&&((Y=z.enum)===null||Y===void 0?void 0:Y.typeName)===((Q=A.enum)===null||Q===void 0?void 0:Q.typeName)}return!0}return!1}function g(H,$){return N(H)&&O in H&&"desc"in H&&N(H.desc)&&H.desc.kind==="message"&&($===void 0||H.desc.typeName==$.typeName)}function a0(H){return e0(H.$typeName)}function o(H){let $=H.fields[0];return e0(H.typeName)&&$!==void 0&&$.fieldKind=="scalar"&&$.name=="value"&&$.number==1}function e0(H){return H.startsWith("google.protobuf.")&&["DoubleValue","FloatValue","Int64Value","UInt64Value","Int32Value","UInt32Value","BoolValue","StringValue","BytesValue"].includes(H.substring(16))}var GH=999,VH=998,r=2;function L0(H,$){if(T($,H))return $;let J=wH(H);if($!==void 0)WH(H,J,$);return J}function WH(H,$,J){for(let K of H.members){let Y=J[K.localName];if(Y==null)continue;let Q;if(K.kind=="oneof"){let z=p(J,K);if(!z)continue;Q=z,Y=s(J,z)}else Q=K;switch(Q.fieldKind){case"message":Y=C0(Q,Y);break;case"scalar":Y=J2(Q,Y);break;case"list":Y=BH(Q,Y);break;case"map":Y=RH(Q,Y);break}i($,Q,Y)}return $}function J2(H,$){if(H.scalar==q.BYTES)return U0($);return $}function RH(H,$){if(N($)){if(H.scalar==q.BYTES)return H2($,U0);if(H.mapKind=="message")return H2($,(J)=>C0(H,J))}return $}function BH(H,$){if(Array.isArray($)){if(H.scalar==q.BYTES)return $.map(U0);if(H.listKind=="message")return $.map((J)=>C0(H,J))}return $}function C0(H,$){if(H.fieldKind=="message"&&!H.oneof&&o(H.message))return J2(H.message.fields[0],$);if(N($)){if(H.message.typeName=="google.protobuf.Struct"&&H.parent.typeName!=="google.protobuf.Value")return $;if(!T($,H.message))return L0(H.message,$)}return $}function U0(H){return Array.isArray(H)?new Uint8Array(H):H}function H2(H,$){let J={};for(let K of Object.entries(H))J[K[0]]=$(K[1]);return J}var OH=Symbol(),$2=new WeakMap;function wH(H){let $;if(!NH(H)){$={$typeName:H.typeName};for(let J of H.members)if(J.kind=="oneof"||J.presence==r)$[J.localName]=X0(J)}else{let J=$2.get(H),K,Y;if(J)({prototype:K,members:Y}=J);else{K={},Y=new Set;for(let Q of H.members){if(Q.kind=="oneof")continue;if(Q.fieldKind!="scalar"&&Q.fieldKind!="enum")continue;if(Q.presence==r)continue;Y.add(Q),K[Q.localName]=X0(Q)}$2.set(H,{prototype:K,members:Y})}$=Object.create(K),$.$typeName=H.typeName;for(let Q of H.members){if(Y.has(Q))continue;if(Q.kind=="field"){if(Q.fieldKind=="message")continue;if(Q.fieldKind=="scalar"||Q.fieldKind=="enum"){if(Q.presence!=r)continue}}$[Q.localName]=X0(Q)}}return $}function NH(H){switch(H.file.edition){case GH:return!1;case VH:return!0;default:return H.fields.some(($)=>$.presence!=r&&$.fieldKind!="message"&&!$.oneof)}}function X0(H){if(H.kind=="oneof")return{case:void 0};if(H.fieldKind=="list")return[];if(H.fieldKind=="map")return{};if(H.fieldKind=="message")return OH;let $=H.getDefaultValue();if($!==void 0)return H.fieldKind=="scalar"&&H.longAsString?$.toString():$;return H.fieldKind=="scalar"?D(H.scalar,H.longAsString):H.enum.values[0].number}class j extends Error{constructor(H,$,J="FieldValueInvalidError"){super($);this.name=J,this.field=()=>H}}var G0=Symbol.for("@bufbuild/protobuf/text-encoding");function l(){if(globalThis[G0]==null){let H=new globalThis.TextEncoder,$=new globalThis.TextDecoder;globalThis[G0]={encodeUtf8(J){return H.encode(J)},decodeUtf8(J){return $.decode(J)},checkUtf8(J){try{return encodeURIComponent(J),!0}catch(K){return!1}}}}return globalThis[G0]}var R;(function(H){H[H.Varint=0]="Varint",H[H.Bit64=1]="Bit64",H[H.LengthDelimited=2]="LengthDelimited",H[H.StartGroup=3]="StartGroup",H[H.EndGroup=4]="EndGroup",H[H.Bit32=5]="Bit32"})(R||(R={}));var K2=340282346638528860000000000000000000000,Q2=-340282346638528860000000000000000000000,Y2=4294967295,z2=2147483647,q2=-2147483648;class V0{constructor(H,$=l().decodeUtf8){this.decodeUtf8=$,this.varint64=n0,this.uint32=p0,this.buf=H,this.len=H.length,this.pos=0,this.view=new DataView(H.buffer,H.byteOffset,H.byteLength)}tag(){let H=this.uint32(),$=H>>>3,J=H&7;if($<=0||J<0||J>5)throw Error("illegal tag: field no "+$+" wire type "+J);return[$,J]}skip(H,$){let J=this.pos;switch(H){case R.Varint:while(this.buf[this.pos++]&128);break;case R.Bit64:this.pos+=4;case R.Bit32:this.pos+=4;break;case R.LengthDelimited:let K=this.uint32();this.pos+=K;break;case R.StartGroup:for(;;){let[Y,Q]=this.tag();if(Q===R.EndGroup){if($!==void 0&&Y!==$)throw Error("invalid end group tag");break}this.skip(Q,Y)}break;default:throw Error("cant skip wire type "+H)}return this.assertBounds(),this.buf.subarray(J,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let H=this.uint32();return H>>>1^-(H&1)}int64(){return U.dec(...this.varint64())}uint64(){return U.uDec(...this.varint64())}sint64(){let[H,$]=this.varint64(),J=-(H&1);return H=(H>>>1|($&1)<<31)^J,$=$>>>1^J,U.dec(H,$)}bool(){let[H,$]=this.varint64();return H!==0||$!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return U.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return U.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let H=this.uint32(),$=this.pos;return this.pos+=H,this.assertBounds(),this.buf.subarray($,$+H)}string(){return this.decodeUtf8(this.bytes())}}function A2(H,$){let J=H.fieldKind=="list"?y($,H):H.fieldKind=="map"?m($,H):R0(H,$);if(J===!0)return;let K;switch(H.fieldKind){case"list":K=`expected ${C2(H)}, got ${a($)}`;break;case"map":K=`expected ${U2(H)}, got ${a($)}`;break;default:K=t(H,$,J)}return new j(H,K)}function W0(H,$,J){let K=R0(H,J);if(K!==!0)return new j(H,`list item #${$+1}: ${t(H,J,K)}`);return}function Z2(H,$,J){let K=X2($,H.mapKey);if(K!==!0)return new j(H,`invalid map key: ${t({scalar:H.mapKey},$,K)}`);let Y=R0(H,J);if(Y!==!0)return new j(H,`map entry ${a($)}: ${t(H,J,Y)}`);return}function R0(H,$){if(H.scalar!==void 0)return X2($,H.scalar);if(H.enum!==void 0){if(H.enum.open)return Number.isInteger($);return H.enum.values.some((J)=>J.number===$)}return g($,H.message)}function X2(H,$){switch($){case q.DOUBLE:return typeof H=="number";case q.FLOAT:if(typeof H!="number")return!1;if(Number.isNaN(H)||!Number.isFinite(H))return!0;if(H>K2||H<Q2)return`${H.toFixed()} out of range`;return!0;case q.INT32:case q.SFIXED32:case q.SINT32:if(typeof H!=="number"||!Number.isInteger(H))return!1;if(H>z2||H<q2)return`${H.toFixed()} out of range`;return!0;case q.FIXED32:case q.UINT32:if(typeof H!=="number"||!Number.isInteger(H))return!1;if(H>Y2||H<0)return`${H.toFixed()} out of range`;return!0;case q.BOOL:return typeof H=="boolean";case q.STRING:if(typeof H!="string")return!1;return l().checkUtf8(H)||"invalid UTF8";case q.BYTES:return H instanceof Uint8Array;case q.INT64:case q.SFIXED64:case q.SINT64:if(typeof H=="bigint"||typeof H=="number"||typeof H=="string"&&H.length>0)try{return U.parse(H),!0}catch(J){return`${H} out of range`}return!1;case q.FIXED64:case q.UINT64:if(typeof H=="bigint"||typeof H=="number"||typeof H=="string"&&H.length>0)try{return U.uParse(H),!0}catch(J){return`${H} out of range`}return!1}}function t(H,$,J){if(J=typeof J=="string"?`: ${J}`:`, got ${a($)}`,H.scalar!==void 0)return`expected ${DH(H.scalar)}`+J;if(H.enum!==void 0)return`expected ${H.enum.toString()}`+J;return`expected ${L2(H.message)}`+J}function a(H){switch(typeof H){case"object":if(H===null)return"null";if(H instanceof Uint8Array)return`Uint8Array(${H.length})`;if(Array.isArray(H))return`Array(${H.length})`;if(y(H))return C2(H.field());if(m(H))return U2(H.field());if(g(H))return L2(H.desc);if(T(H))return`message ${H.$typeName}`;return"object";case"string":return H.length>30?"string":`"${H.split('"').join("\\\"")}"`;case"boolean":return String(H);case"number":return String(H);case"bigint":return String(H)+"n";default:return typeof H}}function L2(H){return`ReflectMessage (${H.typeName})`}function C2(H){switch(H.listKind){case"message":return`ReflectList (${H.message.toString()})`;case"enum":return`ReflectList (${H.enum.toString()})`;case"scalar":return`ReflectList (${q[H.scalar]})`}}function U2(H){switch(H.mapKind){case"message":return`ReflectMap (${q[H.mapKey]}, ${H.message.toString()})`;case"enum":return`ReflectMap (${q[H.mapKey]}, ${H.enum.toString()})`;case"scalar":return`ReflectMap (${q[H.mapKey]}, ${q[H.scalar]})`}}function DH(H){switch(H){case q.STRING:return"string";case q.BOOL:return"boolean";case q.INT64:case q.SINT64:case q.SFIXED64:return"bigint (int64)";case q.UINT64:case q.FIXED64:return"bigint (uint64)";case q.BYTES:return"Uint8Array";case q.DOUBLE:return"number (float64)";case q.FLOAT:return"number (float32)";case q.FIXED32:case q.UINT32:return"number (uint32)";case q.INT32:case q.SFIXED32:case q.SINT32:return"number (int32)"}}function H0(H,$,J=!0){return new w0(H,$,J)}var G2=new WeakMap;class w0{get sortedFields(){let H=G2.get(this.desc);if(H)return H;let $=this.desc.fields.concat().sort((J,K)=>J.number-K.number);return G2.set(this.desc,$),$}constructor(H,$,J=!0){this.lists=new Map,this.maps=new Map,this.check=J,this.desc=H,this.message=this[O]=$!==null&&$!==void 0?$:L0(H),this.fields=H.fields,this.oneofs=H.oneofs,this.members=H.members}findNumber(H){if(!this._fieldsByNumber)this._fieldsByNumber=new Map(this.desc.fields.map(($)=>[$.number,$]));return this._fieldsByNumber.get(H)}oneofCase(H){return v(this.message,H),p(this.message,H)}isSet(H){return v(this.message,H),l0(this.message,H)}clear(H){v(this.message,H),t0(this.message,H)}get(H){v(this.message,H);let $=s(this.message,H);switch(H.fieldKind){case"list":let J=this.lists.get(H);if(!J||J[O]!==$)this.lists.set(H,J=new R2(H,$,this.check));return J;case"map":let K=this.maps.get(H);if(!K||K[O]!==$)this.maps.set(H,K=new B2(H,$,this.check));return K;case"message":return D0(H,$,this.check);case"scalar":return $===void 0?D(H.scalar,!1):j0(H,$);case"enum":return $!==null&&$!==void 0?$:H.enum.values[0].number}}set(H,$){if(v(this.message,H),this.check){let K=A2(H,$);if(K)throw K}let J;if(H.fieldKind=="message")J=N0(H,$);else if(m($)||y($))J=$[O];else J=I0(H,$);i(this.message,H,J)}getUnknown(){return this.message.$unknown}setUnknown(H){this.message.$unknown=H}}function v(H,$){if($.parent.typeName!==H.$typeName)throw new j($,`cannot use ${$.toString()} with message ${H.$typeName}`,"ForeignFieldError")}class R2{field(){return this._field}get size(){return this._arr.length}constructor(H,$,J){this._field=H,this._arr=this[O]=$,this.check=J}get(H){let $=this._arr[H];return $===void 0?void 0:B0(this._field,$,this.check)}set(H,$){if(H<0||H>=this._arr.length)throw new j(this._field,`list item #${H+1}: out of range`);if(this.check){let J=W0(this._field,H,$);if(J)throw J}this._arr[H]=V2(this._field,$)}add(H){if(this.check){let $=W0(this._field,this._arr.length,H);if($)throw $}this._arr.push(V2(this._field,H));return}clear(){this._arr.splice(0,this._arr.length)}[Symbol.iterator](){return this.values()}keys(){return this._arr.keys()}*values(){for(let H of this._arr)yield B0(this._field,H,this.check)}*entries(){for(let H=0;H<this._arr.length;H++)yield[H,B0(this._field,this._arr[H],this.check)]}}class B2{constructor(H,$,J=!0){this.obj=this[O]=$!==null&&$!==void 0?$:{},this.check=J,this._field=H}field(){return this._field}set(H,$){if(this.check){let J=Z2(this._field,H,$);if(J)throw J}return this.obj[e(H)]=jH(this._field,$),this}delete(H){let $=e(H),J=Object.prototype.hasOwnProperty.call(this.obj,$);if(J)delete this.obj[$];return J}clear(){for(let H of Object.keys(this.obj))delete this.obj[H]}get(H){let $=this.obj[e(H)];if($!==void 0)$=O0(this._field,$,this.check);return $}has(H){return Object.prototype.hasOwnProperty.call(this.obj,e(H))}*keys(){for(let H of Object.keys(this.obj))yield W2(H,this._field.mapKey)}*entries(){for(let H of Object.entries(this.obj))yield[W2(H[0],this._field.mapKey),O0(this._field,H[1],this.check)]}[Symbol.iterator](){return this.entries()}get size(){return Object.keys(this.obj).length}*values(){for(let H of Object.values(this.obj))yield O0(this._field,H,this.check)}forEach(H,$){for(let J of this.entries())H.call($,J[1],J[0],this)}}function N0(H,$){if(!g($))return $;if(a0($.message)&&!H.oneof&&H.fieldKind=="message")return $.message.value;if($.desc.typeName=="google.protobuf.Struct"&&H.parent.typeName!="google.protobuf.Value")return w2($.message);return $.message}function D0(H,$,J){if($!==void 0){if(o(H.message)&&!H.oneof&&H.fieldKind=="message")$={$typeName:H.message.typeName,value:j0(H.message.fields[0],$)};else if(H.message.typeName=="google.protobuf.Struct"&&H.parent.typeName!="google.protobuf.Value"&&N($))$=O2($)}return new w0(H.message,$,J)}function V2(H,$){if(H.listKind=="message")return N0(H,$);return I0(H,$)}function B0(H,$,J){if(H.listKind=="message")return D0(H,$,J);return j0(H,$)}function jH(H,$){if(H.mapKind=="message")return N0(H,$);return I0(H,$)}function O0(H,$,J){if(H.mapKind=="message")return D0(H,$,J);return $}function e(H){return typeof H=="string"||typeof H=="number"?H:String(H)}function W2(H,$){switch($){case q.STRING:return H;case q.INT32:case q.FIXED32:case q.UINT32:case q.SFIXED32:case q.SINT32:{let J=Number.parseInt(H);if(Number.isFinite(J))return J;break}case q.BOOL:switch(H){case"true":return!0;case"false":return!1}break;case q.UINT64:case q.FIXED64:try{return U.uParse(H)}catch(J){}break;default:try{return U.parse(H)}catch(J){}break}return H}function j0(H,$){switch(H.scalar){case q.INT64:case q.SFIXED64:case q.SINT64:if("longAsString"in H&&H.longAsString&&typeof $=="string")$=U.parse($);break;case q.FIXED64:case q.UINT64:if("longAsString"in H&&H.longAsString&&typeof $=="string")$=U.uParse($);break}return $}function I0(H,$){switch(H.scalar){case q.INT64:case q.SFIXED64:case q.SINT64:if("longAsString"in H&&H.longAsString)$=String($);else if(typeof $=="string"||typeof $=="number")$=U.parse($);break;case q.FIXED64:case q.UINT64:if("longAsString"in H&&H.longAsString)$=String($);else if(typeof $=="string"||typeof $=="number")$=U.uParse($);break}return $}function O2(H){let $={$typeName:"google.protobuf.Struct",fields:{}};if(N(H))for(let[J,K]of Object.entries(H))$.fields[J]=D2(K);return $}function w2(H){let $={};for(let[J,K]of Object.entries(H.fields))$[J]=N2(K);return $}function N2(H){switch(H.kind.case){case"structValue":return w2(H.kind.value);case"listValue":return H.kind.value.values.map(N2);case"nullValue":case void 0:return null;default:return H.kind.value}}function D2(H){let $={$typeName:"google.protobuf.Value",kind:{case:void 0}};switch(typeof H){case"number":$.kind={case:"numberValue",value:H};break;case"string":$.kind={case:"stringValue",value:H};break;case"boolean":$.kind={case:"boolValue",value:H};break;case"object":if(H===null)$.kind={case:"nullValue",value:0};else if(Array.isArray(H)){let J={$typeName:"google.protobuf.ListValue",values:[]};if(Array.isArray(H))for(let K of H)J.values.push(D2(K));$.kind={case:"listValue",value:J}}else $.kind={case:"structValue",value:O2(H)};break}return $}function h(H){let $=!1,J=[];for(let K=0;K<H.length;K++){let Y=H.charAt(K);switch(Y){case"_":$=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":J.push(Y),$=!1;break;default:if($)$=!1,Y=Y.toUpperCase();J.push(Y);break}}return J.join("")}var IH=new Set(["constructor","toString","toJSON","valueOf"]);function k(H){return IH.has(H)?H+"$":H}function x0(H){for(let $ of H.field)if(!x($,"jsonName"))$.jsonName=h($.name);H.nestedType.forEach(x0)}function j2(H,$){let J=H.values.find((K)=>K.name===$);if(!J)throw Error(`cannot parse ${H} default value: ${$}`);return J.number}function I2(H,$){switch(H){case q.STRING:return $;case q.BYTES:{let J=xH($);if(J===!1)throw Error(`cannot parse ${q[H]} default value: ${$}`);return J}case q.INT64:case q.SFIXED64:case q.SINT64:return U.parse($);case q.UINT64:case q.FIXED64:return U.uParse($);case q.DOUBLE:case q.FLOAT:switch($){case"inf":return Number.POSITIVE_INFINITY;case"-inf":return Number.NEGATIVE_INFINITY;case"nan":return Number.NaN;default:return parseFloat($)}case q.BOOL:return $==="true";case q.INT32:case q.UINT32:case q.SINT32:case q.FIXED32:case q.SFIXED32:return parseInt($,10)}}function xH(H){let $=[],J={tail:H,c:"",next(){if(this.tail.length==0)return!1;return this.c=this.tail[0],this.tail=this.tail.substring(1),!0},take(K){if(this.tail.length>=K){let Y=this.tail.substring(0,K);return this.tail=this.tail.substring(K),Y}return!1}};while(J.next())switch(J.c){case"\\":if(J.next())switch(J.c){case"\\":$.push(J.c.charCodeAt(0));break;case"b":$.push(8);break;case"f":$.push(12);break;case"n":$.push(10);break;case"r":$.push(13);break;case"t":$.push(9);break;case"v":$.push(11);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let K=J.c,Y=J.take(2);if(Y===!1)return!1;let Q=parseInt(K+Y,8);if(Number.isNaN(Q))return!1;$.push(Q);break}case"x":{let K=J.c,Y=J.take(2);if(Y===!1)return!1;let Q=parseInt(K+Y,16);if(Number.isNaN(Q))return!1;$.push(Q);break}case"u":{let K=J.c,Y=J.take(4);if(Y===!1)return!1;let Q=parseInt(K+Y,16);if(Number.isNaN(Q))return!1;let z=new Uint8Array(4);new DataView(z.buffer).setInt32(0,Q,!0),$.push(z[0],z[1],z[2],z[3]);break}case"U":{let K=J.c,Y=J.take(8);if(Y===!1)return!1;let Q=U.uEnc(K+Y),z=new Uint8Array(8),A=new DataView(z.buffer);A.setInt32(0,Q.lo,!0),A.setInt32(4,Q.hi,!0),$.push(z[0],z[1],z[2],z[3],z[4],z[5],z[6],z[7]);break}}break;default:$.push(J.c.charCodeAt(0))}return new Uint8Array($)}function*$0(H){switch(H.kind){case"file":for(let $ of H.messages)yield $,yield*$0($);yield*H.enums,yield*H.services,yield*H.extensions;break;case"message":for(let $ of H.nestedMessages)yield $,yield*$0($);yield*H.nestedEnums,yield*H.nestedExtensions;break}}function k2(...H){let $=MH();if(!H.length)return $;if("$typeName"in H[0]&&H[0].$typeName=="google.protobuf.FileDescriptorSet"){for(let J of H[0].file)F2(J,$);return $}if("$typeName"in H[0]){let Q=function(z){let A=[];for(let X of z.dependency){if($.getFile(X)!=null)continue;if(Y.has(X))continue;let Z=K(X);if(!Z)throw Error(`Unable to resolve ${X}, imported by ${z.name}`);if("kind"in Z)$.addFile(Z,!1,!0);else Y.add(Z.name),A.push(Z)}return A.concat(...A.map(Q))},J=H[0],K=H[1],Y=new Set;for(let z of[J,...Q(J)].reverse())F2(z,$)}else for(let J of H)for(let K of J.files)$.addFile(K);return $}function MH(){let H=new Map,$=new Map,J=new Map;return{kind:"registry",types:H,extendees:$,[Symbol.iterator](){return H.values()},get files(){return J.values()},addFile(K,Y,Q){if(J.set(K.proto.name,K),!Y)for(let z of $0(K))this.add(z);if(Q)for(let z of K.dependencies)this.addFile(z,Y,Q)},add(K){if(K.kind=="extension"){let Y=$.get(K.extendee.typeName);if(!Y)$.set(K.extendee.typeName,Y=new Map);Y.set(K.number,K)}H.set(K.typeName,K)},get(K){return H.get(K)},getFile(K){return J.get(K)},getMessage(K){let Y=H.get(K);return(Y===null||Y===void 0?void 0:Y.kind)=="message"?Y:void 0},getEnum(K){let Y=H.get(K);return(Y===null||Y===void 0?void 0:Y.kind)=="enum"?Y:void 0},getExtension(K){let Y=H.get(K);return(Y===null||Y===void 0?void 0:Y.kind)=="extension"?Y:void 0},getExtensionFor(K,Y){var Q;return(Q=$.get(K.typeName))===null||Q===void 0?void 0:Q.get(Y)},getService(K){let Y=H.get(K);return(Y===null||Y===void 0?void 0:Y.kind)=="service"?Y:void 0}}}var PH=998,FH=999,hH=9,u=10,c=11,kH=12,x2=14,k0=3,EH=2,M2=1,_H=0,M0=1,P2=2,bH=3,SH=1,TH=2,yH=1;var E2={998:{fieldPresence:1,enumType:2,repeatedFieldEncoding:2,utf8Validation:3,messageEncoding:1,jsonFormat:2,enforceNamingStyle:2,defaultSymbolVisibility:1},999:{fieldPresence:2,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:2,defaultSymbolVisibility:1},1000:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:2,defaultSymbolVisibility:1},1001:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:1,defaultSymbolVisibility:2}};function F2(H,$){var J,K;let Y={kind:"file",proto:H,deprecated:(K=(J=H.options)===null||J===void 0?void 0:J.deprecated)!==null&&K!==void 0?K:!1,edition:cH(H),name:H.name.replace(/\.proto$/,""),dependencies:uH(H,$),enums:[],messages:[],extensions:[],services:[],toString(){return`file ${H.name}`}},Q=new Map,z={get(A){return Q.get(A)},add(A){var X;w(((X=A.proto.options)===null||X===void 0?void 0:X.mapEntry)===!0),Q.set(A.typeName,A)}};for(let A of H.enumType)_2(A,Y,void 0,$);for(let A of H.messageType)b2(A,Y,void 0,$,z);for(let A of H.service)mH(A,Y,$);P0(Y,$);for(let A of Q.values())F0(A,$,z);for(let A of Y.messages)F0(A,$,z),P0(A,$);$.addFile(Y,!0)}function P0(H,$){switch(H.kind){case"file":for(let J of H.proto.extension){let K=h0(J,H,$);H.extensions.push(K),$.add(K)}break;case"message":for(let J of H.proto.extension){let K=h0(J,H,$);H.nestedExtensions.push(K),$.add(K)}for(let J of H.nestedMessages)P0(J,$);break}}function F0(H,$,J){let K=H.proto.oneofDecl.map((Q)=>vH(Q,H)),Y=new Set;for(let Q of H.proto.field){let z=dH(Q,K),A=h0(Q,H,$,z,J);if(H.fields.push(A),H.field[A.localName]=A,z===void 0)H.members.push(A);else if(z.fields.push(A),!Y.has(z))Y.add(z),H.members.push(z)}for(let Q of K.filter((z)=>Y.has(z)))H.oneofs.push(Q);for(let Q of H.nestedMessages)F0(Q,$,J)}function _2(H,$,J,K){var Y,Q,z,A,X;let Z=nH(H.name,H.value),L={kind:"enum",proto:H,deprecated:(Q=(Y=H.options)===null||Y===void 0?void 0:Y.deprecated)!==null&&Q!==void 0?Q:!1,file:$,parent:J,open:!0,name:H.name,typeName:J0(H,J,$),value:{},values:[],sharedPrefix:Z,toString(){return`enum ${this.typeName}`}};L.open=oH(L),K.add(L);for(let C of H.value){let V=C.name;L.values.push(L.value[C.number]={kind:"enum_value",proto:C,deprecated:(A=(z=C.options)===null||z===void 0?void 0:z.deprecated)!==null&&A!==void 0?A:!1,parent:L,name:V,localName:k(Z==null?V:V.substring(Z.length)),number:C.number,toString(){return`enum value ${L.typeName}.${V}`}})}((X=J===null||J===void 0?void 0:J.nestedEnums)!==null&&X!==void 0?X:$.enums).push(L)}function b2(H,$,J,K,Y){var Q,z,A,X;let Z={kind:"message",proto:H,deprecated:(z=(Q=H.options)===null||Q===void 0?void 0:Q.deprecated)!==null&&z!==void 0?z:!1,file:$,parent:J,name:H.name,typeName:J0(H,J,$),fields:[],field:{},oneofs:[],members:[],nestedEnums:[],nestedMessages:[],nestedExtensions:[],toString(){return`message ${this.typeName}`}};if(((A=H.options)===null||A===void 0?void 0:A.mapEntry)===!0)Y.add(Z);else((X=J===null||J===void 0?void 0:J.nestedMessages)!==null&&X!==void 0?X:$.messages).push(Z),K.add(Z);for(let L of H.enumType)_2(L,$,Z,K);for(let L of H.nestedType)b2(L,$,Z,K,Y)}function mH(H,$,J){var K,Y;let Q={kind:"service",proto:H,deprecated:(Y=(K=H.options)===null||K===void 0?void 0:K.deprecated)!==null&&Y!==void 0?Y:!1,file:$,name:H.name,typeName:J0(H,void 0,$),methods:[],method:{},toString(){return`service ${this.typeName}`}};$.services.push(Q),J.add(Q);for(let z of H.method){let A=gH(z,Q,J);Q.methods.push(A),Q.method[A.localName]=A}}function gH(H,$,J){var K,Y,Q,z;let A;if(H.clientStreaming&&H.serverStreaming)A="bidi_streaming";else if(H.clientStreaming)A="client_streaming";else if(H.serverStreaming)A="server_streaming";else A="unary";let X=J.getMessage(I(H.inputType)),Z=J.getMessage(I(H.outputType));w(X,`invalid MethodDescriptorProto: input_type ${H.inputType} not found`),w(Z,`invalid MethodDescriptorProto: output_type ${H.inputType} not found`);let L=H.name;return{kind:"rpc",proto:H,deprecated:(Y=(K=H.options)===null||K===void 0?void 0:K.deprecated)!==null&&Y!==void 0?Y:!1,parent:$,name:L,localName:k(L.length?k(L[0].toLowerCase()+L.substring(1)):L),methodKind:A,input:X,output:Z,idempotency:(z=(Q=H.options)===null||Q===void 0?void 0:Q.idempotencyLevel)!==null&&z!==void 0?z:_H,toString(){return`rpc ${$.typeName}.${L}`}}}function vH(H,$){return{kind:"oneof",proto:H,deprecated:!1,parent:$,fields:[],name:H.name,localName:k(h(H.name)),toString(){return`oneof ${$.typeName}.${this.name}`}}}function h0(H,$,J,K,Y){var Q,z,A;let X=Y===void 0,Z={kind:"field",proto:H,deprecated:(z=(Q=H.options)===null||Q===void 0?void 0:Q.deprecated)!==null&&z!==void 0?z:!1,name:H.name,number:H.number,scalar:void 0,message:void 0,enum:void 0,presence:pH(H,K,X,$),listKind:void 0,mapKind:void 0,mapKey:void 0,delimitedEncoding:void 0,packed:void 0,longAsString:!1,getDefaultValue:void 0};if(X){let G=$.kind=="file"?$:$.file,W=$.kind=="file"?void 0:$,B=J0(H,W,G);Z.kind="extension",Z.file=G,Z.parent=W,Z.oneof=void 0,Z.typeName=B,Z.jsonName=`[${B}]`,Z.toString=()=>`extension ${B}`;let F=J.getMessage(I(H.extendee));w(F,`invalid FieldDescriptorProto: extendee ${H.extendee} not found`),Z.extendee=F}else{let G=$;w(G.kind=="message"),Z.parent=G,Z.oneof=K,Z.localName=K?h(H.name):k(h(H.name)),Z.jsonName=H.jsonName,Z.toString=()=>`field ${G.typeName}.${H.name}`}let{label:L,type:C}=H,V=(A=H.options)===null||A===void 0?void 0:A.jstype;if(L===k0){let G=C==c?Y===null||Y===void 0?void 0:Y.get(I(H.typeName)):void 0;if(G){Z.fieldKind="map";let{key:W,value:B}=iH(G);return Z.mapKey=W.scalar,Z.mapKind=B.fieldKind,Z.message=B.message,Z.delimitedEncoding=!1,Z.enum=B.enum,Z.scalar=B.scalar,Z}switch(Z.fieldKind="list",C){case c:case u:Z.listKind="message",Z.message=J.getMessage(I(H.typeName)),w(Z.message),Z.delimitedEncoding=h2(H,$);break;case x2:Z.listKind="enum",Z.enum=J.getEnum(I(H.typeName)),w(Z.enum);break;default:Z.listKind="scalar",Z.scalar=C,Z.longAsString=V==M2;break}return Z.packed=sH(H,$),Z}switch(C){case c:case u:Z.fieldKind="message",Z.message=J.getMessage(I(H.typeName)),w(Z.message,`invalid FieldDescriptorProto: type_name ${H.typeName} not found`),Z.delimitedEncoding=h2(H,$),Z.getDefaultValue=()=>{return};break;case x2:{let G=J.getEnum(I(H.typeName));w(G!==void 0,`invalid FieldDescriptorProto: type_name ${H.typeName} not found`),Z.fieldKind="enum",Z.enum=J.getEnum(I(H.typeName)),Z.getDefaultValue=()=>{return x(H,"defaultValue")?j2(G,H.defaultValue):void 0};break}default:{Z.fieldKind="scalar",Z.scalar=C,Z.longAsString=V==M2,Z.getDefaultValue=()=>{return x(H,"defaultValue")?I2(C,H.defaultValue):void 0};break}}return Z}function cH(H){switch(H.syntax){case"":case"proto2":return PH;case"proto3":return FH;case"editions":if(H.edition in E2)return H.edition;throw Error(`${H.name}: unsupported edition`);default:throw Error(`${H.name}: unsupported syntax "${H.syntax}"`)}}function uH(H,$){return H.dependency.map((J)=>{let K=$.getFile(J);if(!K)throw Error(`Cannot find ${J}, imported by ${H.name}`);return K})}function nH(H,$){let J=fH(H)+"_";for(let K of $){if(!K.name.toLowerCase().startsWith(J))return;let Y=K.name.substring(J.length);if(Y.length==0)return;if(/^\d/.test(Y))return}return J}function fH(H){return(H.substring(0,1)+H.substring(1).replace(/[A-Z]/g,($)=>"_"+$)).toLowerCase()}function J0(H,$,J){let K;if($)K=`${$.typeName}.${H.name}`;else if(J.proto.package.length>0)K=`${J.proto.package}.${H.name}`;else K=`${H.name}`;return K}function I(H){return H.startsWith(".")?H.substring(1):H}function dH(H,$){if(!x(H,"oneofIndex"))return;if(H.proto3Optional)return;let J=$[H.oneofIndex];return w(J,`invalid FieldDescriptorProto: oneof #${H.oneofIndex} for field #${H.number} not found`),J}function pH(H,$,J,K){if(H.label==EH)return bH;if(H.label==k0)return P2;if(!!$||H.proto3Optional)return M0;if(J)return M0;let Y=E("fieldPresence",{proto:H,parent:K});if(Y==P2&&(H.type==c||H.type==u))return M0;return Y}function sH(H,$){if(H.label!=k0)return!1;switch(H.type){case hH:case kH:case u:case c:return!1}let J=H.options;if(J&&x(J,"packed"))return J.packed;return SH==E("repeatedFieldEncoding",{proto:H,parent:$})}function iH(H){let $=H.fields.find((K)=>K.number===1),J=H.fields.find((K)=>K.number===2);return w($&&$.fieldKind=="scalar"&&$.scalar!=q.BYTES&&$.scalar!=q.FLOAT&&$.scalar!=q.DOUBLE&&J&&J.fieldKind!="list"&&J.fieldKind!="map"),{key:$,value:J}}function oH(H){var $;return yH==E("enumType",{proto:H.proto,parent:($=H.parent)!==null&&$!==void 0?$:H.file})}function h2(H,$){if(H.type==u)return!0;return TH==E("messageEncoding",{proto:H,parent:$})}function E(H,$){var J,K;let Y=(J=$.proto.options)===null||J===void 0?void 0:J.features;if(Y){let Q=Y[H];if(Q!=0)return Q}if("kind"in $){if($.kind=="message")return E(H,(K=$.parent)!==null&&K!==void 0?K:$.file);let Q=E2[$.edition];if(!Q)throw Error(`feature default for edition ${$.edition} not found`);return Q[H]}return E(H,$.parent)}function w(H,$){if(!H)throw Error($)}function S2(H){let $=rH(H);return $.messageType.forEach(x0),k2($,()=>{return}).getFile($.name)}function rH(H){let $=Object.create({syntax:"",edition:0});return Object.assign($,Object.assign(Object.assign({$typeName:"google.protobuf.FileDescriptorProto",dependency:[],publicDependency:[],weakDependency:[],optionDependency:[],service:[],extension:[]},H),{messageType:H.messageType.map(T2),enumType:H.enumType.map(y2)}))}function T2(H){var $,J,K,Y,Q,z,A,X;let Z=Object.create({visibility:0});return Object.assign(Z,{$typeName:"google.protobuf.DescriptorProto",name:H.name,field:(J=($=H.field)===null||$===void 0?void 0:$.map(lH))!==null&&J!==void 0?J:[],extension:[],nestedType:(Y=(K=H.nestedType)===null||K===void 0?void 0:K.map(T2))!==null&&Y!==void 0?Y:[],enumType:(z=(Q=H.enumType)===null||Q===void 0?void 0:Q.map(y2))!==null&&z!==void 0?z:[],extensionRange:(X=(A=H.extensionRange)===null||A===void 0?void 0:A.map((L)=>Object.assign({$typeName:"google.protobuf.DescriptorProto.ExtensionRange"},L)))!==null&&X!==void 0?X:[],oneofDecl:[],reservedRange:[],reservedName:[]})}function lH(H){let $=Object.create({label:1,typeName:"",extendee:"",defaultValue:"",oneofIndex:0,jsonName:"",proto3Optional:!1});return Object.assign($,Object.assign(Object.assign({$typeName:"google.protobuf.FieldDescriptorProto"},H),{options:H.options?tH(H.options):void 0}))}function tH(H){var $,J,K;let Y=Object.create({ctype:0,packed:!1,jstype:0,lazy:!1,unverifiedLazy:!1,deprecated:!1,weak:!1,debugRedact:!1,retention:0});return Object.assign(Y,Object.assign(Object.assign({$typeName:"google.protobuf.FieldOptions"},H),{targets:($=H.targets)!==null&&$!==void 0?$:[],editionDefaults:(K=(J=H.editionDefaults)===null||J===void 0?void 0:J.map((Q)=>Object.assign({$typeName:"google.protobuf.FieldOptions.EditionDefault"},Q)))!==null&&K!==void 0?K:[],uninterpretedOption:[]}))}function y2(H){let $=Object.create({visibility:0});return Object.assign($,{$typeName:"google.protobuf.EnumDescriptorProto",name:H.name,reservedName:[],reservedRange:[],value:H.value.map((J)=>Object.assign({$typeName:"google.protobuf.EnumValueDescriptorProto"},J))})}function m2(H,$,...J){return J.reduce((K,Y)=>K.nestedMessages[Y],H.messages[$])}var aH=S2({name:"google/protobuf/descriptor.proto",package:"google.protobuf",messageType:[{name:"FileDescriptorSet",field:[{name:"file",number:1,type:11,label:3,typeName:".google.protobuf.FileDescriptorProto"}],extensionRange:[{start:536000000,end:536000001}]},{name:"FileDescriptorProto",field:[{name:"name",number:1,type:9,label:1},{name:"package",number:2,type:9,label:1},{name:"dependency",number:3,type:9,label:3},{name:"public_dependency",number:10,type:5,label:3},{name:"weak_dependency",number:11,type:5,label:3},{name:"option_dependency",number:15,type:9,label:3},{name:"message_type",number:4,type:11,label:3,typeName:".google.protobuf.DescriptorProto"},{name:"enum_type",number:5,type:11,label:3,typeName:".google.protobuf.EnumDescriptorProto"},{name:"service",number:6,type:11,label:3,typeName:".google.protobuf.ServiceDescriptorProto"},{name:"extension",number:7,type:11,label:3,typeName:".google.protobuf.FieldDescriptorProto"},{name:"options",number:8,type:11,label:1,typeName:".google.protobuf.FileOptions"},{name:"source_code_info",number:9,type:11,label:1,typeName:".google.protobuf.SourceCodeInfo"},{name:"syntax",number:12,type:9,label:1},{name:"edition",number:14,type:14,label:1,typeName:".google.protobuf.Edition"}]},{name:"DescriptorProto",field:[{name:"name",number:1,type:9,label:1},{name:"field",number:2,type:11,label:3,typeName:".google.protobuf.FieldDescriptorProto"},{name:"extension",number:6,type:11,label:3,typeName:".google.protobuf.FieldDescriptorProto"},{name:"nested_type",number:3,type:11,label:3,typeName:".google.protobuf.DescriptorProto"},{name:"enum_type",number:4,type:11,label:3,typeName:".google.protobuf.EnumDescriptorProto"},{name:"extension_range",number:5,type:11,label:3,typeName:".google.protobuf.DescriptorProto.ExtensionRange"},{name:"oneof_decl",number:8,type:11,label:3,typeName:".google.protobuf.OneofDescriptorProto"},{name:"options",number:7,type:11,label:1,typeName:".google.protobuf.MessageOptions"},{name:"reserved_range",number:9,type:11,label:3,typeName:".google.protobuf.DescriptorProto.ReservedRange"},{name:"reserved_name",number:10,type:9,label:3},{name:"visibility",number:11,type:14,label:1,typeName:".google.protobuf.SymbolVisibility"}],nestedType:[{name:"ExtensionRange",field:[{name:"start",number:1,type:5,label:1},{name:"end",number:2,type:5,label:1},{name:"options",number:3,type:11,label:1,typeName:".google.protobuf.ExtensionRangeOptions"}]},{name:"ReservedRange",field:[{name:"start",number:1,type:5,label:1},{name:"end",number:2,type:5,label:1}]}]},{name:"ExtensionRangeOptions",field:[{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"},{name:"declaration",number:2,type:11,label:3,typeName:".google.protobuf.ExtensionRangeOptions.Declaration",options:{retention:2}},{name:"features",number:50,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"verification",number:3,type:14,label:1,typeName:".google.protobuf.ExtensionRangeOptions.VerificationState",defaultValue:"UNVERIFIED",options:{retention:2}}],nestedType:[{name:"Declaration",field:[{name:"number",number:1,type:5,label:1},{name:"full_name",number:2,type:9,label:1},{name:"type",number:3,type:9,label:1},{name:"reserved",number:5,type:8,label:1},{name:"repeated",number:6,type:8,label:1}]}],enumType:[{name:"VerificationState",value:[{name:"DECLARATION",number:0},{name:"UNVERIFIED",number:1}]}],extensionRange:[{start:1000,end:536870912}]},{name:"FieldDescriptorProto",field:[{name:"name",number:1,type:9,label:1},{name:"number",number:3,type:5,label:1},{name:"label",number:4,type:14,label:1,typeName:".google.protobuf.FieldDescriptorProto.Label"},{name:"type",number:5,type:14,label:1,typeName:".google.protobuf.FieldDescriptorProto.Type"},{name:"type_name",number:6,type:9,label:1},{name:"extendee",number:2,type:9,label:1},{name:"default_value",number:7,type:9,label:1},{name:"oneof_index",number:9,type:5,label:1},{name:"json_name",number:10,type:9,label:1},{name:"options",number:8,type:11,label:1,typeName:".google.protobuf.FieldOptions"},{name:"proto3_optional",number:17,type:8,label:1}],enumType:[{name:"Type",value:[{name:"TYPE_DOUBLE",number:1},{name:"TYPE_FLOAT",number:2},{name:"TYPE_INT64",number:3},{name:"TYPE_UINT64",number:4},{name:"TYPE_INT32",number:5},{name:"TYPE_FIXED64",number:6},{name:"TYPE_FIXED32",number:7},{name:"TYPE_BOOL",number:8},{name:"TYPE_STRING",number:9},{name:"TYPE_GROUP",number:10},{name:"TYPE_MESSAGE",number:11},{name:"TYPE_BYTES",number:12},{name:"TYPE_UINT32",number:13},{name:"TYPE_ENUM",number:14},{name:"TYPE_SFIXED32",number:15},{name:"TYPE_SFIXED64",number:16},{name:"TYPE_SINT32",number:17},{name:"TYPE_SINT64",number:18}]},{name:"Label",value:[{name:"LABEL_OPTIONAL",number:1},{name:"LABEL_REPEATED",number:3},{name:"LABEL_REQUIRED",number:2}]}]},{name:"OneofDescriptorProto",field:[{name:"name",number:1,type:9,label:1},{name:"options",number:2,type:11,label:1,typeName:".google.protobuf.OneofOptions"}]},{name:"EnumDescriptorProto",field:[{name:"name",number:1,type:9,label:1},{name:"value",number:2,type:11,label:3,typeName:".google.protobuf.EnumValueDescriptorProto"},{name:"options",number:3,type:11,label:1,typeName:".google.protobuf.EnumOptions"},{name:"reserved_range",number:4,type:11,label:3,typeName:".google.protobuf.EnumDescriptorProto.EnumReservedRange"},{name:"reserved_name",number:5,type:9,label:3},{name:"visibility",number:6,type:14,label:1,typeName:".google.protobuf.SymbolVisibility"}],nestedType:[{name:"EnumReservedRange",field:[{name:"start",number:1,type:5,label:1},{name:"end",number:2,type:5,label:1}]}]},{name:"EnumValueDescriptorProto",field:[{name:"name",number:1,type:9,label:1},{name:"number",number:2,type:5,label:1},{name:"options",number:3,type:11,label:1,typeName:".google.protobuf.EnumValueOptions"}]},{name:"ServiceDescriptorProto",field:[{name:"name",number:1,type:9,label:1},{name:"method",number:2,type:11,label:3,typeName:".google.protobuf.MethodDescriptorProto"},{name:"options",number:3,type:11,label:1,typeName:".google.protobuf.ServiceOptions"}]},{name:"MethodDescriptorProto",field:[{name:"name",number:1,type:9,label:1},{name:"input_type",number:2,type:9,label:1},{name:"output_type",number:3,type:9,label:1},{name:"options",number:4,type:11,label:1,typeName:".google.protobuf.MethodOptions"},{name:"client_streaming",number:5,type:8,label:1,defaultValue:"false"},{name:"server_streaming",number:6,type:8,label:1,defaultValue:"false"}]},{name:"FileOptions",field:[{name:"java_package",number:1,type:9,label:1},{name:"java_outer_classname",number:8,type:9,label:1},{name:"java_multiple_files",number:10,type:8,label:1,defaultValue:"false"},{name:"java_generate_equals_and_hash",number:20,type:8,label:1,options:{deprecated:!0}},{name:"java_string_check_utf8",number:27,type:8,label:1,defaultValue:"false"},{name:"optimize_for",number:9,type:14,label:1,typeName:".google.protobuf.FileOptions.OptimizeMode",defaultValue:"SPEED"},{name:"go_package",number:11,type:9,label:1},{name:"cc_generic_services",number:16,type:8,label:1,defaultValue:"false"},{name:"java_generic_services",number:17,type:8,label:1,defaultValue:"false"},{name:"py_generic_services",number:18,type:8,label:1,defaultValue:"false"},{name:"deprecated",number:23,type:8,label:1,defaultValue:"false"},{name:"cc_enable_arenas",number:31,type:8,label:1,defaultValue:"true"},{name:"objc_class_prefix",number:36,type:9,label:1},{name:"csharp_namespace",number:37,type:9,label:1},{name:"swift_prefix",number:39,type:9,label:1},{name:"php_class_prefix",number:40,type:9,label:1},{name:"php_namespace",number:41,type:9,label:1},{name:"php_metadata_namespace",number:44,type:9,label:1},{name:"ruby_package",number:45,type:9,label:1},{name:"features",number:50,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"}],enumType:[{name:"OptimizeMode",value:[{name:"SPEED",number:1},{name:"CODE_SIZE",number:2},{name:"LITE_RUNTIME",number:3}]}],extensionRange:[{start:1000,end:536870912}]},{name:"MessageOptions",field:[{name:"message_set_wire_format",number:1,type:8,label:1,defaultValue:"false"},{name:"no_standard_descriptor_accessor",number:2,type:8,label:1,defaultValue:"false"},{name:"deprecated",number:3,type:8,label:1,defaultValue:"false"},{name:"map_entry",number:7,type:8,label:1},{name:"deprecated_legacy_json_field_conflicts",number:11,type:8,label:1,options:{deprecated:!0}},{name:"features",number:12,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"}],extensionRange:[{start:1000,end:536870912}]},{name:"FieldOptions",field:[{name:"ctype",number:1,type:14,label:1,typeName:".google.protobuf.FieldOptions.CType",defaultValue:"STRING"},{name:"packed",number:2,type:8,label:1},{name:"jstype",number:6,type:14,label:1,typeName:".google.protobuf.FieldOptions.JSType",defaultValue:"JS_NORMAL"},{name:"lazy",number:5,type:8,label:1,defaultValue:"false"},{name:"unverified_lazy",number:15,type:8,label:1,defaultValue:"false"},{name:"deprecated",number:3,type:8,label:1,defaultValue:"false"},{name:"weak",number:10,type:8,label:1,defaultValue:"false",options:{deprecated:!0}},{name:"debug_redact",number:16,type:8,label:1,defaultValue:"false"},{name:"retention",number:17,type:14,label:1,typeName:".google.protobuf.FieldOptions.OptionRetention"},{name:"targets",number:19,type:14,label:3,typeName:".google.protobuf.FieldOptions.OptionTargetType"},{name:"edition_defaults",number:20,type:11,label:3,typeName:".google.protobuf.FieldOptions.EditionDefault"},{name:"features",number:21,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"feature_support",number:22,type:11,label:1,typeName:".google.protobuf.FieldOptions.FeatureSupport"},{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"}],nestedType:[{name:"EditionDefault",field:[{name:"edition",number:3,type:14,label:1,typeName:".google.protobuf.Edition"},{name:"value",number:2,type:9,label:1}]},{name:"FeatureSupport",field:[{name:"edition_introduced",number:1,type:14,label:1,typeName:".google.protobuf.Edition"},{name:"edition_deprecated",number:2,type:14,label:1,typeName:".google.protobuf.Edition"},{name:"deprecation_warning",number:3,type:9,label:1},{name:"edition_removed",number:4,type:14,label:1,typeName:".google.protobuf.Edition"}]}],enumType:[{name:"CType",value:[{name:"STRING",number:0},{name:"CORD",number:1},{name:"STRING_PIECE",number:2}]},{name:"JSType",value:[{name:"JS_NORMAL",number:0},{name:"JS_STRING",number:1},{name:"JS_NUMBER",number:2}]},{name:"OptionRetention",value:[{name:"RETENTION_UNKNOWN",number:0},{name:"RETENTION_RUNTIME",number:1},{name:"RETENTION_SOURCE",number:2}]},{name:"OptionTargetType",value:[{name:"TARGET_TYPE_UNKNOWN",number:0},{name:"TARGET_TYPE_FILE",number:1},{name:"TARGET_TYPE_EXTENSION_RANGE",number:2},{name:"TARGET_TYPE_MESSAGE",number:3},{name:"TARGET_TYPE_FIELD",number:4},{name:"TARGET_TYPE_ONEOF",number:5},{name:"TARGET_TYPE_ENUM",number:6},{name:"TARGET_TYPE_ENUM_ENTRY",number:7},{name:"TARGET_TYPE_SERVICE",number:8},{name:"TARGET_TYPE_METHOD",number:9}]}],extensionRange:[{start:1000,end:536870912}]},{name:"OneofOptions",field:[{name:"features",number:1,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"}],extensionRange:[{start:1000,end:536870912}]},{name:"EnumOptions",field:[{name:"allow_alias",number:2,type:8,label:1},{name:"deprecated",number:3,type:8,label:1,defaultValue:"false"},{name:"deprecated_legacy_json_field_conflicts",number:6,type:8,label:1,options:{deprecated:!0}},{name:"features",number:7,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"}],extensionRange:[{start:1000,end:536870912}]},{name:"EnumValueOptions",field:[{name:"deprecated",number:1,type:8,label:1,defaultValue:"false"},{name:"features",number:2,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"debug_redact",number:3,type:8,label:1,defaultValue:"false"},{name:"feature_support",number:4,type:11,label:1,typeName:".google.protobuf.FieldOptions.FeatureSupport"},{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"}],extensionRange:[{start:1000,end:536870912}]},{name:"ServiceOptions",field:[{name:"features",number:34,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"deprecated",number:33,type:8,label:1,defaultValue:"false"},{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"}],extensionRange:[{start:1000,end:536870912}]},{name:"MethodOptions",field:[{name:"deprecated",number:33,type:8,label:1,defaultValue:"false"},{name:"idempotency_level",number:34,type:14,label:1,typeName:".google.protobuf.MethodOptions.IdempotencyLevel",defaultValue:"IDEMPOTENCY_UNKNOWN"},{name:"features",number:35,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"uninterpreted_option",number:999,type:11,label:3,typeName:".google.protobuf.UninterpretedOption"}],enumType:[{name:"IdempotencyLevel",value:[{name:"IDEMPOTENCY_UNKNOWN",number:0},{name:"NO_SIDE_EFFECTS",number:1},{name:"IDEMPOTENT",number:2}]}],extensionRange:[{start:1000,end:536870912}]},{name:"UninterpretedOption",field:[{name:"name",number:2,type:11,label:3,typeName:".google.protobuf.UninterpretedOption.NamePart"},{name:"identifier_value",number:3,type:9,label:1},{name:"positive_int_value",number:4,type:4,label:1},{name:"negative_int_value",number:5,type:3,label:1},{name:"double_value",number:6,type:1,label:1},{name:"string_value",number:7,type:12,label:1},{name:"aggregate_value",number:8,type:9,label:1}],nestedType:[{name:"NamePart",field:[{name:"name_part",number:1,type:9,label:2},{name:"is_extension",number:2,type:8,label:2}]}]},{name:"FeatureSet",field:[{name:"field_presence",number:1,type:14,label:1,typeName:".google.protobuf.FeatureSet.FieldPresence",options:{retention:1,targets:[4,1],editionDefaults:[{value:"EXPLICIT",edition:900},{value:"IMPLICIT",edition:999},{value:"EXPLICIT",edition:1000}]}},{name:"enum_type",number:2,type:14,label:1,typeName:".google.protobuf.FeatureSet.EnumType",options:{retention:1,targets:[6,1],editionDefaults:[{value:"CLOSED",edition:900},{value:"OPEN",edition:999}]}},{name:"repeated_field_encoding",number:3,type:14,label:1,typeName:".google.protobuf.FeatureSet.RepeatedFieldEncoding",options:{retention:1,targets:[4,1],editionDefaults:[{value:"EXPANDED",edition:900},{value:"PACKED",edition:999}]}},{name:"utf8_validation",number:4,type:14,label:1,typeName:".google.protobuf.FeatureSet.Utf8Validation",options:{retention:1,targets:[4,1],editionDefaults:[{value:"NONE",edition:900},{value:"VERIFY",edition:999}]}},{name:"message_encoding",number:5,type:14,label:1,typeName:".google.protobuf.FeatureSet.MessageEncoding",options:{retention:1,targets:[4,1],editionDefaults:[{value:"LENGTH_PREFIXED",edition:900}]}},{name:"json_format",number:6,type:14,label:1,typeName:".google.protobuf.FeatureSet.JsonFormat",options:{retention:1,targets:[3,6,1],editionDefaults:[{value:"LEGACY_BEST_EFFORT",edition:900},{value:"ALLOW",edition:999}]}},{name:"enforce_naming_style",number:7,type:14,label:1,typeName:".google.protobuf.FeatureSet.EnforceNamingStyle",options:{retention:2,targets:[1,2,3,4,5,6,7,8,9],editionDefaults:[{value:"STYLE_LEGACY",edition:900},{value:"STYLE2024",edition:1001}]}},{name:"default_symbol_visibility",number:8,type:14,label:1,typeName:".google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility",options:{retention:2,targets:[1],editionDefaults:[{value:"EXPORT_ALL",edition:900},{value:"EXPORT_TOP_LEVEL",edition:1001}]}}],nestedType:[{name:"VisibilityFeature",enumType:[{name:"DefaultSymbolVisibility",value:[{name:"DEFAULT_SYMBOL_VISIBILITY_UNKNOWN",number:0},{name:"EXPORT_ALL",number:1},{name:"EXPORT_TOP_LEVEL",number:2},{name:"LOCAL_ALL",number:3},{name:"STRICT",number:4}]}]}],enumType:[{name:"FieldPresence",value:[{name:"FIELD_PRESENCE_UNKNOWN",number:0},{name:"EXPLICIT",number:1},{name:"IMPLICIT",number:2},{name:"LEGACY_REQUIRED",number:3}]},{name:"EnumType",value:[{name:"ENUM_TYPE_UNKNOWN",number:0},{name:"OPEN",number:1},{name:"CLOSED",number:2}]},{name:"RepeatedFieldEncoding",value:[{name:"REPEATED_FIELD_ENCODING_UNKNOWN",number:0},{name:"PACKED",number:1},{name:"EXPANDED",number:2}]},{name:"Utf8Validation",value:[{name:"UTF8_VALIDATION_UNKNOWN",number:0},{name:"VERIFY",number:2},{name:"NONE",number:3}]},{name:"MessageEncoding",value:[{name:"MESSAGE_ENCODING_UNKNOWN",number:0},{name:"LENGTH_PREFIXED",number:1},{name:"DELIMITED",number:2}]},{name:"JsonFormat",value:[{name:"JSON_FORMAT_UNKNOWN",number:0},{name:"ALLOW",number:1},{name:"LEGACY_BEST_EFFORT",number:2}]},{name:"EnforceNamingStyle",value:[{name:"ENFORCE_NAMING_STYLE_UNKNOWN",number:0},{name:"STYLE2024",number:1},{name:"STYLE_LEGACY",number:2}]}],extensionRange:[{start:1000,end:9995},{start:9995,end:1e4},{start:1e4,end:10001}]},{name:"FeatureSetDefaults",field:[{name:"defaults",number:1,type:11,label:3,typeName:".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault"},{name:"minimum_edition",number:4,type:14,label:1,typeName:".google.protobuf.Edition"},{name:"maximum_edition",number:5,type:14,label:1,typeName:".google.protobuf.Edition"}],nestedType:[{name:"FeatureSetEditionDefault",field:[{name:"edition",number:3,type:14,label:1,typeName:".google.protobuf.Edition"},{name:"overridable_features",number:4,type:11,label:1,typeName:".google.protobuf.FeatureSet"},{name:"fixed_features",number:5,type:11,label:1,typeName:".google.protobuf.FeatureSet"}]}]},{name:"SourceCodeInfo",field:[{name:"location",number:1,type:11,label:3,typeName:".google.protobuf.SourceCodeInfo.Location"}],nestedType:[{name:"Location",field:[{name:"path",number:1,type:5,label:3,options:{packed:!0}},{name:"span",number:2,type:5,label:3,options:{packed:!0}},{name:"leading_comments",number:3,type:9,label:1},{name:"trailing_comments",number:4,type:9,label:1},{name:"leading_detached_comments",number:6,type:9,label:3}]}],extensionRange:[{start:536000000,end:536000001}]},{name:"GeneratedCodeInfo",field:[{name:"annotation",number:1,type:11,label:3,typeName:".google.protobuf.GeneratedCodeInfo.Annotation"}],nestedType:[{name:"Annotation",field:[{name:"path",number:1,type:5,label:3,options:{packed:!0}},{name:"source_file",number:2,type:9,label:1},{name:"begin",number:3,type:5,label:1},{name:"end",number:4,type:5,label:1},{name:"semantic",number:5,type:14,label:1,typeName:".google.protobuf.GeneratedCodeInfo.Annotation.Semantic"}],enumType:[{name:"Semantic",value:[{name:"NONE",number:0},{name:"SET",number:1},{name:"ALIAS",number:2}]}]}]}],enumType:[{name:"Edition",value:[{name:"EDITION_UNKNOWN",number:0},{name:"EDITION_LEGACY",number:900},{name:"EDITION_PROTO2",number:998},{name:"EDITION_PROTO3",number:999},{name:"EDITION_2023",number:1000},{name:"EDITION_2024",number:1001},{name:"EDITION_UNSTABLE",number:9999},{name:"EDITION_1_TEST_ONLY",number:1},{name:"EDITION_2_TEST_ONLY",number:2},{name:"EDITION_99997_TEST_ONLY",number:99997},{name:"EDITION_99998_TEST_ONLY",number:99998},{name:"EDITION_99999_TEST_ONLY",number:99999},{name:"EDITION_MAX",number:2147483647}]},{name:"SymbolVisibility",value:[{name:"VISIBILITY_UNSET",number:0},{name:"VISIBILITY_LOCAL",number:1},{name:"VISIBILITY_EXPORT",number:2}]}]}),QH=m2(aH,0);var g2;(function(H){H[H.DECLARATION=0]="DECLARATION",H[H.UNVERIFIED=1]="UNVERIFIED"})(g2||(g2={}));var v2;(function(H){H[H.DOUBLE=1]="DOUBLE",H[H.FLOAT=2]="FLOAT",H[H.INT64=3]="INT64",H[H.UINT64=4]="UINT64",H[H.INT32=5]="INT32",H[H.FIXED64=6]="FIXED64",H[H.FIXED32=7]="FIXED32",H[H.BOOL=8]="BOOL",H[H.STRING=9]="STRING",H[H.GROUP=10]="GROUP",H[H.MESSAGE=11]="MESSAGE",H[H.BYTES=12]="BYTES",H[H.UINT32=13]="UINT32",H[H.ENUM=14]="ENUM",H[H.SFIXED32=15]="SFIXED32",H[H.SFIXED64=16]="SFIXED64",H[H.SINT32=17]="SINT32",H[H.SINT64=18]="SINT64"})(v2||(v2={}));var c2;(function(H){H[H.OPTIONAL=1]="OPTIONAL",H[H.REPEATED=3]="REPEATED",H[H.REQUIRED=2]="REQUIRED"})(c2||(c2={}));var u2;(function(H){H[H.SPEED=1]="SPEED",H[H.CODE_SIZE=2]="CODE_SIZE",H[H.LITE_RUNTIME=3]="LITE_RUNTIME"})(u2||(u2={}));var n2;(function(H){H[H.STRING=0]="STRING",H[H.CORD=1]="CORD",H[H.STRING_PIECE=2]="STRING_PIECE"})(n2||(n2={}));var f2;(function(H){H[H.JS_NORMAL=0]="JS_NORMAL",H[H.JS_STRING=1]="JS_STRING",H[H.JS_NUMBER=2]="JS_NUMBER"})(f2||(f2={}));var d2;(function(H){H[H.RETENTION_UNKNOWN=0]="RETENTION_UNKNOWN",H[H.RETENTION_RUNTIME=1]="RETENTION_RUNTIME",H[H.RETENTION_SOURCE=2]="RETENTION_SOURCE"})(d2||(d2={}));var p2;(function(H){H[H.TARGET_TYPE_UNKNOWN=0]="TARGET_TYPE_UNKNOWN",H[H.TARGET_TYPE_FILE=1]="TARGET_TYPE_FILE",H[H.TARGET_TYPE_EXTENSION_RANGE=2]="TARGET_TYPE_EXTENSION_RANGE",H[H.TARGET_TYPE_MESSAGE=3]="TARGET_TYPE_MESSAGE",H[H.TARGET_TYPE_FIELD=4]="TARGET_TYPE_FIELD",H[H.TARGET_TYPE_ONEOF=5]="TARGET_TYPE_ONEOF",H[H.TARGET_TYPE_ENUM=6]="TARGET_TYPE_ENUM",H[H.TARGET_TYPE_ENUM_ENTRY=7]="TARGET_TYPE_ENUM_ENTRY",H[H.TARGET_TYPE_SERVICE=8]="TARGET_TYPE_SERVICE",H[H.TARGET_TYPE_METHOD=9]="TARGET_TYPE_METHOD"})(p2||(p2={}));var s2;(function(H){H[H.IDEMPOTENCY_UNKNOWN=0]="IDEMPOTENCY_UNKNOWN",H[H.NO_SIDE_EFFECTS=1]="NO_SIDE_EFFECTS",H[H.IDEMPOTENT=2]="IDEMPOTENT"})(s2||(s2={}));var i2;(function(H){H[H.DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0]="DEFAULT_SYMBOL_VISIBILITY_UNKNOWN",H[H.EXPORT_ALL=1]="EXPORT_ALL",H[H.EXPORT_TOP_LEVEL=2]="EXPORT_TOP_LEVEL",H[H.LOCAL_ALL=3]="LOCAL_ALL",H[H.STRICT=4]="STRICT"})(i2||(i2={}));var o2;(function(H){H[H.FIELD_PRESENCE_UNKNOWN=0]="FIELD_PRESENCE_UNKNOWN",H[H.EXPLICIT=1]="EXPLICIT",H[H.IMPLICIT=2]="IMPLICIT",H[H.LEGACY_REQUIRED=3]="LEGACY_REQUIRED"})(o2||(o2={}));var r2;(function(H){H[H.ENUM_TYPE_UNKNOWN=0]="ENUM_TYPE_UNKNOWN",H[H.OPEN=1]="OPEN",H[H.CLOSED=2]="CLOSED"})(r2||(r2={}));var l2;(function(H){H[H.REPEATED_FIELD_ENCODING_UNKNOWN=0]="REPEATED_FIELD_ENCODING_UNKNOWN",H[H.PACKED=1]="PACKED",H[H.EXPANDED=2]="EXPANDED"})(l2||(l2={}));var t2;(function(H){H[H.UTF8_VALIDATION_UNKNOWN=0]="UTF8_VALIDATION_UNKNOWN",H[H.VERIFY=2]="VERIFY",H[H.NONE=3]="NONE"})(t2||(t2={}));var a2;(function(H){H[H.MESSAGE_ENCODING_UNKNOWN=0]="MESSAGE_ENCODING_UNKNOWN",H[H.LENGTH_PREFIXED=1]="LENGTH_PREFIXED",H[H.DELIMITED=2]="DELIMITED"})(a2||(a2={}));var e2;(function(H){H[H.JSON_FORMAT_UNKNOWN=0]="JSON_FORMAT_UNKNOWN",H[H.ALLOW=1]="ALLOW",H[H.LEGACY_BEST_EFFORT=2]="LEGACY_BEST_EFFORT"})(e2||(e2={}));var HH;(function(H){H[H.ENFORCE_NAMING_STYLE_UNKNOWN=0]="ENFORCE_NAMING_STYLE_UNKNOWN",H[H.STYLE2024=1]="STYLE2024",H[H.STYLE_LEGACY=2]="STYLE_LEGACY"})(HH||(HH={}));var $H;(function(H){H[H.NONE=0]="NONE",H[H.SET=1]="SET",H[H.ALIAS=2]="ALIAS"})($H||($H={}));var JH;(function(H){H[H.EDITION_UNKNOWN=0]="EDITION_UNKNOWN",H[H.EDITION_LEGACY=900]="EDITION_LEGACY",H[H.EDITION_PROTO2=998]="EDITION_PROTO2",H[H.EDITION_PROTO3=999]="EDITION_PROTO3",H[H.EDITION_2023=1000]="EDITION_2023",H[H.EDITION_2024=1001]="EDITION_2024",H[H.EDITION_UNSTABLE=9999]="EDITION_UNSTABLE",H[H.EDITION_1_TEST_ONLY=1]="EDITION_1_TEST_ONLY",H[H.EDITION_2_TEST_ONLY=2]="EDITION_2_TEST_ONLY",H[H.EDITION_99997_TEST_ONLY=99997]="EDITION_99997_TEST_ONLY",H[H.EDITION_99998_TEST_ONLY=99998]="EDITION_99998_TEST_ONLY",H[H.EDITION_99999_TEST_ONLY=99999]="EDITION_99999_TEST_ONLY",H[H.EDITION_MAX=2147483647]="EDITION_MAX"})(JH||(JH={}));var KH;(function(H){H[H.VISIBILITY_UNSET=0]="VISIBILITY_UNSET",H[H.VISIBILITY_LOCAL=1]="VISIBILITY_LOCAL",H[H.VISIBILITY_EXPORT=2]="VISIBILITY_EXPORT"})(KH||(KH={}));var YH={readUnknownFields:!0};function eH(H){return H?Object.assign(Object.assign({},YH),H):YH}function E0(H,$,J){let K=H0(H,void 0,!1);return zH(K,new V0($),eH(J),!1,$.byteLength),K.message}function zH(H,$,J,K,Y){var Q;let z=K?$.len:$.pos+Y,A,X,Z=(Q=H.getUnknown())!==null&&Q!==void 0?Q:[];while($.pos<z){if([A,X]=$.tag(),K&&X==R.EndGroup)break;let L=H.findNumber(A);if(!L){let C=$.skip(X,A);if(J.readUnknownFields)Z.push({no:A,wireType:X,data:C});continue}H1(H,$,L,X,J)}if(K){if(X!=R.EndGroup||A!==Y)throw Error("invalid end group tag")}if(Z.length>0)H.setUnknown(Z)}function H1(H,$,J,K,Y){var Q;switch(J.fieldKind){case"scalar":H.set(J,_($,J.scalar));break;case"enum":let z=_($,q.INT32);if(J.enum.open)H.set(J,z);else if(J.enum.values.some((X)=>X.number===z))H.set(J,z);else if(Y.readUnknownFields){let X=[];Z0(z,X);let Z=(Q=H.getUnknown())!==null&&Q!==void 0?Q:[];Z.push({no:J.number,wireType:K,data:new Uint8Array(X)}),H.setUnknown(Z)}break;case"message":H.set(J,_0($,Y,J,H.get(J)));break;case"list":J1($,K,H.get(J),Y);break;case"map":$1($,H.get(J),Y);break}}function $1(H,$,J){let K=$.field(),Y,Q,z=H.uint32(),A=H.pos+z;while(H.pos<A){let[X]=H.tag();switch(X){case 1:Y=_(H,K.mapKey);break;case 2:switch(K.mapKind){case"scalar":Q=_(H,K.scalar);break;case"enum":Q=H.int32();break;case"message":Q=_0(H,J,K);break}break}}if(Y===void 0)Y=D(K.mapKey,!1);if(Q===void 0)switch(K.mapKind){case"scalar":Q=D(K.scalar,!1);break;case"enum":Q=K.enum.values[0].number;break;case"message":Q=H0(K.message,void 0,!1);break}$.set(Y,Q)}function J1(H,$,J,K){var Y;let Q=J.field();if(Q.listKind==="message"){J.add(_0(H,K,Q));return}let z=(Y=Q.scalar)!==null&&Y!==void 0?Y:q.INT32;if(!($==R.LengthDelimited&&z!=q.STRING&&z!=q.BYTES)){J.add(_(H,z));return}let X=H.uint32()+H.pos;while(H.pos<X)J.add(_(H,z))}function _0(H,$,J,K){let Y=J.delimitedEncoding,Q=K!==null&&K!==void 0?K:H0(J.message,void 0,!1);return zH(Q,H,$,Y,Y?J.number:H.uint32()),Q}function _(H,$){switch($){case q.STRING:return H.string();case q.BOOL:return H.bool();case q.DOUBLE:return H.double();case q.FLOAT:return H.float();case q.INT32:return H.int32();case q.INT64:return H.int64();case q.UINT64:return H.uint64();case q.FIXED64:return H.fixed64();case q.BYTES:return H.bytes();case q.FIXED32:return H.fixed32();case q.SFIXED32:return H.sfixed32();case q.SFIXED64:return H.sfixed64();case q.SINT64:return H.sint64();case q.UINT32:return H.uint32();case q.SINT32:return H.sint32()}}var K0=!1;class b0{descriptor;buffer=[];indentLevel=0;messagePath=[];constructor(H){this.descriptor=H}format(){if(this.buffer=[],this.indentLevel=0,this.messagePath=[],this.line('syntax = "proto2";'),this.emptyLine(),this.descriptor.edition)this.line(`// edition = ${this.descriptor.edition};`);if(this.descriptor.package)this.line(`package ${this.descriptor.package};`),this.emptyLine();this.printFileOptions();for(let H=0;H<this.descriptor.dependency.length;H++){let $=this.descriptor.dependency[H],J="";if(this.descriptor.publicDependency.includes(H))J="public ";else if(this.descriptor.weakDependency.includes(H))J="weak ";this.line(`import ${J}"${$}";`)}if(this.descriptor.dependency.length>0)this.emptyLine();for(let H of this.descriptor.enumType)this.printEnum(H),this.emptyLine();for(let H of this.descriptor.messageType)this.printMessage(H),this.emptyLine();for(let H of this.descriptor.service)this.printService(H),this.emptyLine();for(let H of this.descriptor.extension)this.line(`extend ${H.getExtendee(this.getCurrentScope())} {`),this.indent(),this.printField(H),this.dedent(),this.line("}"),this.emptyLine();return this.buffer.join(`
|
|
3
|
+
`)}printMessage(H){if(this.line(`message ${H.name} {`),this.indent(),H.name)this.messagePath.push(H.name);if(H.options?.deprecated)this.line("option deprecated = true;");if(H.options?.mapEntry)this.line("option map_entry = true;");let $=new Set;for(let Q of H.nestedType)if(Q.options?.mapEntry)$.add(Q.name??"");for(let Q of H.enumType)this.printEnum(Q),this.emptyLine();let J=H.nestedType.filter((Q)=>!Q.options?.mapEntry);for(let Q of J)this.printMessage(Q),this.emptyLine();let{oneofGroups:K,regularFields:Y}=H.getFieldGroups();for(let Q of Y)this.printField(Q,{mapEntryNames:$,nestedTypes:H.nestedType});for(let Q of K){this.line(`oneof ${Q.name} {`),this.indent();for(let z of Q.fields)this.printField(z,{isOneofField:!0});this.dedent(),this.line("}")}if(H.extension&&H.extension.length>0){this.emptyLine();for(let Q of H.extension)this.line(`extend ${Q.getExtendee(this.getCurrentScope())} {`),this.indent(),this.printField(Q),this.dedent(),this.line("}")}if(H.extensionRange&&H.extensionRange.length>0)for(let Q of H.extensionRange){let z="max";if(Q.end)z=Q.end-1;this.line(`extensions ${Q.start} to ${z};`)}if(H.reservedRange&&H.reservedRange.length>0){let Q=H.reservedRange.map((z)=>{if(z.start===z.end)return String(z.start);return`${z.start} to ${z.end-1}`});this.line(`reserved ${Q.join(", ")};`)}if(H.reservedName&&H.reservedName.length>0){let Q=H.reservedName.map((z)=>`"${z}"`);this.line(`reserved ${Q.join(", ")};`)}if(H.name)this.messagePath.pop();this.dedent(),this.line("}")}printEnum(H){if(this.line(`enum ${H.name} {`),this.indent(),H.options?.allowAlias)this.line("option allow_alias = true;");if(H.options?.deprecated)this.line("option deprecated = true;");for(let $ of H.value){let J="";if($.options?.deprecated)J=" [deprecated = true]";this.line(`${$.name} = ${$.number}${J};`)}this.dedent(),this.line("}")}printService(H){this.line(`service ${H.name} {`),this.indent();for(let $ of H.method){let J=$.getSignature(this.getCurrentScope()),K="",Y="";if(J.clientStreaming)K="stream ";if(J.serverStreaming)Y="stream ";this.line(`rpc ${$.name} (${K}${J.inputType}) returns (${Y}${J.outputType});`)}this.dedent(),this.line("}")}printField(H,$={}){let{mapEntryNames:J,nestedTypes:K,isOneofField:Y}=$,Q=this.getCurrentScope();if(J&&K&&H.typeName){let L=H.typeName.split(".").pop()??"";if(J.has(L)){let C=K.find((V)=>V.name===L);if(C&&C.field.length>=2){let V=C.field.find((W)=>W.number===1),G=C.field.find((W)=>W.number===2);if(V&&G){let W=V.getStyle(Q),B=G.getStyle(Q),F=this.formatFieldOptions(H);this.line(`map<${W.typeString}, ${B.typeString}> ${H.name} = ${H.number}${F};`);return}}}}let{prefix:z,typeString:A}=H.getStyle(Q),X=this.formatFieldOptions(H),Z=z;if(Y)Z="";this.line(`${Z}${A} ${H.name} = ${H.number}${X};`)}formatFieldOptions(H){let $=H.getOptions();if($.length===0)return"";let J=$.map((Y)=>`${Y.name} = ${Y.value}`);if(J.length===1)return` [${J[0]}]`;let K=" ".repeat(this.indentLevel+1);return` [
|
|
4
|
+
${K}${J.join(`,
|
|
5
|
+
${K}`)}
|
|
6
|
+
${" ".repeat(this.indentLevel)}]`}getCurrentScope(){return{messagePath:[...this.messagePath],package:this.descriptor.package??""}}indent(){this.indentLevel++}dedent(){this.indentLevel--}line(H){let $=" ".repeat(this.indentLevel);this.buffer.push($+H)}emptyLine(){if(this.buffer.length>0&&this.buffer[this.buffer.length-1]!=="")this.buffer.push("")}printFileOptions(){let H=this.descriptor.getFileOptions();for(let $ of H)if(!$.isDefault)this.line(`option ${$.name} = ${$.value};`);if(H.length>0)this.emptyLine()}}class n{name;value;options;reservedRange;reservedName;constructor(H){this.name=H.name,this.value=H.value,this.options=H.options,this.reservedRange=H.reservedRange,this.reservedName=H.reservedName}}function M(H,$){let J=H;if(H.startsWith("."))J=H.slice(1);let K=J.split("."),Y=[];if($.package)Y.push(...$.package.split("."));Y.push(...$.messagePath);for(let Q=Y.length;Q>=0;Q--){let z=Y.slice(0,Q);if(K1(K,z)){let A=K.slice(z.length);if(A.length>0)return A.join(".")}}return H}function K1(H,$){if($.length>H.length)return!1;for(let J=0;J<$.length;J++)if(H[J]!==$[J])return!1;return!0}class b{name;number;label;type;typeName;extendee;defaultValue;oneofIndex;jsonName;options;constructor(H){if(this.name=H.name,this.number=H.number,this.label=H.label,this.type=H.type,this.typeName=H.typeName,this.extendee=H.extendee,this.defaultValue=H.defaultValue,Object.keys(H).includes("oneofIndex"))this.oneofIndex=H.oneofIndex;else this.oneofIndex=void 0;this.jsonName=H.jsonName,this.options=H.options}getStyle(H){return{prefix:this.resolvePrefix(),typeString:this.resolveTypeString(H)}}getExtendee(H){if(!this.extendee)return"";return M(this.extendee,H)}getOptions(){let H=[];if(this.defaultValue!==void 0&&(K0||this.defaultValue!=="")){if(this.type!==void 0&&this.type!==11&&this.type!==10&&this.label!==3){if(this.type===9)H.push({name:"default",value:`"${this.defaultValue}"`});else if(this.type===12){if(this.defaultValue.length>0||K0)H.push({name:"default",value:`"${this.defaultValue}"`})}else if(this.defaultValue!==""||K0){let K=this.defaultValue;if(K==="")K=this.getDefaultValueForType();if(K!=="")H.push({name:"default",value:K})}}}let $=this.options;if(!$)return H;if($.packed===!0)H.push({name:"packed",value:"true"});if($.deprecated===!0)H.push({name:"deprecated",value:"true"});if($.retention!==void 0&&$.retention!==0){let K={1:"RETENTION_RUNTIME",2:"RETENTION_SOURCE"}[$.retention];if(K)H.push({name:"retention",value:K})}if($.targets&&Array.isArray($.targets)){let J={1:"TARGET_TYPE_FILE",2:"TARGET_TYPE_EXTENSION_RANGE",3:"TARGET_TYPE_MESSAGE",4:"TARGET_TYPE_FIELD",5:"TARGET_TYPE_ONEOF",6:"TARGET_TYPE_ENUM",7:"TARGET_TYPE_ENUM_ENTRY",8:"TARGET_TYPE_SERVICE",9:"TARGET_TYPE_METHOD"};for(let K of $.targets){let Y=J[K];if(Y)H.push({name:"targets",value:Y})}}if($.featureSupport){let J=[],K=$.featureSupport;if(K.editionIntroduced!==void 0&&K.editionIntroduced!==0)J.push(`edition_introduced: ${this.formatEdition(K.editionIntroduced)}`);if(K.editionDeprecated!==void 0&&K.editionDeprecated!==0)J.push(`edition_deprecated: ${this.formatEdition(K.editionDeprecated)}`);if(K.deprecationWarning)J.push(`deprecation_warning: "${K.deprecationWarning}"`);if(K.editionRemoved!==void 0&&K.editionRemoved!==0)J.push(`edition_removed: ${this.formatEdition(K.editionRemoved)}`);if(K.removalError)J.push(`removal_error: "${K.removalError}"`);if(J.length>0)H.push({name:"feature_support",value:`{ ${J.join(", ")} }`})}if($.editionDefaults&&Array.isArray($.editionDefaults))for(let J of $.editionDefaults){let K=[];if(J.edition!==void 0&&J.edition!==0)K.push(`edition: ${this.formatEdition(J.edition)}`);if(J.value!==void 0)K.push(`value: "${J.value}"`);if(K.length>0)H.push({name:"edition_defaults",value:`{ ${K.join(", ")} }`})}return H}formatEdition(H){return{0:"EDITION_UNKNOWN",1:"EDITION_1_TEST_ONLY",1000:"EDITION_2023",1001:"EDITION_2024",2:"EDITION_2_TEST_ONLY",900:"EDITION_LEGACY",998:"EDITION_PROTO2",999:"EDITION_PROTO3",9999:"EDITION_UNSTABLE",99997:"EDITION_99997_TEST_ONLY",99998:"EDITION_99998_TEST_ONLY",99999:"EDITION_99999_TEST_ONLY"}[H]??`EDITION_${H}`}resolvePrefix(){switch(this.label){case 1:return"optional ";case 2:return"required ";case 3:return"repeated ";default:throw Error(`Unexpected field label: ${this.label}`)}}resolveTypeString(H){switch(this.type){case 1:return"double";case 2:return"float";case 3:return"int64";case 4:return"uint64";case 5:return"int32";case 6:return"fixed64";case 7:return"fixed32";case 8:return"bool";case 9:return"string";case 10:return"group";case 11:if(!this.typeName)throw Error(`MESSAGE type field "${this.name}" has no typeName`);return M(this.typeName,H);case 12:return"bytes";case 13:return"uint32";case 14:if(!this.typeName)throw Error(`ENUM type field "${this.name}" has no typeName`);return M(this.typeName,H);case 15:return"sfixed32";case 16:return"sfixed64";case 17:return"sint32";case 18:return"sint64";default:throw Error(`Unexpected field type: ${this.type}`)}}getDefaultValueForType(){switch(this.type){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 13:case 15:case 16:case 17:case 18:return"0";case 8:return"false";case 14:return"";default:return""}}}class S0{name;options;constructor(H){this.name=H.name,this.options=H.options}}class Q0{name;field;extension;nestedType;enumType;extensionRange;oneofDecl;options;reservedRange;reservedName;constructor(H){this.name=H.name,this.field=H.field.map(($)=>new b($)),this.extension=H.extension.map(($)=>new b($)),this.nestedType=H.nestedType.map(($)=>new Q0($)),this.enumType=H.enumType.map(($)=>new n($)),this.extensionRange=H.extensionRange,this.oneofDecl=H.oneofDecl.map(($)=>new S0($)),this.options=H.options,this.reservedRange=H.reservedRange??[],this.reservedName=H.reservedName??[]}getFieldGroups(){let H=new Map,$=[];this.field.forEach((K)=>{if(K.oneofIndex!==void 0){if(!H.has(K.oneofIndex))H.set(K.oneofIndex,[]);H.get(K.oneofIndex)?.push(K)}else $.push(K)});let J=[];if(this.oneofDecl)this.oneofDecl.forEach((K,Y)=>{let Q=H.get(Y);if(Q&&Q.length>0)J.push({fields:Q,name:K.name??""})});return{oneofGroups:J,regularFields:$}}}class T0{name;method;options;constructor(H){this.name=H.name,this.method=H.method.map(($)=>new qH($)),this.options=H.options}}class qH{name;inputType;outputType;options;clientStreaming;serverStreaming;constructor(H){this.name=H.name,this.inputType=H.inputType,this.outputType=H.outputType,this.options=H.options,this.clientStreaming=H.clientStreaming,this.serverStreaming=H.serverStreaming}getSignature(H){if(!this.inputType)throw Error(`Method "${this.name}" has no inputType`);if(!this.outputType)throw Error(`Method "${this.name}" has no outputType`);return{clientStreaming:this.clientStreaming??!1,inputType:M(this.inputType,H),outputType:M(this.outputType,H),serverStreaming:this.serverStreaming??!1}}}class y0{name;package;dependency;publicDependency;weakDependency;optionDependency;messageType;enumType;service;extension;options;sourceCodeInfo;edition;constructor(H){this.name=H.name,this.package=H.package,this.dependency=H.dependency,this.publicDependency=H.publicDependency,this.weakDependency=H.weakDependency,this.messageType=H.messageType.map(($)=>new Q0($)),this.enumType=H.enumType.map(($)=>new n($)),this.service=H.service.map(($)=>new T0($)),this.extension=H.extension.map(($)=>new b($)),this.options=H.options,this.sourceCodeInfo=H.sourceCodeInfo,this.edition=H.edition,this.optionDependency=H.optionDependency??[]}getFileOptions(){let H=[],$=this.options;if(!$)return H;let J=[{key:"javaPackage",name:"java_package"},{key:"javaOuterClassname",name:"java_outer_classname"},{key:"goPackage",name:"go_package"},{key:"objcClassPrefix",name:"objc_class_prefix"},{key:"csharpNamespace",name:"csharp_namespace"},{key:"swiftPrefix",name:"swift_prefix"},{key:"phpClassPrefix",name:"php_class_prefix"},{key:"phpNamespace",name:"php_namespace"},{key:"phpMetadataNamespace",name:"php_metadata_namespace"},{key:"rubyPackage",name:"ruby_package"}];for(let{key:Y,name:Q}of J){let z=$[Y];if(typeof z==="string"){let A=z.length===0;H.push({isDefault:A,name:Q,value:`"${z}"`})}}let K=[{defaultValue:!1,key:"javaMultipleFiles",name:"java_multiple_files"},{defaultValue:!1,key:"javaStringCheckUtf8",name:"java_string_check_utf8"},{defaultValue:!1,key:"ccGenericServices",name:"cc_generic_services"},{defaultValue:!1,key:"javaGenericServices",name:"java_generic_services"},{defaultValue:!1,key:"pyGenericServices",name:"py_generic_services"},{defaultValue:!1,key:"deprecated",name:"deprecated"},{defaultValue:!0,key:"ccEnableArenas",name:"cc_enable_arenas"}];for(let{defaultValue:Y,key:Q,name:z}of K){let A=$[Q];if(typeof A==="boolean"){let X=A===Y;H.push({isDefault:X,name:z,value:String(A)})}}if($.optimizeFor!==void 0){let Q={1:"SPEED",2:"CODE_SIZE",3:"LITE_RUNTIME"}[$.optimizeFor];if(Q)H.push({isDefault:$.optimizeFor===1,name:"optimize_for",value:Q})}return H}}class m0{descriptor;buffer=[];indentLevel=0;messagePath=[];constructor(H){this.descriptor=H}format(){if(this.buffer=[],this.indentLevel=0,this.messagePath=[],this.line('syntax = "proto3";'),this.emptyLine(),this.descriptor.edition)this.line(`// edition = ${this.descriptor.edition};`);if(this.descriptor.package)this.line(`package ${this.descriptor.package};`),this.emptyLine();this.printFileOptions();for(let H=0;H<this.descriptor.dependency.length;H++){let $=this.descriptor.dependency[H],J="";if(this.descriptor.publicDependency.includes(H))J="public ";else if(this.descriptor.weakDependency.includes(H))J="weak ";this.line(`import ${J}"${$}";`)}if(this.descriptor.dependency.length>0)this.emptyLine();for(let H of this.descriptor.enumType)this.printEnum(H),this.emptyLine();for(let H of this.descriptor.messageType)this.printMessage(H),this.emptyLine();for(let H of this.descriptor.service)this.printService(H),this.emptyLine();for(let H of this.descriptor.extension)this.line(`extend ${H.getExtendee(this.getCurrentScope())} {`),this.indent(),this.printField(H),this.dedent(),this.line("}"),this.emptyLine();return this.buffer.join(`
|
|
7
|
+
`)}printMessage(H){if(this.line(`message ${H.name} {`),this.indent(),H.name)this.messagePath.push(H.name);if(H.options?.deprecated)this.line("option deprecated = true;");if(H.options?.mapEntry)this.line("option map_entry = true;");let $=new Set;for(let Q of H.nestedType)if(Q.options?.mapEntry)$.add(Q.name??"");for(let Q of H.enumType)this.printEnum(Q),this.emptyLine();let J=H.nestedType.filter((Q)=>!Q.options?.mapEntry);for(let Q of J)this.printMessage(Q),this.emptyLine();let{oneofGroups:K,regularFields:Y}=H.getFieldGroups();for(let Q of Y)this.printField(Q,{mapEntryNames:$,nestedTypes:H.nestedType});for(let Q of K){this.line(`oneof ${Q.name} {`),this.indent();for(let z of Q.fields)this.printField(z,{isOneofField:!0});this.dedent(),this.line("}")}if(H.extension&&H.extension.length>0){this.emptyLine();for(let Q of H.extension)this.line(`extend ${Q.getExtendee(this.getCurrentScope())} {`),this.indent(),this.printField(Q),this.dedent(),this.line("}")}if(H.extensionRange&&H.extensionRange.length>0)for(let Q of H.extensionRange){let z="max";if(Q.end)z=Q.end-1;this.line(`extensions ${Q.start} to ${z};`)}if(H.reservedRange&&H.reservedRange.length>0){let Q=H.reservedRange.map((z)=>{if(z.start===z.end)return String(z.start);return`${z.start} to ${z.end-1}`});this.line(`reserved ${Q.join(", ")};`)}if(H.reservedName&&H.reservedName.length>0){let Q=H.reservedName.map((z)=>`"${z}"`);this.line(`reserved ${Q.join(", ")};`)}if(H.name)this.messagePath.pop();this.dedent(),this.line("}")}printEnum(H){if(this.line(`enum ${H.name} {`),this.indent(),H.options?.allowAlias)this.line("option allow_alias = true;");if(H.options?.deprecated)this.line("option deprecated = true;");for(let $ of H.value){let J="";if($.options?.deprecated)J=" [deprecated = true]";this.line(`${$.name} = ${$.number}${J};`)}this.dedent(),this.line("}")}printService(H){this.line(`service ${H.name} {`),this.indent();for(let $ of H.method){let J=$.getSignature(this.getCurrentScope()),K="",Y="";if(J.clientStreaming)K="stream ";if(J.serverStreaming)Y="stream ";this.line(`rpc ${$.name} (${K}${J.inputType}) returns (${Y}${J.outputType});`)}this.dedent(),this.line("}")}printField(H,$={}){let{mapEntryNames:J,nestedTypes:K,isOneofField:Y}=$,Q=this.getCurrentScope();if(J&&K&&H.typeName){let L=H.typeName.split(".").pop()??"";if(J.has(L)){let C=K.find((V)=>V.name===L);if(C&&C.field.length>=2){let V=C.field.find((W)=>W.number===1),G=C.field.find((W)=>W.number===2);if(V&&G){let W=V.getStyle(Q),B=G.getStyle(Q),F=this.formatFieldOptions(H);this.line(`map<${W.typeString}, ${B.typeString}> ${H.name} = ${H.number}${F};`);return}}}}let{prefix:z,typeString:A}=H.getStyle(Q),X=this.formatFieldOptions(H),Z=z;if(Y)Z="";this.line(`${Z}${A} ${H.name} = ${H.number}${X};`)}formatFieldOptions(H){let $=H.getOptions();if($.length===0)return"";let J=$.map((Y)=>`${Y.name} = ${Y.value}`);if(J.length===1)return` [${J[0]}]`;let K=" ".repeat(this.indentLevel+1);return` [
|
|
8
|
+
${K}${J.join(`,
|
|
9
|
+
${K}`)}
|
|
10
|
+
${" ".repeat(this.indentLevel)}]`}getCurrentScope(){return{messagePath:[...this.messagePath],package:this.descriptor.package??""}}indent(){this.indentLevel++}dedent(){this.indentLevel--}line(H){let $=" ".repeat(this.indentLevel);this.buffer.push($+H)}emptyLine(){if(this.buffer.length>0&&this.buffer[this.buffer.length-1]!=="")this.buffer.push("")}printFileOptions(){let H=this.descriptor.getFileOptions();for(let $ of H)if(!$.isDefault)this.line(`option ${$.name} = ${$.value};`);if(H.length>0)this.emptyLine()}}class f{name;value;options;reservedRange;reservedName;constructor(H){this.name=H.name,this.value=H.value,this.options=H.options,this.reservedRange=H.reservedRange,this.reservedName=H.reservedName}}function P(H,$){let J=H;if(H.startsWith("."))J=H.slice(1);let K=J.split("."),Y=[];if($.package)Y.push(...$.package.split("."));Y.push(...$.messagePath);for(let Q=Y.length;Q>=0;Q--){let z=Y.slice(0,Q);if(Q1(K,z)){let A=K.slice(z.length);if(A.length>0)return A.join(".")}}return H}function Q1(H,$){if($.length>H.length)return!1;for(let J=0;J<$.length;J++)if(H[J]!==$[J])return!1;return!0}class S{name;number;label;type;typeName;extendee;defaultValue;oneofIndex;jsonName;options;proto3Optional;constructor(H){if(this.name=H.name,this.number=H.number,this.label=H.label,this.type=H.type,this.typeName=H.typeName,this.extendee=H.extendee,this.defaultValue=H.defaultValue,Object.keys(H).includes("oneofIndex"))this.oneofIndex=H.oneofIndex;else this.oneofIndex=void 0;this.jsonName=H.jsonName,this.options=H.options,this.proto3Optional=H.proto3Optional}getStyle(H){return{prefix:this.resolvePrefix(),typeString:this.resolveTypeString(H)}}getExtendee(H){if(!this.extendee)return"";return P(this.extendee,H)}getOptions(){let H=[],$=this.options;if(!$)return H;if($.packed===!0)H.push({name:"packed",value:"true"});if($.deprecated===!0)H.push({name:"deprecated",value:"true"});if($.retention!==void 0&&$.retention!==0){let K={1:"RETENTION_RUNTIME",2:"RETENTION_SOURCE"}[$.retention];if(K)H.push({name:"retention",value:K})}if($.targets&&Array.isArray($.targets)){let J={1:"TARGET_TYPE_FILE",2:"TARGET_TYPE_EXTENSION_RANGE",3:"TARGET_TYPE_MESSAGE",4:"TARGET_TYPE_FIELD",5:"TARGET_TYPE_ONEOF",6:"TARGET_TYPE_ENUM",7:"TARGET_TYPE_ENUM_ENTRY",8:"TARGET_TYPE_SERVICE",9:"TARGET_TYPE_METHOD"};for(let K of $.targets){let Y=J[K];if(Y)H.push({name:"targets",value:Y})}}if($.featureSupport){let J=[],K=$.featureSupport;if(K.editionIntroduced!==void 0&&K.editionIntroduced!==0)J.push(`edition_introduced: ${this.formatEdition(K.editionIntroduced)}`);if(K.editionDeprecated!==void 0&&K.editionDeprecated!==0)J.push(`edition_deprecated: ${this.formatEdition(K.editionDeprecated)}`);if(K.deprecationWarning)J.push(`deprecation_warning: "${K.deprecationWarning}"`);if(K.editionRemoved!==void 0&&K.editionRemoved!==0)J.push(`edition_removed: ${this.formatEdition(K.editionRemoved)}`);if(K.removalError)J.push(`removal_error: "${K.removalError}"`);if(J.length>0)H.push({name:"feature_support",value:`{ ${J.join(", ")} }`})}if($.editionDefaults&&Array.isArray($.editionDefaults))for(let J of $.editionDefaults){let K=[];if(J.edition!==void 0&&J.edition!==0)K.push(`edition: ${this.formatEdition(J.edition)}`);if(J.value!==void 0)K.push(`value: "${J.value}"`);if(K.length>0)H.push({name:"edition_defaults",value:`{ ${K.join(", ")} }`})}return H}formatEdition(H){return{0:"EDITION_UNKNOWN",1:"EDITION_1_TEST_ONLY",1000:"EDITION_2023",1001:"EDITION_2024",2:"EDITION_2_TEST_ONLY",900:"EDITION_LEGACY",998:"EDITION_PROTO2",999:"EDITION_PROTO3",9999:"EDITION_UNSTABLE",99997:"EDITION_99997_TEST_ONLY",99998:"EDITION_99998_TEST_ONLY",99999:"EDITION_99999_TEST_ONLY"}[H]??`EDITION_${H}`}resolvePrefix(){if(this.label===1&&this.proto3Optional)return"optional ";if(this.label===1)return"";switch(this.label){case 2:throw Error(`Unexpected required label in proto3: field "${this.name}"`);case 3:return"repeated ";default:throw Error(`Unexpected field label: ${this.label}`)}}resolveTypeString(H){switch(this.type){case 1:return"double";case 2:return"float";case 3:return"int64";case 4:return"uint64";case 5:return"int32";case 6:return"fixed64";case 7:return"fixed32";case 8:return"bool";case 9:return"string";case 10:return"group";case 11:if(!this.typeName)throw Error(`MESSAGE type field "${this.name}" has no typeName`);return P(this.typeName,H);case 12:return"bytes";case 13:return"uint32";case 14:if(!this.typeName)throw Error(`ENUM type field "${this.name}" has no typeName`);return P(this.typeName,H);case 15:return"sfixed32";case 16:return"sfixed64";case 17:return"sint32";case 18:return"sint64";default:throw Error(`Unexpected field type: ${this.type}`)}}}class g0{name;options;constructor(H){this.name=H.name,this.options=H.options}}class Y0{name;field;extension;nestedType;enumType;extensionRange;oneofDecl;options;reservedRange;reservedName;constructor(H){this.name=H.name,this.field=H.field.map(($)=>new S($)),this.extension=H.extension.map(($)=>new S($)),this.nestedType=H.nestedType.map(($)=>new Y0($)),this.enumType=H.enumType.map(($)=>new f($)),this.extensionRange=H.extensionRange,this.oneofDecl=H.oneofDecl.map(($)=>new g0($)),this.options=H.options,this.reservedRange=H.reservedRange??[],this.reservedName=H.reservedName??[]}getFieldGroups(){let H=new Map,$=[];this.field.forEach((K)=>{if(K.oneofIndex!==void 0&&!K.proto3Optional){if(!H.has(K.oneofIndex))H.set(K.oneofIndex,[]);H.get(K.oneofIndex)?.push(K)}else $.push(K)});let J=[];if(this.oneofDecl)this.oneofDecl.forEach((K,Y)=>{let Q=H.get(Y);if(Q&&Q.length>0)J.push({fields:Q,name:K.name??""})});return{oneofGroups:J,regularFields:$}}}class v0{name;method;options;constructor(H){this.name=H.name,this.method=H.method.map(($)=>new AH($)),this.options=H.options}}class AH{name;inputType;outputType;options;clientStreaming;serverStreaming;constructor(H){this.name=H.name,this.inputType=H.inputType,this.outputType=H.outputType,this.options=H.options,this.clientStreaming=H.clientStreaming,this.serverStreaming=H.serverStreaming}getSignature(H){if(!this.inputType)throw Error(`Method "${this.name}" has no inputType`);if(!this.outputType)throw Error(`Method "${this.name}" has no outputType`);return{clientStreaming:this.clientStreaming??!1,inputType:P(this.inputType,H),outputType:P(this.outputType,H),serverStreaming:this.serverStreaming??!1}}}class c0{name;package;dependency;publicDependency;weakDependency;optionDependency;messageType;enumType;service;extension;options;sourceCodeInfo;edition;constructor(H){this.name=H.name,this.package=H.package,this.dependency=H.dependency,this.publicDependency=H.publicDependency,this.weakDependency=H.weakDependency,this.messageType=H.messageType.map(($)=>new Y0($)),this.enumType=H.enumType.map(($)=>new f($)),this.service=H.service.map(($)=>new v0($)),this.extension=H.extension.map(($)=>new S($)),this.options=H.options,this.sourceCodeInfo=H.sourceCodeInfo,this.edition=H.edition,this.optionDependency=H.optionDependency??[]}getFileOptions(){let H=[],$=this.options;if(!$)return H;let J=[{key:"javaPackage",name:"java_package"},{key:"javaOuterClassname",name:"java_outer_classname"},{key:"goPackage",name:"go_package"},{key:"objcClassPrefix",name:"objc_class_prefix"},{key:"csharpNamespace",name:"csharp_namespace"},{key:"swiftPrefix",name:"swift_prefix"},{key:"phpClassPrefix",name:"php_class_prefix"},{key:"phpNamespace",name:"php_namespace"},{key:"phpMetadataNamespace",name:"php_metadata_namespace"},{key:"rubyPackage",name:"ruby_package"}];for(let{key:Y,name:Q}of J){let z=$[Y];if(typeof z==="string"){let A=z.length===0;H.push({isDefault:A,name:Q,value:`"${z}"`})}}let K=[{defaultValue:!1,key:"javaMultipleFiles",name:"java_multiple_files"},{defaultValue:!1,key:"javaStringCheckUtf8",name:"java_string_check_utf8"},{defaultValue:!1,key:"ccGenericServices",name:"cc_generic_services"},{defaultValue:!1,key:"javaGenericServices",name:"java_generic_services"},{defaultValue:!1,key:"pyGenericServices",name:"py_generic_services"},{defaultValue:!1,key:"deprecated",name:"deprecated"},{defaultValue:!0,key:"ccEnableArenas",name:"cc_enable_arenas"}];for(let{defaultValue:Y,key:Q,name:z}of K){let A=$[Q];if(typeof A==="boolean"){let X=A===Y;H.push({isDefault:X,name:z,value:String(A)})}}if($.optimizeFor!==void 0){let Q={1:"SPEED",2:"CODE_SIZE",3:"LITE_RUNTIME"}[$.optimizeFor];if(Q)H.push({isDefault:$.optimizeFor===1,name:"optimize_for",value:Q})}return H}}var LH=process.argv[2],XH=process.argv[3];if(!LH)console.error("Usage: bun run unbake <input> [output_dir]"),process.exit(1);var X1=q1(LH),L1=E0(QH,X1);function C1(H,$,J){if(J)return ZH(H,J);let K="";if($)K=$.replace(/\./g,"/");return ZH(H,K,"unnamed.proto")}function U1(H){if(H.syntax==="proto3"){let $=new c0(H);return new m0($).format()}else{let $=new y0(H);return new b0($).format()}}for(let H of L1.file){let $=U1(H);if(XH){let J=C1(XH,H.package,H.name),K=Z1(J);if(!Y1(K))z1(K,{recursive:!0});A1(J,$),console.log(`Written: ${J}`)}else console.log($)}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "unbake-proto",
|
|
3
|
+
"module": "src/index.ts",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"unbake-proto": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"lint": "bunx oxlint --type-aware",
|
|
16
|
+
"format": "bunx oxlint --type-aware --fix . ; bunx oxfmt . ; bunx eslint --fix .",
|
|
17
|
+
"check": "bunx tsc --noEmit",
|
|
18
|
+
"precommit": "bun run check && bun run format && bun run build",
|
|
19
|
+
"unbake": "bun run src/index.ts",
|
|
20
|
+
"test": "protoc --descriptor_set_out=test/schema.pb --include_imports test/schema.proto && bun run unbake test/schema.pb",
|
|
21
|
+
"test2": "protoc --descriptor_set_out=test/descriptor.pb --include_imports descriptor.proto && bun run unbake test/descriptor.pb",
|
|
22
|
+
"test3": "protoc --descriptor_set_out=test/comprehensive.pb --include_imports test/comprehensive.proto && bun run unbake test/comprehensive.pb"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@stylistic/eslint-plugin": "^5.6.1",
|
|
26
|
+
"@types/bun": "latest",
|
|
27
|
+
"eslint": "^9.39.1",
|
|
28
|
+
"eslint-plugin-import-x": "^4.16.1",
|
|
29
|
+
"eslint-plugin-oxlint": "^1.32.0",
|
|
30
|
+
"oxfmt": "^0.16.0",
|
|
31
|
+
"oxlint": "^1.32.0",
|
|
32
|
+
"oxlint-tsgolint": "^0.9.1",
|
|
33
|
+
"typescript-eslint": "^8.49.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"typescript": "^5"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@bufbuild/protobuf": "^2.10.2"
|
|
40
|
+
}
|
|
41
|
+
}
|