/* 脚本作者:Maasea 引用地址:https://raw.githubusercontent.com/Maasea/sgmodule/master/Script/Youtube/youtube.response.js */ // Build: 2025/7/12 20:17:26 (()=>{var $r=Object.defineProperty;var jr=(l,e,t)=>e in l?$r(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var ce=(l,e,t)=>(jr(l,typeof e!="symbol"?e+"":e,t),t);(function(l){function e(){}function t(){}var n=String.fromCharCode,i={}.toString,r=i.call(l.SharedArrayBuffer),c=i(),a=l.Uint8Array,o=a||Array,s=a?ArrayBuffer:o,u=s.isView||function(B){return B&&"length"in B},g=i.call(s.prototype);s=t.prototype;var b=l.TextEncoder,m=new(a?Uint16Array:o)(32);e.prototype.decode=function(B){if(!u(B)){var D=i.call(B);if(D!==g&&D!==r&&D!==c)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");B=a?new o(B):B||[]}for(var W=D="",k=0,T=B.length|0,le=T-32|0,C,x,L=0,_=0,$,A=0,j=-1;k>4){case 15:if($=B[k=k+1|0]&255,$>>6!==2||247>6===2?_+4|0:24,x=x+256&768;case 13:case 12:$=B[k=k+1|0]&255,L<<=6,L|=(x&31)<<6|$&63,_=_+7|0,k>6===2&&L>>_&&1114112>L?(x=L,L=L-65536|0,0<=L&&(j=(L>>10)+55296|0,x=(L&1023)+56320|0,31>A?(m[A]=j,A=A+1|0,j=-1):($=j,j=x,x=$))):(x>>=8,k=k-x-1|0,x=65533),L=_=0,C=k<=le?32:T-k|0;default:m[A]=x;continue;case 11:case 10:case 9:case 8:}m[A]=65533}if(W+=n(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],m[8],m[9],m[10],m[11],m[12],m[13],m[14],m[15],m[16],m[17],m[18],m[19],m[20],m[21],m[22],m[23],m[24],m[25],m[26],m[27],m[28],m[29],m[30],m[31]),32>A&&(W=W.slice(0,A-32|0)),k>>31,j=-1,W.length=C)W[T]=C;else{if(2047>=C)W[T]=192|C>>6;else{e:{if(55296<=C)if(56319>=C){var x=B.charCodeAt(k=k+1|0)|0;if(56320<=x&&57343>=x){if(C=(C<<10)+x-56613888|0,65535>18,W[T=T+1|0]=128|C>>12&63,W[T=T+1|0]=128|C>>6&63,W[T=T+1|0]=128|C&63;continue}break e}C=65533}else 57343>=C&&(C=65533);!le&&k<<1>12,W[T=T+1|0]=128|C>>6&63}W[T=T+1|0]=128|C&63}}return a?W.subarray(0,T):W.slice(0,T)},b||(l.TextDecoder=e,l.TextEncoder=t)})(globalThis);function Re(l){let e=typeof l;if(e=="object"){if(Array.isArray(l))return"array";if(l===null)return"null"}return e}function lr(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)}var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),we=[];for(let l=0;l>4,c=r,i=2;break;case 2:t[n++]=(c&15)<<4|(r&60)>>2,c=r,i=3;break;case 3:t[n++]=(c&3)<<6|r,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function ur(l){let e="",t=0,n,i=0;for(let r=0;r>2],i=(n&3)<<4,t=1;break;case 1:e+=V[i|n>>4],i=(n&15)<<2,t=2;break;case 2:e+=V[i|n>>6],e+=V[n&63],t=0;break}return t&&(e+=V[i],e+="=",t==1&&(e+="=")),e}var f;(function(l){l.symbol=Symbol.for("protobuf-ts/unknown"),l.onRead=(t,n,i,r,c)=>{(e(n)?n[l.symbol]:n[l.symbol]=[]).push({no:i,wireType:r,data:c})},l.onWrite=(t,n,i)=>{for(let{no:r,wireType:c,data:a}of l.list(n))i.tag(r,c).raw(a)},l.list=(t,n)=>{if(e(t)){let i=t[l.symbol];return n?i.filter(r=>r.no==n):i}return[]},l.last=(t,n)=>l.list(t,n).slice(-1)[0];let e=t=>t&&Array.isArray(t[l.symbol])})(f||(f={}));var d;(function(l){l[l.Varint=0]="Varint",l[l.Bit64=1]="Bit64",l[l.LengthDelimited=2]="LengthDelimited",l[l.StartGroup=3]="StartGroup",l[l.EndGroup=4]="EndGroup",l[l.Bit32=5]="Bit32"})(d||(d={}));function dr(){let l=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(l|=(i&127)<>4,!(t&128))return this.assertBounds(),[l,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<>>r,a=!(!(c>>>7)&&e==0),o=(a?c|128:c)&255;if(t.push(o),!a)return}let n=l>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?n|128:n)&255),!!i){for(let r=3;r<31;r=r+7){let c=e>>>r,a=!!(c>>>7),o=(a?c|128:c)&255;if(t.push(o),!a)return}t.push(e>>>31&1)}}var Be=(1<<16)*(1<<16);function Ge(l){let e=l[0]=="-";e&&(l=l.slice(1));let t=1e6,n=0,i=0;function r(c,a){let o=Number(l.slice(c,a));i*=t,n=n*t+o,n>=Be&&(i=i+(n/Be|0),n=n%Be)}return r(-24,-18),r(-18,-12),r(-12,-6),r(-6),[e,n,i]}function Te(l,e){if(e>>>0<=2097151)return""+(Be*e+(l>>>0));let t=l&16777215,n=(l>>>24|e<<8)>>>0&16777215,i=e>>16&65535,r=t+n*6777216+i*6710656,c=n+i*8147497,a=i*2,o=1e7;r>=o&&(c+=Math.floor(r/o),r%=o),c>=o&&(a+=Math.floor(c/o),c%=o);function s(u,g){let b=u?String(u):"";return g?"0000000".slice(b.length)+b:b}return s(a,0)+s(c,a)+s(r,1)}function Ke(l,e){if(l>=0){for(;l>127;)e.push(l&127|128),l=l>>>7;e.push(l)}else{for(let t=0;t<9;t++)e.push(l&127|128),l=l>>7;e.push(1)}}function fr(){let l=this.buf[this.pos++],e=l&127;if(!(l&128))return this.assertBounds(),e;if(l=this.buf[this.pos++],e|=(l&127)<<7,!(l&128))return this.assertBounds(),e;if(l=this.buf[this.pos++],e|=(l&127)<<14,!(l&128))return this.assertBounds(),e;if(l=this.buf[this.pos++],e|=(l&127)<<21,!(l&128))return this.assertBounds(),e;l=this.buf[this.pos++],e|=(l&15)<<28;for(let t=5;l&128&&t<10;t++)l=this.buf[this.pos++];if(l&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var N;function Vr(){let l=new DataView(new ArrayBuffer(8));N=globalThis.BigInt!==void 0&&typeof l.getBigInt64=="function"&&typeof l.getBigUint64=="function"&&typeof l.setBigInt64=="function"&&typeof l.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:l}:void 0}Vr();function pr(l){if(!l)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var hr=/^-?[0-9]+$/,Se=4294967296,Ne=2147483648,We=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*Se+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},O=class extends We{static from(e){if(N)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=N.C(e);case"number":if(e===0)return this.ZERO;e=N.C(e);case"bigint":if(!e)return this.ZERO;if(eN.UMAX)throw new Error("ulong too large");return N.V.setBigUint64(0,e,!0),new O(N.V.getInt32(0,!0),N.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!hr.test(e))throw new Error("string is no integer");let[t,n,i]=Ge(e);if(t)throw new Error("signed value for ulong");return new O(n,i);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new O(e,e/Se)}throw new Error("unknown value "+typeof e)}toString(){return N?this.toBigInt().toString():Te(this.lo,this.hi)}toBigInt(){return pr(N),N.V.setInt32(0,this.lo,!0),N.V.setInt32(4,this.hi,!0),N.V.getBigUint64(0,!0)}};O.ZERO=new O(0,0);var I=class extends We{static from(e){if(N)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=N.C(e);case"number":if(e===0)return this.ZERO;e=N.C(e);case"bigint":if(!e)return this.ZERO;if(eN.MAX)throw new Error("signed long too large");return N.V.setBigInt64(0,e,!0),new I(N.V.getInt32(0,!0),N.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!hr.test(e))throw new Error("string is no integer");let[t,n,i]=Ge(e);if(t){if(i>Ne||i==Ne&&n!=0)throw new Error("signed long too small")}else if(i>=Ne)throw new Error("signed long too large");let r=new I(n,i);return t?r.negate():r;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new I(e,e/Se):new I(-e,-e/Se).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&Ne)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new I(t,e)}toString(){if(N)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+Te(e.lo,e.hi)}return Te(this.lo,this.hi)}toBigInt(){return pr(N),N.V.setInt32(0,this.lo,!0),N.V.setInt32(4,this.hi,!0),N.V.getBigInt64(0,!0)}};I.ZERO=new I(0,0);var yr={readUnknownField:!0,readerFactory:l=>new Je(l)};function mr(l){return l?Object.assign(Object.assign({},yr),l):yr}var Je=class{constructor(e,t){this.varint64=dr,this.uint32=fr,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,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case d.Varint:for(;this.buf[this.pos++]&128;);break;case d.Bit64:this.pos+=4;case d.Bit32:this.pos+=4;break;case d.LengthDelimited:let n=this.uint32();this.pos+=n;break;case d.StartGroup:let i;for(;(i=this.tag()[1])!==d.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 I(...this.varint64())}uint64(){return new O(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new I(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 O(this.sfixed32(),this.sfixed32())}sfixed64(){return new I(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 R(l,e){if(!l)throw new Error(e)}var Mr=34028234663852886e22,vr=-34028234663852886e22,Gr=4294967295,Kr=2147483647,Jr=-2147483648;function K(l){if(typeof l!="number")throw new Error("invalid int 32: "+typeof l);if(!Number.isInteger(l)||l>Kr||lGr||l<0)throw new Error("invalid uint 32: "+l)}function z(l){if(typeof l!="number")throw new Error("invalid float 32: "+typeof l);if(Number.isFinite(l)&&(l>Mr||lnew _e};function br(l){return l?Object.assign(Object.assign({},gr),l):gr}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>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(X(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return K(e),Ke(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){z(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){X(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){K(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return K(e),e=(e<<1^e>>31)>>>0,Ke(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=I.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=O.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=I.from(e);return Ie(t.lo,t.hi,this.buf),this}sint64(e){let t=I.from(e),n=t.hi>>31,i=t.lo<<1^n,r=(t.hi<<1|t.lo>>>31)^n;return Ie(i,r,this.buf),this}uint64(e){let t=O.from(e);return Ie(t.lo,t.hi,this.buf),this}};var kr={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Rr={ignoreUnknownFields:!1};function wr(l){return l?Object.assign(Object.assign({},Rr),l):Rr}function Br(l){return l?Object.assign(Object.assign({},kr),l):kr}var xe=Symbol.for("protobuf-ts/message-type");function Xe(l){let e=!1,t=[];for(let n=0;n!i.includes(c))||!n&&i.some(c=>!r.known.includes(c)))return!1;if(t<1)return!0;for(let c of r.oneofs){let a=e[c];if(!Tr(a))return!1;if(a.oneofKind===void 0)continue;let o=this.fields.find(s=>s.localName===a.oneofKind);if(!o||!this.field(a[a.oneofKind],o,n,t))return!1}for(let c of this.fields)if(c.oneof===void 0&&!this.field(e[c.localName],c,n,t))return!1;return!0}field(e,t,n,i){let r=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:r?this.scalars(e,t.T,i,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:r?this.scalars(e,p.INT32,i):this.scalar(e,p.INT32);case"message":return e===void 0?!0:r?this.messages(e,t.T(),n,i):this.message(e,t.T(),n,i);case"map":if(typeof e!="object"||e===null)return!1;if(i<2)return!0;if(!this.mapKeys(e,t.K,i))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,i,t.V.L);case"enum":return this.scalars(Object.values(e),p.INT32,i);case"message":return this.messages(Object.values(e),t.V.T(),n,i)}break}return!0}message(e,t,n,i){return n?t.isAssignable(e,i):t.is(e,i)}messages(e,t,n,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(n){for(let r=0;rparseInt(r)),t,n);case p.BOOL:return this.scalars(i.slice(0,n).map(r=>r=="true"?!0:r=="false"?!1:r),t,n);default:return this.scalars(i,t,n,E.STRING)}}};function F(l,e){switch(e){case E.BIGINT:return l.toBigInt();case E.NUMBER:return l.toNumber();default:return l.toString()}}var Pe=class{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};let t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(let n of t)this.fMap[n.name]=n,this.fMap[n.jsonName]=n,this.fMap[n.localName]=n}}assert(e,t,n){if(!e){let i=Re(n);throw(i=="number"||i=="boolean")&&(i=n.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();let i=[];for(let[r,c]of Object.entries(e)){let a=this.fMap[r];if(!a){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${r}`);continue}let o=a.localName,s;if(a.oneof){if(c===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(i.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);i.push(a.oneof),s=t[a.oneof]={oneofKind:o}}else s=t;if(a.kind=="map"){if(c===null)continue;this.assert(lr(c),a.name,c);let u=s[o];for(let[g,b]of Object.entries(c)){this.assert(b!==null,a.name+" map value",null);let m;switch(a.V.kind){case"message":m=a.V.T().internalJsonRead(b,n);break;case"enum":if(m=this.enum(a.V.T(),b,a.name,n.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(b,a.V.T,a.V.L,a.name);break}this.assert(m!==void 0,a.name+" map value",b);let B=g;a.K==p.BOOL&&(B=B=="true"?!0:B=="false"?!1:B),B=this.scalar(B,a.K,E.STRING,a.name).toString(),u[B]=m}}else if(a.repeat){if(c===null)continue;this.assert(Array.isArray(c),a.name,c);let u=s[o];for(let g of c){this.assert(g!==null,a.name,null);let b;switch(a.kind){case"message":b=a.T().internalJsonRead(g,n);break;case"enum":if(b=this.enum(a.T(),g,a.name,n.ignoreUnknownFields),b===!1)continue;break;case"scalar":b=this.scalar(g,a.T,a.L,a.name);break}this.assert(b!==void 0,a.name,c),u.push(b)}}else switch(a.kind){case"message":if(c===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}s[o]=a.T().internalJsonRead(c,n,s[o]);break;case"enum":let u=this.enum(a.T(),c,a.name,n.ignoreUnknownFields);if(u===!1)continue;s[o]=u;break;case"scalar":s[o]=this.scalar(c,a.T,a.L,a.name);break}}}enum(e,t,n,i){if(e[0]=="google.protobuf.NullValue"&&R(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return R(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let r=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(r=t.substring(e[2].length));let c=e[1][r];return typeof c>"u"&&i?!1:(R(typeof c=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),c)}R(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,i){let r;try{switch(t){case p.DOUBLE:case p.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===""){r="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){r="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let c=Number(e);if(Number.isNaN(c)){r="not a number";break}if(!Number.isFinite(c)){r="too large or small";break}return t==p.FLOAT&&z(c),c;case p.INT32:case p.FIXED32:case p.SFIXED32:case p.SINT32:case p.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?r="empty string":typeof e=="string"&&(e.trim().length!==e.length?r="extra whitespace":a=Number(e)),a===void 0)break;return t==p.UINT32?X(a):K(a),a;case p.INT64:case p.SFIXED64:case p.SINT64:if(e===null)return F(I.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return F(I.from(e),n);case p.FIXED64:case p.UINT64:if(e===null)return F(O.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return F(O.from(e),n);case p.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case p.STRING:if(e===null)return"";if(typeof e!="string"){r="extra whitespace";break}try{encodeURIComponent(e)}catch(o){o="invalid UTF8";break}return e;case p.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return cr(e)}}catch(c){r=c.message}this.assert(!1,i+(r?" - "+r:""),e)}};var Ce=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let n={},i=e;for(let r of this.fields){if(!r.oneof){let s=this.field(r,i[r.localName],t);s!==void 0&&(n[t.useProtoFieldName?r.name:r.jsonName]=s);continue}let c=i[r.oneof];if(c.oneofKind!==r.localName)continue;let a=r.kind=="scalar"||r.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t,o=this.field(r,c[r.localName],a);R(o!==void 0),n[t.useProtoFieldName?r.name:r.jsonName]=o}return n}field(e,t,n){let i;if(e.kind=="map"){R(typeof t=="object"&&t!==null);let r={};switch(e.V.kind){case"scalar":for(let[o,s]of Object.entries(t)){let u=this.scalar(e.V.T,s,e.name,!1,!0);R(u!==void 0),r[o.toString()]=u}break;case"message":let c=e.V.T();for(let[o,s]of Object.entries(t)){let u=this.message(c,s,e.name,n);R(u!==void 0),r[o.toString()]=u}break;case"enum":let a=e.V.T();for(let[o,s]of Object.entries(t)){R(s===void 0||typeof s=="number");let u=this.enum(a,s,e.name,!1,!0,n.enumAsInteger);R(u!==void 0),r[o.toString()]=u}break}(n.emitDefaultValues||Object.keys(r).length>0)&&(i=r)}else if(e.repeat){R(Array.isArray(t));let r=[];switch(e.kind){case"scalar":for(let o=0;o0||n.emitDefaultValues)&&(i=r)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,n);break}return i}enum(e,t,n,i,r,c){if(e[0]=="google.protobuf.NullValue")return!r&&!i?void 0:null;if(t===void 0){R(i);return}if(!(t===0&&!r&&!i))return R(typeof t=="number"),R(Number.isInteger(t)),c||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,n,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,n,i,r){if(t===void 0){R(i);return}let c=r||i;switch(e){case p.INT32:case p.SFIXED32:case p.SINT32:return t===0?c?0:void 0:(K(t),t);case p.FIXED32:case p.UINT32:return t===0?c?0:void 0:(X(t),t);case p.FLOAT:z(t);case p.DOUBLE:return t===0?c?0:void 0:(R(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case p.STRING:return t===""?c?"":void 0:(R(typeof t=="string"),t);case p.BOOL:return t===!1?c?!1:void 0:(R(typeof t=="boolean"),t);case p.UINT64:case p.FIXED64:R(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=O.from(t);return a.isZero()&&!c?void 0:a.toString();case p.INT64:case p.SFIXED64:case p.SINT64:R(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let o=I.from(t);return o.isZero()&&!c?void 0:o.toString();case p.BYTES:return R(t instanceof Uint8Array),t.byteLength?ur(t):c?"":void 0}}};function de(l,e=E.STRING){switch(l){case p.BOOL:return!1;case p.UINT64:case p.FIXED64:return F(O.ZERO,e);case p.INT64:case p.SFIXED64:case p.SINT64:return F(I.ZERO,e);case p.DOUBLE:case p.FLOAT:return 0;case p.BYTES:return new Uint8Array(0);case p.STRING:return"";default:return 0}}var Ue=class{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){let t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(n=>[n.no,n]))}}read(e,t,n,i){this.prepare();let r=i===void 0?e.len:e.pos+i;for(;e.post.no-n.no)}}write(e,t,n){this.prepare();for(let r of this.fields){let c,a,o=r.repeat,s=r.localName;if(r.oneof){let u=e[r.oneof];if(u.oneofKind!==s)continue;c=u[s],a=!0}else c=e[s],a=!1;switch(r.kind){case"scalar":case"enum":let u=r.kind=="enum"?p.INT32:r.T;if(o)if(R(Array.isArray(c)),o==ue.PACKED)this.packed(t,u,r.no,c);else for(let g of c)this.scalar(t,u,r.no,g,!0);else c===void 0?R(r.opt):this.scalar(t,u,r.no,c,a||r.opt);break;case"message":if(o){R(Array.isArray(c));for(let g of c)this.message(t,n,r.T(),r.no,g)}else this.message(t,n,r.T(),r.no,c);break;case"map":R(typeof c=="object"&&c!==null);for(let[g,b]of Object.entries(c))this.mapEntry(t,n,r,g,b);break}}let i=n.writeUnknownFields;i!==!1&&(i===!0?f.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,n,i,r){e.tag(n.no,d.LengthDelimited),e.fork();let c=i;switch(n.K){case p.INT32:case p.FIXED32:case p.UINT32:case p.SFIXED32:case p.SINT32:c=Number.parseInt(i);break;case p.BOOL:R(i=="true"||i=="false"),c=i=="true";break}switch(this.scalar(e,n.K,1,c,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,r,!0);break;case"enum":this.scalar(e,p.INT32,2,r,!0);break;case"message":this.message(e,t,n.V.T(),2,r);break}e.join()}message(e,t,n,i,r){r!==void 0&&(n.internalBinaryWrite(r,e.tag(i,d.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,i,r){let[c,a,o]=this.scalarInfo(t,i);(!o||r)&&(e.tag(n,c),e[a](i))}packed(e,t,n,i){if(!i.length)return;R(t!==p.BYTES&&t!==p.STRING),e.tag(n,d.LengthDelimited),e.fork();let[,r]=this.scalarInfo(t);for(let c=0;cY}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.runs=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posZe}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.serviceTrackingParams=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posze}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.service=0,t.params=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posFe},{no:9,name:"content",kind:"message",T:()=>U},{no:10,name:"onResponseReceivedAction",kind:"message",T:()=>U}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.postt},{no:153515154,name:"elementRenderer",kind:"message",T:()=>Q},{no:49399797,name:"sectionListRenderer",kind:"message",T:()=>q}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posnt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.tabs=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posrt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posU}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posit}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.sectionListSupportedRenderers=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posZ},{no:51845067,name:"shelfRenderer",kind:"message",T:()=>pt},{no:221496734,name:"musicDescriptionShelfRenderer",kind:"message",T:()=>mt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posH}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.richItemContents=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posQ}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posat}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posst},{no:2,name:"renderInfo",kind:"message",T:()=>dt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posot}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.poslt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posct}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posut}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posY},{no:2,name:"footerLabel",kind:"scalar",T:9}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.runs=[],t.footerLabel="",e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posft}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posht}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posyt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posH}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.richItemContents=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posS},{no:10,name:"footer",kind:"message",T:()=>S}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posjt},{no:8,name:"onResponseReceivedAction",kind:"message",T:()=>U}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posVt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posU}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posU},{no:7,name:"onResponseReceivedCommand",kind:"message",T:()=>Kt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posZ},{no:49399797,name:"appendContinuationItemsAction",kind:"message",T:()=>q}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posXt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.entries=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posYt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posqt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posZt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.poszt}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.poste},{no:6,name:"iconItems",kind:"message",repeat:1,T:()=>te}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.labelItems=[],t.iconItems=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posan}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.possn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.rendererItems=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posne},{no:117501096,name:"labelRender",kind:"message",T:()=>ne}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posfn},{no:2,name:"playabilityStatus",kind:"message",T:()=>hn},{no:9,name:"playbackTracking",kind:"message",T:()=>gn},{no:10,name:"captions",kind:"message",T:()=>bn},{no:68,name:"adSlots",kind:"message",repeat:1,T:()=>wn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.adPlacements=[],t.adSlots=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.pospn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posfe},{no:11,name:"backgroundPlayerRender",kind:"message",T:()=>pe}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posyn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posmn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posP},{no:2,name:"videostatsDelayplayUrl",kind:"message",T:()=>P},{no:3,name:"videostatsWatchtimeUrl",kind:"message",T:()=>P},{no:4,name:"ptrackingUrl",kind:"message",T:()=>P},{no:5,name:"qoeUrl",kind:"message",T:()=>P},{no:13,name:"atrUrl",kind:"message",T:()=>P},{no:15,name:"videostatsEngageUrl",kind:"message",T:()=>P},{no:18,name:"pageadViewthroughconversion",kind:"message",T:()=>P}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.poskn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.poshe},{no:2,name:"audioTracks",kind:"message",repeat:1,T:()=>Rn},{no:3,name:"translationLanguages",kind:"message",repeat:1,T:()=>ye},{no:4,name:"defaultAudioTrackIndex",kind:"scalar",opt:!0,T:5},{no:6,name:"defaultCaptionTrackIndex",kind:"scalar",opt:!0,T:5}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.captionTracks=[],t.audioTracks=[],t.translationLanguages=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posS},{no:3,name:"vssId",kind:"scalar",T:9},{no:4,name:"languageCode",kind:"scalar",T:9},{no:5,name:"kind",kind:"scalar",opt:!0,T:9},{no:6,name:"rtl",kind:"scalar",opt:!0,T:8},{no:7,name:"isTranslatable",kind:"scalar",T:8}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.baseUrl="",t.vssId="",t.languageCode="",t.isTranslatable=!1,e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posS}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.languageCode="",e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posBn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posJ},{no:7,name:"CollectionItems",kind:"message",jsonName:"CollectionItems",repeat:1,T:()=>J}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.settingItems=[],t.collectionItems=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posVn},{no:66930374,name:"settingCategoryCollectionRenderer",kind:"message",T:()=>Mn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posS},{no:2,name:"backgroundPlayback",kind:"scalar",T:8},{no:3,name:"download",kind:"scalar",T:8},{no:5,name:"trackingParams",kind:"scalar",T:12},{no:9,name:"downloadQualitySelection",kind:"scalar",T:8},{no:10,name:"smartDownload",kind:"scalar",T:8},{no:14,name:"icon",kind:"message",T:()=>ae}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.backgroundPlayback=!1,t.download=!1,t.trackingParams=new Uint8Array(0),t.downloadQualitySelection=!1,t.smartDownload=!1,e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posS},{no:3,name:"subSettings",kind:"message",repeat:1,T:()=>me},{no:4,name:"categoryId",kind:"scalar",T:5},{no:5,name:"icon",kind:"message",T:()=>ae}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.subSettings=[],t.categoryId=0,e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posvn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posS},{no:3,name:"description",kind:"message",T:()=>S},{no:5,name:"enableServiceEndpoint",kind:"message",T:()=>ie},{no:6,name:"disableServiceEndpoint",kind:"message",T:()=>ie},{no:15,name:"itemId",kind:"scalar",T:5}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.itemId=0,e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posGn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posKn}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posJn},{no:3,name:"boolValue",kind:"scalar",T:8}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.boolValue=!1,e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posrr}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return t.contents=[],e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posre},{no:3,name:"next",kind:"message",T:()=>ee}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&h(this,t,e),t}internalBinaryRead(e,t,n,i){let r=i??this.create(),c=e.pos+t;for(;e.posnew De(e,t,n),Surge:(e,t,n)=>new ge(e,t,n),Loon:(e,t,n)=>new sr(e,t,n)});var Ae=class extends v{getFn(e,t,n){let i=Ae.clientAdapter[t]||t;return super.getFn(e,i,n)}setFn(e,t,n,i){let r=Ae.clientAdapter[t]||t;return super.setFn(e,r,n,i)}init(){try{this.request=this.createProxy($request),this.response=this.createProxy($response)}catch(e){this.debug(e.toString())}}getVal(e){return $persistentStore.read(e)}setVal(e,t){$persistentStore.write(e,t)}msg(e=this.name,t="",n="",i){let r={};i&&(r={action:{"open-url":i}}),$notification.post(e,t,n,r)}async fetch(e){return await new Promise((t,n)=>{let{method:i,body:r,bodyBytes:c,...a}=e,o=c??r,s=o instanceof Uint8Array;$httpClient[i.toLowerCase()]({...a,body:o,"binary-mode":s},(u,g,b)=>{u&&n(u);let m=s?"bodyBytes":"body";t({status:g.status??g.statusCode,headers:g.headers,[m]:b})})})}done(e){let t=e.response??e;t.bodyBytes&&(t.body=t.bodyBytes,delete t.bodyBytes),$done(t)}decodeParams(e){return typeof $argument=="string"&&!$argument.includes("{{{")&&Object.assign(e,JSON.parse($argument)),e}},ge=Ae;ce(ge,"clientAdapter",{bodyBytes:"body"});var M=class extends v{static transferBodyBytes(e,t){return e instanceof ArrayBuffer?t==="Uint8Array"?new Uint8Array(e):e:e instanceof Uint8Array&&t==="ArrayBuffer"?e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset):e}init(){try{this.request=this.createProxy($request),this.response=this.createProxy($response)}catch(e){this.debug(e.toString())}}getFn(e,t,n){let i=M.clientAdapter[t]||t,r=super.getFn(e,i,n);return t==="bodyBytes"&&(r=M.transferBodyBytes(r,"Uint8Array")),r}setFn(e,t,n,i){let r=M.clientAdapter[t]||t,c=n;return t==="bodyBytes"&&(c=M.transferBodyBytes(c,"Uint8Array")),super.setFn(e,r,c,i)}getVal(e){return $prefs.valueForKey(e)}setVal(e,t){$prefs.setValueForKey(e,t)}msg(e=this.name,t="",n="",i){$notify(e,t,n,{"open-url":i??""})}async fetch(e){return await new Promise(t=>{let n={url:"",method:"GET"};for(let[i,r]of Object.entries(e))i==="id"?n.sessionIndex=r:i==="bodyBytes"?n.bodyBytes=M.transferBodyBytes(r,"ArrayBuffer"):n[i]=r;e.bodyBytes&&delete n.body,$task.fetch(n).then(i=>{let r={status:200,headers:{}};for(let[c,a]of Object.entries(i))c==="sessionIndex"?r.id=a:c==="bodyBytes"?r.bodyBytes=M.transferBodyBytes(a,"Uint8Array"):c==="statusCode"?r.status=a:r[c]=a;t(r)})})}done(e){let t=e.response??e,n={};for(let[i,r]of Object.entries(t))i==="status"?n.status=`HTTP/1.1 ${r}`:i==="bodyBytes"?n.bodyBytes=M.transferBodyBytes(r,"ArrayBuffer"):n[i]=r;$done(n)}},De=M;ce(De,"clientAdapter",{id:"sessionIndex",status:"statusCode"});var sr=class extends ge{decodeParams(e){if(typeof $argument<"u")for(let t of Object.keys(e)){let n=$argument?.[t];n!==void 0&&(e[t]=n)}return e}};var w=v.getInstance("YouTube");var G=class{name;needProcess;needSave;message;version="1.0";whiteNo=[];blackNo=[];whiteEml=[];blackEml=["inline_injection_entrypoint_layout.eml"];msgType;argument;constructor(e,t){this.name=t,this.msgType=e,this.argument=this.decodeArgument(),w.isDebug=Boolean(this.argument.debug),w.debug(this.name);let n=w.getJSON("YouTubeAdvertiseInfo");w.debug(`currentVersion: ${this.version}`),w.debug(`storedVersion: ${n.version}`),n?.version===this.version&&Object.assign(this,n)}decodeArgument(){let e={lyricLang:"off",captionLang:"off",blockUpload:!0,blockImmersive:!0,blockShorts:!1,debug:!1};return w.decodeParams(e)}fromBinary(e){return e instanceof Uint8Array?(this.message=this.msgType.fromBinary(e),w.debug(`bodyBytesSize: ${Math.floor(e.length/1024)} kb`),this):(w.log("YouTube can not get binaryBody"),w.exit(),this)}toBinary(){return this.msgType.toBinary(this.message)}save(){if(this.needSave){w.debug("Update Config");let e={version:this.version,whiteNo:this.whiteNo,blackNo:this.blackNo,whiteEml:this.whiteEml,blackEml:this.blackEml};w.debug(e),w.setJSON(e,"YouTubeAdvertiseInfo")}}done(){if(this.save(),this.needProcess){w.timeStart("toBinary");let e=this.toBinary();w.timeEnd("toBinary"),w.debug(`modifiedBodySize: ${Math.floor(e.length/1024)} kb`),w.done({bodyBytes:e})}else w.debug("use $.exit()"),w.exit()}iterate(e={},t,n){let i=typeof e=="object"?[e]:[];for(;i.length;){let r=i.pop(),c=Object.keys(r);for(let a of c){if(a===t&&n(r))return;typeof r[a]=="object"&&i.push(r[a])}}}};function Xr(l){let n=".",i="+-a^+6",r="+-3^+b+-f",c,a,o;for(c=[],a=0,o=0;os?c[a++]=s:(2048>s?c[a++]=s>>6|192:((s&64512)==55296&&o+1>18|240,c[a++]=s>>12&63|128):c[a++]=s>>12|224,c[a++]=s>>6&63|128),c[a++]=s&63|128)}for(l=406644,a=0;al&&(l=(l&2147483647)+2147483648),l%=1e6,l.toString()+n+(l^406644)}function Dr(l,e){let t="a",n="+",i;for(let r=0;r=t?i.charCodeAt(0)-87:Number(i),i=e.charAt(r+1)==n?l>>>i:l<{let t=e.richItemContents;if(!Array.isArray(t))return!1;for(let n=t.length-1;n>=0;n--)this.isAdvertise(t[n])&&(e.richItemContents.splice(n,1),this.needProcess=!0)}),await this.translate(),this}listUnknownFields(e){return f.list(e)}isAdvertise(e){let t=this.listUnknownFields(e)[0];return t?this.handleFieldNo(t):this.handleFieldEml(e)}handleFieldNo(e){let t=e.no;if(this.whiteNo.includes(t))return!1;if(this.blackNo.includes(t))return!0;let n=this.checkBufferIsAd(e);return n?this.blackNo.push(t):this.whiteNo.push(t),this.needSave=!0,n}handleFieldEml(e){let t=!1,n="";return this.iterate(e,"renderInfo",i=>{if(n=i.renderInfo?.layoutRender?.eml?.split("|")?.[0]??"",this.whiteEml.includes(n))t=!1;else if(this.blackEml.includes(n)||/shorts(?!_pivot_item)/.test(n))t=!0;else{let r=i?.videoInfo?.videoContext?.videoContent;r&&(t=this.checkUnknownFiled(r),t?this.blackEml.push(n):this.whiteEml.push(n),this.needSave=!0)}return!0}),t}checkBufferIsAd(e){if(!e||e.data.length<1e3)return!1;let t=e.data,n=[112,97,103,101,97,100],i=t.length,r=n.length,c=new Int32Array(256).fill(r+1);for(let o=0;othis.checkBufferIsAd(n))??!1:!1}getBrowseId(){let e="";return this.iterate(this.message?.responseContext,"key",t=>{if(t.key==="browse_id")return e=t.value,!0}),e}async translate(){let e=this.argument.lyricLang?.trim();if(!(this.name==="Browse"&&this.getBrowseId().startsWith("MPLYt"))||e==="off")return;let t="",n,i=!1;if(this.iterate(this.message,"timedLyricsContent",o=>(n=o.timedLyricsContent,t=o.timedLyricsContent.runs.map(s=>s.text).join(` `),i=!0,!0)),i||this.iterate(this.message,"description",o=>(n=o.description.runs[0],t=o.description.runs[0].text,i=!0,!0)),!i)return;let r=e.split("-")[0],c=Ar(t,e),a=await w.fetch({method:"GET",url:c});if(a.status===200&&a.body){let o=JSON.parse(a.body),s=" & Translated by Google",u=o[2].includes(r);n.text?(n.text=o[0].map(g=>u?g[0]:g[1]+g[0]||"").join(`\r `),this.iterate(this.message,"footer",g=>(g.footer.runs[0].text+=s,!0))):n.runs.length<=o[0].length&&(n.runs.forEach((g,b)=>{g.text=u?o[0][b][0]:g.text+` ${o[0][b][0]}`}),n.footerLabel+=s),this.needProcess=!0}}},be=class extends oe{constructor(e=ee,t="Next"){super(e,t)}},ke=class extends G{constructor(e=re,t="Player"){super(e,t)}async pure(){return this.removeAd(),this.addPremiumAbility(),this.addTranslateCaption(),this.needProcess=!0,this}removeAd(){this.message.adPlacements?.length&&(this.message.adPlacements.length=0),this.message.adSlots?.length&&(this.message.adSlots.length=0),delete this.message?.playbackTracking?.pageadViewthroughconversion}addPremiumAbility(){this.message.playabilityStatus.pictureInPictureRender=fe.create({pictureInPictureAbility:{active:!0,f4:0,f6:0,f8:1}}),this.message.playabilityStatus.backgroundPlayerRender=pe.create({backgroundAbility:{active:!0}})}addTranslateCaption(){let e=this.argument.captionLang;e!=="off"&&this.iterate(this.message,"captionTracks",t=>{let n=t.captionTracks,i=t.audioTracks;if(Array.isArray(n)){let c={[e]:2,en:1},a=-1,o=0;for(let s=0;sa&&(a=g,o=s),u.isTranslatable=!0}if(a!==2){let s=he.create({baseUrl:n[o].baseUrl+`&tlang=${e}`,name:{runs:[{text:`@Enhance (${e})`}]},vssId:`.${e}`,languageCode:e});n.push(s)}if(Array.isArray(i)){let s=a===2?o:n.length-1;for(let u of i)u.captionTrackIndices?.includes(s)||u.captionTrackIndices.push(s),u.defaultCaptionTrackIndex=s,u.captionsInitialState=3}}let r={de:"Deutsch",ru:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",fr:"Fran\xE7ais",fil:"Filipino",ko:"\uD55C\uAD6D\uC5B4",ja:"\u65E5\u672C\u8A9E",en:"English",vi:"Ti\u1EBFng Vi\u1EC7t","zh-Hant":"\u4E2D\u6587\uFF08\u7E41\u9AD4\uFF09","zh-Hans":"\u4E2D\u6587\uFF08\u7B80\u4F53\uFF09",und:"@VirgilClyne"};return t.translationLanguages=Object.entries(r).map(([c,a])=>ye.create({languageCode:c,languageName:{runs:[{text:a}]}})),!0})}},$e=class extends oe{constructor(e=Cr,t="Search"){super(e,t)}},je=class extends G{constructor(e=Ur,t="Shorts"){super(e,t)}async pure(){let e=this.message.entries?.length;if(e)for(let t=e-1;t>=0;t--)this.message.entries[t].command?.reelWatchEndpoint?.overlay||(this.message.entries.splice(t,1),this.needProcess=!0);return this}},Ve=class extends G{constructor(e=Er,t="Guide"){super(e,t)}async pure(){let e=["SPunlimited"];return this.argument.blockUpload&&e.push("FEuploads"),this.argument.blockImmersive&&e.push("FEmusic_immersive"),this.argument.blockShorts&&e.push("FEshorts"),this.iterate(this.message,"rendererItems",t=>{for(let n=t.rendererItems.length-1;n>=0;n--){let i=t.rendererItems[n]?.iconRender?.browseId??t.rendererItems[n]?.labelRender?.browseId;i&&e.includes(i)&&(t.rendererItems.splice(n,1),this.needProcess=!0)}}),this}},Me=class extends G{constructor(e=Lr,t="Setting"){super(e,t)}async pure(){this.iterate(this.message.settingItems,"categoryId",t=>{if(t.categoryId===10135){let n=me.create({settingBooleanRenderer:{itemId:0,enableServiceEndpoint:{setClientSettingEndpoint:{settingData:{clientSettingEnum:{item:151},boolValue:!0}}},disableServiceEndpoint:{setClientSettingEndpoint:{settingData:{clientSettingEnum:{item:151},boolValue:!1}}}}});t.subSettings.push(n)}});let e=J.create({backgroundPlayBackSettingRenderer:{backgroundPlayback:!0,download:!0,downloadQualitySelection:!0,smartDownload:!0,icon:{iconType:1093}}});return this.message.settingItems.push(e),this.needProcess=!0,this}},ve=class extends G{player;next;constructor(e=Fr,t="Watch"){super(e,t),this.player=new ke,this.next=new be}async pure(){for(let e of this.message.contents)e.player&&(this.player.message=e.player,await this.player.pure()),e.next&&(this.next.message=e.next,await this.next.pure()),this.needProcess=!0;return this}};var Yr=new Map([["browse",oe],["next",be],["player",ke],["search",$e],["reel_watch_sequence",je],["guide",Ve],["get_setting",Me],["get_watch",ve]]);function or(l){for(let[e,t]of Yr.entries())if(l.includes(e))return new t;return null}async function qr(){let l=or(w.request.url);if(l){let e=w.response.bodyBytes;w.timeStart("fromBinary"),l.fromBinary(e),w.timeEnd("fromBinary"),w.timeStart("modify"),await l.pure(),w.timeEnd("modify"),l.done()}else w.msg("YouTube Enhance","\u811A\u672C\u9700\u8981\u66F4\u65B0","\u5916\u90E8\u8D44\u6E90 -> \u5168\u90E8\u66F4\u65B0"),w.exit()}qr().catch(l=>{console.log(l.message),w.exit()});})();