diff --git a/Modules/YoutubeAds.sgmodule b/Modules/YoutubeAds.sgmodule index 7369de79b..3de3aeebf 100644 --- a/Modules/YoutubeAds.sgmodule +++ b/Modules/YoutubeAds.sgmodule @@ -1,30 +1,21 @@ #!name=Youtube (Music) Enhance #!desc=适用于 Youtube & Youtube Music (IOS >= 15) - -# > Feature -# - 删除 Youtube (Music) 广告 -# - 删除 Youtube 底部 上传 按钮 & Youtube Music 底部选段、升级按钮 -# + 增加 Youtube 画中画(PIP) -# + 增加 Youtube 字幕翻译 (Thanks @VirgilClyne) -# + 增加 Youtube (Music) 后台播放 -# + 增加 Youtube Music 歌词翻译 +#!arguments=屏蔽上传按钮:true,屏蔽选段按钮:true,字幕翻译语言:zh-Hans,歌词翻译语言:zh-Hans +#!arguments-desc=- 屏蔽参数:[true, false] \n- 翻译参数:[语言代码, off]\n\n# 语言代码遵循 Google Translate Languages Codes, 当填入 off 时关闭翻译 # > Note # Youtube 画中画和后台播放分别在客户端内关闭 # - 设置 -> 通用 -> 画中画 # - 设置 -> 后台播放和下载 -> 后台播放 -# 该模块已足够全面,无需其他规则混用,防止重写规则被破坏 -# 不支持 Mock 的客户端可以用 reject-200/reject-img 替代 -# > Credit -# @Choler & @DivineEngine & @app2smile [Rule] -AND,((DOMAIN-SUFFIX,googlevideo.com), (PROTOCOL,UDP)),REJECT-NO-DROP +AND,((DOMAIN-SUFFIX,googlevideo.com), (PROTOCOL,UDP)),REJECT +AND,((DOMAIN,youtubei.googleapis.com), (PROTOCOL,UDP)),REJECT [Script] -youtube.request = type=http-request,pattern=^https:\/\/youtubei\.googleapis\.com\/youtubei\/v1\/(browse|next|player|reel\/reel_watch_sequence),requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://fleet.fylsen.com/Script/youtube.request.beta.js -youtube.response = type=http-response,pattern=^https:\/\/youtubei\.googleapis\.com\/youtubei\/v1\/(browse|next|player|search|reel\/reel_watch_sequence|guide|account\/get_setting),requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://fleet.fylsen.com/Script/youtube.response.beta.js +youtube.request = type=http-request,pattern=^https:\/\/youtubei\.googleapis\.com\/youtubei\/v1\/(browse|next|player|reel\/reel_watch_sequence),requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://fleet.fylsen.com/Script/youtube.request.preview.js +youtube.response = type=http-response,pattern=^https:\/\/youtubei\.googleapis\.com\/youtubei\/v1\/(browse|next|player|search|reel\/reel_watch_sequence|guide|account\/get_setting),requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://fleet.fylsen.com/Script/youtube.response.preview.js,argument="{"lyricLang":"{{{歌词翻译语言}}}","captionLang":"{{{字幕翻译语言}}}","blockUpload":{{{屏蔽上传按钮}}},"immersive":{{{屏蔽选段按钮}}}}" [URL Rewrite] (^https?:\/\/[\w-]+\.googlevideo\.com\/(?!dclk_video_ads).+?)&ctier=L(&.+?),ctier,(.+) url 302 diff --git a/Script/youtube.request.preview.js b/Script/youtube.request.preview.js new file mode 100644 index 000000000..b04280689 --- /dev/null +++ b/Script/youtube.request.preview.js @@ -0,0 +1,3 @@ +// Author: Maasea Build: 2024/2/18 22:04:23 +(()=>{(function(t){function e(){}function n(){}var s=String.fromCharCode,r={}.toString,o=r.call(t.SharedArrayBuffer),i=r(),a=t.Uint8Array,c=a||Array,u=a?ArrayBuffer:c,l=u.isView||function(h){return h&&"length"in h},m=r.call(u.prototype);u=n.prototype;var p=t.TextEncoder,d=new(a?Uint16Array:c)(32);e.prototype.decode=function(h){if(!l(h)){var E=r.call(h);if(E!==m&&E!==o&&E!==i)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");h=a?new c(h):h||[]}for(var N=E="",g=0,b=h.length|0,G=b-32|0,k,w,F=0,M=0,O,S=0,U=-1;g>4){case 15:if(O=h[g=g+1|0]&255,O>>6!==2||247>6===2?M+4|0:24,w=w+256&768;case 13:case 12:O=h[g=g+1|0]&255,F<<=6,F|=(w&31)<<6|O&63,M=M+7|0,g>6===2&&F>>M&&1114112>F?(w=F,F=F-65536|0,0<=F&&(U=(F>>10)+55296|0,w=(F&1023)+56320|0,31>S?(d[S]=U,S=S+1|0,U=-1):(O=U,U=w,w=O))):(w>>=8,g=g-w-1|0,w=65533),F=M=0,k=g<=G?32:b-g|0;default:d[S]=w;continue;case 11:case 10:case 9:case 8:}d[S]=65533}if(N+=s(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>S&&(N=N.slice(0,S-32|0)),g>>31,U=-1,N.length=k)N[b]=k;else{if(2047>=k)N[b]=192|k>>6;else{e:{if(55296<=k)if(56319>=k){var w=h.charCodeAt(g=g+1|0)|0;if(56320<=w&&57343>=w){if(k=(k<<10)+w-56613888|0,65535>18,N[b=b+1|0]=128|k>>12&63,N[b=b+1|0]=128|k>>6&63,N[b=b+1|0]=128|k&63;continue}break e}k=65533}else 57343>=k&&(k=65533);!G&&g<<1>12,N[b=b+1|0]=128|k>>6&63}N[b=b+1|0]=128|k&63}}return a?N.subarray(0,b):N.slice(0,b)},p||(t.TextDecoder=e,t.TextEncoder=n)})(globalThis);function T(t,e){if(!t)throw new Error(e)}var it=34028234663852886e22,at=-34028234663852886e22,ct=4294967295,ft=2147483647,ut=-2147483648;function C(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>ft||tct||t<0)throw new Error("invalid uint 32: "+t)}function K(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>it||t({no:r.no,name:r.name,localName:t[r.no]})),s)}function me(t,e,n){let s=Object.create(null),r=Object.create(null),o=[];for(let i of e){let a=Be(i);o.push(a),s[i.name]=a,r[i.no]=a}return{typeName:t,values:o,findName(i){return s[i]},findNumber(i){return r[i]}}}function Ee(t,e,n){let s={};for(let r of e){let o=Be(r);s[o.localName]=o.no,s[o.no]=o.localName}return de(s,t,e,n),s}function Be(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}var I=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){let s=this.getType(),r=s.runtime.bin,o=r.makeReadOptions(n);return r.readMessage(this,o.readerFactory(e),e.byteLength,o),this}fromJson(e,n){let s=this.getType(),r=s.runtime.json,o=r.makeReadOptions(n);return r.readMessage(s,e,o,this),this}fromJsonString(e,n){let s;try{s=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(s,n)}toBinary(e){let n=this.getType(),s=n.runtime.bin,r=s.makeWriteOptions(e),o=r.writerFactory();return s.writeMessage(this,o,r),o.finish()}toJson(e){let n=this.getType(),s=n.runtime.json,r=s.makeWriteOptions(e);return s.writeMessage(this,r)}toJsonString(e){var n;let s=this.toJson(e);return JSON.stringify(s,null,(n=e?.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function Se(t,e,n,s){var r;let o=(r=s?.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),i={[o]:function(a){t.util.initFields(this),t.util.initPartial(a,this)}}[o];return Object.setPrototypeOf(i.prototype,new I),Object.assign(i,{runtime:t,typeName:e,fields:t.util.newFieldList(n),fromBinary(a,c){return new i().fromBinary(a,c)},fromJson(a,c){return new i().fromJson(a,c)},fromJsonString(a,c){return new i().fromJsonString(a,c)},equals(a,c){return t.util.equals(i,a,c)}}),i}var f;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(f||(f={}));var A;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(A||(A={}));function Ue(){let t=0,e=0;for(let s=0;s<28;s+=7){let r=this.buf[this.pos++];if(t|=(r&127)<>4,!(n&128))return this.assertBounds(),[t,e];for(let s=3;s<=31;s+=7){let r=this.buf[this.pos++];if(e|=(r&127)<>>o,a=!(!(i>>>7)&&e==0),c=(a?i|128:i)&255;if(n.push(c),!a)return}let s=t>>>28&15|(e&7)<<4,r=!!(e>>3);if(n.push((r?s|128:s)&255),!!r){for(let o=3;o<31;o=o+7){let i=e>>>o,a=!!(i>>>7),c=(a?i|128:i)&255;if(n.push(c),!a)return}n.push(e>>>31&1)}}var z=4294967296;function pe(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,s=0,r=0;function o(i,a){let c=Number(t.slice(i,a));r*=n,s=s*n+c,s>=z&&(r=r+(s/z|0),s=s%z)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),e?De(s,r):ge(s,r)}function Ae(t,e){let n=ge(t,e),s=n.hi&2147483648;s&&(n=De(n.lo,n.hi));let r=he(n.lo,n.hi);return s?"-"+r:r}function he(t,e){if({lo:t,hi:e}=lt(t,e),e<=2097151)return String(z*e+t);let n=t&16777215,s=(t>>>24|e<<8)&16777215,r=e>>16&65535,o=n+s*6777216+r*6710656,i=s+r*8147497,a=r*2,c=1e7;return o>=c&&(i+=Math.floor(o/c),o%=c),i>=c&&(a+=Math.floor(i/c),i%=c),a.toString()+Oe(i)+Oe(o)}function lt(t,e){return{lo:t>>>0,hi:e>>>0}}function ge(t,e){return{lo:t|0,hi:e|0}}function De(t,e){return e=~e,t?t=~t+1:e+=1,ge(t,e)}var Oe=t=>{let e=String(t);return"0000000".slice(e.length)+e};function ye(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function $e(){let t=this.buf[this.pos++],e=t&127;if(!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,!(t&128))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;t&128&&n<10;n++)t=this.buf[this.pos++];if(t&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function dt(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),i=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){let u=typeof c=="bigint"?c:BigInt(c);if(u>o||ua||uT(/^-?[0-9]+$/.test(r),`int64 invalid: ${r}`),s=r=>T(/^[0-9]+$/.test(r),`uint64 invalid: ${r}`);return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),n(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),s(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),n(r),pe(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),s(r),pe(r)},dec(r,o){return Ae(r,o)},uDec(r,o){return he(r,o)}}}var x=dt();var y;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(y||(y={}));var H=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 r=0;r>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(_(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return C(e),ye(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 n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){K(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){_(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){C(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return C(e),e=(e<<1^e>>31)>>>0,ye(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),s=new DataView(n.buffer),r=x.enc(e);return s.setInt32(0,r.lo,!0),s.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),s=new DataView(n.buffer),r=x.uEnc(e);return s.setInt32(0,r.lo,!0),s.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=x.enc(e);return Q(n.lo,n.hi,this.buf),this}sint64(e){let n=x.enc(e),s=n.hi>>31,r=n.lo<<1^s,o=(n.hi<<1|n.lo>>>31)^s;return Q(r,o,this.buf),this}uint64(e){let n=x.uEnc(e);return Q(n.lo,n.hi,this.buf),this}},Z=class{constructor(e,n){this.varint64=Ue,this.uint32=$e,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,s=e&7;if(n<=0||s<0||s>5)throw new Error("illegal tag: field no "+n+" wire type "+s);return[n,s]}skip(e){let n=this.pos;switch(e){case y.Varint:for(;this.buf[this.pos++]&128;);break;case y.Bit64:this.pos+=4;case y.Bit32:this.pos+=4;break;case y.LengthDelimited:let s=this.uint32();this.pos+=s;break;case y.StartGroup:let r;for(;(r=this.tag()[1])!==y.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,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 x.dec(...this.varint64())}uint64(){return x.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),s=-(e&1);return e=(e>>>1|(n&1)<<31)^s,n=n>>>1^s,x.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return x.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return x.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}};function $(t,e,n){if(e===n)return!0;if(t==f.BYTES){if(!(e instanceof Uint8Array)||!(n instanceof Uint8Array)||e.length!==n.length)return!1;for(let s=0;sn[e]]}function mt(t){let e=t.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return J(e.T,e.L);case"message":let n=e.T,s=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(s):s;case"map":throw"map fields are not allowed to be extensions"}}function Le(t,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let n=t.length-1;n>=0;--n)if(t[n].no==e.no)return[t[n]];return[]}return t.filter(n=>n.no===e.no)}function Re(t,e,n,s){return{syntax:t,json:e,bin:n,util:s,makeMessageType(r,o,i){return Se(this,r,o,i)},makeEnum:Ee,makeEnumType:me,getEnumType:Fe,makeExtension(r,o,i){return ve(this,r,o,i)}}}function te(t,e){return e instanceof I||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}var gn={"google.protobuf.DoubleValue":f.DOUBLE,"google.protobuf.FloatValue":f.FLOAT,"google.protobuf.Int64Value":f.INT64,"google.protobuf.UInt64Value":f.UINT64,"google.protobuf.Int32Value":f.INT32,"google.protobuf.UInt32Value":f.UINT32,"google.protobuf.BoolValue":f.BOOL,"google.protobuf.StringValue":f.STRING,"google.protobuf.BytesValue":f.BYTES};var P=Symbol("@bufbuild/protobuf/unknown-fields"),Me={readUnknownFields:!0,readerFactory:t=>new Z(t)},Je={writeUnknownFields:!0,writerFactory:()=>new H};function pt(t){return t?Object.assign(Object.assign({},Me),t):Me}function ht(t){return t?Object.assign(Object.assign({},Je),t):Je}function Pe(){return{makeReadOptions:pt,makeWriteOptions:ht,listUnknownFields(t){var e;return(e=t[P])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[P]},writeUnknownFields(t,e){let s=t[P];if(s)for(let r of s)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(t,e,n,s){let r=t;Array.isArray(r[P])||(r[P]=[]),r[P].push({no:e,wireType:n,data:s})},readMessage(t,e,n,s,r){let o=t.getType(),i=r?e.len:e.pos+n,a,c;for(;e.pos0&&(c=yt),o){let p=t[i];if(s==y.LengthDelimited&&a!=f.STRING&&a!=f.BYTES){let h=e.uint32()+e.pos;for(;e.pos>4,i=o,r=2;break;case 2:n[s++]=(i&15)<<4|(o&60)>>2,i=o,r=3;break;case 3:n[s++]=(i&3)<<6|o,r=0;break}}if(r==1)throw Error("invalid base64 string.");return n.subarray(0,s)},enc(t){let e="",n=0,s,r=0;for(let o=0;o>2],r=(s&3)<<4,n=1;break;case 1:e+=v[r|s>>4],r=(s&15)<<2,n=2;break;case 2:e+=v[r|s>>6],e+=v[s&63],n=0;break}return n&&(e+=v[r],e+="=",n==1&&(e+="=")),e}};function _e(t,e,n){je(e,t);let s=e.runtime.bin.makeReadOptions(n),r=Le(t.getType().runtime.bin.listUnknownFields(t),e.field),[o,i]=ee(e);for(let a of r)e.runtime.bin.readField(o,s.readerFactory(a.data),e.field,a.wireType,s);return i()}function Ye(t,e,n,s){je(e,t);let r=e.runtime.bin.makeReadOptions(s),o=e.runtime.bin.makeWriteOptions(s);if(Te(t,e)){let u=t.getType().runtime.bin.listUnknownFields(t).filter(l=>l.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(let l of u)t.getType().runtime.bin.onUnknownField(t,l.no,l.wireType,l.data)}let i=o.writerFactory(),a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,n,i,o);let c=r.readerFactory(i.finish());for(;c.poss.no==e.field.no)}function je(t,e){T(t.extendee.typeName==e.getType().typeName,`extension ${t.typeName} can only be applied to message ${t.extendee.typeName}`)}var We={ignoreUnknownFields:!1},Ke={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function bt(t){return t?Object.assign(Object.assign({},We),t):We}function wt(t){return t?Object.assign(Object.assign({},Ke),t):Ke}function He(t,e){let n=e(kt,Qe);return{makeReadOptions:bt,makeWriteOptions:wt,readMessage(s,r,o,i){if(r==null||Array.isArray(r)||typeof r!="object")throw new Error(`cannot decode message ${s.typeName} from JSON: ${D(r)}`);i=i??new s;let a=new Map,c=o.typeRegistry;for(let[u,l]of Object.entries(r)){let m=s.fields.findJsonName(u);if(m){if(m.oneof){if(l===null&&m.kind=="scalar")continue;let p=a.get(m.oneof);if(p!==void 0)throw new Error(`cannot decode message ${s.typeName} from JSON: multiple keys for oneof "${m.oneof.name}" present: "${p}", "${u}"`);a.set(m.oneof,u)}ze(i,l,m,o,s,t)}else{let p=!1;if(c?.findExtension&&u.startsWith("[")&&u.endsWith("]")){let d=c.findExtension(u.substring(1,u.length-1));if(d&&d.extendee.typeName==s.typeName){p=!0;let[h,E]=ee(d);ze(h,l,d.field,o,d,!0),Ye(i,d,E(),o)}}if(!p&&!o.ignoreUnknownFields)throw new Error(`cannot decode message ${s.typeName} from JSON: key "${u}" is unknown`)}}return i},writeMessage(s,r){let o=s.getType(),i={},a;try{for(let u of o.fields.byMember()){let l;if(u.kind=="oneof"){let m=s[u.localName];if(m.value===void 0)continue;if(a=u.findField(m.case),!a)throw"oneof case not found: "+m.case;l=n(a,m.value,r)}else a=u,l=n(a,s[a.localName],r);l!==void 0&&(i[r.useProtoFieldName?a.name:a.jsonName]=l)}let c=r.typeRegistry;if(c?.findExtensionFor)for(let u of o.runtime.bin.listUnknownFields(s)){let l=c.findExtensionFor(o.typeName,u.no);if(l&&Te(s,l)){let m=_e(s,l,r),p=n(l.field,m,r);p!==void 0&&(i[l.field.jsonName]=p)}}}catch(c){let u=a?`cannot encode field ${o.typeName}.${a.name} to JSON`:`cannot encode message ${o.typeName} to JSON`,l=c instanceof Error?c.message:String(c);throw new Error(u+(l.length>0?`: ${l}`:""))}return i},readScalar:(s,r,o)=>Y(s,r,o,t),writeScalar:Qe,debug:D}}function D(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":`"${t.split('"').join('\\"')}"`;default:return String(t)}}function ze(t,e,n,s,r,o){let i=n.localName;if(n.oneof){if(e===null&&n.kind=="scalar")return;t=t[n.oneof.localName]={case:i},i="value"}if(n.repeated){if(e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${D(e)}`);let a=t[i];for(let c of e){if(c===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${D(c)}`);let u;switch(n.kind){case"message":u=n.T.fromJson(c,s);break;case"enum":if(u=Ne(n.T,c,s.ignoreUnknownFields,!0),u===void 0)continue;break;case"scalar":try{u=Y(n.T,c,n.L,!0)}catch(l){let m=`cannot decode field ${r.typeName}.${n.name} from JSON: ${D(c)}`;throw l instanceof Error&&l.message.length>0&&(m+=`: ${l.message}`),new Error(m)}break}a.push(u)}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${D(e)}`);let a=t[i];for(let[c,u]of Object.entries(e)){if(u===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let l;switch(n.V.kind){case"message":l=n.V.T.fromJson(u,s);break;case"enum":if(l=Ne(n.V.T,u,s.ignoreUnknownFields,!0),l===void 0)continue;break;case"scalar":try{l=Y(n.V.T,u,A.BIGINT,!0)}catch(m){let p=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${D(e)}`;throw m instanceof Error&&m.message.length>0&&(p+=`: ${m.message}`),new Error(p)}break}try{a[Y(n.K,n.K==f.BOOL?c=="true"?!0:c=="false"?!1:c:c,A.BIGINT,!0).toString()]=l}catch(m){let p=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${D(e)}`;throw m instanceof Error&&m.message.length>0&&(p+=`: ${m.message}`),new Error(p)}}}else switch(n.kind){case"message":let a=n.T;if(e===null&&a.typeName!="google.protobuf.Value"){if(n.oneof)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: null is invalid for oneof field`);return}t[i]instanceof I?t[i].fromJson(e,s):(t[i]=a.fromJson(e,s),a.fieldWrapper&&!n.oneof&&(t[i]=a.fieldWrapper.unwrapField(t[i])));break;case"enum":let c=Ne(n.T,e,s.ignoreUnknownFields,o);c!==void 0&&(t[i]=c);break;case"scalar":try{t[i]=Y(n.T,e,n.L,o)}catch(u){let l=`cannot decode field ${r.typeName}.${n.name} from JSON: ${D(e)}`;throw u instanceof Error&&u.message.length>0&&(l+=`: ${u.message}`),new Error(l)}break}}function Y(t,e,n,s){switch(t){case f.DOUBLE:case f.FLOAT:if(e===null)return s?0:void 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;let r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==f.FLOAT&&K(r),r;case f.INT32:case f.FIXED32:case f.SFIXED32:case f.SINT32:case f.UINT32:if(e===null)return s?0:void 0;let o;if(typeof e=="number"?o=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(o=Number(e)),o===void 0)break;return t==f.UINT32?_(o):C(o),o;case f.INT64:case f.SFIXED64:case f.SINT64:if(e===null)return s?x.zero:void 0;if(typeof e!="number"&&typeof e!="string")break;let i=x.parse(e);return n?i.toString():i;case f.FIXED64:case f.UINT64:if(e===null)return s?x.zero:void 0;if(typeof e!="number"&&typeof e!="string")break;let a=x.uParse(e);return n?a.toString():a;case f.BOOL:if(e===null)return s?!1:void 0;if(typeof e!="boolean")break;return e;case f.STRING:if(e===null)return s?"":void 0;if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case f.BYTES:if(e===null)return s?new Uint8Array(0):void 0;if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return ke.dec(e)}throw new Error}function Ne(t,e,n,s){if(e===null)return s?t.values[0].no:void 0;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":let r=t.findName(e);if(r||n)return r?.no;break}throw new Error(`cannot decode enum ${t.typeName} from JSON: ${D(e)}`)}function kt(t,e,n,s){var r;if(e===void 0)return e;if(!n&&t.values[0].no===e)return;if(s)return e;if(t.typeName=="google.protobuf.NullValue")return null;let o=t.findNumber(e);return(r=o?.name)!==null&&r!==void 0?r:e}function Qe(t,e,n){if(e!==void 0)switch(t){case f.INT32:case f.SFIXED32:case f.SINT32:case f.FIXED32:case f.UINT32:return T(typeof e=="number"),e!=0||n?e:void 0;case f.FLOAT:case f.DOUBLE:return T(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e!==0||n?e:void 0;case f.STRING:return T(typeof e=="string"),e.length>0||n?e:void 0;case f.BOOL:return T(typeof e=="boolean"),e||n?e:void 0;case f.UINT64:case f.FIXED64:case f.INT64:case f.SFIXED64:case f.SINT64:return T(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),n||e!=0?e.toString(10):void 0;case f.BYTES:return T(e instanceof Uint8Array),n||e.byteLength>0?ke.enc(e):void 0}}function Ze(){return He(!0,(t,e)=>function(s,r,o){if(s.kind=="map"){let i={};switch(s.V.kind){case"scalar":for(let[c,u]of Object.entries(r)){let l=e(s.V.T,u,!0);T(l!==void 0),i[c.toString()]=l}break;case"message":for(let[c,u]of Object.entries(r))i[c.toString()]=u.toJson(o);break;case"enum":let a=s.V.T;for(let[c,u]of Object.entries(r)){T(u===void 0||typeof u=="number");let l=t(a,u,!0,o.enumAsInteger);T(l!==void 0),i[c.toString()]=l}break}return o.emitDefaultValues||Object.keys(i).length>0?i:void 0}else if(s.repeated){let i=[];switch(s.kind){case"scalar":for(let a=0;a0?i:void 0}else{if(r===void 0)return;switch(s.kind){case"scalar":return e(s.T,r,!!s.oneof||s.opt||o.emitDefaultValues);case"enum":return t(s.T,r,!!s.oneof||s.opt||o.emitDefaultValues,o.enumAsInteger);case"message":return te(s.T,r).toJson(o)}}})}function et(){return{setEnumType:de,initPartial(t,e){if(t===void 0)return;let n=e.getType();for(let s of n.fields.byMember()){let r=s.localName,o=e,i=t;if(i[r]!==void 0)switch(s.kind){case"oneof":let a=i[r].case;if(a===void 0)continue;let c=s.findField(a),u=i[r].value;c&&c.kind=="message"&&!(u instanceof c.T)?u=new c.T(u):c&&c.kind==="scalar"&&c.T===f.BYTES&&(u=j(u)),o[r]={case:a,value:u};break;case"scalar":case"enum":let l=i[r];s.T===f.BYTES&&(l=s.repeated?l.map(j):j(l)),o[r]=l;break;case"map":switch(s.V.kind){case"scalar":case"enum":if(s.V.T===f.BYTES)for(let[d,h]of Object.entries(i[r]))o[r][d]=j(h);else Object.assign(o[r],i[r]);break;case"message":let p=s.V.T;for(let d of Object.keys(i[r])){let h=i[r][d];p.fieldWrapper||(h=new p(h)),o[r][d]=h}break}break;case"message":let m=s.T;if(s.repeated)o[r]=i[r].map(p=>p instanceof m?p:new m(p));else if(i[r]!==void 0){let p=i[r];m.fieldWrapper?m.typeName==="google.protobuf.BytesValue"?o[r]=j(p):o[r]=p:o[r]=p instanceof m?p:new m(p)}break}}},equals(t,e,n){return e===n?!0:!e||!n?!1:t.fields.byMember().every(s=>{let r=e[s.localName],o=n[s.localName];if(s.repeated){if(r.length!==o.length)return!1;switch(s.kind){case"message":return r.every((i,a)=>s.T.equals(i,o[a]));case"scalar":return r.every((i,a)=>$(s.T,i,o[a]));case"enum":return r.every((i,a)=>$(f.INT32,i,o[a]))}throw new Error(`repeated cannot contain ${s.kind}`)}switch(s.kind){case"message":return s.T.equals(r,o);case"enum":return $(f.INT32,r,o);case"scalar":return $(s.T,r,o);case"oneof":if(r.case!==o.case)return!1;let i=s.findField(r.case);if(i===void 0)return!0;switch(i.kind){case"message":return i.T.equals(r.value,o.value);case"enum":return $(f.INT32,r.value,o.value);case"scalar":return $(i.T,r.value,o.value)}throw new Error(`oneof cannot contain ${i.kind}`);case"map":let a=Object.keys(r).concat(Object.keys(o));switch(s.V.kind){case"message":let c=s.V.T;return a.every(l=>c.equals(r[l],o[l]));case"enum":return a.every(l=>$(f.INT32,r[l],o[l]));case"scalar":let u=s.V.T;return a.every(l=>$(u,r[l],o[l]))}break}})},clone(t){let e=t.getType(),n=new e,s=n;for(let r of e.fields.byMember()){let o=t[r.localName],i;if(r.repeated)i=o.map(oe);else if(r.kind=="map"){i=s[r.localName];for(let[a,c]of Object.entries(o))i[a]=oe(c)}else r.kind=="oneof"?i=r.findField(o.case)?{case:o.case,value:oe(o.value)}:{case:void 0}:i=oe(o);s[r.localName]=i}return n}}}function oe(t){if(t===void 0)return t;if(t instanceof I)return t.clone();if(t instanceof Uint8Array){let e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function j(t){return t instanceof Uint8Array?t:new Uint8Array(t)}var ie=class{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){let n={};for(let s of this.list())n[s.jsonName]=n[s.name]=s;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){let n={};for(let s of this.list())n[s.no]=s;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,n;for(let s of this.list())s.oneof?s.oneof!==n&&(n=s.oneof,e.push(n)):e.push(s)}return this.members}};function xe(t,e){let n=rt(t);return e?n:It(xt(n))}function tt(t){return xe(t,!1)}var nt=rt;function rt(t){let e=!1,n=[];for(let s=0;s`${t}$`,xt=t=>Nt.has(t)?st(t):t,It=t=>Tt.has(t)?st(t):t;var ae=class{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=tt(e)}addField(e){T(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;n[{no:1,name:"context",kind:"message",T:Et},{no:2,name:"browseId",kind:"scalar",T:9}]),Et=q.makeMessageType("youtube.request.common.Context",()=>[{no:9,name:"adSignalsInfo",kind:"message",T:Bt}]),Bt=q.makeMessageType("youtube.request.common.AdSignalsInfo",()=>[{no:1,name:"params",kind:"message",T:St,repeated:!0}]),St=q.makeMessageType("youtube.request.common.Params",()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:9}]);var X=class{constructor(e,n,s){this._times=new Map;this.name=e??"",this.debug=s?.debug??!1,e&&this.log(`${e} Start`),this.className=n??"",this.init()}static getInstance(e,n){let s=typeof $task<"u"?"QuanX":"Surge";return X.instances[s]||(X.instances[s]=X.classNames[s](e,s,n)),X.instances[s]}createProxy(e){return new Proxy(e,{get:this.getFn,set:this.setFn})}getFn(e,n,s){return e[n]}setFn(e,n,s,r){return e[n]=s,!0}getJSON(e,n={}){let s=this.getVal(e);return s?JSON.parse(s):n}setJSON(e,n){this.setVal(JSON.stringify(e),n)}msg(e=this.name,n="",s="",r){}log(e){this.debug&&(typeof e=="object"&&(e=JSON.stringify(e)),console.log(e))}timeStart(e){this._times=this._times||{},this._times[e]=Date.now()}timeEnd(e){if(this._times?.has(e)){let n=Date.now()-this._times[e];this.log(`${e}: ${n}ms`),this._times.delete(e)}else this.log(`Timer with label ${e} does not exist.`)}exit(){$done({})}reject(){$done()}},R=X;R.instances={},R.classNames={QuanX:(e,n,s)=>new fe(e,n,s),Surge:(e,n,s)=>new ce(e,n,s)};var ue=class extends R{getFn(e,n,s){let r=ue.clientAdapter[n]||n;return super.getFn(e,r,s)}setFn(e,n,s,r){let o=ue.clientAdapter[n]||n;return super.setFn(e,o,s,r)}init(){try{this.request=this.createProxy($request),this.response=this.createProxy($response)}catch(e){this.log(e.toString())}}getVal(e){return $persistentStore.read(e)}setVal(e,n){$persistentStore.write(e,n)}msg(e=this.name,n="",s="",r){$notification.post(e,n,s,{url:r??""})}async fetch(e){return await new Promise((n,s)=>{let{method:r,body:o,bodyBytes:i,...a}=e,c=i??o,u=c instanceof Uint8Array;$httpClient[r.toLowerCase()]({...a,body:c,"binary-mode":u},(l,m,p)=>{l&&s(l);let d=u?"bodyBytes":"body";n({status:m.status||m.statusCode,headers:m.headers,[d]:p})})})}done(e){let n=e.response??e,s,r;n.bodyBytes?(s=n.bodyBytes,delete n.bodyBytes,r={...e},r.response?r.response.body=s:r.body=s):r=e,$done(r)}},ce=ue;ce.clientAdapter={bodyBytes:"body"};var L=class extends R{static transferBodyBytes(e,n){return e instanceof ArrayBuffer?n==="Uint8Array"?new Uint8Array(e):e:e instanceof Uint8Array&&n==="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.log(e.toString())}}getFn(e,n,s){let r=L.clientAdapter[n]||n,o=super.getFn(e,r,s);return n==="bodyBytes"&&(o=L.transferBodyBytes(o,"Uint8Array")),o}setFn(e,n,s,r){let o=L.clientAdapter[n]||n,i=s;return n==="bodyBytes"&&(i=L.transferBodyBytes(i,"Uint8Array")),super.setFn(e,o,i,r)}getVal(e){return $prefs.valueForKey(e)?.replace(/\0/g,"")}setVal(e,n){$prefs.setValueForKey(e,n)}msg(e=this.name,n="",s="",r){$notify(e,n,s,{"open-url":r??""})}async fetch(e){return await new Promise(n=>{let s={url:"",method:"GET"};for(let[r,o]of Object.entries(e))r==="id"?s.sessionIndex=o:r==="bodyBytes"?s.bodyBytes=L.transferBodyBytes(o,"ArrayBuffer"):s[r]=o;e.bodyBytes&&delete s.body,$task.fetch(s).then(r=>{let o={status:200,headers:{}};for(let[i,a]of Object.entries(r))i==="sessionIndex"?o.id=a:i==="bodyBytes"?o.bodyBytes=L.transferBodyBytes(a,"Uint8Array"):i==="statusCode"?o.status=a:o[i]=a;n(o)})})}done(e){let n=e.response??e,s={};for(let[r,o]of Object.entries(n))r==="status"?s.status=`HTTP/1.1 ${o}`:r==="bodyBytes"?s.bodyBytes=L.transferBodyBytes(o,"ArrayBuffer"):s[r]=o;$done(s)}},fe=L;fe.clientAdapter={id:"sessionIndex",status:"statusCode"};var B=R.getInstance("YouTube",{debug:!1});var le=class{constructor(e,n){this.decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0});B.log(n),this.name=n,this.msgType=e,Object.assign(this,B.getJSON("YouTubeAdvertiseInfo",{whiteNo:[],blackNo:[],whiteEml:[],blackEml:[]})),this.argument=this.decodeArgument()}decodeArgument(){let e={lyricLang:"zh-Hans",captionLang:"zh-Hans",blockUpload:!0,immersive:!0};return typeof $argument=="string"&&!$argument.includes("{{{")?JSON.parse($argument):e}fromBinary(e){return this.message=this.msgType.fromBinary(e),this}async modify(){let e=this.pure();return e instanceof Promise?await e:e}toBinary(){return this.message.toBinary()}listUnknownFields(e){return e instanceof I?e.getType().runtime.bin.listUnknownFields(e):[]}save(){if(this.needSave){B.log("Update Config");let e={whiteNo:this.whiteNo,blackNo:this.blackNo,whiteEml:this.whiteEml,blackEml:this.blackEml};B.setJSON(e,"YouTubeAdvertiseInfo")}}done(e){this.save();let n=e.bodyBytes;this.needProcess&&(n=this.toBinary()),e.headers["Content-Encoding"]="identity",e.headers["Content-Length"]=(n?.length??0)?.toString(),B.done({response:{...e,bodyBytes:n}})}doneResponse(){this.save(),this.needProcess&&B.done({bodyBytes:this.toBinary()}),B.exit()}iterate(e={},n,s){let r=typeof e=="object"?[e]:[];for(;r.length;){let o=r.pop(),i=Object.keys(o);if(typeof n=="symbol"){for(let a of Object.getOwnPropertySymbols(o))if(a.description===n.description){s(o,r);break}}for(let a of i)a===n?s(o,r):typeof o[a]=="object"&&r.push(o[a])}}isAdvertise(e){let n=this.listUnknownFields(e)[0];return n?this.handleFieldNo(n):this.handleFieldEml(e)}handleFieldNo(e){let n=e.no;if(this.whiteNo.includes(n))return!1;if(this.blackNo.includes(n))return!0;let r=this.decoder.decode(e.data).includes("pagead");return r?this.blackNo.push(n):this.whiteNo.push(n),this.needSave=!0,r}handleFieldEml(e){let n=!1,s="";return this.iterate(e,"renderInfo",(r,o)=>{if(s=r.renderInfo.layoutRender.eml.split("|")[0],this.whiteEml.includes(s))n=!1;else if(this.blackEml.includes(s)||/shorts(?!_pivot_item)/.test(s))n=!0;else{let i=r?.videoInfo?.videoContext?.videoContent;if(i){let a=this.listUnknownFields(i)[0];n=this.decoder.decode(a.data).includes("pagead"),n?this.blackEml.push(s):this.whiteEml.push(s),this.needSave=!0}}o.length=0}),n}isShorts(e){let n=!1;return this.iterate(e,"eml",(s,r)=>{n=/shorts(?!_pivot_item)/.test(s.eml),r.length=0}),n}};var W=class extends le{constructor(e=ot,n="Request"){super(e,n)}pure(){return this.message.context.adSignalsInfo.params.length=0,this.needProcess=!0,this}};var Ot=new W;try{let t=Ot.fromBinary(B.request.bodyBytes).pure().toBinary();B.done({bodyBytes:t})}catch(t){B.log(t.toString()),B.exit()}})(); diff --git a/Script/youtube.response.preview.js b/Script/youtube.response.preview.js new file mode 100644 index 000000000..9a4488f36 --- /dev/null +++ b/Script/youtube.response.preview.js @@ -0,0 +1,6 @@ +// Author: Maasea Build: 2024/2/18 22:04:23 +(()=>{(function(t){function e(){}function n(){}var s=String.fromCharCode,r={}.toString,o=r.call(t.SharedArrayBuffer),i=r(),a=t.Uint8Array,c=a||Array,f=a?ArrayBuffer:c,d=f.isView||function(h){return h&&"length"in h},l=r.call(f.prototype);f=n.prototype;var g=t.TextEncoder,p=new(a?Uint16Array:c)(32);e.prototype.decode=function(h){if(!d(h)){var R=r.call(h);if(R!==l&&R!==o&&R!==i)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");h=a?new c(h):h||[]}for(var I=R="",y=0,k=h.length|0,W=k-32|0,w,T,F=0,V=0,C,B=0,O=-1;y>4){case 15:if(C=h[y=y+1|0]&255,C>>6!==2||247>6===2?V+4|0:24,T=T+256&768;case 13:case 12:C=h[y=y+1|0]&255,F<<=6,F|=(T&31)<<6|C&63,V=V+7|0,y>6===2&&F>>V&&1114112>F?(T=F,F=F-65536|0,0<=F&&(O=(F>>10)+55296|0,T=(F&1023)+56320|0,31>B?(p[B]=O,B=B+1|0,O=-1):(C=O,O=T,T=C))):(T>>=8,y=y-T-1|0,T=65533),F=V=0,w=y<=W?32:k-y|0;default:p[B]=T;continue;case 11:case 10:case 9:case 8:}p[B]=65533}if(I+=s(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15],p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23],p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]),32>B&&(I=I.slice(0,B-32|0)),y>>31,O=-1,I.length=w)I[k]=w;else{if(2047>=w)I[k]=192|w>>6;else{e:{if(55296<=w)if(56319>=w){var T=h.charCodeAt(y=y+1|0)|0;if(56320<=T&&57343>=T){if(w=(w<<10)+T-56613888|0,65535>18,I[k=k+1|0]=128|w>>12&63,I[k=k+1|0]=128|w>>6&63,I[k=k+1|0]=128|w&63;continue}break e}w=65533}else 57343>=w&&(w=65533);!W&&y<<1>12,I[k=k+1|0]=128|w>>6&63}I[k=k+1|0]=128|w&63}}return a?I.subarray(0,k):I.slice(0,k)},g||(t.TextDecoder=e,t.TextEncoder=n)})(globalThis);function x(t,e){if(!t)throw new Error(e)}var Dt=34028234663852886e22,$t=-34028234663852886e22,Vt=4294967295,Jt=2147483647,Gt=-2147483648;function G(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>Jt||tVt||t<0)throw new Error("invalid uint 32: "+t)}function H(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>Dt||t<$t))throw new Error("invalid float 32: "+t)}var Ve=Symbol("@bufbuild/protobuf/enum-type");function Je(t){let e=t[Ve];return x(e,"missing enum type on enum object"),e}function Te(t,e,n,s){t[Ve]=we(e,n.map(r=>({no:r.no,name:r.name,localName:t[r.no]})),s)}function we(t,e,n){let s=Object.create(null),r=Object.create(null),o=[];for(let i of e){let a=_e(i);o.push(a),s[i.name]=a,r[i.no]=a}return{typeName:t,values:o,findName(i){return s[i]},findNumber(i){return r[i]}}}function Ge(t,e,n){let s={};for(let r of e){let o=_e(r);s[o.localName]=o.no,s[o.no]=o.localName}return Te(s,t,e,n),s}function _e(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}var E=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){let s=this.getType(),r=s.runtime.bin,o=r.makeReadOptions(n);return r.readMessage(this,o.readerFactory(e),e.byteLength,o),this}fromJson(e,n){let s=this.getType(),r=s.runtime.json,o=r.makeReadOptions(n);return r.readMessage(s,e,o,this),this}fromJsonString(e,n){let s;try{s=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(s,n)}toBinary(e){let n=this.getType(),s=n.runtime.bin,r=s.makeWriteOptions(e),o=r.writerFactory();return s.writeMessage(this,o,r),o.finish()}toJson(e){let n=this.getType(),s=n.runtime.json,r=s.makeWriteOptions(e);return s.writeMessage(this,r)}toJsonString(e){var n;let s=this.toJson(e);return JSON.stringify(s,null,(n=e?.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function qe(t,e,n,s){var r;let o=(r=s?.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),i={[o]:function(a){t.util.initFields(this),t.util.initPartial(a,this)}}[o];return Object.setPrototypeOf(i.prototype,new E),Object.assign(i,{runtime:t,typeName:e,fields:t.util.newFieldList(n),fromBinary(a,c){return new i().fromBinary(a,c)},fromJson(a,c){return new i().fromJson(a,c)},fromJsonString(a,c){return new i().fromJsonString(a,c)},equals(a,c){return t.util.equals(i,a,c)}}),i}var u;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(u||(u={}));var M;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(M||(M={}));function Ye(){let t=0,e=0;for(let s=0;s<28;s+=7){let r=this.buf[this.pos++];if(t|=(r&127)<>4,!(n&128))return this.assertBounds(),[t,e];for(let s=3;s<=31;s+=7){let r=this.buf[this.pos++];if(e|=(r&127)<>>o,a=!(!(i>>>7)&&e==0),c=(a?i|128:i)&255;if(n.push(c),!a)return}let s=t>>>28&15|(e&7)<<4,r=!!(e>>3);if(n.push((r?s|128:s)&255),!!r){for(let o=3;o<31;o=o+7){let i=e>>>o,a=!!(i>>>7),c=(a?i|128:i)&255;if(n.push(c),!a)return}n.push(e>>>31&1)}}var Q=4294967296;function xe(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,s=0,r=0;function o(i,a){let c=Number(t.slice(i,a));r*=n,s=s*n+c,s>=Q&&(r=r+(s/Q|0),s=s%Q)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),e?je(s,r):Ne(s,r)}function We(t,e){let n=Ne(t,e),s=n.hi&2147483648;s&&(n=je(n.lo,n.hi));let r=Ie(n.lo,n.hi);return s?"-"+r:r}function Ie(t,e){if({lo:t,hi:e}=_t(t,e),e<=2097151)return String(Q*e+t);let n=t&16777215,s=(t>>>24|e<<8)&16777215,r=e>>16&65535,o=n+s*6777216+r*6710656,i=s+r*8147497,a=r*2,c=1e7;return o>=c&&(i+=Math.floor(o/c),o%=c),i>=c&&(a+=Math.floor(i/c),i%=c),a.toString()+Xe(i)+Xe(o)}function _t(t,e){return{lo:t>>>0,hi:e>>>0}}function Ne(t,e){return{lo:t|0,hi:e|0}}function je(t,e){return e=~e,t?t=~t+1:e+=1,Ne(t,e)}var Xe=t=>{let e=String(t);return"0000000".slice(e.length)+e};function Se(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function Ke(){let t=this.buf[this.pos++],e=t&127;if(!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,!(t&128))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;t&128&&n<10;n++)t=this.buf[this.pos++];if(t&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function qt(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),i=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){let f=typeof c=="bigint"?c:BigInt(c);if(f>o||fa||fx(/^-?[0-9]+$/.test(r),`int64 invalid: ${r}`),s=r=>x(/^[0-9]+$/.test(r),`uint64 invalid: ${r}`);return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),n(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),s(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),n(r),xe(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),s(r),xe(r)},dec(r,o){return We(r,o)},uDec(r,o){return Ie(r,o)}}}var N=qt();var b;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(b||(b={}));var ee=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 r=0;r>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(j(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return G(e),Se(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 n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){H(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){j(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){G(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return G(e),e=(e<<1^e>>31)>>>0,Se(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),s=new DataView(n.buffer),r=N.enc(e);return s.setInt32(0,r.lo,!0),s.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),s=new DataView(n.buffer),r=N.uEnc(e);return s.setInt32(0,r.lo,!0),s.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=N.enc(e);return Z(n.lo,n.hi,this.buf),this}sint64(e){let n=N.enc(e),s=n.hi>>31,r=n.lo<<1^s,o=(n.hi<<1|n.lo>>>31)^s;return Z(r,o,this.buf),this}uint64(e){let n=N.uEnc(e);return Z(n.lo,n.hi,this.buf),this}},te=class{constructor(e,n){this.varint64=Ye,this.uint32=Ke,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,s=e&7;if(n<=0||s<0||s>5)throw new Error("illegal tag: field no "+n+" wire type "+s);return[n,s]}skip(e){let n=this.pos;switch(e){case b.Varint:for(;this.buf[this.pos++]&128;);break;case b.Bit64:this.pos+=4;case b.Bit32:this.pos+=4;break;case b.LengthDelimited:let s=this.uint32();this.pos+=s;break;case b.StartGroup:let r;for(;(r=this.tag()[1])!==b.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,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 N.dec(...this.varint64())}uint64(){return N.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),s=-(e&1);return e=(e>>>1|(n&1)<<31)^s,n=n>>>1^s,N.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return N.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return N.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}};function P(t,e,n){if(e===n)return!0;if(t==u.BYTES){if(!(e instanceof Uint8Array)||!(n instanceof Uint8Array)||e.length!==n.length)return!1;for(let s=0;sn[e]]}function Xt(t){let e=t.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return J(e.T,e.L);case"message":let n=e.T,s=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(s):s;case"map":throw"map fields are not allowed to be extensions"}}function He(t,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let n=t.length-1;n>=0;--n)if(t[n].no==e.no)return[t[n]];return[]}return t.filter(n=>n.no===e.no)}function Qe(t,e,n,s){return{syntax:t,json:e,bin:n,util:s,makeMessageType(r,o,i){return qe(this,r,o,i)},makeEnum:Ge,makeEnumType:we,getEnumType:Je,makeExtension(r,o,i){return ze(this,r,o,i)}}}function re(t,e){return e instanceof E||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}var $r={"google.protobuf.DoubleValue":u.DOUBLE,"google.protobuf.FloatValue":u.FLOAT,"google.protobuf.Int64Value":u.INT64,"google.protobuf.UInt64Value":u.UINT64,"google.protobuf.Int32Value":u.INT32,"google.protobuf.UInt32Value":u.UINT32,"google.protobuf.BoolValue":u.BOOL,"google.protobuf.StringValue":u.STRING,"google.protobuf.BytesValue":u.BYTES};var _=Symbol("@bufbuild/protobuf/unknown-fields"),Ze={readUnknownFields:!0,readerFactory:t=>new te(t)},et={writeUnknownFields:!0,writerFactory:()=>new ee};function Yt(t){return t?Object.assign(Object.assign({},Ze),t):Ze}function Wt(t){return t?Object.assign(Object.assign({},et),t):et}function nt(){return{makeReadOptions:Yt,makeWriteOptions:Wt,listUnknownFields(t){var e;return(e=t[_])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[_]},writeUnknownFields(t,e){let s=t[_];if(s)for(let r of s)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(t,e,n,s){let r=t;Array.isArray(r[_])||(r[_]=[]),r[_].push({no:e,wireType:n,data:s})},readMessage(t,e,n,s,r){let o=t.getType(),i=r?e.len:e.pos+n,a,c;for(;e.pos0&&(c=Kt),o){let g=t[i];if(s==b.LengthDelimited&&a!=u.STRING&&a!=u.BYTES){let h=e.uint32()+e.pos;for(;e.pos>4,i=o,r=2;break;case 2:n[s++]=(i&15)<<4|(o&60)>>2,i=o,r=3;break;case 3:n[s++]=(i&3)<<6|o,r=0;break}}if(r==1)throw Error("invalid base64 string.");return n.subarray(0,s)},enc(t){let e="",n=0,s,r=0;for(let o=0;o>2],r=(s&3)<<4,n=1;break;case 1:e+=U[r|s>>4],r=(s&15)<<2,n=2;break;case 2:e+=U[r|s>>6],e+=U[s&63],n=0;break}return n&&(e+=U[r],e+="=",n==1&&(e+="=")),e}};function at(t,e,n){ut(e,t);let s=e.runtime.bin.makeReadOptions(n),r=He(t.getType().runtime.bin.listUnknownFields(t),e.field),[o,i]=ne(e);for(let a of r)e.runtime.bin.readField(o,s.readerFactory(a.data),e.field,a.wireType,s);return i()}function ct(t,e,n,s){ut(e,t);let r=e.runtime.bin.makeReadOptions(s),o=e.runtime.bin.makeWriteOptions(s);if(Be(t,e)){let f=t.getType().runtime.bin.listUnknownFields(t).filter(d=>d.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(let d of f)t.getType().runtime.bin.onUnknownField(t,d.no,d.wireType,d.data)}let i=o.writerFactory(),a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,n,i,o);let c=r.readerFactory(i.finish());for(;c.poss.no==e.field.no)}function ut(t,e){x(t.extendee.typeName==e.getType().typeName,`extension ${t.typeName} can only be applied to message ${t.extendee.typeName}`)}var ft={ignoreUnknownFields:!1},dt={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function zt(t){return t?Object.assign(Object.assign({},ft),t):ft}function Ht(t){return t?Object.assign(Object.assign({},dt),t):dt}function pt(t,e){let n=e(Qt,lt);return{makeReadOptions:zt,makeWriteOptions:Ht,readMessage(s,r,o,i){if(r==null||Array.isArray(r)||typeof r!="object")throw new Error(`cannot decode message ${s.typeName} from JSON: ${A(r)}`);i=i??new s;let a=new Map,c=o.typeRegistry;for(let[f,d]of Object.entries(r)){let l=s.fields.findJsonName(f);if(l){if(l.oneof){if(d===null&&l.kind=="scalar")continue;let g=a.get(l.oneof);if(g!==void 0)throw new Error(`cannot decode message ${s.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${g}", "${f}"`);a.set(l.oneof,f)}mt(i,d,l,o,s,t)}else{let g=!1;if(c?.findExtension&&f.startsWith("[")&&f.endsWith("]")){let p=c.findExtension(f.substring(1,f.length-1));if(p&&p.extendee.typeName==s.typeName){g=!0;let[h,R]=ne(p);mt(h,d,p.field,o,p,!0),ct(i,p,R(),o)}}if(!g&&!o.ignoreUnknownFields)throw new Error(`cannot decode message ${s.typeName} from JSON: key "${f}" is unknown`)}}return i},writeMessage(s,r){let o=s.getType(),i={},a;try{for(let f of o.fields.byMember()){let d;if(f.kind=="oneof"){let l=s[f.localName];if(l.value===void 0)continue;if(a=f.findField(l.case),!a)throw"oneof case not found: "+l.case;d=n(a,l.value,r)}else a=f,d=n(a,s[a.localName],r);d!==void 0&&(i[r.useProtoFieldName?a.name:a.jsonName]=d)}let c=r.typeRegistry;if(c?.findExtensionFor)for(let f of o.runtime.bin.listUnknownFields(s)){let d=c.findExtensionFor(o.typeName,f.no);if(d&&Be(s,d)){let l=at(s,d,r),g=n(d.field,l,r);g!==void 0&&(i[d.field.jsonName]=g)}}}catch(c){let f=a?`cannot encode field ${o.typeName}.${a.name} to JSON`:`cannot encode message ${o.typeName} to JSON`,d=c instanceof Error?c.message:String(c);throw new Error(f+(d.length>0?`: ${d}`:""))}return i},readScalar:(s,r,o)=>K(s,r,o,t),writeScalar:lt,debug:A}}function A(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":`"${t.split('"').join('\\"')}"`;default:return String(t)}}function mt(t,e,n,s,r,o){let i=n.localName;if(n.oneof){if(e===null&&n.kind=="scalar")return;t=t[n.oneof.localName]={case:i},i="value"}if(n.repeated){if(e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${A(e)}`);let a=t[i];for(let c of e){if(c===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${A(c)}`);let f;switch(n.kind){case"message":f=n.T.fromJson(c,s);break;case"enum":if(f=Ce(n.T,c,s.ignoreUnknownFields,!0),f===void 0)continue;break;case"scalar":try{f=K(n.T,c,n.L,!0)}catch(d){let l=`cannot decode field ${r.typeName}.${n.name} from JSON: ${A(c)}`;throw d instanceof Error&&d.message.length>0&&(l+=`: ${d.message}`),new Error(l)}break}a.push(f)}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${A(e)}`);let a=t[i];for(let[c,f]of Object.entries(e)){if(f===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let d;switch(n.V.kind){case"message":d=n.V.T.fromJson(f,s);break;case"enum":if(d=Ce(n.V.T,f,s.ignoreUnknownFields,!0),d===void 0)continue;break;case"scalar":try{d=K(n.V.T,f,M.BIGINT,!0)}catch(l){let g=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${A(e)}`;throw l instanceof Error&&l.message.length>0&&(g+=`: ${l.message}`),new Error(g)}break}try{a[K(n.K,n.K==u.BOOL?c=="true"?!0:c=="false"?!1:c:c,M.BIGINT,!0).toString()]=d}catch(l){let g=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${A(e)}`;throw l instanceof Error&&l.message.length>0&&(g+=`: ${l.message}`),new Error(g)}}}else switch(n.kind){case"message":let a=n.T;if(e===null&&a.typeName!="google.protobuf.Value"){if(n.oneof)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: null is invalid for oneof field`);return}t[i]instanceof E?t[i].fromJson(e,s):(t[i]=a.fromJson(e,s),a.fieldWrapper&&!n.oneof&&(t[i]=a.fieldWrapper.unwrapField(t[i])));break;case"enum":let c=Ce(n.T,e,s.ignoreUnknownFields,o);c!==void 0&&(t[i]=c);break;case"scalar":try{t[i]=K(n.T,e,n.L,o)}catch(f){let d=`cannot decode field ${r.typeName}.${n.name} from JSON: ${A(e)}`;throw f instanceof Error&&f.message.length>0&&(d+=`: ${f.message}`),new Error(d)}break}}function K(t,e,n,s){switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return s?0:void 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;let r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==u.FLOAT&&H(r),r;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return s?0:void 0;let o;if(typeof e=="number"?o=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(o=Number(e)),o===void 0)break;return t==u.UINT32?j(o):G(o),o;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return s?N.zero:void 0;if(typeof e!="number"&&typeof e!="string")break;let i=N.parse(e);return n?i.toString():i;case u.FIXED64:case u.UINT64:if(e===null)return s?N.zero:void 0;if(typeof e!="number"&&typeof e!="string")break;let a=N.uParse(e);return n?a.toString():a;case u.BOOL:if(e===null)return s?!1:void 0;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return s?"":void 0;if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case u.BYTES:if(e===null)return s?new Uint8Array(0):void 0;if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Re.dec(e)}throw new Error}function Ce(t,e,n,s){if(e===null)return s?t.values[0].no:void 0;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":let r=t.findName(e);if(r||n)return r?.no;break}throw new Error(`cannot decode enum ${t.typeName} from JSON: ${A(e)}`)}function Qt(t,e,n,s){var r;if(e===void 0)return e;if(!n&&t.values[0].no===e)return;if(s)return e;if(t.typeName=="google.protobuf.NullValue")return null;let o=t.findNumber(e);return(r=o?.name)!==null&&r!==void 0?r:e}function lt(t,e,n){if(e!==void 0)switch(t){case u.INT32:case u.SFIXED32:case u.SINT32:case u.FIXED32:case u.UINT32:return x(typeof e=="number"),e!=0||n?e:void 0;case u.FLOAT:case u.DOUBLE:return x(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e!==0||n?e:void 0;case u.STRING:return x(typeof e=="string"),e.length>0||n?e:void 0;case u.BOOL:return x(typeof e=="boolean"),e||n?e:void 0;case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:return x(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),n||e!=0?e.toString(10):void 0;case u.BYTES:return x(e instanceof Uint8Array),n||e.byteLength>0?Re.enc(e):void 0}}function gt(){return pt(!0,(t,e)=>function(s,r,o){if(s.kind=="map"){let i={};switch(s.V.kind){case"scalar":for(let[c,f]of Object.entries(r)){let d=e(s.V.T,f,!0);x(d!==void 0),i[c.toString()]=d}break;case"message":for(let[c,f]of Object.entries(r))i[c.toString()]=f.toJson(o);break;case"enum":let a=s.V.T;for(let[c,f]of Object.entries(r)){x(f===void 0||typeof f=="number");let d=t(a,f,!0,o.enumAsInteger);x(d!==void 0),i[c.toString()]=d}break}return o.emitDefaultValues||Object.keys(i).length>0?i:void 0}else if(s.repeated){let i=[];switch(s.kind){case"scalar":for(let a=0;a0?i:void 0}else{if(r===void 0)return;switch(s.kind){case"scalar":return e(s.T,r,!!s.oneof||s.opt||o.emitDefaultValues);case"enum":return t(s.T,r,!!s.oneof||s.opt||o.emitDefaultValues,o.enumAsInteger);case"message":return re(s.T,r).toJson(o)}}})}function ht(){return{setEnumType:Te,initPartial(t,e){if(t===void 0)return;let n=e.getType();for(let s of n.fields.byMember()){let r=s.localName,o=e,i=t;if(i[r]!==void 0)switch(s.kind){case"oneof":let a=i[r].case;if(a===void 0)continue;let c=s.findField(a),f=i[r].value;c&&c.kind=="message"&&!(f instanceof c.T)?f=new c.T(f):c&&c.kind==="scalar"&&c.T===u.BYTES&&(f=z(f)),o[r]={case:a,value:f};break;case"scalar":case"enum":let d=i[r];s.T===u.BYTES&&(d=s.repeated?d.map(z):z(d)),o[r]=d;break;case"map":switch(s.V.kind){case"scalar":case"enum":if(s.V.T===u.BYTES)for(let[p,h]of Object.entries(i[r]))o[r][p]=z(h);else Object.assign(o[r],i[r]);break;case"message":let g=s.V.T;for(let p of Object.keys(i[r])){let h=i[r][p];g.fieldWrapper||(h=new g(h)),o[r][p]=h}break}break;case"message":let l=s.T;if(s.repeated)o[r]=i[r].map(g=>g instanceof l?g:new l(g));else if(i[r]!==void 0){let g=i[r];l.fieldWrapper?l.typeName==="google.protobuf.BytesValue"?o[r]=z(g):o[r]=g:o[r]=g instanceof l?g:new l(g)}break}}},equals(t,e,n){return e===n?!0:!e||!n?!1:t.fields.byMember().every(s=>{let r=e[s.localName],o=n[s.localName];if(s.repeated){if(r.length!==o.length)return!1;switch(s.kind){case"message":return r.every((i,a)=>s.T.equals(i,o[a]));case"scalar":return r.every((i,a)=>P(s.T,i,o[a]));case"enum":return r.every((i,a)=>P(u.INT32,i,o[a]))}throw new Error(`repeated cannot contain ${s.kind}`)}switch(s.kind){case"message":return s.T.equals(r,o);case"enum":return P(u.INT32,r,o);case"scalar":return P(s.T,r,o);case"oneof":if(r.case!==o.case)return!1;let i=s.findField(r.case);if(i===void 0)return!0;switch(i.kind){case"message":return i.T.equals(r.value,o.value);case"enum":return P(u.INT32,r.value,o.value);case"scalar":return P(i.T,r.value,o.value)}throw new Error(`oneof cannot contain ${i.kind}`);case"map":let a=Object.keys(r).concat(Object.keys(o));switch(s.V.kind){case"message":let c=s.V.T;return a.every(d=>c.equals(r[d],o[d]));case"enum":return a.every(d=>P(u.INT32,r[d],o[d]));case"scalar":let f=s.V.T;return a.every(d=>P(f,r[d],o[d]))}break}})},clone(t){let e=t.getType(),n=new e,s=n;for(let r of e.fields.byMember()){let o=t[r.localName],i;if(r.repeated)i=o.map(ae);else if(r.kind=="map"){i=s[r.localName];for(let[a,c]of Object.entries(o))i[a]=ae(c)}else r.kind=="oneof"?i=r.findField(o.case)?{case:o.case,value:ae(o.value)}:{case:void 0}:i=ae(o);s[r.localName]=i}return n}}}function ae(t){if(t===void 0)return t;if(t instanceof E)return t.clone();if(t instanceof Uint8Array){let e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function z(t){return t instanceof Uint8Array?t:new Uint8Array(t)}var ce=class{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){let n={};for(let s of this.list())n[s.jsonName]=n[s.name]=s;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){let n={};for(let s of this.list())n[s.no]=s;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,n;for(let s of this.list())s.oneof?s.oneof!==n&&(n=s.oneof,e.push(n)):e.push(s)}return this.members}};function Oe(t,e){let n=kt(t);return e?n:nn(tn(n))}function yt(t){return Oe(t,!1)}var bt=kt;function kt(t){let e=!1,n=[];for(let s=0;s`${t}$`,tn=t=>en.has(t)?Tt(t):t,nn=t=>Zt.has(t)?Tt(t):t;var ue=class{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=yt(e)}addField(e){x(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;n[{no:1,name:"responseContext",kind:"message",T:sn},{no:9,name:"contents",kind:"message",T:D},{no:10,name:"onResponseReceivedActions",kind:"message",T:D}]),sn=m.makeMessageType("youtube.response.browse.ResponseContext",()=>[{no:6,name:"serviceTrackingParams",kind:"message",T:on,repeated:!0}]),on=m.makeMessageType("youtube.response.browse.ServiceTrackingParams",()=>[{no:1,name:"service",kind:"scalar",T:5},{no:2,name:"params",kind:"message",T:an,repeated:!0}]),an=m.makeMessageType("youtube.response.browse.Params",()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:9}]),D=m.makeMessageType("youtube.response.browse.Contents",()=>[{no:58173949,name:"browseResultsRenderer",kind:"message",T:cn},{no:153515154,name:"videoWithContextRenderer",kind:"message",T:Nt},{no:49399797,name:"richGridRenderer",kind:"message",T:Me}]),cn=m.makeMessageType("youtube.response.browse.BrowseResultsRenderer",()=>[{no:1,name:"tabs",kind:"message",T:un,repeated:!0}]),un=m.makeMessageType("youtube.response.browse.Tab",()=>[{no:58174010,name:"tabRenderer",kind:"message",T:fn}]),fn=m.makeMessageType("youtube.response.browse.TabRenderer",()=>[{no:4,name:"contents",kind:"message",T:D}]),Me=m.makeMessageType("youtube.response.browse.RichGridRenderer",()=>[{no:1,name:"richGridContents",kind:"message",T:dn,repeated:!0}]),dn=m.makeMessageType("youtube.response.browse.RichGridContent",()=>[{no:50195462,name:"richItemRenderer",kind:"message",T:Ae},{no:51845067,name:"richSectionRenderer",kind:"message",T:Tn},{no:221496734,name:"musicDescriptionShelfRenderer",kind:"message",T:In}]),Ae=m.makeMessageType("youtube.response.browse.RichItemRenderer",()=>[{no:1,name:"richItemContent",kind:"message",T:It,repeated:!0}]),It=m.makeMessageType("youtube.response.browse.RichItemContent",()=>[{no:153515154,name:"videoWithContextRenderer",kind:"message",T:Nt}]),Nt=m.makeMessageType("youtube.response.browse.VideoWithContextRenderer",()=>[{no:172660663,name:"videoRendererContent",kind:"message",T:mn}]),mn=m.makeMessageType("youtube.response.browse.VideoRendererContent",()=>[{no:1,name:"videoInfo",kind:"message",T:ln},{no:2,name:"renderInfo",kind:"message",T:bn}]),ln=m.makeMessageType("youtube.response.browse.VideoInfo",()=>[{no:168777401,name:"videoContext",kind:"message",T:pn}]),pn=m.makeMessageType("youtube.response.browse.VideoContext",()=>[{no:5,name:"videoContent",kind:"message",T:gn}]),gn=m.makeMessageType("youtube.response.browse.VideoContent",()=>[{no:465160965,name:"timedLyricsRender",kind:"message",T:hn}]),hn=m.makeMessageType("youtube.response.browse.TimedLyricsRender",()=>[{no:4,name:"timedLyricsContent",kind:"message",T:yn}]),yn=m.makeMessageType("youtube.response.browse.TimedLyricsContent",()=>[{no:1,name:"runs",kind:"message",T:St,repeated:!0},{no:2,name:"footerLabel",kind:"scalar",T:9}]),bn=m.makeMessageType("youtube.response.browse.RenderInfo",()=>[{no:183314536,name:"layoutRender",kind:"message",T:kn}]),kn=m.makeMessageType("youtube.response.browse.LayoutRender",()=>[{no:1,name:"eml",kind:"scalar",T:9}]),Tn=m.makeMessageType("youtube.response.browse.RichSectionRenderer",()=>[{no:5,name:"richSectionContent",kind:"message",T:wn}]),wn=m.makeMessageType("youtube.response.browse.RichSectionContent",()=>[{no:51431404,name:"reelShelfRenderer",kind:"message",T:xn}]),xn=m.makeMessageType("youtube.response.browse.ReelShelfRenderer",()=>[{no:1,name:"richItemContent",kind:"message",T:It,repeated:!0}]),In=m.makeMessageType("youtube.response.browse.MusicDescriptionShelfRenderer",()=>[{no:3,name:"description",kind:"message",T:wt},{no:10,name:"footer",kind:"message",T:wt}]),wt=m.makeMessageType("youtube.response.browse.Label",()=>[{no:1,name:"runs",kind:"message",T:St,repeated:!0}]),St=m.makeMessageType("youtube.response.browse.Run",()=>[{no:1,name:"text",kind:"scalar",T:9}]);var Et=m.makeMessageType("youtube.response.next.Next",()=>[{no:7,name:"Contents",kind:"message",T:Nn},{no:8,name:"onResponseReceivedActions",kind:"message",T:D}]),Nn=m.makeMessageType("youtube.response.next.Contents",()=>[{no:51779735,name:"NextResults",kind:"message",T:Sn}]),Sn=m.makeMessageType("youtube.response.next.NextResults",()=>[{no:1,name:"Contents",kind:"message",T:D}]);var Ft=m.makeMessageType("youtube.response.search.Search",()=>[{no:4,name:"contents",kind:"message",T:D},{no:7,name:"onResponseReceivedCommands",kind:"message",T:En}]),En=m.makeMessageType("youtube.response.search.OnResponseReceivedCommands",()=>[{no:50195462,name:"richItemRenderer",kind:"message",T:Ae},{no:49399797,name:"appendContinuationItemsAction",kind:"message",T:Me}]);var Rt=m.makeMessageType("youtube.response.shorts.Shorts",()=>[{no:2,name:"entries",kind:"message",T:Fn,repeated:!0}]),Fn=m.makeMessageType("youtube.response.shorts.Entry",()=>[{no:1,name:"command",kind:"message",T:Rn}]),Rn=m.makeMessageType("youtube.response.shorts.Command",()=>[{no:139608561,name:"reelWatchEndpoint",kind:"message",T:Bn}]),Bn=m.makeMessageType("youtube.response.shorts.ReelWatchEndpoint",()=>[{no:8,name:"overlay",kind:"message",T:Cn}]),Cn=m.makeMessageType("youtube.response.shorts.Overlay",()=>[{no:139970731,name:"reelPlayerOverlayRenderer",kind:"message",T:On}]),On=m.makeMessageType("youtube.response.shorts.ReelPlayerOverlayRenderer",()=>[{no:12,name:"style",kind:"scalar",T:5}]);var Ot=m.makeMessageType("youtube.response.browse.Guide",()=>[{no:4,name:"items4",kind:"message",T:Bt,repeated:!0},{no:6,name:"items6",kind:"message",T:Bt,repeated:!0}]),Bt=m.makeMessageType("youtube.response.browse.Item",()=>[{no:117866661,name:"guideSectionRenderer",kind:"message",T:Mn}]),Mn=m.makeMessageType("youtube.response.browse.GuideSectionRenderer",()=>[{no:1,name:"rendererItems",kind:"message",T:An,repeated:!0}]),An=m.makeMessageType("youtube.response.browse.RendererItem",()=>[{no:318370163,name:"iconRender",kind:"message",T:Ct},{no:117501096,name:"labelRender",kind:"message",T:Ct}]),Ct=m.makeMessageType("youtube.response.browse.guideEntryRenderer",()=>[{no:1,name:"browseId",kind:"scalar",T:9}]);var Mt=m.makeMessageType("youtube.response.player.Player",()=>[{no:7,name:"adPlacements",kind:"message",T:Pn,repeated:!0},{no:2,name:"playabilityStatus",kind:"message",T:vn},{no:10,name:"captions",kind:"message",T:Vn}]),Pn=m.makeMessageType("youtube.response.player.AdPlacement",()=>[{no:84813246,name:"adPlacementRenderer",kind:"message",T:Un}]),Un=m.makeMessageType("youtube.response.player.AdPlacementRenderer",()=>[{no:4,name:"params",kind:"scalar",T:9}]),vn=m.makeMessageType("youtube.response.player.PlayabilityStatus",()=>[{no:21,name:"miniPlayer",kind:"message",T:Ln},{no:11,name:"backgroundPlayer",kind:"message",T:Pe}]),Ln=m.makeMessageType("youtube.response.player.MiniPlayer",()=>[{no:151635310,name:"miniPlayerRender",kind:"message",T:Dn}]),Pe=m.makeMessageType("youtube.response.player.BackgroundPlayer",()=>[{no:64657230,name:"backgroundPlayerRender",kind:"message",T:$n}]),Dn=m.makeMessageType("youtube.response.player.MiniPlayerRender",()=>[{no:1,name:"active",kind:"scalar",T:8}]),$n=m.makeMessageType("youtube.response.player.BackgroundPlayerRender",()=>[{no:1,name:"active",kind:"scalar",T:8}]),Vn=m.makeMessageType("youtube.response.player.Captions",()=>[{no:51621377,name:"playerCaptionsTrackListRenderer",jsonName:"playerCaptionsTracklistRenderer",kind:"message",T:Jn}]),Jn=m.makeMessageType("youtube.response.player.PlayerCaptionsTrackListRenderer",()=>[{no:1,name:"captionTracks",kind:"message",T:Ue,repeated:!0},{no:2,name:"audioTracks",kind:"message",T:Gn,repeated:!0},{no:3,name:"translationLanguages",kind:"message",T:ve,repeated:!0},{no:4,name:"defaultAudioTrackIndex",kind:"scalar",T:5,opt:!0},{no:6,name:"defaultCaptionTrackIndex",kind:"scalar",T:5,opt:!0}]),Ue=m.makeMessageType("youtube.response.player.CaptionTrack",()=>[{no:1,name:"baseUrl",kind:"scalar",T:9},{no:2,name:"name",kind:"message",T:At},{no:3,name:"vssId",kind:"scalar",T:9},{no:4,name:"languageCode",kind:"scalar",T:9},{no:5,name:"kind",kind:"scalar",T:9,opt:!0},{no:6,name:"rtl",kind:"scalar",T:8,opt:!0},{no:7,name:"isTranslatable",kind:"scalar",T:8}]),Gn=m.makeMessageType("youtube.response.player.AudioTrack",()=>[{no:2,name:"captionTrackIndices",kind:"scalar",T:5,repeated:!0,packed:!1},{no:3,name:"defaultCaptionTrackIndex",kind:"scalar",T:5,opt:!0},{no:4,name:"forcedCaptionTrackIndex",kind:"scalar",T:5,opt:!0},{no:5,name:"visibility",kind:"scalar",T:5,opt:!0},{no:6,name:"hasDefaultTrack",kind:"scalar",T:8,opt:!0},{no:7,name:"hasForcedTrack",kind:"scalar",T:8,opt:!0},{no:8,name:"audioTrackId",kind:"scalar",T:9,opt:!0},{no:11,name:"captionsInitialState",kind:"scalar",T:5,opt:!0}]),ve=m.makeMessageType("youtube.response.player.TranslationLanguage",()=>[{no:1,name:"languageCode",kind:"scalar",T:9},{no:2,name:"languageName",kind:"message",T:At}]),At=m.makeMessageType("youtube.response.player.Name",()=>[{no:1,name:"runs",kind:"message",T:_n,repeated:!0}]),_n=m.makeMessageType("youtube.response.player.Name.Run",()=>[{no:1,name:"text",kind:"scalar",T:9}],{localName:"Name_Run"});var Ut=m.makeMessageType("youtube.response.setting.Setting",()=>[{no:6,name:"settingItems",kind:"message",T:Le,repeated:!0},{no:10,name:"trackingParams",kind:"message",T:fe}]),Le=m.makeMessageType("youtube.response.setting.SettingItem",()=>[{no:88478200,name:"settingCategoryEntryRenderer",kind:"message",T:Xn},{no:66930374,name:"settingCategoryCollectionRenderer",kind:"message",T:Yn}]),fe=m.makeMessageType("youtube.response.setting.TrackingParams",()=>[{no:1,name:"f1",kind:"scalar",T:5},{no:2,name:"f2",kind:"scalar",T:5},{no:3,name:"f3",kind:"scalar",T:5},{no:4,name:"timeInfo",kind:"message",T:qn}]),qn=m.makeMessageType("youtube.response.setting.TimeInfo",()=>[{no:1,name:"timestamp",kind:"scalar",T:4,L:1},{no:2,name:"f2",kind:"scalar",T:7},{no:3,name:"f3",kind:"scalar",T:7}]),Xn=m.makeMessageType("youtube.response.setting.SettingCategoryEntryRenderer",()=>[{no:2,name:"f2",kind:"scalar",T:5},{no:3,name:"f3",kind:"scalar",T:5},{no:5,name:"trackingParams",kind:"message",T:fe},{no:6,name:"f6",kind:"scalar",T:5},{no:7,name:"f7",kind:"scalar",T:5},{no:8,name:"f8",kind:"scalar",T:5},{no:9,name:"f9",kind:"scalar",T:5},{no:10,name:"f10",kind:"scalar",T:5},{no:12,name:"f12",kind:"scalar",T:5}]),Yn=m.makeMessageType("youtube.response.setting.SettingCategoryCollectionRenderer",()=>[{no:3,name:"subSettings",kind:"message",T:De,repeated:!0},{no:4,name:"categoryId",kind:"scalar",T:5}]),De=m.makeMessageType("youtube.response.setting.SubSetting",()=>[{no:61331416,name:"settingBooleanRenderer",kind:"message",T:Wn}]),Wn=m.makeMessageType("youtube.response.setting.SettingBooleanRenderer",()=>[{no:5,name:"enableServiceEndpoint",kind:"message",T:Pt},{no:6,name:"disableServiceEndpoint",kind:"message",T:Pt},{no:13,name:"clickTrackingParams",kind:"message",T:fe},{no:15,name:"itemId",kind:"scalar",T:5}]),Pt=m.makeMessageType("youtube.response.setting.ServiceEndpoint",()=>[{no:2,name:"trackingParams",kind:"message",T:fe},{no:81212182,name:"setClientSettingEndpoint",kind:"message",T:jn}]),jn=m.makeMessageType("youtube.response.setting.SetClientSettingEndpoint",()=>[{no:1,name:"settingDatas",kind:"message",T:Kn}]),Kn=m.makeMessageType("youtube.response.setting.SettingDatas",()=>[{no:1,name:"clientSettingEnum",kind:"message",T:zn},{no:3,name:"boolValue",kind:"scalar",T:8}]),zn=m.makeMessageType("youtube.response.setting.ClientSettingEnum",()=>[{no:1,name:"item",kind:"scalar",T:5}]);var X=class{constructor(e,n,s){this._times=new Map;this.name=e??"",this.debug=s?.debug??!1,e&&this.log(`${e} Start`),this.className=n??"",this.init()}static getInstance(e,n){let s=typeof $task<"u"?"QuanX":"Surge";return X.instances[s]||(X.instances[s]=X.classNames[s](e,s,n)),X.instances[s]}createProxy(e){return new Proxy(e,{get:this.getFn,set:this.setFn})}getFn(e,n,s){return e[n]}setFn(e,n,s,r){return e[n]=s,!0}getJSON(e,n={}){let s=this.getVal(e);return s?JSON.parse(s):n}setJSON(e,n){this.setVal(JSON.stringify(e),n)}msg(e=this.name,n="",s="",r){}log(e){this.debug&&(typeof e=="object"&&(e=JSON.stringify(e)),console.log(e))}timeStart(e){this._times=this._times||{},this._times[e]=Date.now()}timeEnd(e){if(this._times?.has(e)){let n=Date.now()-this._times[e];this.log(`${e}: ${n}ms`),this._times.delete(e)}else this.log(`Timer with label ${e} does not exist.`)}exit(){$done({})}reject(){$done()}},L=X;L.instances={},L.classNames={QuanX:(e,n,s)=>new me(e,n,s),Surge:(e,n,s)=>new de(e,n,s)};var le=class extends L{getFn(e,n,s){let r=le.clientAdapter[n]||n;return super.getFn(e,r,s)}setFn(e,n,s,r){let o=le.clientAdapter[n]||n;return super.setFn(e,o,s,r)}init(){try{this.request=this.createProxy($request),this.response=this.createProxy($response)}catch(e){this.log(e.toString())}}getVal(e){return $persistentStore.read(e)}setVal(e,n){$persistentStore.write(e,n)}msg(e=this.name,n="",s="",r){$notification.post(e,n,s,{url:r??""})}async fetch(e){return await new Promise((n,s)=>{let{method:r,body:o,bodyBytes:i,...a}=e,c=i??o,f=c instanceof Uint8Array;$httpClient[r.toLowerCase()]({...a,body:c,"binary-mode":f},(d,l,g)=>{d&&s(d);let p=f?"bodyBytes":"body";n({status:l.status||l.statusCode,headers:l.headers,[p]:g})})})}done(e){let n=e.response??e,s,r;n.bodyBytes?(s=n.bodyBytes,delete n.bodyBytes,r={...e},r.response?r.response.body=s:r.body=s):r=e,$done(r)}},de=le;de.clientAdapter={bodyBytes:"body"};var v=class extends L{static transferBodyBytes(e,n){return e instanceof ArrayBuffer?n==="Uint8Array"?new Uint8Array(e):e:e instanceof Uint8Array&&n==="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.log(e.toString())}}getFn(e,n,s){let r=v.clientAdapter[n]||n,o=super.getFn(e,r,s);return n==="bodyBytes"&&(o=v.transferBodyBytes(o,"Uint8Array")),o}setFn(e,n,s,r){let o=v.clientAdapter[n]||n,i=s;return n==="bodyBytes"&&(i=v.transferBodyBytes(i,"Uint8Array")),super.setFn(e,o,i,r)}getVal(e){return $prefs.valueForKey(e)?.replace(/\0/g,"")}setVal(e,n){$prefs.setValueForKey(e,n)}msg(e=this.name,n="",s="",r){$notify(e,n,s,{"open-url":r??""})}async fetch(e){return await new Promise(n=>{let s={url:"",method:"GET"};for(let[r,o]of Object.entries(e))r==="id"?s.sessionIndex=o:r==="bodyBytes"?s.bodyBytes=v.transferBodyBytes(o,"ArrayBuffer"):s[r]=o;e.bodyBytes&&delete s.body,$task.fetch(s).then(r=>{let o={status:200,headers:{}};for(let[i,a]of Object.entries(r))i==="sessionIndex"?o.id=a:i==="bodyBytes"?o.bodyBytes=v.transferBodyBytes(a,"Uint8Array"):i==="statusCode"?o.status=a:o[i]=a;n(o)})})}done(e){let n=e.response??e,s={};for(let[r,o]of Object.entries(n))r==="status"?s.status=`HTTP/1.1 ${o}`:r==="bodyBytes"?s.bodyBytes=v.transferBodyBytes(o,"ArrayBuffer"):s[r]=o;$done(s)}},me=v;me.clientAdapter={id:"sessionIndex",status:"statusCode"};var S=L.getInstance("YouTube",{debug:!1});var $=class{constructor(e,n){this.decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0});S.log(n),this.name=n,this.msgType=e,Object.assign(this,S.getJSON("YouTubeAdvertiseInfo",{whiteNo:[],blackNo:[],whiteEml:[],blackEml:[]})),this.argument=this.decodeArgument()}decodeArgument(){let e={lyricLang:"zh-Hans",captionLang:"zh-Hans",blockUpload:!0,immersive:!0};return typeof $argument=="string"&&!$argument.includes("{{{")?JSON.parse($argument):e}fromBinary(e){return this.message=this.msgType.fromBinary(e),this}async modify(){let e=this.pure();return e instanceof Promise?await e:e}toBinary(){return this.message.toBinary()}listUnknownFields(e){return e instanceof E?e.getType().runtime.bin.listUnknownFields(e):[]}save(){if(this.needSave){S.log("Update Config");let e={whiteNo:this.whiteNo,blackNo:this.blackNo,whiteEml:this.whiteEml,blackEml:this.blackEml};S.setJSON(e,"YouTubeAdvertiseInfo")}}done(e){this.save();let n=e.bodyBytes;this.needProcess&&(n=this.toBinary()),e.headers["Content-Encoding"]="identity",e.headers["Content-Length"]=(n?.length??0)?.toString(),S.done({response:{...e,bodyBytes:n}})}doneResponse(){this.save(),this.needProcess&&S.done({bodyBytes:this.toBinary()}),S.exit()}iterate(e={},n,s){let r=typeof e=="object"?[e]:[];for(;r.length;){let o=r.pop(),i=Object.keys(o);if(typeof n=="symbol"){for(let a of Object.getOwnPropertySymbols(o))if(a.description===n.description){s(o,r);break}}for(let a of i)a===n?s(o,r):typeof o[a]=="object"&&r.push(o[a])}}isAdvertise(e){let n=this.listUnknownFields(e)[0];return n?this.handleFieldNo(n):this.handleFieldEml(e)}handleFieldNo(e){let n=e.no;if(this.whiteNo.includes(n))return!1;if(this.blackNo.includes(n))return!0;let r=this.decoder.decode(e.data).includes("pagead");return r?this.blackNo.push(n):this.whiteNo.push(n),this.needSave=!0,r}handleFieldEml(e){let n=!1,s="";return this.iterate(e,"renderInfo",(r,o)=>{if(s=r.renderInfo.layoutRender.eml.split("|")[0],this.whiteEml.includes(s))n=!1;else if(this.blackEml.includes(s)||/shorts(?!_pivot_item)/.test(s))n=!0;else{let i=r?.videoInfo?.videoContext?.videoContent;if(i){let a=this.listUnknownFields(i)[0];n=this.decoder.decode(a.data).includes("pagead"),n?this.blackEml.push(s):this.whiteEml.push(s),this.needSave=!0}}o.length=0}),n}isShorts(e){let n=!1;return this.iterate(e,"eml",(s,r)=>{n=/shorts(?!_pivot_item)/.test(s.eml),r.length=0}),n}};function Hn(t){let s=".",r="+-a^+6",o="+-3^+b+-f",i,a,c;for(i=[],a=0,c=0;cf?i[a++]=f:(2048>f?i[a++]=f>>6|192:((f&64512)==55296&&c+1>18|240,i[a++]=f>>12&63|128):i[a++]=f>>12|224,i[a++]=f>>6&63|128),i[a++]=f&63|128)}for(t=406644,a=0;at&&(t=(t&2147483647)+2147483648),t%=1e6,t.toString()+s+(t^406644)}function vt(t,e){let n="a",s="+",r;for(let o=0;o=n?r.charCodeAt(0)-87:Number(r),r=e.charAt(o+1)==s?t>>>r:t<{for(let n=e.richGridContents.length-1;n>=0;n--)this.removeCommonAD(e,n),this.removeShorts(e,n)}),await this.translate(),this}removeCommonAD(e,n){let r=e.richGridContents[n]?.richItemRenderer?.richItemContent;for(let o=r?.length-1;o>=0;o--)this.isAdvertise(r[o])&&(r.splice(o,1),this.needProcess=!0)}removeShorts(e,n){let s=e.richGridContents[n]?.richSectionRenderer;this.isShorts(s)&&(e.richGridContents.splice(n,1),this.needProcess=!0)}getBrowseId(){let e="";return this.iterate(this.message?.responseContext,"key",(n,s)=>{n.key==="browse_id"&&(e=n.value,s.length=0)}),e}async translate(){let e=this.argument.lyricLang?.trim();if(!(this.name==="Browse"&&this.getBrowseId().startsWith("MPLYt"))||e==="off")return;let n="",s,r=!1;if(this.iterate(this.message,"timedLyricsContent",(c,f)=>{s=c.timedLyricsContent,n=c.timedLyricsContent.runs.map(d=>d.text).join(` +`),r=!0,f.length=0}),r||this.iterate(this.message,"description",(c,f)=>{s=c.description.runs[0],n=c.description.runs[0].text,f.length=0,r=!0}),!r)return;let o=e.split("-")[0],i=Lt(n,e),a=await S.fetch({method:"GET",url:i});if(a.status===200&&a.body){let c=JSON.parse(a.body),f=" & Translated by Google",d=c[2].includes(o);s.text?(s.text=c[0].map(l=>d?l[0]:l[1]+l[0]||"").join(`\r +`),this.iterate(this.message,"footer",(l,g)=>{l.footer.runs[0].text+=f,g.length=0})):s.runs.length<=c[0].length&&(s.runs.forEach((l,g)=>{l.text=d?c[0][g][0]:l.text+` +${c[0][g][0]}`}),s.footerLabel+=f),this.needProcess=!0}}},pe=class extends Y{constructor(e=Et,n="Next"){super(e,n)}addTranslateTab(){this.iterate(this.message?.a1F7?.musicPlayRender,"items",(e,n)=>{let s=e.items.find(r=>r.tab.info?.browseInfo?.browseId.startsWith("MPLYt"));s&&(s.tab.name=s.tab.name+"\u21C4"),this.needProcess=!0,n.length=0})}},ge=class extends ${constructor(e=Mt,n="Player"){super(e,n)}pure(){return this.message.adPlacements?.length&&(this.message.adPlacements.length=0),this.addPlayAbility(),this.addTranslateCaption(),this.needProcess=!0,this}addPlayAbility(){let e=this.message?.playabilityStatus?.miniPlayer?.miniPlayerRender;typeof e=="object"&&(e.active=!0),typeof this.message.playabilityStatus=="object"&&(this.message.playabilityStatus.backgroundPlayer=new Pe({backgroundPlayerRender:{active:!0}}))}addTranslateCaption(){let e=this.argument.captionLang;e!=="off"&&this.iterate(this.message,"captionTracks",(n,s)=>{let r=n.captionTracks,o=n.audioTracks;if(Array.isArray(r)){let a={["."+e]:2,".en":1,"a.en":0},c=-1,f=0;for(let d=0;dc&&(c=g,f=d),l.isTranslatable=!0}if(c!==2){let d=new Ue({baseUrl:r[f].baseUrl+`&tlang=${e}`,name:{runs:[{text:`@Enhance (${e})`}]},vssId:`.${e}`,languageCode:e});r.push(d)}if(Array.isArray(o)){let d=c===2?f:r.length-1;for(let l of o)l.captionTrackIndices?.includes(d)||l.captionTrackIndices.push(d),l.defaultCaptionTrackIndex=d,l.captionsInitialState=3}}let i={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"};n.translationLanguages=Object.entries(i).map(([a,c])=>new ve({languageCode:a,languageName:{runs:[{text:c}]}})),s.length=0})}},he=class extends Y{constructor(e=Ft,n="Search"){super(e,n)}},ye=class extends ${constructor(e=Rt,n="Shorts"){super(e,n)}pure(){let e=this.message.entries?.length;if(e)for(let n=e-1;n>=0;n--)this.message.entries[n].command?.reelWatchEndpoint?.overlay||(this.message.entries.splice(n,1),this.needProcess=!0);return this}},be=class extends ${constructor(e=Ot,n="Guide"){super(e,n)}pure(){let e=["SPunlimited"];return this.argument.blockUpload&&e.push("FEuploads"),this.argument.immersive&&e.push("FEmusic_immersive"),this.iterate(this.message,"rendererItems",n=>{for(let s=n.rendererItems.length-1;s>=0;s--){let r=n.rendererItems[s]?.iconRender?.browseId||n.rendererItems[s]?.labelRender?.browseId;e.includes(r)&&(n.rendererItems.splice(s,1),this.needProcess=!0)}}),this}},ke=class extends ${constructor(e=Ut,n="Setting"){super(e,n)}pure(){this.iterate(this.message,"categoryId",n=>{if(n.categoryId===10005){let s={f1:135,f2:20434,f3:2,timeInfo:this.message.trackingParams.timeInfo},r=new De({settingBooleanRenderer:{itemId:0,enableServiceEndpoint:{trackingParams:s,setClientSettingEndpoint:{settingDatas:{clientSettingEnum:{item:151},boolValue:!0}}},disableServiceEndpoint:{trackingParams:s,setClientSettingEndpoint:{settingDatas:{clientSettingEnum:{item:151},boolValue:!1}}},clickTrackingParams:s}});n.subSettings.push(r)}});let e=new Le({settingCategoryEntryRenderer:{f2:1,f3:1,trackingParams:{f1:2,f2:20020,f3:8,timeInfo:this.message.trackingParams.timeInfo},f6:0,f7:1,f8:1,f9:1,f10:1,f12:1}});return this.message.settingItems.push(e),this.needProcess=!0,this}};var Qn=new Map([["browse",Y],["next",pe],["player",ge],["search",he],["reel_watch_sequence",ye],["guide",be],["get_setting",ke]]);function $e(t){for(let[e,n]of Qn.entries())if(t.includes(e))return new n;return null}async function Zn(){try{let t=$e(S.request.url);if(!t){S.msg("YouTube Enhance","\u811A\u672C\u9700\u8981\u66F4\u65B0","\u5916\u90E8\u8D44\u6E90 -> \u5168\u90E8\u66F4\u65B0"),S.exit();return}let e=S.response.bodyBytes;await t.fromBinary(e).modify(),t.doneResponse()}catch(t){console.log(t.toString()),S.exit()}}Zn();})();