// Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // Browser-compatible process shim for googlevideo var __Process$ = { env: {} }; // googlevideo library - bundled with esbuild var Je=Object.defineProperty;var et=(e,n)=>{for(var t in n)Je(e,t,{get:n[t],enumerable:!0})};var D="2147483647",J={VIDEO_AND_AUDIO:0,0:"VIDEO_AND_AUDIO",AUDIO_ONLY:1,1:"AUDIO_ONLY",VIDEO_ONLY:2,2:"VIDEO_ONLY"};function Hn(e){if(e.startsWith("sabr://"))return!0;let n=e.split("?"),t=n[0],r=n[1]||"";if(t.endsWith("/videoplayback")){let o=new URLSearchParams(r);if(o.get("source")==="youtube"||o.has("sabr")||o.has("lsig")||o.has("expire"))return!0}else if(t.includes("/videoplayback/")){let o=t.split("/");return["videoplayback","sabr","lsig","expire"].some(i=>o.includes(i))}return!1}function Ae(e){if(!e)return;let n=e.split("=")[1]?.split("-");if(n?.length){let t=Number(n[0]),r=Number(n[1]);return{start:t,end:r}}}function Vn(e){return btoa(String.fromCharCode.apply(null,Array.from(e)))}function ee(e){let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n.padEnd(n.length+(4-n.length%4)%4,"=");return new Uint8Array(atob(t).split("").map(r=>r.charCodeAt(0)))}function te(e){let n=e.reduce((o,i)=>o+i.length,0),t=new Uint8Array(n),r=0;for(let o of e)t.set(o,r),r+=o.length;return t}function Kn(e){return{itag:e.itag,lastModified:e.last_modified_ms||e.lastModified||"0",xtags:e.xtags,width:e.width,height:e.height,mimeType:e.mime_type||e.mimeType,audioQuality:e.audio_quality||e.audioQuality,bitrate:e.bitrate,averageBitrate:e.average_bitrate||e.averageBitrate,quality:e.quality,qualityLabel:e.quality_label||e.qualityLabel,audioTrackId:e.audio_track?.id||e.audioTrackId,approxDurationMs:e.approx_duration_ms||parseInt(e.approxDurationMs||"0"),contentLength:parseInt(e.contentLength||"0")||e.content_length,isDrc:e.is_drc,isAutoDubbed:e.is_auto_dubbed,isDescriptive:e.is_descriptive,isDubbed:e.is_dubbed,language:e.language,isOriginal:e.is_original,isSecondary:e.is_secondary}}function Wn(e){return new Promise(n=>setTimeout(n,e))}var ye={};et(ye,{createKey:()=>F,createSegmentCacheKey:()=>w,createSegmentCacheKeyFromMetadata:()=>nt,fromFormat:()=>R,fromFormatInitializationMetadata:()=>tt,fromMediaHeader:()=>m,getUniqueFormatId:()=>it});function F(e,n){return`${e||""}:${n||""}`}function R(e){if(e)return F(e.itag,e.xtags)}function m(e){return F(e.itag,e.xtags)}function tt(e){return e.formatId?F(e.formatId.itag,e.formatId.xtags):""}function w(e,n){return e.isInitSeg&&n?`${e.itag}:${e.xtags||""}:${n.contentLength||""}:${n.mimeType||""}`:`${e.startRange||"0"}-${e.itag}-${e.xtags||""}`}function nt(e){if(!e.byteRange||!e.format)throw new Error("Invalid metadata: byteRange or format is missing");let n={itag:e.format.itag,xtags:e.format.xtags||"",startRange:e.byteRange.start.toString(),isInitSeg:e.isInit};return w(n,e.isInit?e.format:void 0)}function it(e){if(e.width)return e.itag.toString();let n=[e.itag.toString()];return e.audioTrackId&&n.push(e.audioTrackId),e.isDrc&&n.push("drc"),n.join("-")}var l={NONE:0,0:"NONE",ERROR:1,1:"ERROR",WARN:2,2:"WARN",INFO:3,3:"INFO",DEBUG:4,4:"DEBUG",ALL:99,99:"ALL"},M=class e{constructor(){this.currentLogLevels=new Set([l.INFO,l.ERROR])}static getInstance(){return e.instance||(e.instance=new e),e.instance}setLogLevels(...n){n.length===0||n.includes(l.NONE)?this.currentLogLevels=new Set:n.includes(l.ALL)?this.currentLogLevels=new Set([l.ERROR,l.WARN,l.INFO,l.DEBUG]):this.currentLogLevels=new Set(n.filter(t=>t!==l.NONE&&t!==l.ALL))}getLogLevels(){return new Set(this.currentLogLevels)}log(n,t,...r){if(n!==l.NONE&&this.currentLogLevels.has(n)){let o=`[${l[n]}] [${t}]`;switch(n){case l.ERROR:console.error(o,...r);break;case l.WARN:console.warn(o,...r);break;case l.INFO:console.info(o,...r);break;case l.DEBUG:console.debug(o,...r);break}}}error(n,...t){this.log(l.ERROR,n,...t)}warn(n,...t){this.log(l.WARN,n,...t)}info(n,...t){this.log(l.INFO,n,...t)}debug(n,...t){this.log(l.DEBUG,n,...t)}};var U="CacheManager",v=class{constructor(n=50,t=600){this.initSegmentCache=new Map,this.segmentCache=new Map,this.currentSize=0,this.logger=M.getInstance(),this.maxCacheSize=n*1024*1024,this.maxAge=t*1e3,this.startGarbageCollection()}getCacheEntries(){return{initSegmentCache:this.initSegmentCache,segmentCache:this.segmentCache}}setInitSegment(n,t){let r={data:t,timestamp:Date.now(),size:t.byteLength};this.initSegmentCache.has(n)||(this.currentSize+=r.size,this.enforceStorageLimit()),this.initSegmentCache.set(n,r)}setSegment(n,t){let r={data:t,timestamp:Date.now(),size:t.byteLength};this.currentSize+=r.size,this.enforceStorageLimit(),this.segmentCache.set(n,r)}getInitSegment(n){let t=this.initSegmentCache.get(n);if(t&&!this.isExpired(t))return this.logger.debug(U,`Cache hit for init segment: ${n}`),t.timestamp=Date.now(),t.data;t&&(this.initSegmentCache.delete(n),this.currentSize-=t.size)}getSegment(n){let t=this.segmentCache.get(n);if(t&&!this.isExpired(t)){this.logger.debug(U,`Cache hit for segment: ${n}`);let r=t.data;return this.segmentCache.delete(n),this.currentSize-=t.size,r}t&&(this.segmentCache.delete(n),this.currentSize-=t.size)}isExpired(n){return Date.now()-n.timestamp>this.maxAge}enforceStorageLimit(){this.currentSize<=this.maxCacheSize||(this.clearExpiredEntries(),this.currentSize>this.maxCacheSize&&this.removeOldestEntries())}clearExpiredEntries(){let n=Date.now();for(let[t,r]of this.segmentCache.entries())n-r.timestamp>this.maxAge&&(this.logger.debug(U,`Removing expired segment from cache: ${t}`),this.segmentCache.delete(t),this.currentSize-=r.size);for(let[t,r]of this.initSegmentCache.entries())n-r.timestamp>this.maxAge&&(this.logger.debug(U,`Removing expired init segment from cache: ${t}`),this.initSegmentCache.delete(t),this.currentSize-=r.size)}removeOldestEntries(){let n=Array.from(this.segmentCache.entries()),t=Array.from(this.initSegmentCache.entries()),r=[...n,...t].sort((o,i)=>o[1].timestamp-i[1].timestamp);for(;this.currentSize>this.maxCacheSize&&r.length>0;){let[o,i]=r.shift();this.segmentCache.delete(o),this.initSegmentCache.delete(o),this.currentSize-=i.size}}startGarbageCollection(){this.timerId=setInterval(()=>{this.clearExpiredEntries()},6e4)}dispose(){this.initSegmentCache.clear(),this.segmentCache.clear(),this.currentSize=0,this.timerId&&(clearInterval(this.timerId),this.timerId=void 0),this.logger.debug(U,"Disposed")}};var ot=function(e,n,t,r,o){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?e!==n||!o:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?o.call(e,t):o?o.value=t:n.set(e,t),t},S=function(e,n,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!r:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(e):r?r.value:n.get(e)},H,_,g=class extends Event{constructor(n,t){super(n,t),H.set(this,void 0),ot(this,H,t?.detail??null,"f")}get detail(){return S(this,H,"f")}};H=new WeakMap;var I=class extends Error{constructor(n,t){super(`[SabrStreamingAdapter] ${n}`),this.code=t,this.name="SabrAdapterError"}},Ne=class extends EventTarget{constructor(){super(),_.set(this,new Map)}emit(n,...t){let r=new g(n,{detail:t});this.dispatchEvent(r)}on(n,t){let r=o=>{o instanceof g?t(...o.detail):t(o)};S(this,_,"f").set(t,{type:n,wrapper:r}),this.addEventListener(n,r)}once(n,t){let r=o=>{o instanceof g?t(...o.detail):t(o),this.off(n,t)};S(this,_,"f").set(t,{type:n,wrapper:r}),this.addEventListener(n,r)}off(n,t){let r=S(this,_,"f").get(t);r&&r.type===n&&(this.removeEventListener(n,r.wrapper),S(this,_,"f").delete(t))}removeAllListeners(n){if(n)for(let[t,r]of S(this,_,"f").entries())r.type===n&&(this.removeEventListener(n,r.wrapper),S(this,_,"f").delete(t));else for(let[t,r]of S(this,_,"f").entries())this.removeEventListener(r.type,r.wrapper),S(this,_,"f").delete(t)}};_=new WeakMap;var V=class{constructor(){this.CLEANUP_INTERVAL=3e4,this.ENTRY_EXPIRATION_TIME=1e3*60*3,this.metadataMap=new Map,this.lastCleanup=Date.now()}getRequestMetadata(n,t=!1){let r=new URL(n).searchParams.get("rn")||"",o=this.metadataMap.get(r);if(o&&Date.now()-o.timestamp>this.ENTRY_EXPIRATION_TIME){this.metadataMap.delete(r);return}return t&&this.metadataMap.delete(r),this.conditionalCleanUp(),o}setRequestMetadata(n,t){let r=new URL(n).searchParams.get("rn");r&&(this.metadataMap.set(r,t),this.conditionalCleanUp())}conditionalCleanUp(){let n=Date.now();n-this.lastCleanup>this.CLEANUP_INTERVAL&&(this.cleanUp(),this.lastCleanup=n)}cleanUp(){for(let[n,t]of this.metadataMap.entries())Date.now()-t.timestamp>this.ENTRY_EXPIRATION_TIME&&this.metadataMap.delete(n)}};function Ce(){let e=0,n=0;for(let r=0;r<28;r+=7){let o=this.buf[this.pos++];if(e|=(o&127)<>4,(t&128)==0)return this.assertBounds(),[e,n];for(let r=3;r<=31;r+=7){let o=this.buf[this.pos++];if(n|=(o&127)<>>i,s=!(!(c>>>7)&&n==0),u=(s?c|128:c)&255;if(t.push(u),!s)return}let r=e>>>28&15|(n&7)<<4,o=n>>3!=0;if(t.push((o?r|128:r)&255),!!o){for(let i=3;i<31;i=i+7){let c=n>>>i,s=!!(c>>>7),u=(s?c|128:c)&255;if(t.push(u),!s)return}t.push(n>>>31&1)}}var K=4294967296;function ne(e){let n=e[0]==="-";n&&(e=e.slice(1));let t=1e6,r=0,o=0;function i(c,s){let u=Number(e.slice(c,s));o*=t,r=r*t+u,r>=K&&(o=o+(r/K|0),r=r%K)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),n?Me(r,o):oe(r,o)}function Oe(e,n){let t=oe(e,n),r=t.hi&2147483648;r&&(t=Me(t.lo,t.hi));let o=ie(t.lo,t.hi);return r?"-"+o:o}function ie(e,n){if({lo:e,hi:n}=rt(e,n),n<=2097151)return String(K*n+e);let t=e&16777215,r=(e>>>24|n<<8)&16777215,o=n>>16&65535,i=t+r*6777216+o*6710656,c=r+o*8147497,s=o*2,u=1e7;return i>=u&&(c+=Math.floor(i/u),i%=u),c>=u&&(s+=Math.floor(c/u),c%=u),s.toString()+Pe(c)+Pe(i)}function rt(e,n){return{lo:e>>>0,hi:n>>>0}}function oe(e,n){return{lo:e|0,hi:n|0}}function Me(e,n){return n=~n,e?e=~e+1:n+=1,oe(e,n)}var Pe=e=>{let n=String(e);return"0000000".slice(n.length)+n};function re(e,n){if(e>=0){for(;e>127;)n.push(e&127|128),e=e>>>7;n.push(e)}else{for(let t=0;t<9;t++)n.push(e&127|128),e=e>>7;n.push(1)}}function xe(){let e=this.buf[this.pos++],n=e&127;if((e&128)==0)return this.assertBounds(),n;if(e=this.buf[this.pos++],n|=(e&127)<<7,(e&128)==0)return this.assertBounds(),n;if(e=this.buf[this.pos++],n|=(e&127)<<14,(e&128)==0)return this.assertBounds(),n;if(e=this.buf[this.pos++],n|=(e&127)<<21,(e&128)==0)return this.assertBounds(),n;e=this.buf[this.pos++],n|=(e&15)<<28;for(let t=5;(e&128)!==0&&t<10;t++)e=this.buf[this.pos++];if((e&128)!=0)throw new Error("invalid varint");return this.assertBounds(),n>>>0}var p=at();function at(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let t=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),o=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){let s=typeof c=="bigint"?c:BigInt(c);if(s>r||si||s>>0)}raw(n){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(n),this}uint32(n){for(De(n);n>127;)this.buf.push(n&127|128),n=n>>>7;return this.buf.push(n),this}int32(n){return ce(n),re(n,this.buf),this}bool(n){return this.buf.push(n?1:0),this}bytes(n){return this.uint32(n.byteLength),this.raw(n)}string(n){let t=this.encodeUtf8(n);return this.uint32(t.byteLength),this.raw(t)}float(n){lt(n);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,n,!0),this.raw(t)}double(n){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,n,!0),this.raw(t)}fixed32(n){De(n);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n,!0),this.raw(t)}sfixed32(n){ce(n);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,n,!0),this.raw(t)}sint32(n){return ce(n),n=(n<<1^n>>31)>>>0,re(n,this.buf),this}sfixed64(n){let t=new Uint8Array(8),r=new DataView(t.buffer),o=p.enc(n);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(t)}fixed64(n){let t=new Uint8Array(8),r=new DataView(t.buffer),o=p.uEnc(n);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(t)}int64(n){let t=p.enc(n);return W(t.lo,t.hi,this.buf),this}sint64(n){let t=p.enc(n),r=t.hi>>31,o=t.lo<<1^r,i=(t.hi<<1|t.lo>>>31)^r;return W(o,i,this.buf),this}uint64(n){let t=p.uEnc(n);return W(t.lo,t.hi,this.buf),this}},a=class{constructor(n,t=de().decodeUtf8){this.decodeUtf8=t,this.varint64=Ce,this.uint32=xe,this.buf=n,this.len=n.length,this.pos=0,this.view=new DataView(n.buffer,n.byteOffset,n.byteLength)}tag(){let n=this.uint32(),t=n>>>3,r=n&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(n,t){let r=this.pos;switch(n){case A.Varint:for(;this.buf[this.pos++]&128;);break;case A.Bit64:this.pos+=4;case A.Bit32:this.pos+=4;break;case A.LengthDelimited:let o=this.uint32();this.pos+=o;break;case A.StartGroup:for(;;){let[i,c]=this.tag();if(c===A.EndGroup){if(t!==void 0&&i!==t)throw new Error("invalid end group tag");break}this.skip(c,i)}break;default:throw new Error("cant skip wire type "+n)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let n=this.uint32();return n>>>1^-(n&1)}int64(){return p.dec(...this.varint64())}uint64(){return p.uDec(...this.varint64())}sint64(){let[n,t]=this.varint64(),r=-(n&1);return n=(n>>>1|(t&1)<<31)^r,t=t>>>1^r,p.dec(n,t)}bool(){let[n,t]=this.varint64();return n!==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 p.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return p.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 n=this.uint32(),t=this.pos;return this.pos+=n,this.assertBounds(),this.buf.subarray(t,t+n)}string(){return this.decodeUtf8(this.bytes())}};function ce(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>ut||est||e<0)throw new Error("invalid uint32: "+e)}function lt(e){if(typeof e=="string"){let n=e;if(e=Number(e),Number.isNaN(e)&&n!=="NaN")throw new Error("invalid float32: "+n)}else if(typeof e!="number")throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>dt||e>>3){case 1:{if(i!==10)break;o.name=t.string();continue}case 2:{if(i!==18)break;o.value=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function kt(){return{itag:0,lastModified:"0",xtags:""}}var f={encode(e,n=new d){return e.itag!==void 0&&e.itag!==0&&n.uint32(8).int32(e.itag),e.lastModified!==void 0&&e.lastModified!=="0"&&n.uint32(16).uint64(e.lastModified),e.xtags!==void 0&&e.xtags!==""&&n.uint32(26).string(e.xtags),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=kt();for(;t.pos>>3){case 1:{if(i!==8)break;o.itag=t.int32();continue}case 2:{if(i!==16)break;o.lastModified=t.uint64().toString();continue}case 3:{if(i!==26)break;o.xtags=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Tt(){return{legacyStart:0,legacyEnd:0,start:0,end:0}}var x={encode(e,n=new d){return e.legacyStart!==void 0&&e.legacyStart!==0&&n.uint32(8).int32(e.legacyStart),e.legacyEnd!==void 0&&e.legacyEnd!==0&&n.uint32(16).int32(e.legacyEnd),e.start!==void 0&&e.start!==0&&n.uint32(24).int32(e.start),e.end!==void 0&&e.end!==0&&n.uint32(32).int32(e.end),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Tt();for(;t.pos>>3){case 1:{if(i!==8)break;o.legacyStart=t.int32();continue}case 2:{if(i!==16)break;o.legacyEnd=t.int32();continue}case 3:{if(i!==24)break;o.start=t.int32();continue}case 4:{if(i!==32)break;o.end=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function At(){return{requestNumber:0,field5:0}}var yt={encode(e,n=new d){return e.requestNumber!==void 0&&e.requestNumber!==0&&n.uint32(8).int32(e.requestNumber),e.field5!==void 0&&e.field5!==0&&n.uint32(40).int32(e.field5),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=At();for(;t.pos>>3){case 1:{if(i!==8)break;o.requestNumber=t.int32();continue}case 5:{if(i!==40)break;o.field5=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Nt(){return{key:"",value:""}}var Pt={encode(e,n=new d){return e.key!==void 0&&e.key!==""&&n.uint32(10).string(e.key),e.value!==void 0&&e.value!==""&&n.uint32(18).string(e.value),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Nt();for(;t.pos>>3){case 1:{if(i!==10)break;o.key=t.string();continue}case 2:{if(i!==18)break;o.value=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Ct(){return{trackType:0,isHdr:!1}}var se={encode(e,n=new d){return e.trackType!==void 0&&e.trackType!==0&&n.uint32(8).int32(e.trackType),e.isHdr!==void 0&&e.isHdr!==!1&&n.uint32(16).bool(e.isHdr),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Ct();for(;t.pos>>3){case 1:{if(i!==8)break;o.trackType=t.int32();continue}case 2:{if(i!==16)break;o.isHdr=t.bool();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Ot(){return{authorizedFormats:[],sabrLicenseConstraint:new Uint8Array(0)}}var G={encode(e,n=new d){for(let t of e.authorizedFormats)se.encode(t,n.uint32(10).fork()).join();return e.sabrLicenseConstraint!==void 0&&e.sabrLicenseConstraint.length!==0&&n.uint32(18).bytes(e.sabrLicenseConstraint),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Ot();for(;t.pos>>3){case 1:{if(i!==10)break;o.authorizedFormats.push(se.decode(t,t.uint32()));continue}case 2:{if(i!==18)break;o.sabrLicenseConstraint=t.bytes();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Mt(){return{videoId:"",formatId:void 0,endTimeMs:"0",endSegmentNumber:"0",mimeType:"",initRange:void 0,indexRange:void 0,field8:"0",durationUnits:"0",durationTimescale:"0"}}var ue={encode(e,n=new d){return e.videoId!==void 0&&e.videoId!==""&&n.uint32(10).string(e.videoId),e.formatId!==void 0&&f.encode(e.formatId,n.uint32(18).fork()).join(),e.endTimeMs!==void 0&&e.endTimeMs!=="0"&&n.uint32(24).int64(e.endTimeMs),e.endSegmentNumber!==void 0&&e.endSegmentNumber!=="0"&&n.uint32(32).int64(e.endSegmentNumber),e.mimeType!==void 0&&e.mimeType!==""&&n.uint32(42).string(e.mimeType),e.initRange!==void 0&&x.encode(e.initRange,n.uint32(50).fork()).join(),e.indexRange!==void 0&&x.encode(e.indexRange,n.uint32(58).fork()).join(),e.field8!==void 0&&e.field8!=="0"&&n.uint32(64).int64(e.field8),e.durationUnits!==void 0&&e.durationUnits!=="0"&&n.uint32(72).int64(e.durationUnits),e.durationTimescale!==void 0&&e.durationTimescale!=="0"&&n.uint32(80).int64(e.durationTimescale),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Mt();for(;t.pos>>3){case 1:{if(i!==10)break;o.videoId=t.string();continue}case 2:{if(i!==18)break;o.formatId=f.decode(t,t.uint32());continue}case 3:{if(i!==24)break;o.endTimeMs=t.int64().toString();continue}case 4:{if(i!==32)break;o.endSegmentNumber=t.int64().toString();continue}case 5:{if(i!==42)break;o.mimeType=t.string();continue}case 6:{if(i!==50)break;o.initRange=x.decode(t,t.uint32());continue}case 7:{if(i!==58)break;o.indexRange=x.decode(t,t.uint32());continue}case 8:{if(i!==64)break;o.field8=t.int64().toString();continue}case 9:{if(i!==72)break;o.durationUnits=t.int64().toString();continue}case 10:{if(i!==80)break;o.durationTimescale=t.int64().toString();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function xt(){return{startTicks:"0",durationTicks:"0",timescale:0}}var k={encode(e,n=new d){return e.startTicks!==void 0&&e.startTicks!=="0"&&n.uint32(8).int64(e.startTicks),e.durationTicks!==void 0&&e.durationTicks!=="0"&&n.uint32(16).int64(e.durationTicks),e.timescale!==void 0&&e.timescale!==0&&n.uint32(24).int32(e.timescale),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=xt();for(;t.pos>>3){case 1:{if(i!==8)break;o.startTicks=t.int64().toString();continue}case 2:{if(i!==16)break;o.durationTicks=t.int64().toString();continue}case 3:{if(i!==24)break;o.timescale=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Lt(){return{headerId:0,videoId:"",itag:0,lmt:"0",xtags:"",startRange:"0",compressionAlgorithm:0,isInitSeg:!1,sequenceNumber:0,bitrateBps:"0",startMs:"0",durationMs:"0",formatId:void 0,contentLength:"0",timeRange:void 0,sequenceLmt:"0"}}var fe={encode(e,n=new d){return e.headerId!==void 0&&e.headerId!==0&&n.uint32(8).uint32(e.headerId),e.videoId!==void 0&&e.videoId!==""&&n.uint32(18).string(e.videoId),e.itag!==void 0&&e.itag!==0&&n.uint32(24).int32(e.itag),e.lmt!==void 0&&e.lmt!=="0"&&n.uint32(32).uint64(e.lmt),e.xtags!==void 0&&e.xtags!==""&&n.uint32(42).string(e.xtags),e.startRange!==void 0&&e.startRange!=="0"&&n.uint32(48).int64(e.startRange),e.compressionAlgorithm!==void 0&&e.compressionAlgorithm!==0&&n.uint32(56).int32(e.compressionAlgorithm),e.isInitSeg!==void 0&&e.isInitSeg!==!1&&n.uint32(64).bool(e.isInitSeg),e.sequenceNumber!==void 0&&e.sequenceNumber!==0&&n.uint32(72).int32(e.sequenceNumber),e.bitrateBps!==void 0&&e.bitrateBps!=="0"&&n.uint32(80).int64(e.bitrateBps),e.startMs!==void 0&&e.startMs!=="0"&&n.uint32(88).int64(e.startMs),e.durationMs!==void 0&&e.durationMs!=="0"&&n.uint32(96).int64(e.durationMs),e.formatId!==void 0&&f.encode(e.formatId,n.uint32(106).fork()).join(),e.contentLength!==void 0&&e.contentLength!=="0"&&n.uint32(112).int64(e.contentLength),e.timeRange!==void 0&&k.encode(e.timeRange,n.uint32(122).fork()).join(),e.sequenceLmt!==void 0&&e.sequenceLmt!=="0"&&n.uint32(128).uint64(e.sequenceLmt),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Lt();for(;t.pos>>3){case 1:{if(i!==8)break;o.headerId=t.uint32();continue}case 2:{if(i!==18)break;o.videoId=t.string();continue}case 3:{if(i!==24)break;o.itag=t.int32();continue}case 4:{if(i!==32)break;o.lmt=t.uint64().toString();continue}case 5:{if(i!==42)break;o.xtags=t.string();continue}case 6:{if(i!==48)break;o.startRange=t.int64().toString();continue}case 7:{if(i!==56)break;o.compressionAlgorithm=t.int32();continue}case 8:{if(i!==64)break;o.isInitSeg=t.bool();continue}case 9:{if(i!==72)break;o.sequenceNumber=t.int32();continue}case 10:{if(i!==80)break;o.bitrateBps=t.int64().toString();continue}case 11:{if(i!==88)break;o.startMs=t.int64().toString();continue}case 12:{if(i!==96)break;o.durationMs=t.int64().toString();continue}case 13:{if(i!==106)break;o.formatId=f.decode(t,t.uint32());continue}case 14:{if(i!==112)break;o.contentLength=t.int64().toString();continue}case 15:{if(i!==122)break;o.timeRange=k.decode(t,t.uint32());continue}case 16:{if(i!==128)break;o.sequenceLmt=t.uint64().toString();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Bt(){return{formatId:void 0,startTimeMs:"0",durationMs:"0",startSegmentIndex:0,endSegmentIndex:0,timeRange:void 0,field9:void 0,field11:void 0,field12:void 0}}var T={encode(e,n=new d){return e.formatId!==void 0&&f.encode(e.formatId,n.uint32(10).fork()).join(),e.startTimeMs!=="0"&&n.uint32(16).int64(e.startTimeMs),e.durationMs!=="0"&&n.uint32(24).int64(e.durationMs),e.startSegmentIndex!==0&&n.uint32(32).int32(e.startSegmentIndex),e.endSegmentIndex!==0&&n.uint32(40).int32(e.endSegmentIndex),e.timeRange!==void 0&&k.encode(e.timeRange,n.uint32(50).fork()).join(),e.field9!==void 0&&me.encode(e.field9,n.uint32(74).fork()).join(),e.field11!==void 0&&Y.encode(e.field11,n.uint32(90).fork()).join(),e.field12!==void 0&&Y.encode(e.field12,n.uint32(98).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Bt();for(;t.pos>>3){case 1:{if(i!==10)break;o.formatId=f.decode(t,t.uint32());continue}case 2:{if(i!==16)break;o.startTimeMs=t.int64().toString();continue}case 3:{if(i!==24)break;o.durationMs=t.int64().toString();continue}case 4:{if(i!==32)break;o.startSegmentIndex=t.int32();continue}case 5:{if(i!==40)break;o.endSegmentIndex=t.int32();continue}case 6:{if(i!==50)break;o.timeRange=k.decode(t,t.uint32());continue}case 9:{if(i!==74)break;o.field9=me.decode(t,t.uint32());continue}case 11:{if(i!==90)break;o.field11=Y.decode(t,t.uint32());continue}case 12:{if(i!==98)break;o.field12=Y.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Dt(){return{field1:[]}}var me={encode(e,n=new d){for(let t of e.field1)Ue.encode(t,n.uint32(10).fork()).join();return n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Dt();for(;t.pos>>3){case 1:{if(i!==10)break;o.field1.push(Ue.decode(t,t.uint32()));continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function mt(){return{videoId:"",lmt:"0"}}var Ue={encode(e,n=new d){return e.videoId!==void 0&&e.videoId!==""&&n.uint32(10).string(e.videoId),e.lmt!==void 0&&e.lmt!=="0"&&n.uint32(16).uint64(e.lmt),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=mt();for(;t.pos>>3){case 1:{if(i!==10)break;o.videoId=t.string();continue}case 2:{if(i!==16)break;o.lmt=t.uint64().toString();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Ut(){return{field1:0,field2:0,field3:0}}var Y={encode(e,n=new d){return e.field1!==void 0&&e.field1!==0&&n.uint32(8).int32(e.field1),e.field2!==void 0&&e.field2!==0&&n.uint32(16).int32(e.field2),e.field3!==void 0&&e.field3!==0&&n.uint32(24).int32(e.field3),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Ut();for(;t.pos>>3){case 1:{if(i!==8)break;o.field1=t.int32();continue}case 2:{if(i!==16)break;o.field2=t.int32();continue}case 3:{if(i!==24)break;o.field3=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function gt(){return{videoFormatCapabilities:[],audioFormatCapabilities:[],hdrModeBitmask:0}}var q={encode(e,n=new d){for(let t of e.videoFormatCapabilities)ge.encode(t,n.uint32(10).fork()).join();for(let t of e.audioFormatCapabilities)Fe.encode(t,n.uint32(18).fork()).join();return e.hdrModeBitmask!==void 0&&e.hdrModeBitmask!==0&&n.uint32(40).int32(e.hdrModeBitmask),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=gt();for(;t.pos>>3){case 1:{if(i!==10)break;o.videoFormatCapabilities.push(ge.decode(t,t.uint32()));continue}case 2:{if(i!==18)break;o.audioFormatCapabilities.push(Fe.decode(t,t.uint32()));continue}case 5:{if(i!==40)break;o.hdrModeBitmask=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Ft(){return{videoCodec:0,maxHeight:0,maxWidth:0,maxFramerate:0,maxBitrateBps:0,is10BitSupported:!1}}var ge={encode(e,n=new d){return e.videoCodec!==void 0&&e.videoCodec!==0&&n.uint32(8).int32(e.videoCodec),e.maxHeight!==void 0&&e.maxHeight!==0&&n.uint32(24).int32(e.maxHeight),e.maxWidth!==void 0&&e.maxWidth!==0&&n.uint32(32).int32(e.maxWidth),e.maxFramerate!==void 0&&e.maxFramerate!==0&&n.uint32(88).int32(e.maxFramerate),e.maxBitrateBps!==void 0&&e.maxBitrateBps!==0&&n.uint32(96).int32(e.maxBitrateBps),e.is10BitSupported!==void 0&&e.is10BitSupported!==!1&&n.uint32(120).bool(e.is10BitSupported),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Ft();for(;t.pos>>3){case 1:{if(i!==8)break;o.videoCodec=t.int32();continue}case 3:{if(i!==24)break;o.maxHeight=t.int32();continue}case 4:{if(i!==32)break;o.maxWidth=t.int32();continue}case 11:{if(i!==88)break;o.maxFramerate=t.int32();continue}case 12:{if(i!==96)break;o.maxBitrateBps=t.int32();continue}case 15:{if(i!==120)break;o.is10BitSupported=t.bool();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function wt(){return{audioCodec:0,numChannels:0,maxBitrateBps:0,spatialCapabilityBitmask:0}}var Fe={encode(e,n=new d){return e.audioCodec!==void 0&&e.audioCodec!==0&&n.uint32(8).int32(e.audioCodec),e.numChannels!==void 0&&e.numChannels!==0&&n.uint32(16).int32(e.numChannels),e.maxBitrateBps!==void 0&&e.maxBitrateBps!==0&&n.uint32(24).int32(e.maxBitrateBps),e.spatialCapabilityBitmask!==void 0&&e.spatialCapabilityBitmask!==0&&n.uint32(48).int32(e.spatialCapabilityBitmask),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=wt();for(;t.pos>>3){case 1:{if(i!==8)break;o.audioCodec=t.int32();continue}case 2:{if(i!==16)break;o.numChannels=t.int32();continue}case 3:{if(i!==24)break;o.maxBitrateBps=t.int32();continue}case 6:{if(i!==48)break;o.spatialCapabilityBitmask=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function vt(){return{hmac:new Uint8Array(0),iv:new Uint8Array(0),compressionType:0}}var j={encode(e,n=new d){return e.hmac!==void 0&&e.hmac.length!==0&&n.uint32(34).bytes(e.hmac),e.iv!==void 0&&e.iv.length!==0&&n.uint32(42).bytes(e.iv),e.compressionType!==void 0&&e.compressionType!==0&&n.uint32(48).int32(e.compressionType),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=vt();for(;t.pos>>3){case 4:{if(i!==34)break;o.hmac=t.bytes();continue}case 5:{if(i!==42)break;o.iv=t.bytes();continue}case 6:{if(i!==48)break;o.compressionType=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Ht(){return{resolution:0,field2:0,videoFmt:void 0,audioFmt:void 0}}var L={encode(e,n=new d){return e.resolution!==void 0&&e.resolution!==0&&n.uint32(8).int32(e.resolution),e.field2!==void 0&&e.field2!==0&&n.uint32(16).int32(e.field2),e.videoFmt!==void 0&&f.encode(e.videoFmt,n.uint32(58).fork()).join(),e.audioFmt!==void 0&&f.encode(e.audioFmt,n.uint32(66).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Ht();for(;t.pos>>3){case 1:{if(i!==8)break;o.resolution=t.int32();continue}case 2:{if(i!==16)break;o.field2=t.int32();continue}case 7:{if(i!==58)break;o.videoFmt=f.decode(t,t.uint32());continue}case 8:{if(i!==66)break;o.audioFmt=f.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Vt(){return{startMinReadaheadPolicy:void 0,resumeMinReadaheadPolicy:void 0}}var Kt={encode(e,n=new d){return e.startMinReadaheadPolicy!==void 0&&z.encode(e.startMinReadaheadPolicy,n.uint32(10).fork()).join(),e.resumeMinReadaheadPolicy!==void 0&&z.encode(e.resumeMinReadaheadPolicy,n.uint32(18).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Vt();for(;t.pos>>3){case 1:{if(i!==10)break;o.startMinReadaheadPolicy=z.decode(t,t.uint32());continue}case 2:{if(i!==18)break;o.resumeMinReadaheadPolicy=z.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Wt(){return{minReadaheadMs:0,minBandwidthBytesPerSec:0}}var z={encode(e,n=new d){return e.minReadaheadMs!==void 0&&e.minReadaheadMs!==0&&n.uint32(16).int32(e.minReadaheadMs),e.minBandwidthBytesPerSec!==void 0&&e.minBandwidthBytesPerSec!==0&&n.uint32(8).int32(e.minBandwidthBytesPerSec),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Wt();for(;t.pos>>3){case 2:{if(i!==16)break;o.minReadaheadMs=t.int32();continue}case 1:{if(i!==8)break;o.minBandwidthBytesPerSec=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Gt(){return{timeSinceLastManualFormatSelectionMs:"0",lastManualDirection:0,lastManualSelectedResolution:0,detailedNetworkType:0,clientViewportWidth:0,clientViewportHeight:0,clientBitrateCapBytesPerSec:"0",stickyResolution:0,clientViewportIsFlexible:!1,bandwidthEstimate:"0",minAudioQuality:0,maxAudioQuality:0,videoQualitySetting:0,audioRoute:0,playerTimeMs:"0",timeSinceLastSeek:"0",dataSaverMode:!1,networkMeteredState:0,visibility:0,playbackRate:0,elapsedWallTimeMs:"0",mediaCapabilities:void 0,timeSinceLastActionMs:"0",enabledTrackTypesBitfield:0,maxPacingRate:0,playerState:"0",drcEnabled:!1,field48:0,field50:0,field51:0,sabrReportRequestCancellationInfo:0,disableStreamingXhr:!1,field57:"0",preferVp9:!1,av1QualityThreshold:0,field60:0,isPrefetch:!1,sabrSupportQualityConstraints:!1,sabrLicenseConstraint:new Uint8Array(0),allowProximaLiveLatency:0,sabrForceProxima:0,field67:0,sabrForceMaxNetworkInterruptionDurationMs:"0",audioTrackId:"",enableVoiceBoost:!1,playbackAuthorization:void 0}}var N={encode(e,n=new d){return e.timeSinceLastManualFormatSelectionMs!==void 0&&e.timeSinceLastManualFormatSelectionMs!=="0"&&n.uint32(104).int64(e.timeSinceLastManualFormatSelectionMs),e.lastManualDirection!==void 0&&e.lastManualDirection!==0&&n.uint32(112).sint32(e.lastManualDirection),e.lastManualSelectedResolution!==void 0&&e.lastManualSelectedResolution!==0&&n.uint32(128).int32(e.lastManualSelectedResolution),e.detailedNetworkType!==void 0&&e.detailedNetworkType!==0&&n.uint32(136).int32(e.detailedNetworkType),e.clientViewportWidth!==void 0&&e.clientViewportWidth!==0&&n.uint32(144).int32(e.clientViewportWidth),e.clientViewportHeight!==void 0&&e.clientViewportHeight!==0&&n.uint32(152).int32(e.clientViewportHeight),e.clientBitrateCapBytesPerSec!==void 0&&e.clientBitrateCapBytesPerSec!=="0"&&n.uint32(160).int64(e.clientBitrateCapBytesPerSec),e.stickyResolution!==void 0&&e.stickyResolution!==0&&n.uint32(168).int32(e.stickyResolution),e.clientViewportIsFlexible!==void 0&&e.clientViewportIsFlexible!==!1&&n.uint32(176).bool(e.clientViewportIsFlexible),e.bandwidthEstimate!==void 0&&e.bandwidthEstimate!=="0"&&n.uint32(184).int64(e.bandwidthEstimate),e.minAudioQuality!==void 0&&e.minAudioQuality!==0&&n.uint32(192).int32(e.minAudioQuality),e.maxAudioQuality!==void 0&&e.maxAudioQuality!==0&&n.uint32(200).int32(e.maxAudioQuality),e.videoQualitySetting!==void 0&&e.videoQualitySetting!==0&&n.uint32(208).int32(e.videoQualitySetting),e.audioRoute!==void 0&&e.audioRoute!==0&&n.uint32(216).int32(e.audioRoute),e.playerTimeMs!==void 0&&e.playerTimeMs!=="0"&&n.uint32(224).int64(e.playerTimeMs),e.timeSinceLastSeek!==void 0&&e.timeSinceLastSeek!=="0"&&n.uint32(232).int64(e.timeSinceLastSeek),e.dataSaverMode!==void 0&&e.dataSaverMode!==!1&&n.uint32(240).bool(e.dataSaverMode),e.networkMeteredState!==void 0&&e.networkMeteredState!==0&&n.uint32(256).int32(e.networkMeteredState),e.visibility!==void 0&&e.visibility!==0&&n.uint32(272).int32(e.visibility),e.playbackRate!==void 0&&e.playbackRate!==0&&n.uint32(285).float(e.playbackRate),e.elapsedWallTimeMs!==void 0&&e.elapsedWallTimeMs!=="0"&&n.uint32(288).int64(e.elapsedWallTimeMs),e.mediaCapabilities!==void 0&&q.encode(e.mediaCapabilities,n.uint32(306).fork()).join(),e.timeSinceLastActionMs!==void 0&&e.timeSinceLastActionMs!=="0"&&n.uint32(312).int64(e.timeSinceLastActionMs),e.enabledTrackTypesBitfield!==void 0&&e.enabledTrackTypesBitfield!==0&&n.uint32(320).int32(e.enabledTrackTypesBitfield),e.maxPacingRate!==void 0&&e.maxPacingRate!==0&&n.uint32(344).int32(e.maxPacingRate),e.playerState!==void 0&&e.playerState!=="0"&&n.uint32(352).int64(e.playerState),e.drcEnabled!==void 0&&e.drcEnabled!==!1&&n.uint32(368).bool(e.drcEnabled),e.field48!==void 0&&e.field48!==0&&n.uint32(384).int32(e.field48),e.field50!==void 0&&e.field50!==0&&n.uint32(400).int32(e.field50),e.field51!==void 0&&e.field51!==0&&n.uint32(408).int32(e.field51),e.sabrReportRequestCancellationInfo!==void 0&&e.sabrReportRequestCancellationInfo!==0&&n.uint32(432).int32(e.sabrReportRequestCancellationInfo),e.disableStreamingXhr!==void 0&&e.disableStreamingXhr!==!1&&n.uint32(448).bool(e.disableStreamingXhr),e.field57!==void 0&&e.field57!=="0"&&n.uint32(456).int64(e.field57),e.preferVp9!==void 0&&e.preferVp9!==!1&&n.uint32(464).bool(e.preferVp9),e.av1QualityThreshold!==void 0&&e.av1QualityThreshold!==0&&n.uint32(472).int32(e.av1QualityThreshold),e.field60!==void 0&&e.field60!==0&&n.uint32(480).int32(e.field60),e.isPrefetch!==void 0&&e.isPrefetch!==!1&&n.uint32(488).bool(e.isPrefetch),e.sabrSupportQualityConstraints!==void 0&&e.sabrSupportQualityConstraints!==!1&&n.uint32(496).bool(e.sabrSupportQualityConstraints),e.sabrLicenseConstraint!==void 0&&e.sabrLicenseConstraint.length!==0&&n.uint32(506).bytes(e.sabrLicenseConstraint),e.allowProximaLiveLatency!==void 0&&e.allowProximaLiveLatency!==0&&n.uint32(512).int32(e.allowProximaLiveLatency),e.sabrForceProxima!==void 0&&e.sabrForceProxima!==0&&n.uint32(528).int32(e.sabrForceProxima),e.field67!==void 0&&e.field67!==0&&n.uint32(536).int32(e.field67),e.sabrForceMaxNetworkInterruptionDurationMs!==void 0&&e.sabrForceMaxNetworkInterruptionDurationMs!=="0"&&n.uint32(544).int64(e.sabrForceMaxNetworkInterruptionDurationMs),e.audioTrackId!==void 0&&e.audioTrackId!==""&&n.uint32(554).string(e.audioTrackId),e.enableVoiceBoost!==void 0&&e.enableVoiceBoost!==!1&&n.uint32(608).bool(e.enableVoiceBoost),e.playbackAuthorization!==void 0&&G.encode(e.playbackAuthorization,n.uint32(634).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Gt();for(;t.pos>>3){case 13:{if(i!==104)break;o.timeSinceLastManualFormatSelectionMs=t.int64().toString();continue}case 14:{if(i!==112)break;o.lastManualDirection=t.sint32();continue}case 16:{if(i!==128)break;o.lastManualSelectedResolution=t.int32();continue}case 17:{if(i!==136)break;o.detailedNetworkType=t.int32();continue}case 18:{if(i!==144)break;o.clientViewportWidth=t.int32();continue}case 19:{if(i!==152)break;o.clientViewportHeight=t.int32();continue}case 20:{if(i!==160)break;o.clientBitrateCapBytesPerSec=t.int64().toString();continue}case 21:{if(i!==168)break;o.stickyResolution=t.int32();continue}case 22:{if(i!==176)break;o.clientViewportIsFlexible=t.bool();continue}case 23:{if(i!==184)break;o.bandwidthEstimate=t.int64().toString();continue}case 24:{if(i!==192)break;o.minAudioQuality=t.int32();continue}case 25:{if(i!==200)break;o.maxAudioQuality=t.int32();continue}case 26:{if(i!==208)break;o.videoQualitySetting=t.int32();continue}case 27:{if(i!==216)break;o.audioRoute=t.int32();continue}case 28:{if(i!==224)break;o.playerTimeMs=t.int64().toString();continue}case 29:{if(i!==232)break;o.timeSinceLastSeek=t.int64().toString();continue}case 30:{if(i!==240)break;o.dataSaverMode=t.bool();continue}case 32:{if(i!==256)break;o.networkMeteredState=t.int32();continue}case 34:{if(i!==272)break;o.visibility=t.int32();continue}case 35:{if(i!==285)break;o.playbackRate=t.float();continue}case 36:{if(i!==288)break;o.elapsedWallTimeMs=t.int64().toString();continue}case 38:{if(i!==306)break;o.mediaCapabilities=q.decode(t,t.uint32());continue}case 39:{if(i!==312)break;o.timeSinceLastActionMs=t.int64().toString();continue}case 40:{if(i!==320)break;o.enabledTrackTypesBitfield=t.int32();continue}case 43:{if(i!==344)break;o.maxPacingRate=t.int32();continue}case 44:{if(i!==352)break;o.playerState=t.int64().toString();continue}case 46:{if(i!==368)break;o.drcEnabled=t.bool();continue}case 48:{if(i!==384)break;o.field48=t.int32();continue}case 50:{if(i!==400)break;o.field50=t.int32();continue}case 51:{if(i!==408)break;o.field51=t.int32();continue}case 54:{if(i!==432)break;o.sabrReportRequestCancellationInfo=t.int32();continue}case 56:{if(i!==448)break;o.disableStreamingXhr=t.bool();continue}case 57:{if(i!==456)break;o.field57=t.int64().toString();continue}case 58:{if(i!==464)break;o.preferVp9=t.bool();continue}case 59:{if(i!==472)break;o.av1QualityThreshold=t.int32();continue}case 60:{if(i!==480)break;o.field60=t.int32();continue}case 61:{if(i!==488)break;o.isPrefetch=t.bool();continue}case 62:{if(i!==496)break;o.sabrSupportQualityConstraints=t.bool();continue}case 63:{if(i!==506)break;o.sabrLicenseConstraint=t.bytes();continue}case 64:{if(i!==512)break;o.allowProximaLiveLatency=t.int32();continue}case 66:{if(i!==528)break;o.sabrForceProxima=t.int32();continue}case 67:{if(i!==536)break;o.field67=t.int32();continue}case 68:{if(i!==544)break;o.sabrForceMaxNetworkInterruptionDurationMs=t.int64().toString();continue}case 69:{if(i!==554)break;o.audioTrackId=t.string();continue}case 76:{if(i!==608)break;o.enableVoiceBoost=t.bool();continue}case 79:{if(i!==634)break;o.playbackAuthorization=G.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Yt(){return{clientInfo:void 0,poToken:new Uint8Array(0),playbackCookie:new Uint8Array(0),field4:new Uint8Array(0),sabrContexts:[],unsentSabrContexts:[],field7:"",field8:void 0}}var P={encode(e,n=new d){e.clientInfo!==void 0&&le.encode(e.clientInfo,n.uint32(10).fork()).join(),e.poToken!==void 0&&e.poToken.length!==0&&n.uint32(18).bytes(e.poToken),e.playbackCookie!==void 0&&e.playbackCookie.length!==0&&n.uint32(26).bytes(e.playbackCookie),e.field4!==void 0&&e.field4.length!==0&&n.uint32(34).bytes(e.field4);for(let t of e.sabrContexts)ve.encode(t,n.uint32(42).fork()).join();n.uint32(50).fork();for(let t of e.unsentSabrContexts)n.int32(t);return n.join(),e.field7!==void 0&&e.field7!==""&&n.uint32(58).string(e.field7),e.field8!==void 0&&He.encode(e.field8,n.uint32(66).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Yt();for(;t.pos>>3){case 1:{if(i!==10)break;o.clientInfo=le.decode(t,t.uint32());continue}case 2:{if(i!==18)break;o.poToken=t.bytes();continue}case 3:{if(i!==26)break;o.playbackCookie=t.bytes();continue}case 4:{if(i!==34)break;o.field4=t.bytes();continue}case 5:{if(i!==42)break;o.sabrContexts.push(ve.decode(t,t.uint32()));continue}case 6:{if(i===48){o.unsentSabrContexts.push(t.int32());continue}if(i===50){let c=t.uint32()+t.pos;for(;t.pos>>3){case 12:{if(i!==98)break;o.deviceMake=t.string();continue}case 13:{if(i!==106)break;o.deviceModel=t.string();continue}case 16:{if(i!==128)break;o.clientName=t.int32();continue}case 17:{if(i!==138)break;o.clientVersion=t.string();continue}case 18:{if(i!==146)break;o.osName=t.string();continue}case 19:{if(i!==154)break;o.osVersion=t.string();continue}case 21:{if(i!==170)break;o.acceptLanguage=t.string();continue}case 22:{if(i!==178)break;o.acceptRegion=t.string();continue}case 37:{if(i!==296)break;o.screenWidthPoints=t.int32();continue}case 38:{if(i!==304)break;o.screenHeightPoints=t.int32();continue}case 39:{if(i!==317)break;o.screenWidthInches=t.float();continue}case 40:{if(i!==325)break;o.screenHeightInches=t.float();continue}case 41:{if(i!==328)break;o.screenPixelDensity=t.int32();continue}case 46:{if(i!==368)break;o.clientFormFactor=t.int32();continue}case 50:{if(i!==400)break;o.gmscoreVersionCode=t.int32();continue}case 55:{if(i!==440)break;o.windowWidthPoints=t.int32();continue}case 56:{if(i!==448)break;o.windowHeightPoints=t.int32();continue}case 64:{if(i!==512)break;o.androidSdkVersion=t.int32();continue}case 65:{if(i!==525)break;o.screenDensityFloat=t.float();continue}case 67:{if(i!==536)break;o.utcOffsetMinutes=t.int64().toString();continue}case 80:{if(i!==642)break;o.timeZone=t.string();continue}case 92:{if(i!==738)break;o.chipset=t.string();continue}case 102:{if(i!==818)break;o.glDeviceInfo=we.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function jt(){return{glRenderer:"",glEsVersionMajor:0,glEsVersionMinor:0}}var we={encode(e,n=new d){return e.glRenderer!==void 0&&e.glRenderer!==""&&n.uint32(10).string(e.glRenderer),e.glEsVersionMajor!==void 0&&e.glEsVersionMajor!==0&&n.uint32(16).int32(e.glEsVersionMajor),e.glEsVersionMinor!==void 0&&e.glEsVersionMinor!==0&&n.uint32(24).int32(e.glEsVersionMinor),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=jt();for(;t.pos>>3){case 1:{if(i!==10)break;o.glRenderer=t.string();continue}case 2:{if(i!==16)break;o.glEsVersionMajor=t.int32();continue}case 3:{if(i!==24)break;o.glEsVersionMinor=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function zt(){return{type:0,value:new Uint8Array(0)}}var ve={encode(e,n=new d){return e.type!==void 0&&e.type!==0&&n.uint32(8).int32(e.type),e.value!==void 0&&e.value.length!==0&&n.uint32(18).bytes(e.value),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=zt();for(;t.pos>>3){case 1:{if(i!==8)break;o.type=t.int32();continue}case 2:{if(i!==18)break;o.value=t.bytes();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Xt(){return{field1:new Uint8Array(0),field2:void 0}}var He={encode(e,n=new d){return e.field1!==void 0&&e.field1.length!==0&&n.uint32(10).bytes(e.field1),e.field2!==void 0&&Ve.encode(e.field2,n.uint32(18).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Xt();for(;t.pos>>3){case 1:{if(i!==10)break;o.field1=t.bytes();continue}case 2:{if(i!==18)break;o.field2=Ve.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Qt(){return{code:0,message:""}}var Ve={encode(e,n=new d){return e.code!==void 0&&e.code!==0&&n.uint32(8).int32(e.code),e.message!==void 0&&e.message!==""&&n.uint32(18).string(e.message),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Qt();for(;t.pos>>3){case 1:{if(i!==8)break;o.code=t.int32();continue}case 2:{if(i!==18)break;o.message=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function $t(){return{clientAbrState:void 0,selectedFormatIds:[],bufferedRanges:[],playerTimeMs:"0",videoPlaybackUstreamerConfig:new Uint8Array(0),field6:void 0,preferredAudioFormatIds:[],preferredVideoFormatIds:[],preferredSubtitleFormatIds:[],streamerContext:void 0,field21:void 0,field22:0,field23:0,field1000:[]}}var he={encode(e,n=new d){e.clientAbrState!==void 0&&N.encode(e.clientAbrState,n.uint32(10).fork()).join();for(let t of e.selectedFormatIds)f.encode(t,n.uint32(18).fork()).join();for(let t of e.bufferedRanges)T.encode(t,n.uint32(26).fork()).join();e.playerTimeMs!==void 0&&e.playerTimeMs!=="0"&&n.uint32(32).int64(e.playerTimeMs),e.videoPlaybackUstreamerConfig!==void 0&&e.videoPlaybackUstreamerConfig.length!==0&&n.uint32(42).bytes(e.videoPlaybackUstreamerConfig),e.field6!==void 0&&Ke.encode(e.field6,n.uint32(50).fork()).join();for(let t of e.preferredAudioFormatIds)f.encode(t,n.uint32(130).fork()).join();for(let t of e.preferredVideoFormatIds)f.encode(t,n.uint32(138).fork()).join();for(let t of e.preferredSubtitleFormatIds)f.encode(t,n.uint32(146).fork()).join();e.streamerContext!==void 0&&P.encode(e.streamerContext,n.uint32(154).fork()).join(),e.field21!==void 0&&We.encode(e.field21,n.uint32(170).fork()).join(),e.field22!==void 0&&e.field22!==0&&n.uint32(176).int32(e.field22),e.field23!==void 0&&e.field23!==0&&n.uint32(184).int32(e.field23);for(let t of e.field1000)Ge.encode(t,n.uint32(8002).fork()).join();return n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=$t();for(;t.pos>>3){case 1:{if(i!==10)break;o.clientAbrState=N.decode(t,t.uint32());continue}case 2:{if(i!==18)break;o.selectedFormatIds.push(f.decode(t,t.uint32()));continue}case 3:{if(i!==26)break;o.bufferedRanges.push(T.decode(t,t.uint32()));continue}case 4:{if(i!==32)break;o.playerTimeMs=t.int64().toString();continue}case 5:{if(i!==42)break;o.videoPlaybackUstreamerConfig=t.bytes();continue}case 6:{if(i!==50)break;o.field6=Ke.decode(t,t.uint32());continue}case 16:{if(i!==130)break;o.preferredAudioFormatIds.push(f.decode(t,t.uint32()));continue}case 17:{if(i!==138)break;o.preferredVideoFormatIds.push(f.decode(t,t.uint32()));continue}case 18:{if(i!==146)break;o.preferredSubtitleFormatIds.push(f.decode(t,t.uint32()));continue}case 19:{if(i!==154)break;o.streamerContext=P.decode(t,t.uint32());continue}case 21:{if(i!==170)break;o.field21=We.decode(t,t.uint32());continue}case 22:{if(i!==176)break;o.field22=t.int32();continue}case 23:{if(i!==184)break;o.field23=t.int32();continue}case 1e3:{if(i!==8002)break;o.field1000.push(Ge.decode(t,t.uint32()));continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Zt(){return{formatId:void 0,lmt:"0",sequenceNumber:0,timeRange:void 0,field5:0}}var Ke={encode(e,n=new d){return e.formatId!==void 0&&f.encode(e.formatId,n.uint32(10).fork()).join(),e.lmt!==void 0&&e.lmt!=="0"&&n.uint32(16).sint64(e.lmt),e.sequenceNumber!==void 0&&e.sequenceNumber!==0&&n.uint32(24).int32(e.sequenceNumber),e.timeRange!==void 0&&k.encode(e.timeRange,n.uint32(34).fork()).join(),e.field5!==void 0&&e.field5!==0&&n.uint32(40).int32(e.field5),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Zt();for(;t.pos>>3){case 1:{if(i!==10)break;o.formatId=f.decode(t,t.uint32());continue}case 2:{if(i!==16)break;o.lmt=t.sint64().toString();continue}case 3:{if(i!==24)break;o.sequenceNumber=t.int32();continue}case 4:{if(i!==34)break;o.timeRange=k.decode(t,t.uint32());continue}case 5:{if(i!==40)break;o.field5=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Jt(){return{field1:[],field2:new Uint8Array(0),field3:"",field4:0,field5:0,field6:""}}var We={encode(e,n=new d){for(let t of e.field1)n.uint32(10).string(t);return e.field2!==void 0&&e.field2.length!==0&&n.uint32(18).bytes(e.field2),e.field3!==void 0&&e.field3!==""&&n.uint32(26).string(e.field3),e.field4!==void 0&&e.field4!==0&&n.uint32(32).int32(e.field4),e.field5!==void 0&&e.field5!==0&&n.uint32(40).int32(e.field5),e.field6!==void 0&&e.field6!==""&&n.uint32(50).string(e.field6),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Jt();for(;t.pos>>3){case 1:{if(i!==10)break;o.field1.push(t.string());continue}case 2:{if(i!==18)break;o.field2=t.bytes();continue}case 3:{if(i!==26)break;o.field3=t.string();continue}case 4:{if(i!==32)break;o.field4=t.int32();continue}case 5:{if(i!==40)break;o.field5=t.int32();continue}case 6:{if(i!==50)break;o.field6=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function en(){return{formatIds:[],ud:[],clipId:""}}var Ge={encode(e,n=new d){for(let t of e.formatIds)f.encode(t,n.uint32(10).fork()).join();for(let t of e.ud)T.encode(t,n.uint32(18).fork()).join();return e.clipId!==void 0&&e.clipId!==""&&n.uint32(26).string(e.clipId),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=en();for(;t.pos>>3){case 1:{if(i!==10)break;o.formatIds.push(f.decode(t,t.uint32()));continue}case 2:{if(i!==18)break;o.ud.push(T.decode(t,t.uint32()));continue}case 3:{if(i!==26)break;o.clipId=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function tn(){return{targetAudioReadaheadMs:0,targetVideoReadaheadMs:0,maxTimeSinceLastRequestMs:0,backoffTimeMs:0,minAudioReadaheadMs:0,minVideoReadaheadMs:0,playbackCookie:void 0,videoId:""}}var Ee={encode(e,n=new d){return e.targetAudioReadaheadMs!==void 0&&e.targetAudioReadaheadMs!==0&&n.uint32(8).int32(e.targetAudioReadaheadMs),e.targetVideoReadaheadMs!==void 0&&e.targetVideoReadaheadMs!==0&&n.uint32(16).int32(e.targetVideoReadaheadMs),e.maxTimeSinceLastRequestMs!==void 0&&e.maxTimeSinceLastRequestMs!==0&&n.uint32(24).int32(e.maxTimeSinceLastRequestMs),e.backoffTimeMs!==void 0&&e.backoffTimeMs!==0&&n.uint32(32).int32(e.backoffTimeMs),e.minAudioReadaheadMs!==void 0&&e.minAudioReadaheadMs!==0&&n.uint32(40).int32(e.minAudioReadaheadMs),e.minVideoReadaheadMs!==void 0&&e.minVideoReadaheadMs!==0&&n.uint32(48).int32(e.minVideoReadaheadMs),e.playbackCookie!==void 0&&L.encode(e.playbackCookie,n.uint32(58).fork()).join(),e.videoId!==void 0&&e.videoId!==""&&n.uint32(66).string(e.videoId),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=tn();for(;t.pos>>3){case 1:{if(i!==8)break;o.targetAudioReadaheadMs=t.int32();continue}case 2:{if(i!==16)break;o.targetVideoReadaheadMs=t.int32();continue}case 3:{if(i!==24)break;o.maxTimeSinceLastRequestMs=t.int32();continue}case 4:{if(i!==32)break;o.backoffTimeMs=t.int32();continue}case 5:{if(i!==40)break;o.minAudioReadaheadMs=t.int32();continue}case 6:{if(i!==48)break;o.minVideoReadaheadMs=t.int32();continue}case 7:{if(i!==58)break;o.playbackCookie=L.decode(t,t.uint32());continue}case 8:{if(i!==66)break;o.videoId=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function nn(){return{N0:0,items:[],jq:0}}var on={encode(e,n=new d){e.N0!==void 0&&e.N0!==0&&n.uint32(8).int32(e.N0);for(let t of e.items)Ye.encode(t,n.uint32(18).fork()).join();return e.jq!==void 0&&e.jq!==0&&n.uint32(24).int32(e.jq),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=nn();for(;t.pos>>3){case 1:{if(i!==8)break;o.N0=t.int32();continue}case 2:{if(i!==18)break;o.items.push(Ye.decode(t,t.uint32()));continue}case 3:{if(i!==24)break;o.jq=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function rn(){return{fR:0,NK:0,minReadaheadMs:0}}var Ye={encode(e,n=new d){return e.fR!==void 0&&e.fR!==0&&n.uint32(8).int32(e.fR),e.NK!==void 0&&e.NK!==0&&n.uint32(16).int32(e.NK),e.minReadaheadMs!==void 0&&e.minReadaheadMs!==0&&n.uint32(24).int32(e.minReadaheadMs),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=rn();for(;t.pos>>3){case 1:{if(i!==8)break;o.fR=t.int32();continue}case 2:{if(i!==16)break;o.NK=t.int32();continue}case 3:{if(i!==24)break;o.minReadaheadMs=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function an(){return{token:""}}var dn={encode(e,n=new d){return e.token!==void 0&&e.token!==""&&n.uint32(10).string(e.token),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=an();for(;t.pos>>3){case 1:{if(i!==10)break;o.token=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function cn(){return{type:"",code:0}}var pe={encode(e,n=new d){return e.type!==void 0&&e.type!==""&&n.uint32(10).string(e.type),e.code!==void 0&&e.code!==0&&n.uint32(16).int32(e.code),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=cn();for(;t.pos>>3){case 1:{if(i!==10)break;o.type=t.string();continue}case 2:{if(i!==16)break;o.code=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function sn(){return{url:""}}var be={encode(e,n=new d){return e.url!==void 0&&e.url!==""&&n.uint32(10).string(e.url),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=sn();for(;t.pos>>3){case 1:{if(i!==10)break;o.url=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function un(){return{context:new Uint8Array(0),encryptedOnesieInnertubeRequest:new Uint8Array(0),encryptedClientKey:new Uint8Array(0),iv:new Uint8Array(0),hmac:new Uint8Array(0),reverseProxyConfig:"",serializeResponseAsJson:!1,enableAdPlacementsPreroll:!1,enableCompression:!1,ustreamerFlags:void 0,unencryptedOnesieInnertubeRequest:new Uint8Array(0),useJsonformatterToParsePlayerResponse:!1}}var X={encode(e,n=new d){return e.context!==void 0&&e.context.length!==0&&n.uint32(10).bytes(e.context),e.encryptedOnesieInnertubeRequest!==void 0&&e.encryptedOnesieInnertubeRequest.length!==0&&n.uint32(18).bytes(e.encryptedOnesieInnertubeRequest),e.encryptedClientKey!==void 0&&e.encryptedClientKey.length!==0&&n.uint32(42).bytes(e.encryptedClientKey),e.iv!==void 0&&e.iv.length!==0&&n.uint32(50).bytes(e.iv),e.hmac!==void 0&&e.hmac.length!==0&&n.uint32(58).bytes(e.hmac),e.reverseProxyConfig!==void 0&&e.reverseProxyConfig!==""&&n.uint32(74).string(e.reverseProxyConfig),e.serializeResponseAsJson!==void 0&&e.serializeResponseAsJson!==!1&&n.uint32(80).bool(e.serializeResponseAsJson),e.enableAdPlacementsPreroll!==void 0&&e.enableAdPlacementsPreroll!==!1&&n.uint32(104).bool(e.enableAdPlacementsPreroll),e.enableCompression!==void 0&&e.enableCompression!==!1&&n.uint32(112).bool(e.enableCompression),e.ustreamerFlags!==void 0&&_e.encode(e.ustreamerFlags,n.uint32(122).fork()).join(),e.unencryptedOnesieInnertubeRequest!==void 0&&e.unencryptedOnesieInnertubeRequest.length!==0&&n.uint32(130).bytes(e.unencryptedOnesieInnertubeRequest),e.useJsonformatterToParsePlayerResponse!==void 0&&e.useJsonformatterToParsePlayerResponse!==!1&&n.uint32(136).bool(e.useJsonformatterToParsePlayerResponse),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=un();for(;t.pos>>3){case 1:{if(i!==10)break;o.context=t.bytes();continue}case 2:{if(i!==18)break;o.encryptedOnesieInnertubeRequest=t.bytes();continue}case 5:{if(i!==42)break;o.encryptedClientKey=t.bytes();continue}case 6:{if(i!==50)break;o.iv=t.bytes();continue}case 7:{if(i!==58)break;o.hmac=t.bytes();continue}case 9:{if(i!==74)break;o.reverseProxyConfig=t.string();continue}case 10:{if(i!==80)break;o.serializeResponseAsJson=t.bool();continue}case 13:{if(i!==104)break;o.enableAdPlacementsPreroll=t.bool();continue}case 14:{if(i!==112)break;o.enableCompression=t.bool();continue}case 15:{if(i!==122)break;o.ustreamerFlags=_e.decode(t,t.uint32());continue}case 16:{if(i!==130)break;o.unencryptedOnesieInnertubeRequest=t.bytes();continue}case 17:{if(i!==136)break;o.useJsonformatterToParsePlayerResponse=t.bool();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function fn(){return{sendVideoPlaybackConfig:!1}}var _e={encode(e,n=new d){return e.sendVideoPlaybackConfig!==void 0&&e.sendVideoPlaybackConfig!==!1&&n.uint32(16).bool(e.sendVideoPlaybackConfig),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=fn();for(;t.pos>>3){case 2:{if(i!==16)break;o.sendVideoPlaybackConfig=t.bool();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function ln(){return{token:""}}var B={encode(e,n=new d){return e.token!==void 0&&e.token!==""&&n.uint32(10).string(e.token),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=ln();for(;t.pos>>3){case 1:{if(i!==10)break;o.token=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function hn(){return{reloadPlaybackParams:void 0}}var Re={encode(e,n=new d){return e.reloadPlaybackParams!==void 0&&B.encode(e.reloadPlaybackParams,n.uint32(10).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=hn();for(;t.pos>>3){case 1:{if(i!==10)break;o.reloadPlaybackParams=B.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function En(){return{urls:[],clientAbrState:void 0,innertubeRequest:void 0,onesieUstreamerConfig:new Uint8Array(0),maxVp9Height:0,clientDisplayHeight:0,streamerContext:void 0,requestTarget:0,bufferedRanges:[],reloadPlaybackParams:void 0}}var pn={encode(e,n=new d){for(let t of e.urls)n.uint32(10).string(t);e.clientAbrState!==void 0&&N.encode(e.clientAbrState,n.uint32(18).fork()).join(),e.innertubeRequest!==void 0&&X.encode(e.innertubeRequest,n.uint32(26).fork()).join(),e.onesieUstreamerConfig!==void 0&&e.onesieUstreamerConfig.length!==0&&n.uint32(34).bytes(e.onesieUstreamerConfig),e.maxVp9Height!==void 0&&e.maxVp9Height!==0&&n.uint32(40).int32(e.maxVp9Height),e.clientDisplayHeight!==void 0&&e.clientDisplayHeight!==0&&n.uint32(48).int32(e.clientDisplayHeight),e.streamerContext!==void 0&&P.encode(e.streamerContext,n.uint32(82).fork()).join(),e.requestTarget!==void 0&&e.requestTarget!==0&&n.uint32(104).int32(e.requestTarget);for(let t of e.bufferedRanges)T.encode(t,n.uint32(114).fork()).join();return e.reloadPlaybackParams!==void 0&&B.encode(e.reloadPlaybackParams,n.uint32(122).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=En();for(;t.pos>>3){case 1:{if(i!==10)break;o.urls.push(t.string());continue}case 2:{if(i!==18)break;o.clientAbrState=N.decode(t,t.uint32());continue}case 3:{if(i!==26)break;o.innertubeRequest=X.decode(t,t.uint32());continue}case 4:{if(i!==34)break;o.onesieUstreamerConfig=t.bytes();continue}case 5:{if(i!==40)break;o.maxVp9Height=t.int32();continue}case 6:{if(i!==48)break;o.clientDisplayHeight=t.int32();continue}case 10:{if(i!==82)break;o.streamerContext=P.decode(t,t.uint32());continue}case 13:{if(i!==104)break;o.requestTarget=t.int32();continue}case 14:{if(i!==114)break;o.bufferedRanges.push(T.decode(t,t.uint32()));continue}case 15:{if(i!==122)break;o.reloadPlaybackParams=B.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function bn(){return{type:0,videoId:"",itag:"",cryptoParams:void 0,lastModified:"0",expectedMediaSizeBytes:"0",restrictedFormats:[],xtags:"",sequenceNumber:"0",field23:void 0,field34:void 0}}var _n={encode(e,n=new d){e.type!==void 0&&e.type!==0&&n.uint32(8).int32(e.type),e.videoId!==void 0&&e.videoId!==""&&n.uint32(18).string(e.videoId),e.itag!==void 0&&e.itag!==""&&n.uint32(26).string(e.itag),e.cryptoParams!==void 0&&j.encode(e.cryptoParams,n.uint32(34).fork()).join(),e.lastModified!==void 0&&e.lastModified!=="0"&&n.uint32(40).uint64(e.lastModified),e.expectedMediaSizeBytes!==void 0&&e.expectedMediaSizeBytes!=="0"&&n.uint32(56).int64(e.expectedMediaSizeBytes);for(let t of e.restrictedFormats)n.uint32(90).string(t);return e.xtags!==void 0&&e.xtags!==""&&n.uint32(122).string(e.xtags),e.sequenceNumber!==void 0&&e.sequenceNumber!=="0"&&n.uint32(144).int64(e.sequenceNumber),e.field23!==void 0&&qe.encode(e.field23,n.uint32(186).fork()).join(),e.field34!==void 0&&je.encode(e.field34,n.uint32(274).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=bn();for(;t.pos>>3){case 1:{if(i!==8)break;o.type=t.int32();continue}case 2:{if(i!==18)break;o.videoId=t.string();continue}case 3:{if(i!==26)break;o.itag=t.string();continue}case 4:{if(i!==34)break;o.cryptoParams=j.decode(t,t.uint32());continue}case 5:{if(i!==40)break;o.lastModified=t.uint64().toString();continue}case 7:{if(i!==56)break;o.expectedMediaSizeBytes=t.int64().toString();continue}case 11:{if(i!==90)break;o.restrictedFormats.push(t.string());continue}case 15:{if(i!==122)break;o.xtags=t.string();continue}case 18:{if(i!==144)break;o.sequenceNumber=t.int64().toString();continue}case 23:{if(i!==186)break;o.field23=qe.decode(t,t.uint32());continue}case 34:{if(i!==274)break;o.field34=je.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Rn(){return{videoId:""}}var qe={encode(e,n=new d){return e.videoId!==void 0&&e.videoId!==""&&n.uint32(18).string(e.videoId),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Rn();for(;t.pos>>3){case 2:{if(i!==18)break;o.videoId=t.string();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Sn(){return{itagDenylist:[]}}var je={encode(e,n=new d){for(let t of e.itagDenylist)n.uint32(10).string(t);return n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Sn();for(;t.pos>>3){case 1:{if(i!==10)break;o.itagDenylist.push(t.string());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};var In={ONESIE_PLAYER_RESPONSE:0,0:"ONESIE_PLAYER_RESPONSE",MEDIA:1,1:"MEDIA",MEDIA_DECRYPTION_KEY:2,2:"MEDIA_DECRYPTION_KEY",CLEAR_MEDIA:3,3:"CLEAR_MEDIA",CLEAR_INIT_SEGMENT:4,4:"CLEAR_INIT_SEGMENT",ACK:5,5:"ACK",MEDIA_STREAMER_HOSTNAME:6,6:"MEDIA_STREAMER_HOSTNAME",MEDIA_SIZE_HINT:7,7:"MEDIA_SIZE_HINT",PLAYER_SERVICE_RESPONSE_PUSH_URL:8,8:"PLAYER_SERVICE_RESPONSE_PUSH_URL",LAST_HIGH_PRIORITY_HINT:9,9:"LAST_HIGH_PRIORITY_HINT",STREAM_METADATA:16,16:"STREAM_METADATA",ENCRYPTED_INNERTUBE_RESPONSE_PART:25,25:"ENCRYPTED_INNERTUBE_RESPONSE_PART",UNRECOGNIZED:-1,"-1":"UNRECOGNIZED"};function kn(){return{url:"",headers:[],body:"",proxiedByTrustedBandaid:!1,skipResponseEncryption:!1}}var Tn={encode(e,n=new d){e.url!==void 0&&e.url!==""&&n.uint32(10).string(e.url);for(let t of e.headers)y.encode(t,n.uint32(18).fork()).join();return e.body!==void 0&&e.body!==""&&n.uint32(26).string(e.body),e.proxiedByTrustedBandaid!==void 0&&e.proxiedByTrustedBandaid!==!1&&n.uint32(32).bool(e.proxiedByTrustedBandaid),e.skipResponseEncryption!==void 0&&e.skipResponseEncryption!==!1&&n.uint32(48).bool(e.skipResponseEncryption),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=kn();for(;t.pos>>3){case 1:{if(i!==10)break;o.url=t.string();continue}case 2:{if(i!==18)break;o.headers.push(y.decode(t,t.uint32()));continue}case 3:{if(i!==26)break;o.body=t.string();continue}case 4:{if(i!==32)break;o.proxiedByTrustedBandaid=t.bool();continue}case 6:{if(i!==48)break;o.skipResponseEncryption=t.bool();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function An(){return{onesieProxyStatus:0,httpStatus:0,headers:[],body:new Uint8Array(0)}}var yn={encode(e,n=new d){e.onesieProxyStatus!==void 0&&e.onesieProxyStatus!==0&&n.uint32(8).int32(e.onesieProxyStatus),e.httpStatus!==void 0&&e.httpStatus!==0&&n.uint32(16).int32(e.httpStatus);for(let t of e.headers)y.encode(t,n.uint32(26).fork()).join();return e.body!==void 0&&e.body.length!==0&&n.uint32(34).bytes(e.body),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=An();for(;t.pos>>3){case 1:{if(i!==8)break;o.onesieProxyStatus=t.int32();continue}case 2:{if(i!==16)break;o.httpStatus=t.int32();continue}case 3:{if(i!==26)break;o.headers.push(y.decode(t,t.uint32()));continue}case 4:{if(i!==34)break;o.body=t.bytes();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};var Nn={UNKNOWN:0,0:"UNKNOWN",OK:1,1:"OK",DECRYPTION_FAILED:2,2:"DECRYPTION_FAILED",PARSING_FAILED:3,3:"PARSING_FAILED",MISSING_X_FORWARDED_FOR:4,4:"MISSING_X_FORWARDED_FOR",INVALID_X_FORWARDED_FOR:5,5:"INVALID_X_FORWARDED_FOR",INVALID_CONTENT_TYPE:6,6:"INVALID_CONTENT_TYPE",BACKEND_ERROR:7,7:"BACKEND_ERROR",CLIENT_ERROR:8,8:"CLIENT_ERROR",MISSING_CRYPTER:9,9:"MISSING_CRYPTER",RESPONSE_JSON_SERIALIZATION_FAILED:10,10:"RESPONSE_JSON_SERIALIZATION_FAILED",DECOMPRESSION_FAILED:11,11:"DECOMPRESSION_FAILED",JSON_PARSING_FAILED:12,12:"JSON_PARSING_FAILED",UNKNOWN_COMPRESSION_TYPE:13,13:"UNKNOWN_COMPRESSION_TYPE",UNRECOGNIZED:-1,"-1":"UNRECOGNIZED"};var Q={UNSPECIFIED:0,0:"UNSPECIFIED",OVERWRITE:1,1:"OVERWRITE",KEEP_EXISTING:2,2:"KEEP_EXISTING",UNRECOGNIZED:-1,"-1":"UNRECOGNIZED"};function Pn(){return{type:0,scope:0,value:new Uint8Array(0),sendByDefault:!1,writePolicy:0}}var Se={encode(e,n=new d){return e.type!==void 0&&e.type!==0&&n.uint32(8).int32(e.type),e.scope!==void 0&&e.scope!==0&&n.uint32(16).int32(e.scope),e.value!==void 0&&e.value.length!==0&&n.uint32(26).bytes(e.value),e.sendByDefault!==void 0&&e.sendByDefault!==!1&&n.uint32(32).bool(e.sendByDefault),e.writePolicy!==void 0&&e.writePolicy!==0&&n.uint32(40).int32(e.writePolicy),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Pn();for(;t.pos>>3){case 1:{if(i!==8)break;o.type=t.int32();continue}case 2:{if(i!==16)break;o.scope=t.int32();continue}case 3:{if(i!==26)break;o.value=t.bytes();continue}case 4:{if(i!==32)break;o.sendByDefault=t.bool();continue}case 5:{if(i!==40)break;o.writePolicy=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Cn(){return{timing:void 0,signature:new Uint8Array(0),field5:0}}var On={encode(e,n=new d){return e.timing!==void 0&&Xe.encode(e.timing,n.uint32(10).fork()).join(),e.signature!==void 0&&e.signature.length!==0&&n.uint32(18).bytes(e.signature),e.field5!==void 0&&e.field5!==0&&n.uint32(40).int32(e.field5),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Cn();for(;t.pos>>3){case 1:{if(i!==10)break;o.timing=Xe.decode(t,t.uint32());continue}case 2:{if(i!==18)break;o.signature=t.bytes();continue}case 5:{if(i!==40)break;o.field5=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Mn(){return{contentId:"",contentType:0}}var ze={encode(e,n=new d){return e.contentId!==void 0&&e.contentId!==""&&n.uint32(10).string(e.contentId),e.contentType!==void 0&&e.contentType!==0&&n.uint32(16).int32(e.contentType),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Mn();for(;t.pos>>3){case 1:{if(i!==10)break;o.contentId=t.string();continue}case 2:{if(i!==16)break;o.contentType=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function xn(){return{timestampMs:"0",durationMs:0,content:void 0}}var Xe={encode(e,n=new d){return e.timestampMs!==void 0&&e.timestampMs!=="0"&&n.uint32(8).int64(e.timestampMs),e.durationMs!==void 0&&e.durationMs!==0&&n.uint32(16).int32(e.durationMs),e.content!==void 0&&ze.encode(e.content,n.uint32(26).fork()).join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=xn();for(;t.pos>>3){case 1:{if(i!==8)break;o.timestampMs=t.int64().toString();continue}case 2:{if(i!==16)break;o.durationMs=t.int32();continue}case 3:{if(i!==26)break;o.content=ze.decode(t,t.uint32());continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Ln(){return{startPolicy:[],stopPolicy:[],discardPolicy:[]}}var Ie={encode(e,n=new d){n.uint32(10).fork();for(let t of e.startPolicy)n.int32(t);n.join(),n.uint32(18).fork();for(let t of e.stopPolicy)n.int32(t);n.join(),n.uint32(26).fork();for(let t of e.discardPolicy)n.int32(t);return n.join(),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Ln();for(;t.pos>>3){case 1:{if(i===8){o.startPolicy.push(t.int32());continue}if(i===10){let c=t.uint32()+t.pos;for(;t.pos>>3){case 1:{if(i!==8)break;o.status=t.int32();continue}case 2:{if(i!==16)break;o.maxRetries=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Dn(){return{broadcastId:"",headSequenceNumber:"0",headTimeMs:"0",wallTimeMs:"0",videoId:"",postLiveDvr:!1,headm:"0",minSeekableTimeTicks:"0",minSeekableTimescale:0,maxSeekableTimeTicks:"0",maxSeekableTimescale:0}}var mn={encode(e,n=new d){return e.broadcastId!==void 0&&e.broadcastId!==""&&n.uint32(10).string(e.broadcastId),e.headSequenceNumber!==void 0&&e.headSequenceNumber!=="0"&&n.uint32(24).int64(e.headSequenceNumber),e.headTimeMs!==void 0&&e.headTimeMs!=="0"&&n.uint32(32).int64(e.headTimeMs),e.wallTimeMs!==void 0&&e.wallTimeMs!=="0"&&n.uint32(40).int64(e.wallTimeMs),e.videoId!==void 0&&e.videoId!==""&&n.uint32(50).string(e.videoId),e.postLiveDvr!==void 0&&e.postLiveDvr!==!1&&n.uint32(64).bool(e.postLiveDvr),e.headm!==void 0&&e.headm!=="0"&&n.uint32(80).int64(e.headm),e.minSeekableTimeTicks!==void 0&&e.minSeekableTimeTicks!=="0"&&n.uint32(96).int64(e.minSeekableTimeTicks),e.minSeekableTimescale!==void 0&&e.minSeekableTimescale!==0&&n.uint32(104).int32(e.minSeekableTimescale),e.maxSeekableTimeTicks!==void 0&&e.maxSeekableTimeTicks!=="0"&&n.uint32(112).int64(e.maxSeekableTimeTicks),e.maxSeekableTimescale!==void 0&&e.maxSeekableTimescale!==0&&n.uint32(120).int32(e.maxSeekableTimescale),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Dn();for(;t.pos>>3){case 1:{if(i!==10)break;o.broadcastId=t.string();continue}case 3:{if(i!==24)break;o.headSequenceNumber=t.int64().toString();continue}case 4:{if(i!==32)break;o.headTimeMs=t.int64().toString();continue}case 5:{if(i!==40)break;o.wallTimeMs=t.int64().toString();continue}case 6:{if(i!==50)break;o.videoId=t.string();continue}case 8:{if(i!==64)break;o.postLiveDvr=t.bool();continue}case 10:{if(i!==80)break;o.headm=t.int64().toString();continue}case 12:{if(i!==96)break;o.minSeekableTimeTicks=t.int64().toString();continue}case 13:{if(i!==104)break;o.minSeekableTimescale=t.int32();continue}case 14:{if(i!==112)break;o.maxSeekableTimeTicks=t.int64().toString();continue}case 15:{if(i!==120)break;o.maxSeekableTimescale=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};function Un(){return{id:0}}var Te={encode(e,n=new d){return e.id!==void 0&&e.id!==0&&n.uint32(8).int32(e.id),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=Un();for(;t.pos>>3){case 1:{if(i!==8)break;o.id=t.int32();continue}}if((i&7)===4||i===0)break;t.skip(i&7)}return o}};var h={UNKNOWN:0,0:"UNKNOWN",ONESIE_HEADER:10,10:"ONESIE_HEADER",ONESIE_DATA:11,11:"ONESIE_DATA",ONESIE_ENCRYPTED_MEDIA:12,12:"ONESIE_ENCRYPTED_MEDIA",MEDIA_HEADER:20,20:"MEDIA_HEADER",MEDIA:21,21:"MEDIA",MEDIA_END:22,22:"MEDIA_END",CONFIG:30,30:"CONFIG",LIVE_METADATA:31,31:"LIVE_METADATA",HOSTNAME_CHANGE_HINT_DEPRECATED:32,32:"HOSTNAME_CHANGE_HINT_DEPRECATED",LIVE_METADATA_PROMISE:33,33:"LIVE_METADATA_PROMISE",LIVE_METADATA_PROMISE_CANCELLATION:34,34:"LIVE_METADATA_PROMISE_CANCELLATION",NEXT_REQUEST_POLICY:35,35:"NEXT_REQUEST_POLICY",USTREAMER_VIDEO_AND_FORMAT_METADATA:36,36:"USTREAMER_VIDEO_AND_FORMAT_METADATA",FORMAT_SELECTION_CONFIG:37,37:"FORMAT_SELECTION_CONFIG",USTREAMER_SELECTED_MEDIA_STREAM:38,38:"USTREAMER_SELECTED_MEDIA_STREAM",FORMAT_INITIALIZATION_METADATA:42,42:"FORMAT_INITIALIZATION_METADATA",SABR_REDIRECT:43,43:"SABR_REDIRECT",SABR_ERROR:44,44:"SABR_ERROR",SABR_SEEK:45,45:"SABR_SEEK",RELOAD_PLAYER_RESPONSE:46,46:"RELOAD_PLAYER_RESPONSE",PLAYBACK_START_POLICY:47,47:"PLAYBACK_START_POLICY",ALLOWED_CACHED_FORMATS:48,48:"ALLOWED_CACHED_FORMATS",START_BW_SAMPLING_HINT:49,49:"START_BW_SAMPLING_HINT",PAUSE_BW_SAMPLING_HINT:50,50:"PAUSE_BW_SAMPLING_HINT",SELECTABLE_FORMATS:51,51:"SELECTABLE_FORMATS",REQUEST_IDENTIFIER:52,52:"REQUEST_IDENTIFIER",REQUEST_CANCELLATION_POLICY:53,53:"REQUEST_CANCELLATION_POLICY",ONESIE_PREFETCH_REJECTION:54,54:"ONESIE_PREFETCH_REJECTION",TIMELINE_CONTEXT:55,55:"TIMELINE_CONTEXT",REQUEST_PIPELINING:56,56:"REQUEST_PIPELINING",SABR_CONTEXT_UPDATE:57,57:"SABR_CONTEXT_UPDATE",STREAM_PROTECTION_STATUS:58,58:"STREAM_PROTECTION_STATUS",SABR_CONTEXT_SENDING_POLICY:59,59:"SABR_CONTEXT_SENDING_POLICY",LAWNMOWER_POLICY:60,60:"LAWNMOWER_POLICY",SABR_ACK:61,61:"SABR_ACK",END_OF_TRACK:62,62:"END_OF_TRACK",CACHE_LOAD_POLICY:63,63:"CACHE_LOAD_POLICY",LAWNMOWER_MESSAGING_POLICY:64,64:"LAWNMOWER_MESSAGING_POLICY",PREWARM_CONNECTION:65,65:"PREWARM_CONNECTION",PLAYBACK_DEBUG_INFO:66,66:"PLAYBACK_DEBUG_INFO",SNACKBAR_MESSAGE:67,67:"SNACKBAR_MESSAGE",UNRECOGNIZED:-1,"-1":"UNRECOGNIZED"};function gn(){return{itags:[],videoId:"",resolution:0}}var Fn={encode(e,n=new d){n.uint32(18).fork();for(let t of e.itags)n.int32(t);return n.join(),e.videoId!==void 0&&e.videoId!==""&&n.uint32(26).string(e.videoId),e.resolution!==void 0&&e.resolution!==0&&n.uint32(32).int32(e.resolution),n},decode(e,n){let t=e instanceof a?e:new a(e),r=n===void 0?t.len:t.pos+n,o=gn();for(;t.pos>>3){case 2:{if(i===16){o.itags.push(t.int32());continue}if(i===18){let c=t.uint32()+t.pos;for(;t.posR(E)===(t.searchParams.get(C.KEY_PARAM)||""));if(!i)throw new I(`Could not determine current format from URL: ${n.url}`);this.playerAdapter.getPlayerTime(){let u=o?.width?"video":"audio",E=R(o)||"",O=new URL(`${C.PROTOCOL}//${u}?${C.KEY_PARAM}=${E}`);return await this.makeFollowupRequest(n,O.toString(),c,i)};if(r.snackbarMessage&&(this.logger.debug(b,"Received snackbar message:",r.snackbarMessage),this.onSnackbarMessageCallback&&this.onSnackbarMessageCallback(r.snackbarMessage)),r.redirect?.url){let u=new URL(r.redirect?.url);if(this.logger.info(b,`Redirecting to ${u}`),c){this.serverAbrStreamingUrl=r.redirect?.url;let E=o?.width?"video":"audio",O=R(o)||"";u=new URL(`${C.PROTOCOL}//${E}?${C.KEY_PARAM}=${O}`)}if(!n.data?.byteLength)return await this.makeFollowupRequest(n,u.toString(),c,i)}if(r.nextRequestPolicy){this.lastPlaybackCookie=r.nextRequestPolicy?.playbackCookie;let u=r.nextRequestPolicy.backoffTimeMs||0;u>0&&!this.activeDelayPromise&&(this.logger.info(b,`Delaying next requests by ${u/1e3} seconds.`),this.activeDelayPromise=new Promise(E=>{setTimeout(()=>{this.logger.info(b,"Delay completed, resuming requests."),this.activeDelayPromise=null,E()},u)}))}if(r.sabrContextSendingPolicy){for(let u of r.sabrContextSendingPolicy.startPolicy)this.activeSabrContextTypes.has(u)||(this.activeSabrContextTypes.add(u),this.logger.debug(b,`Activated SABR context for type ${u}`));for(let u of r.sabrContextSendingPolicy.stopPolicy)this.activeSabrContextTypes.has(u)&&(this.activeSabrContextTypes.delete(u),this.logger.debug(b,`Deactivated SABR context for type ${u}`));for(let u of r.sabrContextSendingPolicy.discardPolicy)this.sabrContexts.has(u)&&(this.sabrContexts.delete(u),this.logger.debug(b,`Discarded SABR context for type ${u}`))}if(r.sabrContextUpdate&&r.sabrContextUpdate.type!==void 0&&r.sabrContextUpdate.value?.length&&((!this.sabrContexts.has(r.sabrContextUpdate.type)||r.sabrContextUpdate.writePolicy===Q.OVERWRITE)&&(this.logger.debug(b,`Received SABR context update (type: ${r.sabrContextUpdate.type}, writePolicy: ${Q[r.sabrContextUpdate.writePolicy]} sendByDefault: ${r.sabrContextUpdate.sendByDefault})`),this.sabrContexts.set(r.sabrContextUpdate.type,r.sabrContextUpdate)),r.sabrContextUpdate.sendByDefault&&this.activeSabrContextTypes.add(r.sabrContextUpdate.type),!n.data?.byteLength))return s();if(r.reloadPlaybackContext&&this.onReloadPlayerResponseCallback)return this.logger.info(b,"Server requested player reload with new parameters:",r.reloadPlaybackContext),await this.onReloadPlayerResponseCallback(r.reloadPlaybackContext),s();if(r.mediaHeader){let u=m(r.mediaHeader);if(r.mediaHeader.isInitSeg)return;let E=this.initializedFormats.get(u)||{};E.lastSegmentMetadata={formatId:r.mediaHeader.formatId,startSequenceNumber:r.mediaHeader.sequenceNumber||1,endSequenceNumber:r.mediaHeader.sequenceNumber||1,startTimeMs:r.mediaHeader.startMs||"0",durationMs:r.mediaHeader.durationMs||"0",timescale:r.mediaHeader.timeRange?.timescale||1e3},this.initializedFormats.set(u,E)}return n}async makeFollowupRequest(n,t,r,o){this.activeDelayPromise&&await this.activeDelayPromise;let i={};r&&o&&(i.Range=`bytes=${o.start}-${o.end}`);let c=await n.makeRequest(t,i);return Object.assign(n,c),n}checkDisposed(){if(this.isDisposed)throw new I("Adapter has been disposed.")}dispose(){this.isDisposed||(this.cacheManager?.dispose(),this.cacheManager=null,this.initializedFormats.clear(),this.requestMetadataManager.metadataMap.clear(),this.sabrContexts.clear(),this.activeSabrContextTypes.clear(),this.lastPlaybackCookie=void 0,this.lastPlayerTimeSecs=0,this.sabrFormats=[],this.serverAbrStreamingUrl=void 0,this.ustreamerConfig=void 0,this.activeDelayPromise=null,this.playerAdapter.dispose(),this.requestNumber=0,this.onReloadPlayerResponseCallback=void 0,this.onSnackbarMessageCallback=void 0,this.onMintPoTokenCallback=void 0,this.options=void 0,this.isDisposed=!0,this.logger.debug(b,"Disposed"))}};var $=class e{constructor(n=[]){this.chunks=[],this.currentChunkOffset=this.currentChunkIndex=0,this.currentDataView=void 0,this.totalLength=0,n.forEach(t=>this.append(t))}append(n){if(n instanceof Uint8Array){if(this.canMergeWithLastChunk(n)){let t=this.chunks[this.chunks.length-1];this.chunks[this.chunks.length-1]=new Uint8Array(t.buffer,t.byteOffset,t.length+n.length),this.resetFocus()}else this.chunks.push(n);this.totalLength+=n.length}else n.chunks.forEach(t=>this.append(t))}split(n){let t=new e,r=new e,o=this.chunks[Symbol.iterator](),i=o.next();for(;!i.done;){let c=i.value;n>=c.length?(t.append(c),n-=c.length):n>0?(t.append(new Uint8Array(c.buffer,c.byteOffset,n)),r.append(new Uint8Array(c.buffer,c.byteOffset+n,c.length-n)),n=0):r.append(c),i=o.next()}return{extractedBuffer:t,remainingBuffer:r}}getLength(){return this.totalLength}canReadBytes(n,t){return n+t<=this.totalLength}getUint8(n){return this.focus(n),this.chunks[this.currentChunkIndex][n-this.currentChunkOffset]}focus(n){if(!this.isFocused(n)){for(n=this.currentChunkOffset&&n{let r;this.partialPart?(r=this.partialPart.data,r.append(n)):r=new $([n]);let o=new Z(r);this.partialPart=o.read(i=>{let s=this.umpPartHandlers.get(i.type)?.(i);s&&(this.partialPart=void 0,this.desiredHeaderId=void 0,this.partialSegments.clear(),t(s))}),t(void 0)})}getSegmentInfo(){return this.partialSegments.get(this.desiredHeaderId||0)}decodePart(n,t){if(n.data.chunks.length)try{return t.decode(te(n.data.chunks))}catch{return}}handleFormatInitMetadata(n){let t=this.decodePart(n,ue);t&&this.formatInitMetadata.push(t)}handleNextRequestPolicy(n){let t=this.decodePart(n,Ee);t&&(this.requestMetadata.streamInfo={...this.requestMetadata.streamInfo,nextRequestPolicy:t})}handleMediaHeader(n){let t=this.decodePart(n,fe);if(!t)return;let r=R(this.requestMetadata.format),o=m(t);if(!this.requestMetadata.isSABR||o===r){let i={headerId:t.headerId,mediaHeader:t,bufferedChunks:[],lastChunkSize:0};this.desiredHeaderId===void 0&&(this.desiredHeaderId=t.headerId),this.partialSegments.set(t.headerId,i)}}handleMedia(n){let t=n.data.getUint8(0),r=n.data.split(1).remainingBuffer,o=this.partialSegments.get(t);if(o){o.lastChunkSize=r.getLength();for(let i of r.chunks)o.bufferedChunks.push(i)}}handleMediaEnd(n){let t=n.data.getUint8(0),r=this.partialSegments.get(t);if(r&&r.headerId===this.desiredHeaderId){let o=te(r.bufferedChunks);return this.requestMetadata.streamInfo={...this.requestMetadata.streamInfo,formatInitMetadata:this.formatInitMetadata,mediaHeader:r.mediaHeader},this.requestMetadata.isInit&&this.requestMetadata.byteRange&&this.requestMetadata.format?(this.cacheManager&&this.cacheManager.setInitSegment(w(r.mediaHeader,this.requestMetadata.format),o),{data:o.slice(this.requestMetadata.byteRange.start,this.requestMetadata.byteRange.end+1),done:!0}):{data:o,done:!0}}}handleSnackbarMessage(n){let t=this.decodePart(n,Te);t&&(this.requestMetadata.streamInfo={...this.requestMetadata.streamInfo,snackbarMessage:t})}handleSabrError(n){let t=this.decodePart(n,pe);return this.requestMetadata.error={sabrError:t},{done:!0}}handleStreamProtectionStatus(n){let t=this.decodePart(n,ke);if(t&&(this.requestMetadata.streamInfo={...this.requestMetadata.streamInfo,streamProtectionStatus:t},t.status===3))return{done:!0}}handleReloadPlayerResponse(n){let t=this.decodePart(n,Re);if(t)return this.requestMetadata.streamInfo={...this.requestMetadata.streamInfo,reloadPlaybackContext:t},{done:!0}}handleSabrRedirect(n){let t=this.decodePart(n,be);if(t&&(this.requestMetadata.streamInfo={...this.requestMetadata.streamInfo,redirect:t},this.requestMetadata.isUMP&&!this.requestMetadata.isSABR))return{done:!0}}handleSabrContextUpdate(n){let t=this.decodePart(n,Se);t&&(this.requestMetadata.streamInfo={...this.requestMetadata.streamInfo,sabrContextUpdate:t})}handleSabrContextSendingPolicy(n){let t=this.decodePart(n,Ie);t&&(this.requestMetadata.streamInfo={...this.requestMetadata.streamInfo,sabrContextSendingPolicy:t})}};var Ze=class{constructor(n){this.compositeBuffer=n}write(n,t){let r=t.length;this.writeVarInt(n),this.writeVarInt(r),this.compositeBuffer.append(t)}writeVarInt(n){if(n<0)throw new Error("VarInt value cannot be negative.");if(n<128)this.compositeBuffer.append(new Uint8Array([n]));else if(n<16384)this.compositeBuffer.append(new Uint8Array([n&63|128,n>>6]));else if(n<2097152)this.compositeBuffer.append(new Uint8Array([n&31|192,n>>5&255,n>>13]));else if(n<268435456)this.compositeBuffer.append(new Uint8Array([n&15|224,n>>4&255,n>>12&255,n>>20]));else{let t=new Uint8Array(5),r=new DataView(t.buffer);t[0]=240,r.setUint32(1,n,!0),this.compositeBuffer.append(t)}}};export{Et as AudioQuality,se as AuthorizedFormat,T as BufferedRange,v as CacheManager,N as ClientAbrState,le as ClientInfo,$ as CompositeBuffer,ht as CompressionType,j as CryptoParams,J as EnabledTrackTypes,Ne as EventEmitterLike,f as FormatId,ue as FormatInitializationMetadata,ye as FormatKeyUtils,Fn as FormatSelectionConfig,y as HttpHeader,yt as IdentifierToken,X as InnertubeRequest,Pt as KeyValuePair,mn as LiveMetadata,l as LogLevel,M as Logger,D as MAX_INT32_VALUE,q as MediaCapabilities,fe as MediaHeader,_t as NetworkMeteredState,Ee as NextRequestPolicy,_n as OnesieHeader,In as OnesieHeaderType,Tn as OnesieInnertubeRequest,yn as OnesieInnertubeResponse,Nn as OnesieProxyStatus,pn as OnesieRequest,St as OnesieRequestTarget,bt as PlaybackAudioRouteOutputType,G as PlaybackAuthorization,L as PlaybackCookie,Kt as PlaybackStartPolicy,x as Range,Re as ReloadPlaybackContext,B as ReloadPlaybackParams,on as RequestCancellationPolicy,dn as RequestIdentifier,V as RequestMetadataManager,C as SABR_CONSTANTS,I as SabrAdapterError,Ie as SabrContextSendingPolicy,Se as SabrContextUpdate,On as SabrContextValue,Q as SabrContextWritePolicy,pe as SabrError,be as SabrRedirect,Qe as SabrStreamingAdapter,$e as SabrUmpProcessor,Rt as SeekSource,Te as SnackbarMessage,ke as StreamProtectionStatus,P as StreamerContext,h as UMPPartId,Z as UmpReader,Ze as UmpWriter,_e as UstreamerFlags,he as VideoPlaybackAbrRequest,pt as VideoQualitySetting,ee as base64ToU8,Kn as buildSabrFormat,te as concatenateChunks,Hn as isGoogleVideoURL,Ae as parseRangeHeader,Vn as u8ToBase64,Wn as wait};