Files
wool_scripts/Scripts/bilibili/protoA.js
2025-06-30 21:59:46 +08:00

4 lines
74 KiB
JavaScript

// Build: 2023/9/5 22:23:15
(()=>{console.time=function(n){this._times=this._times||{},this._times[n]=Date.now()};console.timeEnd=function(n){if(this._times&&this._times[n]){let e=Date.now()-this._times[n];console.log(`${n}: ${e}ms`),delete this._times[n]}else console.log(`Timer with label ${n} does not exist.`)};function Kn(n){"use strict";function e(){}function t(){}var r=String.fromCharCode,i={}.toString,s=i.call(n.SharedArrayBuffer),l=i(),o=n.Uint8Array,a=o||Array,f=o?ArrayBuffer:a,u=f.isView||function(E){return E&&"length"in E},p=i.call(f.prototype);f=t.prototype;var g=n.TextEncoder,d=new(o?Uint16Array:a)(32);e.prototype.decode=function(E){if(!u(E)){var S=i.call(E);if(S!==p&&S!==s&&S!==l)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");E=o?new a(E):E||[]}for(var B=S="",k=0,N=E.length|0,K=N-32|0,U,T,V=0,z=0,L,C=0,R=-1;k<N;){for(U=k<=K?32:N-k|0;C<U;k=k+1|0,C=C+1|0){switch(T=E[k]&255,T>>4){case 15:if(L=E[k=k+1|0]&255,L>>6!==2||247<T){k=k-1|0;break}V=(T&7)<<6|L&63,z=5,T=256;case 14:L=E[k=k+1|0]&255,V<<=6,V|=(T&15)<<6|L&63,z=L>>6===2?z+4|0:24,T=T+256&768;case 13:case 12:L=E[k=k+1|0]&255,V<<=6,V|=(T&31)<<6|L&63,z=z+7|0,k<N&&L>>6===2&&V>>z&&1114112>V?(T=V,V=V-65536|0,0<=V&&(R=(V>>10)+55296|0,T=(V&1023)+56320|0,31>C?(d[C]=R,C=C+1|0,R=-1):(L=R,R=T,T=L))):(T>>=8,k=k-T-1|0,T=65533),V=z=0,U=k<=K?32:N-k|0;default:d[C]=T;continue;case 11:case 10:case 9:case 8:}d[C]=65533}if(B+=r(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8],d[9],d[10],d[11],d[12],d[13],d[14],d[15],d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23],d[24],d[25],d[26],d[27],d[28],d[29],d[30],d[31]),32>C&&(B=B.slice(0,C-32|0)),k<N){if(d[0]=R,C=~R>>>31,R=-1,B.length<S.length)continue}else R!==-1&&(B+=r(R));S+=B,B=""}return S},f.encode=function(E){E=E===void 0?"":""+E;var S=E.length|0,B=new a((S<<1)+8|0),k,N=0,K=!o;for(k=0;k<S;k=k+1|0,N=N+1|0){var U=E.charCodeAt(k)|0;if(127>=U)B[N]=U;else{if(2047>=U)B[N]=192|U>>6;else{e:{if(55296<=U)if(56319>=U){var T=E.charCodeAt(k=k+1|0)|0;if(56320<=T&&57343>=T){if(U=(U<<10)+T-56613888|0,65535<U){B[N]=240|U>>18,B[N=N+1|0]=128|U>>12&63,B[N=N+1|0]=128|U>>6&63,B[N=N+1|0]=128|U&63;continue}break e}U=65533}else 57343>=U&&(U=65533);!K&&k<<1<N&&k<<1<(N-7|0)&&(K=!0,T=new a(3*S),T.set(B),B=T)}B[N]=224|U>>12,B[N=N+1|0]=128|U>>6&63}B[N=N+1|0]=128|U&63}}return o?B.subarray(0,N):B.slice(0,N)},n.TextDecoder=e,n.TextEncoder=t}var y=Kn(globalThis);var P=Uint8Array,ie=Uint16Array,Jn=Int32Array,tn=new P([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),nn=new P([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Yn=new P([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rn=function(n,e){for(var t=new ie(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];for(var i=new Jn(t[30]),r=1;r<30;++r)for(var s=t[r];s<t[r+1];++s)i[s]=s-t[r]<<5|r;return{b:t,r:i}},sn=rn(tn,2),on=sn.b,Xn=sn.r;on[28]=258,Xn[258]=28;var an=rn(nn,0),Zn=an.b,Er=an.r,Ce=new ie(32768);for(I=0;I<32768;++I)J=(I&43690)>>1|(I&21845)<<1,J=(J&52428)>>2|(J&13107)<<2,J=(J&61680)>>4|(J&3855)<<4,Ce[I]=((J&65280)>>8|(J&255)<<8)>>1;var J,I,fe=function(n,e,t){for(var r=n.length,i=0,s=new ie(e);i<r;++i)n[i]&&++s[n[i]-1];var l=new ie(e);for(i=1;i<e;++i)l[i]=l[i-1]+s[i-1]<<1;var o;if(t){o=new ie(1<<e);var a=15-e;for(i=0;i<r;++i)if(n[i])for(var f=i<<4|n[i],u=e-n[i],p=l[n[i]-1]++<<u,g=p|(1<<u)-1;p<=g;++p)o[Ce[p]>>a]=f}else for(o=new ie(r),i=0;i<r;++i)n[i]&&(o[i]=Ce[l[n[i]-1]++]>>15-n[i]);return o},ue=new P(288);for(I=0;I<144;++I)ue[I]=8;var I;for(I=144;I<256;++I)ue[I]=9;var I;for(I=256;I<280;++I)ue[I]=7;var I;for(I=280;I<288;++I)ue[I]=8;var I,ln=new P(32);for(I=0;I<32;++I)ln[I]=5;var I;var qn=fe(ue,9,1);var Hn=fe(ln,5,1),Le=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},M=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(e&7)&t},De=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},Qn=function(n){return(n+7)/8|0},er=function(n,e,t){(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length);var r=new P(t-e);return r.set(n.subarray(e,t)),r};var tr=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],G=function(n,e,t){var r=new Error(e||tr[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,G),!t)throw r;return r},nr=function(n,e,t,r){var i=n.length,s=r?r.length:0;if(!i||e.f&&!e.l)return t||new P(0);var l=!t||e.i!=2,o=e.i;t||(t=new P(i*3));var a=function(Ht){var Qt=t.length;if(Ht>Qt){var en=new P(Math.max(Qt*2,Ht));en.set(t),t=en}},f=e.f||0,u=e.p||0,p=e.b||0,g=e.l,d=e.d,E=e.m,S=e.n,B=i*8;do{if(!g){f=M(n,u,1);var k=M(n,u+1,3);if(u+=3,k)if(k==1)g=qn,d=Hn,E=9,S=5;else if(k==2){var T=M(n,u,31)+257,V=M(n,u+10,15)+4,z=T+M(n,u+5,31)+1;u+=14;for(var L=new P(z),C=new P(19),R=0;R<V;++R)C[Yn[R]]=M(n,u+R*3,7);u+=V*3;for(var Jt=Le(C),_n=(1<<Jt)-1,Mn=fe(C,Jt,1),R=0;R<z;){var Yt=Mn[M(n,u,_n)];u+=Yt&15;var N=Yt>>4;if(N<16)L[R++]=N;else{var ne=0,ye=0;for(N==16?(ye=3+M(n,u,3),u+=2,ne=L[R-1]):N==17?(ye=3+M(n,u,7),u+=3):N==18&&(ye=11+M(n,u,127),u+=7);ye--;)L[R++]=ne}}var Xt=L.subarray(0,T),_=L.subarray(T);E=Le(Xt),S=Le(_),g=fe(Xt,E,1),d=fe(_,S,1)}else G(1);else{var N=Qn(u)+4,K=n[N-4]|n[N-3]<<8,U=N+K;if(U>i){o&&G(0);break}l&&a(p+K),t.set(n.subarray(N,U),p),e.b=p+=K,e.p=u=U*8,e.f=f;continue}if(u>B){o&&G(0);break}}l&&a(p+131072);for(var Gn=(1<<E)-1,zn=(1<<S)-1,Fe=u;;Fe=u){var ne=g[De(n,u)&Gn],re=ne>>4;if(u+=ne&15,u>B){o&&G(0);break}if(ne||G(2),re<256)t[p++]=re;else if(re==256){Fe=u,g=null;break}else{var Zt=re-254;if(re>264){var R=re-257,le=tn[R];Zt=M(n,u,(1<<le)-1)+on[R],u+=le}var Re=d[De(n,u)&zn],Se=Re>>4;Re||G(3),u+=Re&15;var _=Zn[Se];if(Se>3){var le=nn[Se];_+=De(n,u)&(1<<le)-1,u+=le}if(u>B){o&&G(0);break}l&&a(p+131072);var Ve=p+Zt;if(p<_){var qt=s-_,jn=Math.min(_,Ve);for(qt+p<0&&G(3);p<jn;++p)t[p]=r[qt+p]}for(;p<Ve;p+=4)t[p]=t[p-_],t[p+1]=t[p+1-_],t[p+2]=t[p+2-_],t[p+3]=t[p+3-_];p=Ve}}e.l=g,e.p=Fe,e.b=p,e.f=f,g&&(f=1,e.m=E,e.d=d,e.n=S)}while(!f);return p==t.length?t:er(t,0,p)};var rr=new P(0);var ir=function(n){(n[0]!=31||n[1]!=139||n[2]!=8)&&G(6,"invalid gzip data");var e=n[3],t=10;e&4&&(t+=(n[10]|n[11]<<8)+2);for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!n[t++]);return t+(e&2)},sr=function(n){var e=n.length;return(n[e-4]|n[e-3]<<8|n[e-2]<<16|n[e-1]<<24)>>>0};function fn(n,e){var t=ir(n);return t+8>n.length&&G(6,"invalid gzip data"),nr(n.subarray(t,-8),{i:2},e&&e.out||new P(sr(n)),e&&e.dictionary)}var or=typeof TextDecoder<"u"&&new TextDecoder,ar=0;try{or.decode(rr,{stream:!0}),ar=1}catch{}function Q(n){let e=typeof n;if(e=="object"){if(Array.isArray(n))return"array";if(n===null)return"null"}return e}function se(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}var Y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ve=[];for(let n=0;n<Y.length;n++)ve[Y[n].charCodeAt(0)]=n;ve["-".charCodeAt(0)]=Y.indexOf("+");ve["_".charCodeAt(0)]=Y.indexOf("/");function un(n){let e=n.length*3/4;n[n.length-2]=="="?e-=2:n[n.length-1]=="="&&(e-=1);let t=new Uint8Array(e),r=0,i=0,s,l=0;for(let o=0;o<n.length;o++){if(s=ve[n.charCodeAt(o)],s===void 0)switch(n[o]){case"=":i=0;case`
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:l=s,i=1;break;case 1:t[r++]=l<<2|(s&48)>>4,l=s,i=2;break;case 2:t[r++]=(l&15)<<4|(s&60)>>2,l=s,i=3;break;case 3:t[r++]=(l&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,r)}function hn(n){let e="",t=0,r,i=0;for(let s=0;s<n.length;s++)switch(r=n[s],t){case 0:e+=Y[r>>2],i=(r&3)<<4,t=1;break;case 1:e+=Y[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=Y[i|r>>6],e+=Y[r&63],t=0;break}return t&&(e+=Y[i],e+="=",t==1&&(e+="=")),e}var m;(function(n){n.symbol=Symbol.for("protobuf-ts/unknown"),n.onRead=(t,r,i,s,l)=>{(e(r)?r[n.symbol]:r[n.symbol]=[]).push({no:i,wireType:s,data:l})},n.onWrite=(t,r,i)=>{for(let{no:s,wireType:l,data:o}of n.list(r))i.tag(s,l).raw(o)},n.list=(t,r)=>{if(e(t)){let i=t[n.symbol];return r?i.filter(s=>s.no==r):i}return[]},n.last=(t,r)=>n.list(t,r).slice(-1)[0];let e=t=>t&&Array.isArray(t[n.symbol])})(m||(m={}));var c;(function(n){n[n.Varint=0]="Varint",n[n.Bit64=1]="Bit64",n[n.LengthDelimited=2]="LengthDelimited",n[n.StartGroup=3]="StartGroup",n[n.EndGroup=4]="EndGroup",n[n.Bit32=5]="Bit32"})(c||(c={}));function cn(){let n=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(n|=(i&127)<<r,!(i&128))return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<r,!(i&128))return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function ke(n,e,t){for(let s=0;s<28;s=s+7){let l=n>>>s,o=!(!(l>>>7)&&e==0),a=(o?l|128:l)&255;if(t.push(a),!o)return}let r=n>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){let l=e>>>s,o=!!(l>>>7),a=(o?l|128:l)&255;if(t.push(a),!o)return}t.push(e>>>31&1)}}var be=65536*65536;function We(n){let e=n[0]=="-";e&&(n=n.slice(1));let t=1e6,r=0,i=0;function s(l,o){let a=Number(n.slice(l,o));i*=t,r=r*t+a,r>=be&&(i=i+(r/be|0),r=r%be)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,r,i]}function Ne(n,e){if(e<=2097151)return""+(be*e+(n>>>0));let t=n&16777215,r=(n>>>24|e<<8)>>>0&16777215,i=e>>16&65535,s=t+r*6777216+i*6710656,l=r+i*8147497,o=i*2,a=1e7;s>=a&&(l+=Math.floor(s/a),s%=a),l>=a&&(o+=Math.floor(l/a),l%=a);function f(u,p){let g=u?String(u):"";return p?"0000000".slice(g.length)+g:g}return f(o,0)+f(l,o)+f(s,1)}function $e(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function mn(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function lr(){let n=new DataView(new ArrayBuffer(8));return globalThis.BigInt!==void 0&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:n}:void 0}var A=lr();function pn(n){if(!n)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var dn=/^-?[0-9]+$/,Ee=65536*65536,xe=class{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Ee+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},F=class extends xe{static from(e){if(A)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=A.C(e);case"number":if(e===0)return this.ZERO;e=A.C(e);case"bigint":if(!e)return this.ZERO;if(e<A.UMIN)throw new Error("signed value for ulong");if(e>A.UMAX)throw new Error("ulong too large");return A.V.setBigUint64(0,e,!0),new F(A.V.getInt32(0,!0),A.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!dn.test(e))throw new Error("string is no integer");let[t,r,i]=We(e);if(t)throw new Error("signed value");return new F(r,i);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new F(e,e/Ee)}throw new Error("unknown value "+typeof e)}toString(){return A?this.toBigInt().toString():Ne(this.lo,this.hi)}toBigInt(){return pn(A),A.V.setInt32(0,this.lo,!0),A.V.setInt32(4,this.hi,!0),A.V.getBigUint64(0,!0)}};F.ZERO=new F(0,0);var O=class extends xe{static from(e){if(A)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=A.C(e);case"number":if(e===0)return this.ZERO;e=A.C(e);case"bigint":if(!e)return this.ZERO;if(e<A.MIN)throw new Error("ulong too small");if(e>A.MAX)throw new Error("ulong too large");return A.V.setBigInt64(0,e,!0),new O(A.V.getInt32(0,!0),A.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!dn.test(e))throw new Error("string is no integer");let[t,r,i]=We(e),s=new O(r,i);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new O(e,e/Ee):new O(-e,-e/Ee).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&2147483648)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new O(t,e)}toString(){if(A)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+Ne(e.lo,e.hi)}return Ne(this.lo,this.hi)}toBigInt(){return pn(A),A.V.setInt32(0,this.lo,!0),A.V.setInt32(4,this.hi,!0),A.V.getBigInt64(0,!0)}};O.ZERO=new O(0,0);var gn={readUnknownField:!0,readerFactory:n=>new Pe(n)};function wn(n){return n?Object.assign(Object.assign({},gn),n):gn}var Pe=class{constructor(e,t){this.varint64=cn,this.uint32=mn,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e){let t=this.pos;switch(e){case c.Varint:for(;this.buf[this.pos++]&128;);break;case c.Bit64:this.pos+=4;case c.Bit32:this.pos+=4;break;case c.LengthDelimited:let r=this.uint32();this.pos+=r;break;case c.StartGroup:let i;for(;(i=this.tag()[1])!==c.EndGroup;)this.skip(i);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new O(...this.varint64())}uint64(){return new F(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,new O(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new F(this.sfixed32(),this.sfixed32())}sfixed64(){return new O(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};function x(n,e){if(!n)throw new Error(e)}var fr=34028234663852886e22,ur=-34028234663852886e22,hr=4294967295,cr=2147483647,mr=-2147483648;function Z(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>cr||n<mr)throw new Error("invalid int 32: "+n)}function ee(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>hr||n<0)throw new Error("invalid uint 32: "+n)}function oe(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>fr||n<ur))throw new Error("invalid float 32: "+n)}var yn={writeUnknownFields:!0,writerFactory:()=>new _e};function vn(n){return n?Object.assign(Object.assign({},yn),n):yn}var _e=class{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let t=new Uint8Array(e),r=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],r),r+=this.chunks[i].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ee(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Z(e),$e(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){oe(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ee(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Z(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Z(e),e=(e<<1^e>>31)>>>0,$e(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=O.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=F.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=O.from(e);return ke(t.lo,t.hi,this.buf),this}sint64(e){let t=O.from(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return ke(i,s,this.buf),this}uint64(e){let t=F.from(e);return ke(t.lo,t.hi,this.buf),this}};var bn={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},kn={ignoreUnknownFields:!1};function Me(n){return n?Object.assign(Object.assign({},kn),n):kn}function he(n){return n?Object.assign(Object.assign({},bn),n):bn}var v=Symbol.for("protobuf-ts/message-type");function Ge(n){let e=!1,t=[];for(let r=0;r<n.length;r++){let i=n.charAt(r);i=="_"?e=!0:/\d/.test(i)?(t.push(i),e=!0):e?(t.push(i.toUpperCase()),e=!1):r==0?t.push(i.toLowerCase()):t.push(i)}return t.join("")}var h;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(h||(h={}));var W;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING",n[n.NUMBER=2]="NUMBER"})(W||(W={}));var ce;(function(n){n[n.NO=0]="NO",n[n.PACKED=1]="PACKED",n[n.UNPACKED=2]="UNPACKED"})(ce||(ce={}));function Nn(n){var e,t,r,i;return n.localName=(e=n.localName)!==null&&e!==void 0?e:Ge(n.name),n.jsonName=(t=n.jsonName)!==null&&t!==void 0?t:Ge(n.name),n.repeat=(r=n.repeat)!==null&&r!==void 0?r:ce.NO,n.opt=(i=n.opt)!==null&&i!==void 0?i:n.repeat||n.oneof?!1:n.kind=="message",n}function En(n){if(typeof n!="object"||n===null||!n.hasOwnProperty("oneofKind"))return!1;switch(typeof n.oneofKind){case"string":return n[n.oneofKind]===void 0?!1:Object.keys(n).length==2;case"undefined":return Object.keys(n).length==1;default:return!1}}var Ie=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;let e=[],t=[],r=[];for(let i of this.fields)if(i.oneof)r.includes(i.oneof)||(r.push(i.oneof),e.push(i.oneof),t.push(i.oneof));else switch(t.push(i.localName),i.kind){case"scalar":case"enum":(!i.opt||i.repeat)&&e.push(i.localName);break;case"message":i.repeat&&e.push(i.localName);break;case"map":e.push(i.localName);break}this.data={req:e,known:t,oneofs:Object.values(r)}}is(e,t,r=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let i=Object.keys(e),s=this.data;if(i.length<s.req.length||s.req.some(l=>!i.includes(l))||!r&&i.some(l=>!s.known.includes(l)))return!1;if(t<1)return!0;for(let l of s.oneofs){let o=e[l];if(!En(o))return!1;if(o.oneofKind===void 0)continue;let a=this.fields.find(f=>f.localName===o.oneofKind);if(!a||!this.field(o[o.oneofKind],a,r,t))return!1}for(let l of this.fields)if(l.oneof===void 0&&!this.field(e[l.localName],l,r,t))return!1;return!0}field(e,t,r,i){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,i,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,h.INT32,i):this.scalar(e,h.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),r,i):this.message(e,t.T(),r,i);case"map":if(typeof e!="object"||e===null)return!1;if(i<2)return!0;if(!this.mapKeys(e,t.K,i))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,i,t.V.L);case"enum":return this.scalars(Object.values(e),h.INT32,i);case"message":return this.messages(Object.values(e),t.V.T(),r,i)}break}return!0}message(e,t,r,i){return r?t.isAssignable(e,i):t.is(e,i)}messages(e,t,r,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(r){for(let s=0;s<e.length&&s<i;s++)if(!t.isAssignable(e[s],i-1))return!1}else for(let s=0;s<e.length&&s<i;s++)if(!t.is(e[s],i-1))return!1;return!0}scalar(e,t,r){let i=typeof e;switch(t){case h.UINT64:case h.FIXED64:case h.INT64:case h.SFIXED64:case h.SINT64:switch(r){case W.BIGINT:return i=="bigint";case W.NUMBER:return i=="number"&&!isNaN(e);default:return i=="string"}case h.BOOL:return i=="boolean";case h.STRING:return i=="string";case h.BYTES:return e instanceof Uint8Array;case h.DOUBLE:case h.FLOAT:return i=="number"&&!isNaN(e);default:return i=="number"&&Number.isInteger(e)}}scalars(e,t,r,i){if(!Array.isArray(e))return!1;if(r<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<r;s++)if(!this.scalar(e[s],t,i))return!1}return!0}mapKeys(e,t,r){let i=Object.keys(e);switch(t){case h.INT32:case h.FIXED32:case h.SFIXED32:case h.SINT32:case h.UINT32:return this.scalars(i.slice(0,r).map(s=>parseInt(s)),t,r);case h.BOOL:return this.scalars(i.slice(0,r).map(s=>s=="true"?!0:s=="false"?!1:s),t,r);default:return this.scalars(i,t,r,W.STRING)}}};function $(n,e){switch(e){case W.BIGINT:return n.toBigInt();case W.NUMBER:return n.toNumber();default:return n.toString()}}var Be=class{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};let t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(let r of t)this.fMap[r.name]=r,this.fMap[r.jsonName]=r,this.fMap[r.localName]=r}}assert(e,t,r){if(!e){let i=Q(r);throw(i=="number"||i=="boolean")&&(i=r.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,r){this.prepare();let i=[];for(let[s,l]of Object.entries(e)){let o=this.fMap[s];if(!o){if(!r.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let a=o.localName,f;if(o.oneof){if(i.includes(o.oneof))throw new Error(`Multiple members of the oneof group "${o.oneof}" of ${this.info.typeName} are present in JSON.`);i.push(o.oneof),f=t[o.oneof]={oneofKind:a}}else f=t;if(o.kind=="map"){if(l===null)continue;this.assert(se(l),o.name,l);let u=f[a];for(let[p,g]of Object.entries(l)){this.assert(g!==null,o.name+" map value",null);let d;switch(o.V.kind){case"message":d=o.V.T().internalJsonRead(g,r);break;case"enum":if(d=this.enum(o.V.T(),g,o.name,r.ignoreUnknownFields),d===!1)continue;break;case"scalar":d=this.scalar(g,o.V.T,o.V.L,o.name);break}this.assert(d!==void 0,o.name+" map value",g);let E=p;o.K==h.BOOL&&(E=E=="true"?!0:E=="false"?!1:E),E=this.scalar(E,o.K,W.STRING,o.name).toString(),u[E]=d}}else if(o.repeat){if(l===null)continue;this.assert(Array.isArray(l),o.name,l);let u=f[a];for(let p of l){this.assert(p!==null,o.name,null);let g;switch(o.kind){case"message":g=o.T().internalJsonRead(p,r);break;case"enum":if(g=this.enum(o.T(),p,o.name,r.ignoreUnknownFields),g===!1)continue;break;case"scalar":g=this.scalar(p,o.T,o.L,o.name);break}this.assert(g!==void 0,o.name,l),u.push(g)}}else switch(o.kind){case"message":if(l===null&&o.T().typeName!="google.protobuf.Value"){this.assert(o.oneof===void 0,o.name+" (oneof member)",null);continue}f[a]=o.T().internalJsonRead(l,r,f[a]);break;case"enum":let u=this.enum(o.T(),l,o.name,r.ignoreUnknownFields);if(u===!1)continue;f[a]=u;break;case"scalar":f[a]=this.scalar(l,o.T,o.L,o.name);break}}}enum(e,t,r,i){if(e[0]=="google.protobuf.NullValue"&&x(t===null,`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return x(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${r}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let l=e[1][s];return typeof l>"u"&&i?!1:(x(typeof l=="number",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} has no value for "${t}".`),l)}x(!1,`Unable to parse field ${this.info.typeName}#${r}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,r,i){let s;try{switch(t){case h.DOUBLE:case h.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let l=Number(e);if(Number.isNaN(l)){s="not a number";break}if(!Number.isFinite(l)){s="too large or small";break}return t==h.FLOAT&&oe(l),l;case h.INT32:case h.FIXED32:case h.SFIXED32:case h.SINT32:case h.UINT32:if(e===null)return 0;let o;if(typeof e=="number"?o=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":o=Number(e)),o===void 0)break;return t==h.UINT32?ee(o):Z(o),o;case h.INT64:case h.SFIXED64:case h.SINT64:if(e===null)return $(O.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return $(O.from(e),r);case h.FIXED64:case h.UINT64:if(e===null)return $(F.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return $(F.from(e),r);case h.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case h.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(a){a="invalid UTF8";break}return e;case h.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return un(e)}}catch(l){s=l.message}this.assert(!1,i+(s?" - "+s:""),e)}};var Oe=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let r={},i=e;for(let s of this.fields){if(!s.oneof){let f=this.field(s,i[s.localName],t);f!==void 0&&(r[t.useProtoFieldName?s.name:s.jsonName]=f);continue}let l=i[s.oneof];if(l.oneofKind!==s.localName)continue;let o=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t,a=this.field(s,l[s.localName],o);x(a!==void 0),r[t.useProtoFieldName?s.name:s.jsonName]=a}return r}field(e,t,r){let i;if(e.kind=="map"){x(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[a,f]of Object.entries(t)){let u=this.scalar(e.V.T,f,e.name,!1,!0);x(u!==void 0),s[a.toString()]=u}break;case"message":let l=e.V.T();for(let[a,f]of Object.entries(t)){let u=this.message(l,f,e.name,r);x(u!==void 0),s[a.toString()]=u}break;case"enum":let o=e.V.T();for(let[a,f]of Object.entries(t)){x(f===void 0||typeof f=="number");let u=this.enum(o,f,e.name,!1,!0,r.enumAsInteger);x(u!==void 0),s[a.toString()]=u}break}(r.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){x(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let a=0;a<t.length;a++){let f=this.scalar(e.T,t[a],e.name,e.opt,!0);x(f!==void 0),s.push(f)}break;case"enum":let l=e.T();for(let a=0;a<t.length;a++){x(t[a]===void 0||typeof t[a]=="number");let f=this.enum(l,t[a],e.name,e.opt,!0,r.enumAsInteger);x(f!==void 0),s.push(f)}break;case"message":let o=e.T();for(let a=0;a<t.length;a++){let f=this.message(o,t[a],e.name,r);x(f!==void 0),s.push(f)}break}(r.emitDefaultValues||s.length>0||r.emitDefaultValues)&&(i=s)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,r.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,r.emitDefaultValues,r.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,r);break}return i}enum(e,t,r,i,s,l){if(e[0]=="google.protobuf.NullValue")return null;if(t===void 0){x(i);return}if(!(t===0&&!s&&!i))return x(typeof t=="number"),x(Number.isInteger(t)),l||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,r,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,r,i,s){if(t===void 0){x(i);return}let l=s||i;switch(e){case h.INT32:case h.SFIXED32:case h.SINT32:return t===0?l?0:void 0:(Z(t),t);case h.FIXED32:case h.UINT32:return t===0?l?0:void 0:(ee(t),t);case h.FLOAT:oe(t);case h.DOUBLE:return t===0?l?0:void 0:(x(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case h.STRING:return t===""?l?"":void 0:(x(typeof t=="string"),t);case h.BOOL:return t===!1?l?!1:void 0:(x(typeof t=="boolean"),t);case h.UINT64:case h.FIXED64:x(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let o=F.from(t);return o.isZero()&&!l?void 0:o.toString();case h.INT64:case h.SFIXED64:case h.SINT64:x(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=O.from(t);return a.isZero()&&!l?void 0:a.toString();case h.BYTES:return x(t instanceof Uint8Array),t.byteLength?hn(t):l?"":void 0}}};function me(n,e=W.STRING){switch(n){case h.BOOL:return!1;case h.UINT64:case h.FIXED64:return $(F.ZERO,e);case h.INT64:case h.SFIXED64:case h.SINT64:return $(O.ZERO,e);case h.DOUBLE:case h.FLOAT:return 0;case h.BYTES:return new Uint8Array(0);case h.STRING:return"";default:return 0}}var Te=class{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){let t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(r=>[r.no,r]))}}read(e,t,r,i){this.prepare();let s=i===void 0?e.len:e.pos+i;for(;e.pos<s;){let[l,o]=e.tag(),a=this.fieldNoToField.get(l);if(!a){let g=r.readUnknownField;if(g=="throw")throw new Error(`Unknown field ${l} (wire type ${o}) for ${this.info.typeName}`);let d=e.skip(o);g!==!1&&(g===!0?m.onRead:g)(this.info.typeName,t,l,o,d);continue}let f=t,u=a.repeat,p=a.localName;switch(a.oneof&&(f=f[a.oneof],f.oneofKind!==p&&(f=t[a.oneof]={oneofKind:p})),a.kind){case"scalar":case"enum":let g=a.kind=="enum"?h.INT32:a.T,d=a.kind=="scalar"?a.L:void 0;if(u){let B=f[p];if(o==c.LengthDelimited&&g!=h.STRING&&g!=h.BYTES){let k=e.uint32()+e.pos;for(;e.pos<k;)B.push(this.scalar(e,g,d))}else B.push(this.scalar(e,g,d))}else f[p]=this.scalar(e,g,d);break;case"message":if(u){let B=f[p],k=a.T().internalBinaryRead(e,e.uint32(),r);B.push(k)}else f[p]=a.T().internalBinaryRead(e,e.uint32(),r,f[p]);break;case"map":let[E,S]=this.mapEntry(a,e,r);f[p][E]=S;break}}}mapEntry(e,t,r){let i=t.uint32(),s=t.pos+i,l,o;for(;t.pos<s;){let[a,f]=t.tag();switch(a){case 1:e.K==h.BOOL?l=t.bool().toString():l=this.scalar(t,e.K,W.STRING);break;case 2:switch(e.V.kind){case"scalar":o=this.scalar(t,e.V.T,e.V.L);break;case"enum":o=t.int32();break;case"message":o=e.V.T().internalBinaryRead(t,t.uint32(),r);break}break;default:throw new Error(`Unknown field ${a} (wire type ${f}) in map entry for ${this.info.typeName}#${e.name}`)}}if(l===void 0){let a=me(e.K);l=e.K==h.BOOL?a.toString():a}if(o===void 0)switch(e.V.kind){case"scalar":o=me(e.V.T,e.V.L);break;case"enum":o=0;break;case"message":o=e.V.T().create();break}return[l,o]}scalar(e,t,r){switch(t){case h.INT32:return e.int32();case h.STRING:return e.string();case h.BOOL:return e.bool();case h.DOUBLE:return e.double();case h.FLOAT:return e.float();case h.INT64:return $(e.int64(),r);case h.UINT64:return $(e.uint64(),r);case h.FIXED64:return $(e.fixed64(),r);case h.FIXED32:return e.fixed32();case h.BYTES:return e.bytes();case h.UINT32:return e.uint32();case h.SFIXED32:return e.sfixed32();case h.SFIXED64:return $(e.sfixed64(),r);case h.SINT32:return e.sint32();case h.SINT64:return $(e.sint64(),r)}}};var Ue=class{constructor(e){this.info=e}prepare(){if(!this.fields){let e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,r)=>t.no-r.no)}}write(e,t,r){this.prepare();for(let s of this.fields){let l,o,a=s.repeat,f=s.localName;if(s.oneof){let u=e[s.oneof];if(u.oneofKind!==f)continue;l=u[f],o=!0}else l=e[f],o=!1;switch(s.kind){case"scalar":case"enum":let u=s.kind=="enum"?h.INT32:s.T;if(a)if(x(Array.isArray(l)),a==ce.PACKED)this.packed(t,u,s.no,l);else for(let p of l)this.scalar(t,u,s.no,p,!0);else l===void 0?x(s.opt):this.scalar(t,u,s.no,l,o||s.opt);break;case"message":if(a){x(Array.isArray(l));for(let p of l)this.message(t,r,s.T(),s.no,p)}else this.message(t,r,s.T(),s.no,l);break;case"map":x(typeof l=="object"&&l!==null);for(let[p,g]of Object.entries(l))this.mapEntry(t,r,s,p,g);break}}let i=r.writeUnknownFields;i!==!1&&(i===!0?m.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,r,i,s){e.tag(r.no,c.LengthDelimited),e.fork();let l=i;switch(r.K){case h.INT32:case h.FIXED32:case h.UINT32:case h.SFIXED32:case h.SINT32:l=Number.parseInt(i);break;case h.BOOL:x(i=="true"||i=="false"),l=i=="true";break}switch(this.scalar(e,r.K,1,l,!0),r.V.kind){case"scalar":this.scalar(e,r.V.T,2,s,!0);break;case"enum":this.scalar(e,h.INT32,2,s,!0);break;case"message":this.message(e,t,r.V.T(),2,s);break}e.join()}message(e,t,r,i,s){s!==void 0&&(r.internalBinaryWrite(s,e.tag(i,c.LengthDelimited).fork(),t),e.join())}scalar(e,t,r,i,s){let[l,o,a]=this.scalarInfo(t,i);(!a||s)&&(e.tag(r,l),e[o](i))}packed(e,t,r,i){if(!i.length)return;x(t!==h.BYTES&&t!==h.STRING),e.tag(r,c.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let l=0;l<i.length;l++)e[s](i[l]);e.join()}scalarInfo(e,t){let r=c.Varint,i,s=t===void 0,l=t===0;switch(e){case h.INT32:i="int32";break;case h.STRING:l=s||!t.length,r=c.LengthDelimited,i="string";break;case h.BOOL:l=t===!1,i="bool";break;case h.UINT32:i="uint32";break;case h.DOUBLE:r=c.Bit64,i="double";break;case h.FLOAT:r=c.Bit32,i="float";break;case h.INT64:l=s||O.from(t).isZero(),i="int64";break;case h.UINT64:l=s||F.from(t).isZero(),i="uint64";break;case h.FIXED64:l=s||F.from(t).isZero(),r=c.Bit64,i="fixed64";break;case h.BYTES:l=s||!t.byteLength,r=c.LengthDelimited,i="bytes";break;case h.FIXED32:r=c.Bit32,i="fixed32";break;case h.SFIXED32:r=c.Bit32,i="sfixed32";break;case h.SFIXED64:l=s||O.from(t).isZero(),r=c.Bit64,i="sfixed64";break;case h.SINT32:i="sint32";break;case h.SINT64:l=s||O.from(t).isZero(),i="sint64";break}return[r,i,s||l]}};function xn(n){let e={};Object.defineProperty(e,v,{enumerable:!1,value:n});for(let t of n.fields){let r=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[r]=[];else switch(t.kind){case"scalar":e[r]=me(t.T,t.L);break;case"enum":e[r]=0;break;case"map":e[r]={};break}}return e}function w(n,e,t){let r,i=t,s;for(let l of n.fields){let o=l.localName;if(l.oneof){let a=i[l.oneof];if(a?.oneofKind==null)continue;if(r=a[o],s=e[l.oneof],s.oneofKind=a.oneofKind,r==null){delete s[o];continue}}else if(r=i[o],s=e,r==null)continue;switch(l.repeat&&(s[o].length=r.length),l.kind){case"scalar":case"enum":if(l.repeat)for(let f=0;f<r.length;f++)s[o][f]=r[f];else s[o]=r;break;case"message":let a=l.T();if(l.repeat)for(let f=0;f<r.length;f++)s[o][f]=a.create(r[f]);else s[o]===void 0?s[o]=a.create(r):a.mergePartial(s[o],r);break;case"map":switch(l.V.kind){case"scalar":case"enum":Object.assign(s[o],r);break;case"message":let f=l.V.T();for(let u of Object.keys(r))s[o][u]=f.create(r[u]);break}break}}}function On(n,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let r of n.fields){let i=r.localName,s=r.oneof?e[r.oneof][i]:e[i],l=r.oneof?t[r.oneof][i]:t[i];switch(r.kind){case"enum":case"scalar":let o=r.kind=="enum"?h.INT32:r.T;if(!(r.repeat?In(o,s,l):Tn(o,s,l)))return!1;break;case"map":if(!(r.V.kind=="message"?Bn(r.V.T(),Ae(s),Ae(l)):In(r.V.kind=="enum"?h.INT32:r.V.T,Ae(s),Ae(l))))return!1;break;case"message":let a=r.T();if(!(r.repeat?Bn(a,s,l):a.equals(s,l)))return!1;break}}return!0}var Ae=Object.values;function Tn(n,e,t){if(e===t)return!0;if(n!==h.BYTES)return!1;let r=e,i=t;if(r.length!==i.length)return!1;for(let s=0;s<r.length;s++)if(r[s]!=i[s])return!1;return!0}function In(n,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Tn(n,e[r],t[r]))return!1;return!0}function Bn(n,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!n.equals(e[r],t[r]))return!1;return!0}var b=class{constructor(e,t,r){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Nn),this.options=r??{},this.refTypeCheck=new Ie(this),this.refJsonReader=new Be(this),this.refJsonWriter=new Oe(this),this.refBinReader=new Te(this),this.refBinWriter=new Ue(this)}create(e){let t=xn(this);return e!==void 0&&w(this,t,e),t}clone(e){let t=this.create();return w(this,t,e),t}equals(e,t){return On(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){w(this,e,t)}fromBinary(e,t){let r=wn(t);return this.internalBinaryRead(r.readerFactory(e),e.byteLength,r)}fromJson(e,t){return this.internalJsonRead(e,Me(t))}fromJsonString(e,t){let r=JSON.parse(e);return this.fromJson(r,t)}toJson(e,t){return this.internalJsonWrite(e,he(t))}toJsonString(e,t){var r;let i=this.toJson(e,t);return JSON.stringify(i,null,(r=t?.prettySpaces)!==null&&r!==void 0?r:0)}toBinary(e,t){let r=vn(t);return this.internalBinaryWrite(e,r.writerFactory(),r).finish()}internalJsonRead(e,t,r){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let i=r??this.create();return this.refJsonReader.read(e,i,t),i}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Q(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,r){return this.refBinWriter.write(e,t,r),t}internalBinaryRead(e,t,r,i){let s=i??this.create();return this.refBinReader.read(e,s,r,t),s}};var je=class extends b{constructor(){super("CommandDm",[{no:1,name:"id",kind:"scalar",T:3,L:0},{no:2,name:"oid",kind:"scalar",T:3,L:0},{no:3,name:"mid",kind:"scalar",T:3,L:0},{no:4,name:"command",kind:"scalar",T:9},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"progress",kind:"scalar",T:5},{no:7,name:"ctime",kind:"scalar",T:9},{no:8,name:"mtime",kind:"scalar",T:9},{no:9,name:"extra",kind:"scalar",T:9},{no:10,name:"idStr",kind:"scalar",T:9}])}create(e){let t={id:0n,oid:0n,mid:0n,command:"",content:"",progress:0,ctime:"",mtime:"",extra:"",idStr:""};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.id=e.int64().toBigInt();break;case 2:s.oid=e.int64().toBigInt();break;case 3:s.mid=e.int64().toBigInt();break;case 4:s.command=e.string();break;case 5:s.content=e.string();break;case 6:s.progress=e.int32();break;case 7:s.ctime=e.string();break;case 8:s.mtime=e.string();break;case 9:s.extra=e.string();break;case 10:s.idStr=e.string();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.id!==0n&&t.tag(1,c.Varint).int64(e.id),e.oid!==0n&&t.tag(2,c.Varint).int64(e.oid),e.mid!==0n&&t.tag(3,c.Varint).int64(e.mid),e.command!==""&&t.tag(4,c.LengthDelimited).string(e.command),e.content!==""&&t.tag(5,c.LengthDelimited).string(e.content),e.progress!==0&&t.tag(6,c.Varint).int32(e.progress),e.ctime!==""&&t.tag(7,c.LengthDelimited).string(e.ctime),e.mtime!==""&&t.tag(8,c.LengthDelimited).string(e.mtime),e.extra!==""&&t.tag(9,c.LengthDelimited).string(e.extra),e.idStr!==""&&t.tag(10,c.LengthDelimited).string(e.idStr);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},te=new je,Ke=class extends b{constructor(){super("DmView",[{no:1,name:"commandDms",kind:"message",repeat:1,T:()=>te}])}create(e){let t={commandDms:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.commandDms.push(te.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){for(let s=0;s<e.commandDms.length;s++)te.internalBinaryWrite(e.commandDms[s],t.tag(1,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},ze=new Ke,Je=class extends b{constructor(){super("DmViewReply",[{no:22,name:"dmView",kind:"message",T:()=>ze}])}create(e){let t={};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 22:s.dmView=ze.internalBinaryRead(e,e.uint32(),r,s.dmView);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.dmView&&ze.internalBinaryWrite(e.dmView,t.tag(22,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Ye=new Je;var pe=class{constructor(n,e,t){this._times=new Map,this.name=n??"",this.debug=t?.debug??!1,n&&this.log(`${n} Start`),this.className=e??"",this.init()}static getInstance(n,e){let t=typeof $task<"u"?"QuanX":"Surge";return pe.instances[t]||(pe.instances[t]=pe.classNames[t](n,t,e)),pe.instances[t]}createProxy(n){return new Proxy(n,{get:this.getFn,set:this.setFn})}getFn(n,e,t){return n[e]}setFn(n,e,t,r){return n[e]=t,!0}getJSON(n,e={}){let t=this.getVal(n);return t?JSON.parse(t):e}setJSON(n,e){this.setVal(JSON.stringify(n),e)}msg(n=this.name,e="",t="",r){}log(n){this.debug&&(typeof n=="object"&&(n=JSON.stringify(n)),console.log(n))}timeStart(n){this._times.set(n,Date.now())}timeEnd(n){if(this._times?.has(n)){let e=Date.now()-this._times.get(n);this.log(`${n}: ${e}ms`),this._times.delete(n)}else this.log(`Timer with label ${n} does not exist.`)}exit(){$done({})}reject(){$done()}},H=pe;H.instances={},H.classNames={QuanX:(n,e,t)=>new An(n,e,t),Surge:(n,e,t)=>new Un(n,e,t)};var Xe=class extends H{getFn(n,e,t){let r=Xe.clientAdapter[e]||e;return super.getFn(n,r,t)}setFn(n,e,t,r){let i=Xe.clientAdapter[e]||e;return super.setFn(n,i,t,r)}init(){try{this.request=this.createProxy($request),this.response=this.createProxy($response)}catch(n){this.log(n.toString())}}getVal(n){return $persistentStore.read(n)}setVal(n,e){$persistentStore.write(n,e)}msg(n=this.name,e="",t="",r){$notification.post(n,e,t,{url:r??""})}async fetch(n){return await new Promise((e,t)=>{let{method:r,body:i,bodyBytes:s,...l}=n,o=s??i,a=o instanceof Uint8Array;$httpClient[r.toLowerCase()]({...l,body:o,"binary-mode":a},(f,u,p)=>{f&&t(f);let g=a?"bodyBytes":"body";e({status:u.status,headers:u.headers,[g]:p})})})}done(n){let e=n.response??n,t,r;e.bodyBytes?(t=e.bodyBytes,delete e.bodyBytes,r={...n},r.response?r.response.body=t:r.body=t):r=n,$done(r)}},Un=Xe;Un.clientAdapter={bodyBytes:"body"};var q=class extends H{static transferBodyBytes(n,e){return n instanceof ArrayBuffer?e==="Uint8Array"?new Uint8Array(n):n:n instanceof Uint8Array&&e==="ArrayBuffer"?n.buffer.slice(n.byteOffset,n.byteLength+n.byteOffset):n}init(){try{this.request=this.createProxy($request),this.response=this.createProxy($response)}catch(n){this.log(n.toString())}}getFn(n,e,t){let r=q.clientAdapter[e]||e,i=super.getFn(n,r,t);return e==="bodyBytes"&&(i=q.transferBodyBytes(i,"Uint8Array")),i}setFn(n,e,t,r){let i=q.clientAdapter[e]||e,s=t;return e==="bodyBytes"&&(s=q.transferBodyBytes(s,"Uint8Array")),super.setFn(n,i,s,r)}getVal(n){return $prefs.valueForKey(n)?.replace(/\0/g,"")}setVal(n,e){$prefs.setValueForKey(n,e)}msg(n=this.name,e="",t="",r){$notify(n,e,t,{"open-url":r??""})}async fetch(n){return await new Promise(e=>{let t={url:"",method:"GET"};for(let[r,i]of Object.entries(n))r==="id"?t.sessionIndex=i:r==="bodyBytes"?t.bodyBytes=q.transferBodyBytes(i,"ArrayBuffer"):t[r]=i;n.bodyBytes&&delete t.body,$task.fetch(t).then(r=>{let i={status:200,headers:{}};for(let[s,l]of Object.entries(r))s==="sessionIndex"?i.id=l:s==="bodyBytes"?i.bodyBytes=q.transferBodyBytes(l,"Uint8Array"):s==="statusCode"?i.status=l:i[s]=l;e(i)})})}done(n){let e=n.response??n,t={};for(let[r,i]of Object.entries(e))r==="status"?t.status=`HTTP/1.1 ${i}`:r==="bodyBytes"?t.bodyBytes=q.transferBodyBytes(i,"ArrayBuffer"):t[r]=i;$done(t)}},An=q;An.clientAdapter={id:"sessionIndex",status:"statusCode"};var pr=H.getInstance("Bilibili Helper",{debug:!1});function dr(n){let e=gr(n.length),t=new Uint8Array(5+n.length);return t[0]=0,t.set(e,1),t.set(n,5),t}function gr(n){let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,n,!1),new Uint8Array(e)}function X(n,e){let t=n.toBinary(e);pr.done({bodyBytes:dr(t)})}var He=class extends b{constructor(){super("ModeStatus",[{no:1,name:"modes",kind:"message",repeat:1,T:()=>Ze}])}create(e){let t={modes:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.modes.push(Ze.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){for(let s=0;s<e.modes.length;s++)Ze.internalBinaryWrite(e.modes[s],t.tag(1,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},tt=new He,Qe=class extends b{constructor(){super("Mode",[{no:1,name:"id",kind:"scalar",T:5},{no:2,name:"name",kind:"scalar",T:9},{no:4,name:"f4",kind:"scalar",T:5},{no:5,name:"f5",kind:"message",T:()=>qe}])}create(e){let t={id:0,name:"",f4:0};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.id=e.int32();break;case 2:s.name=e.string();break;case 4:s.f4=e.int32();break;case 5:s.f5=qe.internalBinaryRead(e,e.uint32(),r,s.f5);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.id!==0&&t.tag(1,c.Varint).int32(e.id),e.name!==""&&t.tag(2,c.LengthDelimited).string(e.name),e.f4!==0&&t.tag(4,c.Varint).int32(e.f4),e.f5&&qe.internalBinaryWrite(e.f5,t.tag(5,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Ze=new Qe,et=class extends b{constructor(){super("F5",[{no:1,name:"f1",kind:"scalar",T:5}])}create(e){let t={f1:0};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.f1=e.int32();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.f1!==0&&t.tag(1,c.Varint).int32(e.f1);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},qe=new et;var nt=class extends b{constructor(){super("google.protobuf.Any",[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}])}pack(e,t){return{typeUrl:this.typeNameToUrl(t.typeName),value:t.toBinary(e)}}unpack(e,t,r){if(!this.contains(e,t))throw new Error("Cannot unpack google.protobuf.Any with typeUrl '"+e.typeUrl+"' as "+t.typeName+".");return t.fromBinary(e.value,r)}contains(e,t){if(!e.typeUrl.length)return!1;let r=typeof t=="string"?t:t.typeName,i=this.typeUrlToName(e.typeUrl);return r===i}internalJsonWrite(e,t){var r;if(e.typeUrl==="")return{};let i=this.typeUrlToName(e.typeUrl),s=he(t),l=(r=s.typeRegistry)===null||r===void 0?void 0:r.find(f=>f.typeName===i);if(!l)throw new globalThis.Error("Unable to convert google.protobuf.Any with typeUrl '"+e.typeUrl+"' to JSON. The specified type "+i+" is not available in the type registry.");let o=l.fromBinary(e.value,{readUnknownField:!1}),a=l.internalJsonWrite(o,s);return(i.startsWith("google.protobuf.")||!se(a))&&(a={value:a}),a["@type"]=e.typeUrl,a}internalJsonRead(e,t,r){var i;if(!se(e))throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON "+Q(e)+".");if(typeof e["@type"]!="string"||e["@type"]=="")return this.create();let s=this.typeUrlToName(e["@type"]),l=(i=t?.typeRegistry)===null||i===void 0?void 0:i.find(a=>a.typeName==s);if(!l)throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON. The specified type "+s+" is not available in the type registry.");let o;if(s.startsWith("google.protobuf.")&&e.hasOwnProperty("value"))o=l.fromJson(e.value,t);else{let a=Object.assign({},e);delete a["@type"],o=l.fromJson(a,t)}return r===void 0&&(r=this.create()),r.typeUrl=e["@type"],r.value=l.toBinary(o),r}typeNameToUrl(e){if(!e.length)throw new Error("invalid type name: "+e);return"type.googleapis.com/"+e}typeUrlToName(e){if(!e.length)throw new Error("invalid type url: "+e);let t=e.lastIndexOf("/"),r=t>0?e.substring(t+1):e;if(!r.length)throw new Error("invalid type url: "+e);return r}create(e){let t={typeUrl:"",value:new Uint8Array(0)};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.typeUrl=e.string();break;case 2:s.value=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.typeUrl!==""&&t.tag(1,c.LengthDelimited).string(e.typeUrl),e.value.length&&t.tag(2,c.LengthDelimited).bytes(e.value);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},D=new nt;var st=class extends b{constructor(){super("CM",[{no:1,name:"source_content",kind:"message",T:()=>D}])}create(e){let t={};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.sourceContent=D.internalBinaryRead(e,e.uint32(),r,s.sourceContent);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.sourceContent&&D.internalBinaryWrite(e.sourceContent,t.tag(1,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},j=new st,ot=class extends b{constructor(){super("CMConfig",[{no:1,name:"ads_control",kind:"message",T:()=>D}])}create(e){let t={};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.adsControl=D.internalBinaryRead(e,e.uint32(),r,s.adsControl);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.adsControl&&D.internalBinaryWrite(e.adsControl,t.tag(1,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},rt=new ot,at=class extends b{constructor(){super("CmIpad",[{no:1,name:"cm",kind:"message",T:()=>j},{no:4,name:"duration",kind:"scalar",T:3,L:0},{no:5,name:"aid",kind:"scalar",T:3,L:0}])}create(e){let t={duration:0n,aid:0n};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.cm=j.internalBinaryRead(e,e.uint32(),r,s.cm);break;case 4:s.duration=e.int64().toBigInt();break;case 5:s.aid=e.int64().toBigInt();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.cm&&j.internalBinaryWrite(e.cm,t.tag(1,c.LengthDelimited).fork(),r).join(),e.duration!==0n&&t.tag(4,c.Varint).int64(e.duration),e.aid!==0n&&t.tag(5,c.Varint).int64(e.aid);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},it=new at,lt=class extends b{constructor(){super("ViewReply",[{no:30,name:"cms",kind:"message",repeat:1,T:()=>j},{no:31,name:"cm_config",kind:"message",T:()=>rt},{no:41,name:"cm_ipad",kind:"message",T:()=>it}])}create(e){let t={cms:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 30:s.cms.push(j.internalBinaryRead(e,e.uint32(),r));break;case 31:s.cmConfig=rt.internalBinaryRead(e,e.uint32(),r,s.cmConfig);break;case 41:s.cmIpad=it.internalBinaryRead(e,e.uint32(),r,s.cmIpad);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){for(let s=0;s<e.cms.length;s++)j.internalBinaryWrite(e.cms[s],t.tag(30,c.LengthDelimited).fork(),r).join();e.cmConfig&&rt.internalBinaryWrite(e.cmConfig,t.tag(31,c.LengthDelimited).fork(),r).join(),e.cmIpad&&it.internalBinaryWrite(e.cmIpad,t.tag(41,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},ft=new lt;var ut=class extends b{constructor(){super("MainListReply",[{no:11,name:"cm",kind:"message",T:()=>j}])}create(e){let t={};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 11:s.cm=j.internalBinaryRead(e,e.uint32(),r,s.cm);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.cm&&j.internalBinaryWrite(e.cm,t.tag(11,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},ht=new ut;var mt=class extends b{constructor(){super("Item",[{no:4,name:"linktype",kind:"scalar",T:9}])}create(e){let t={linktype:""};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 4:s.linktype=e.string();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.linktype!==""&&t.tag(4,c.LengthDelimited).string(e.linktype);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},ct=new mt,pt=class extends b{constructor(){super("SearchAll",[{no:4,name:"items",kind:"message",repeat:1,T:()=>ct}])}create(e){let t={items:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 4:s.items.push(ct.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){for(let s=0;s<e.items.length;s++)ct.internalBinaryWrite(e.items[s],t.tag(4,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},dt=new pt;var ae;(function(n){n[n.dyn_none=0]="dyn_none",n[n.forward=1]="forward",n[n.av=2]="av",n[n.pgc=3]="pgc",n[n.courses=4]="courses",n[n.fold=5]="fold",n[n.word=6]="word",n[n.draw=7]="draw",n[n.article=8]="article",n[n.music=9]="music",n[n.common_square=10]="common_square",n[n.common_vertical=11]="common_vertical",n[n.live=12]="live",n[n.medialist=13]="medialist",n[n.courses_season=14]="courses_season",n[n.ad=15]="ad",n[n.applet=16]="applet",n[n.subscription=17]="subscription",n[n.live_rcmd=18]="live_rcmd",n[n.banner=19]="banner",n[n.ugc_season=20]="ugc_season",n[n.subscription_new=21]="subscription_new",n[n.story=22]="story",n[n.topic_rcmd=23]="topic_rcmd"})(ae||(ae={}));var vt=class extends b{constructor(){super("DynamicItem",[{no:1,name:"card_type",kind:"enum",T:()=>["DynamicType",ae]},{no:2,name:"item_type",kind:"enum",T:()=>["DynamicType",ae]},{no:5,name:"has_fold",kind:"scalar",T:5},{no:6,name:"server_info",kind:"scalar",T:9}])}create(e){let t={cardType:0,itemType:0,hasFold:0,serverInfo:""};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.cardType=e.int32();break;case 2:s.itemType=e.int32();break;case 5:s.hasFold=e.int32();break;case 6:s.serverInfo=e.string();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.cardType!==0&&t.tag(1,c.Varint).int32(e.cardType),e.itemType!==0&&t.tag(2,c.Varint).int32(e.itemType),e.hasFold!==0&&t.tag(5,c.Varint).int32(e.hasFold),e.serverInfo!==""&&t.tag(6,c.LengthDelimited).string(e.serverInfo);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},gt=new vt,bt=class extends b{constructor(){super("DynamicList",[{no:1,name:"list",kind:"message",repeat:1,T:()=>gt},{no:2,name:"update_num",kind:"scalar",T:3,L:0},{no:3,name:"history_offset",kind:"scalar",T:9},{no:4,name:"update_baseline",kind:"scalar",T:9},{no:5,name:"has_more",kind:"scalar",T:8}])}create(e){let t={list:[],updateNum:0n,historyOffset:"",updateBaseline:"",hasMore:!1};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.list.push(gt.internalBinaryRead(e,e.uint32(),r));break;case 2:s.updateNum=e.int64().toBigInt();break;case 3:s.historyOffset=e.string();break;case 4:s.updateBaseline=e.string();break;case 5:s.hasMore=e.bool();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){for(let s=0;s<e.list.length;s++)gt.internalBinaryWrite(e.list[s],t.tag(1,c.LengthDelimited).fork(),r).join();e.updateNum!==0n&&t.tag(2,c.Varint).int64(e.updateNum),e.historyOffset!==""&&t.tag(3,c.LengthDelimited).string(e.historyOffset),e.updateBaseline!==""&&t.tag(4,c.LengthDelimited).string(e.updateBaseline),e.hasMore!==!1&&t.tag(5,c.Varint).bool(e.hasMore);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},wt=new bt,kt=class extends b{constructor(){super("TopicList",[{no:1,name:"title",kind:"scalar",T:9}])}create(e){let t={title:""};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.title=e.string();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.title!==""&&t.tag(1,c.LengthDelimited).string(e.title);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},yt=new kt,Nt=class extends b{constructor(){super("DynAllReply",[{no:1,name:"dynamic_list",kind:"message",T:()=>wt},{no:3,name:"topic_list",kind:"message",T:()=>yt}])}create(e){let t={};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.dynamicList=wt.internalBinaryRead(e,e.uint32(),r,s.dynamicList);break;case 3:s.topicList=yt.internalBinaryRead(e,e.uint32(),r,s.topicList);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.dynamicList&&wt.internalBinaryWrite(e.dynamicList,t.tag(1,c.LengthDelimited).fork(),r).join(),e.topicList&&yt.internalBinaryWrite(e.topicList,t.tag(3,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Et=new Nt;var It=class extends b{constructor(){super("ViewProgress",[{no:1,name:"dm",kind:"message",T:()=>xt}])}create(e){let t={};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.dm=xt.internalBinaryRead(e,e.uint32(),r,s.dm);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.dm&&xt.internalBinaryWrite(e.dm,t.tag(1,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Ot=new It,Bt=class extends b{constructor(){super("DM",[{no:2,name:"commandDms",kind:"message",repeat:1,T:()=>te}])}create(e){let t={commandDms:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 2:s.commandDms.push(te.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){for(let s=0;s<e.commandDms.length;s++)te.internalBinaryWrite(e.commandDms[s],t.tag(2,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},xt=new Bt;var Lt;(function(n){n[n.TAB_NONE=0]="TAB_NONE",n[n.TAB_INTRODUCTION=1]="TAB_INTRODUCTION",n[n.TAB_REPLY=2]="TAB_REPLY",n[n.TAB_OGV_ACTIVITY=3]="TAB_OGV_ACTIVITY"})(Lt||(Lt={}));var de;(function(n){n[n.UNKNOWN=0]="UNKNOWN",n[n.OGV_INTRODUCTION=1]="OGV_INTRODUCTION",n[n.OGV_TITLE=2]="OGV_TITLE",n[n.UGC_HEADLINE=3]="UGC_HEADLINE",n[n.UGC_INTRODUCTION=4]="UGC_INTRODUCTION",n[n.KING_POSITION=5]="KING_POSITION",n[n.MASTER_USER_LIST=6]="MASTER_USER_LIST",n[n.STAFFS=7]="STAFFS",n[n.HONOR=8]="HONOR",n[n.OWNER=9]="OWNER",n[n.PAGE=10]="PAGE",n[n.ACTIVITY_RESERVE=11]="ACTIVITY_RESERVE",n[n.LIVE_ORDER=12]="LIVE_ORDER",n[n.POSITIVE=13]="POSITIVE",n[n.SECTION=14]="SECTION",n[n.RELATE=15]="RELATE",n[n.PUGV=16]="PUGV",n[n.COLLECTION_CARD=17]="COLLECTION_CARD",n[n.ACTIVITY=18]="ACTIVITY",n[n.CHARACTER=19]="CHARACTER",n[n.FOLLOW_LAYER=20]="FOLLOW_LAYER",n[n.OGV_SEASONS=21]="OGV_SEASONS",n[n.UGC_SEASON=22]="UGC_SEASON",n[n.OGV_LIVE_RESERVE=23]="OGV_LIVE_RESERVE",n[n.COMBINATION_EPISODE=24]="COMBINATION_EPISODE",n[n.SPONSOR=25]="SPONSOR",n[n.ACTIVITY_ENTRANCE=26]="ACTIVITY_ENTRANCE",n[n.THEATRE_HOT_TOPIC=27]="THEATRE_HOT_TOPIC",n[n.RELATED_RECOMMEND=28]="RELATED_RECOMMEND",n[n.PAY_BAR=29]="PAY_BAR",n[n.BANNER=30]="BANNER",n[n.AUDIO=31]="AUDIO",n[n.AGG_CARD=32]="AGG_CARD",n[n.SINGLE_EP=33]="SINGLE_EP",n[n.LIKE_COMMENT=34]="LIKE_COMMENT",n[n.ATTENTION_RECOMMEND=35]="ATTENTION_RECOMMEND",n[n.COVENANTER=36]="COVENANTER"})(de||(de={}));var ge;(function(n){n[n.CARD_TYPE_UNKNOWN=0]="CARD_TYPE_UNKNOWN",n[n.AV=1]="AV",n[n.BANGUMI=2]="BANGUMI",n[n.RESOURCE=3]="RESOURCE",n[n.GAME=4]="GAME",n[n.CM_TYPE=5]="CM_TYPE",n[n.LIVE=6]="LIVE",n[n.AI_RECOMMEND=7]="AI_RECOMMEND",n[n.BANGUMI_AV=8]="BANGUMI_AV",n[n.BANGUMI_UGC=9]="BANGUMI_UGC",n[n.SPECIAL=10]="SPECIAL"})(ge||(ge={}));var Dt=class extends b{constructor(){super("viewunite.v1.RelateCard",[{no:1,name:"relate_card_type",kind:"enum",T:()=>["viewunite.v1.RelateCardType",ge]}])}create(e){let t={relateCardType:0};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.relateCardType=e.int32();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.relateCardType!==0&&t.tag(1,c.Varint).int32(e.relateCardType);let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Tt=new Dt,Ct=class extends b{constructor(){super("viewunite.v1.Relates",[{no:1,name:"cards",kind:"message",repeat:1,T:()=>Tt}])}create(e){let t={cards:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.cards.push(Tt.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){for(let s=0;s<e.cards.length;s++)Tt.internalBinaryWrite(e.cards[s],t.tag(1,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Ut=new Ct,Wt=class extends b{constructor(){super("viewunite.v1.CommonModule",[{no:1,name:"type",kind:"enum",T:()=>["viewunite.v1.ModuleType",de]},{no:22,name:"relates",kind:"message",oneof:"data",T:()=>Ut}])}create(e){let t={type:0,data:{oneofKind:void 0}};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.type=e.int32();break;case 22:s.data={oneofKind:"relates",relates:Ut.internalBinaryRead(e,e.uint32(),r,s.data.relates)};break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.type!==0&&t.tag(1,c.Varint).int32(e.type),e.data.oneofKind==="relates"&&Ut.internalBinaryWrite(e.data.relates,t.tag(22,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},At=new Wt,$t=class extends b{constructor(){super("viewunite.v1.IntroductionTab",[{no:1,name:"title",kind:"scalar",T:9},{no:2,name:"modules",kind:"message",repeat:1,T:()=>At}])}create(e){let t={title:"",modules:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.title=e.string();break;case 2:s.modules.push(At.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.title!==""&&t.tag(1,c.LengthDelimited).string(e.title);for(let s=0;s<e.modules.length;s++)At.internalBinaryWrite(e.modules[s],t.tag(2,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Ft=new $t,Pt=class extends b{constructor(){super("viewunite.v1.TabModule",[{no:1,name:"tab_type",kind:"enum",T:()=>["viewunite.v1.TabType",Lt]},{no:2,name:"introduction",kind:"message",oneof:"tab",T:()=>Ft}])}create(e){let t={tabType:0,tab:{oneofKind:void 0}};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.tabType=e.int32();break;case 2:s.tab={oneofKind:"introduction",introduction:Ft.internalBinaryRead(e,e.uint32(),r,s.tab.introduction)};break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.tabType!==0&&t.tag(1,c.Varint).int32(e.tabType),e.tab.oneofKind==="introduction"&&Ft.internalBinaryWrite(e.tab.introduction,t.tag(2,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Rt=new Pt,_t=class extends b{constructor(){super("viewunite.v1.Tab",[{no:1,name:"tab_module",kind:"message",repeat:1,T:()=>Rt}])}create(e){let t={tabModule:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.tabModule.push(Rt.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){for(let s=0;s<e.tabModule.length;s++)Rt.internalBinaryWrite(e.tabModule[s],t.tag(1,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},St=new _t,Mt=class extends b{constructor(){super("viewunite.v1.CM",[{no:1,name:"cm_under_player",kind:"message",T:()=>D},{no:2,name:"ads_control",kind:"message",T:()=>D},{no:3,name:"source_content",kind:"message",repeat:1,T:()=>D}])}create(e){let t={sourceContent:[]};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 1:s.cmUnderPlayer=D.internalBinaryRead(e,e.uint32(),r,s.cmUnderPlayer);break;case 2:s.adsControl=D.internalBinaryRead(e,e.uint32(),r,s.adsControl);break;case 3:s.sourceContent.push(D.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.cmUnderPlayer&&D.internalBinaryWrite(e.cmUnderPlayer,t.tag(1,c.LengthDelimited).fork(),r).join(),e.adsControl&&D.internalBinaryWrite(e.adsControl,t.tag(2,c.LengthDelimited).fork(),r).join();for(let s=0;s<e.sourceContent.length;s++)D.internalBinaryWrite(e.sourceContent[s],t.tag(3,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},Vt=new Mt,Gt=class extends b{constructor(){super("viewunite.v1.ViewUniteReply",[{no:5,name:"tab",kind:"message",T:()=>St},{no:7,name:"cm",kind:"message",T:()=>Vt}])}create(e){let t={};return globalThis.Object.defineProperty(t,v,{enumerable:!1,value:this}),e!==void 0&&w(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),l=e.pos+t;for(;e.pos<l;){let[o,a]=e.tag();switch(o){case 5:s.tab=St.internalBinaryRead(e,e.uint32(),r,s.tab);break;case 7:s.cm=Vt.internalBinaryRead(e,e.uint32(),r,s.cm);break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${a}) for ${this.typeName}`);let u=e.skip(a);f!==!1&&(f===!0?m.onRead:f)(this.typeName,s,o,a,u)}}return s}internalBinaryWrite(e,t,r){e.tab&&St.internalBinaryWrite(e.tab,t.tag(5,c.LengthDelimited).fork(),r).join(),e.cm&&Vt.internalBinaryWrite(e.cm,t.tag(7,c.LengthDelimited).fork(),r).join();let i=r.writeUnknownFields;return i!==!1&&(i==!0?m.onWrite:i)(this.typeName,e,t),t}},zt=new Gt;function Fn(n){let e=Ye.fromBinary(n);e.dmView?.commandDms?.length&&(e.dmView.commandDms.length=0,X(Ye,e))}function Rn(n){let e=tt.fromBinary(n),t=e.modes.find(r=>r.name==="teenagers");t?.f5?.f1&&(t.f5.f1=0,X(tt,e))}function Sn(n){let e=ft.fromBinary(n);delete e.cmConfig,delete e.cmIpad,e.cms.length=0,X(ft,e)}function Vn(n){let e=ht.fromBinary(n);delete e.cm,X(ht,e)}function Ln(n){let e=dt.fromBinary(n);e.items=e.items.filter(t=>!t.linktype.endsWith("_ad")),X(dt,e)}function Dn(n){let e=Et.fromBinary(n);delete e.topicList,e.dynamicList.list=e.dynamicList.list.filter(t=>t.cardType!==ae.ad),X(Et,e)}function Cn(n){let e=Ot.fromBinary(n);delete e.dm,X(Ot,e)}function Wn(n){let e=zt.fromBinary(n);delete e.cm,e.tab.tabModule.forEach(t=>{if(t.tab.oneofKind!=="introduction")return;let r=t.tab.introduction.modules.find(i=>i.type===de.RELATED_RECOMMEND);r?.data?.oneofKind!=="relates"||!r.data.relates.cards||(r.data.relates.cards=r.data.relates.cards.filter(i=>i.relateCardType===ge.AV))}),X(zt,e)}var wr=/(?<scheme>.+):\/\/(?<host>[^/]+)\/?(?<path>[^?]+)?\??(?<params>.*)?/,we=class{constructor(e=""){if(this.name="URL v1.0.2",!e)throw new Error("Empty URL");this.parse(e)}parse(e){let{scheme:t,host:r,path:i="",params:s}=e.match(wr)?.groups??{};this.scheme=t,this.host=r,this.path=i,this.params=s?s.split("&").reduce((l,o)=>{let[a,f]=o.split("=");return l[a]=f,l},{}):{}}toString(){let e=this.scheme+"://"+this.host+"/"+this.path;return this.params&&(e+="?"+Object.entries(this.params).reduce((t,[r,i],s)=>t+(s?"&":"")+r+"="+i,"")),e}};var Kt=H.getInstance("Bilibili Helper",{debug:!1}),yr=Kt.request.url,Pn=Kt.response.bodyBytes,vr=new we(yr).path,br=typeof $utils=="object"&&typeof $utils?.ungzip=="function"?$utils.ungzip:fn,kr=Pn.slice(0,5),jt=Pn.slice(5);kr[0]&&(jt=br(jt));var $n={"v1.DM/DmView":Fn,"v1.Teenagers/ModeStatus":Rn,"v1.Reply/MainList":Vn,"v1.Search/SearchAll":Ln,"v2.Dynamic/DynAll":Dn,"viewunite.v1.View/View":Wn,"view.v1.View/ViewProgress":Cn,"view.v1.View/View":Sn};for(let n in $n)if(vr.endsWith(n)){$n[n](jt);break}Kt.exit();})();