UNPKG

@np-dev/youtubei-js

Version:

A wrapper around YouTube's private API. Supports YouTube, YouTube Music, YouTube Kids and YouTube Studio (WIP).

2 lines 532 kB
/* eslint-disable */ var Ay=Object.defineProperty;var n=(t,e)=>Ay(t,"name",{value:e,configurable:!0});var D=(t,e)=>{for(var i in e)Ay(t,i,{get:e[i],enumerable:!0})};function My(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(i[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(i[o[s]]=t[o[s]]);return i}n(My,"__rest");function Vy(t,e,i){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:i?"".concat(i," ",e):e})}n(Vy,"__setFunctionName");function b(t,e,i,o){function s(r){return r instanceof i?r:new i(function(l){l(r)})}return n(s,"adopt"),new(i||(i=Promise))(function(r,l){function p(_){try{h(o.next(_))}catch(g){l(g)}}n(p,"fulfilled");function f(_){try{h(o.throw(_))}catch(g){l(g)}}n(f,"rejected");function h(_){_.done?r(_.value):s(_.value).then(p,f)}n(h,"step"),h((o=o.apply(t,e||[])).next())})}n(b,"__awaiter");function Ry(t){var e=typeof Symbol=="function"&&Symbol.iterator,i=e&&t[e],o=0;if(i)return i.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}n(Ry,"__values");function co(t){return this instanceof co?(this.v=t,this):new co(t)}n(co,"__await");function Oy(t,e,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=i.apply(t,e||[]),s,r=[];return s={},l("next"),l("throw"),l("return"),s[Symbol.asyncIterator]=function(){return this},s;function l(T){o[T]&&(s[T]=function(y){return new Promise(function(C,N){r.push([T,y,C,N])>1||p(T,y)})})}function p(T,y){try{f(o[T](y))}catch(C){g(r[0][3],C)}}function f(T){T.value instanceof co?Promise.resolve(T.value.v).then(h,_):g(r[0][2],T)}function h(T){p("next",T)}function _(T){p("throw",T)}function g(T,y){T(y),r.shift(),r.length&&p(r[0][0],r[0][1])}}n(Oy,"__asyncGenerator");function Dy(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],i;return e?e.call(t):(t=typeof Ry=="function"?Ry(t):t[Symbol.iterator](),i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i);function o(r){i[r]=t[r]&&function(l){return new Promise(function(p,f){l=t[r](l),s(p,f,l.done,l.value)})}}function s(r,l,p,f){Promise.resolve(f).then(function(h){r({value:h,done:p})},l)}}n(Dy,"__asyncValues");function d(t,e,i,o){if(i==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?o:i==="a"?o.call(t):o?o.value:e.get(t)}n(d,"__classPrivateFieldGet");function S(t,e,i,o,s){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?s.call(t,i):s?s.value=i:e.set(t,i),i}n(S,"__classPrivateFieldSet");var jb={};D(jb,{ChannelError:()=>gs,InnertubeError:()=>x,MissingParamError:()=>xn,OAuthError:()=>ri,ParsingError:()=>vt,Platform:()=>B,PlayerError:()=>ft,SessionError:()=>$s,base64ToU8:()=>bb,concatMemos:()=>Db,debugFetch:()=>fE,deepCompare:()=>kh,escapeStringRegexp:()=>Zb,generateRandomString:()=>yt,generateSidAuth:()=>Ub,getRandomUserAgent:()=>zo,getStringBetweenStrings:()=>He,hasKeys:()=>pE,isTextRun:()=>Qe,streamToIterable:()=>Hb,throwIfMissing:()=>Z,timeToSeconds:()=>Le,u8ToBase64:()=>ct});var eb={};D(eb,{Maybe:()=>fo,Memo:()=>Ii,SuperParsedResult:()=>Kt,YTNode:()=>a,observe:()=>ae});var Zg,By,Me,ce,zt,ci,po,Ly=Symbol("ObservedArray.isObserved"),a=class{constructor(){Zg.add(this),this.type=this.constructor.type}is(...e){return e.some(i=>d(this,Zg,"m",By).call(this,i))}as(...e){if(!this.is(...e))throw new vt(`Cannot cast ${this.type} to one of ${e.map(i=>i.type).join(", ")}`);return this}hasKey(e){return Reflect.has(this,e)}key(e){if(!this.hasKey(e))throw new vt(`Missing key ${e}`);return new fo(this[e])}};n(a,"YTNode");Zg=new WeakSet,By=n(function(e){return this.type===e.type},"_YTNode_is");a.type="YTNode";var fo=class{constructor(e){Me.add(this),ce.set(this,void 0),S(this,ce,e,"f")}get typeof(){return typeof d(this,ce,"f")}string(){return d(this,Me,"m",ci).call(this,"string")}isString(){return d(this,Me,"m",zt).call(this,"string")}number(){return d(this,Me,"m",ci).call(this,"number")}isNumber(){return d(this,Me,"m",zt).call(this,"number")}bigint(){return d(this,Me,"m",ci).call(this,"bigint")}isBigint(){return d(this,Me,"m",zt).call(this,"bigint")}boolean(){return d(this,Me,"m",ci).call(this,"boolean")}isBoolean(){return d(this,Me,"m",zt).call(this,"boolean")}symbol(){return d(this,Me,"m",ci).call(this,"symbol")}isSymbol(){return d(this,Me,"m",zt).call(this,"symbol")}undefined(){return d(this,Me,"m",ci).call(this,"undefined")}isUndefined(){return d(this,Me,"m",zt).call(this,"undefined")}null(){if(d(this,ce,"f")!==null)throw new TypeError(`Expected null, got ${typeof d(this,ce,"f")}`);return d(this,ce,"f")}isNull(){return d(this,ce,"f")===null}object(){return d(this,Me,"m",ci).call(this,"object")}isObject(){return d(this,Me,"m",zt).call(this,"object")}function(){return d(this,Me,"m",ci).call(this,"function")}isFunction(){return d(this,Me,"m",zt).call(this,"function")}array(){if(!Array.isArray(d(this,ce,"f")))throw new TypeError(`Expected array, got ${typeof d(this,ce,"f")}`);return d(this,ce,"f")}arrayOfMaybe(){let e=[];return new Proxy(this.array(),{get(i,o){return Reflect.has(e,o)?Reflect.get(i,o):new fo(Reflect.get(i,o))}})}isArray(){return Array.isArray(d(this,ce,"f"))}node(){if(!(d(this,ce,"f")instanceof a))throw new TypeError(`Expected YTNode, got ${d(this,ce,"f").constructor.name}`);return d(this,ce,"f")}isNode(){return d(this,ce,"f")instanceof a}nodeOfType(...e){return this.node().as(...e)}isNodeOfType(...e){return this.isNode()&&this.node().is(...e)}observed(){if(!this.isObserved())throw new TypeError(`Expected ObservedArray, got ${typeof d(this,ce,"f")}`);return d(this,ce,"f")}isObserved(){var e;return(e=d(this,ce,"f"))===null||e===void 0?void 0:e[Ly]}parsed(){if(!(d(this,ce,"f")instanceof Kt))throw new TypeError(`Expected SuperParsedResult, got ${typeof d(this,ce,"f")}`);return d(this,ce,"f")}isParsed(){return d(this,ce,"f")instanceof Kt}any(){return console.warn("This call is not meant to be used outside of debugging. Please use the specific type getter instead."),d(this,ce,"f")}instanceof(e){if(!this.isInstanceof(e))throw new TypeError(`Expected instance of ${e.name}, got ${d(this,ce,"f").constructor.name}`);return d(this,ce,"f")}isInstanceof(e){return d(this,ce,"f")instanceof e}};n(fo,"Maybe");ce=new WeakMap,Me=new WeakSet,zt=n(function(e){return typeof d(this,ce,"f")===e},"_Maybe_checkPrimative"),ci=n(function(e){if(!d(this,Me,"m",zt).call(this,e))throw new TypeError(`Expected ${e}, got ${this.typeof}`);return d(this,ce,"f")},"_Maybe_assertPrimative");var Kt=class{constructor(e){po.set(this,void 0),S(this,po,e,"f")}get is_null(){return d(this,po,"f")===null}get is_array(){return!this.is_null&&Array.isArray(d(this,po,"f"))}get is_node(){return!this.is_array}array(){if(!this.is_array)throw new TypeError("Expected an array, got a node");return d(this,po,"f")}item(){if(!this.is_node)throw new TypeError("Expected a node, got an array");return d(this,po,"f")}};n(Kt,"SuperParsedResult");po=new WeakMap;function ae(t){return new Proxy(t,{get(e,i){return i=="get"?(o,s)=>e.find((r,l)=>{let p=kh(o,r);return p&&s&&e.splice(l,1),p}):i==Ly?!0:i=="getAll"?(o,s)=>e.filter((r,l)=>{let p=kh(o,r);return p&&s&&e.splice(l,1),p}):i=="matchCondition"?o=>e.find(s=>o(s)):i=="filterType"?(...o)=>ae(e.filter(s=>!!s.is(...o))):i=="firstOfType"?(...o)=>e.find(s=>!!s.is(...o)):i=="first"?()=>e[0]:i=="as"?(...o)=>ae(e.map(s=>{if(s.is(...o))return s;throw new vt(`Expected node of any type ${o.map(r=>r.type).join(", ")}, got ${s.type}`)})):i=="remove"?o=>e.splice(o,1):Reflect.get(e,i)}})}n(ae,"observe");var Ii=class extends Map{getType(...e){return e=e.flat(),ae(e.flatMap(i=>this.get(i.type)||[]))}};n(Ii,"Memo");var Qb={};D(Qb,{Author:()=>M,ChildElement:()=>uv,EmojiRun:()=>Ci,Format:()=>l_,Text:()=>u,TextRun:()=>Ei,Thumbnail:()=>w,VideoDetails:()=>Ai});var We={};D(We,{CLIENTS:()=>G,INNERTUBE_HEADERS_BASE:()=>uk,OAUTH:()=>ki,STREAM_HEADERS:()=>Ch,URLS:()=>pe});var pe=Object.freeze({YT_BASE:"https://www.youtube.com",YT_MUSIC_BASE:"https://music.youtube.com",YT_SUGGESTIONS:"https://suggestqueries.google.com/complete/",YT_UPLOAD:"https://upload.youtube.com/",API:Object.freeze({BASE:"https://youtubei.googleapis.com",PRODUCTION_1:"https://www.youtube.com/youtubei/",PRODUCTION_2:"https://youtubei.googleapis.com/youtubei/",STAGING:"https://green-youtubei.sandbox.googleapis.com/youtubei/",RELEASE:"https://release-youtubei.sandbox.googleapis.com/youtubei/",TEST:"https://test-youtubei.sandbox.googleapis.com/youtubei/",CAMI:"http://cami-youtubei.sandbox.googleapis.com/youtubei/",UYTFE:"https://uytfe.sandbox.google.com/youtubei/"})}),ki=Object.freeze({SCOPE:"http://gdata.youtube.com https://www.googleapis.com/auth/youtube-paid-content",GRANT_TYPE:"http://oauth.net/grant_type/device/1.0",MODEL_NAME:"ytlr::",HEADERS:Object.freeze({accept:"*/*",origin:"https://www.youtube.com","user-agent":"Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version","content-type":"application/json",referer:"https://www.youtube.com/tv","accept-language":"en-US"}),REGEX:Object.freeze({AUTH_SCRIPT:/<script id="base-js" src="(.*?)" nonce=".*?"><\/script>/,CLIENT_IDENTITY:new RegExp('var .+?={clientId:"(?<client_id>.+?)",.+?:"(?<client_secret>.+?)".+?}')})}),G=Object.freeze({iOS:{NAME:"iOS",VERSION:"18.06.35",USER_AGENT:"com.google.ios.youtube/18.06.35 (iPhone; CPU iPhone OS 14_4 like Mac OS X; en_US)",DEVICE_MODEL:"iPhone10,6"},WEB:{NAME:"WEB",VERSION:"2.20230622.06.00",API_KEY:"AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8",API_VERSION:"v1",STATIC_VISITOR_ID:"6zpwvWUNAco"},WEB_KIDS:{NAME:"WEB_KIDS",VERSION:"2.20230111.00.00"},YTMUSIC:{NAME:"WEB_REMIX",VERSION:"1.20211213.00.00"},ANDROID:{NAME:"ANDROID",VERSION:"18.06.35",SDK_VERSION:"29",USER_AGENT:"com.google.android.youtube/18.06.35 (Linux; U; Android 10; US)"},YTSTUDIO_ANDROID:{NAME:"ANDROID_CREATOR",VERSION:"22.43.101"},YTMUSIC_ANDROID:{NAME:"ANDROID_MUSIC",VERSION:"5.34.51"},TV_EMBEDDED:{NAME:"TVHTML5_SIMPLY_EMBEDDED_PLAYER",VERSION:"2.0"}}),Ch=Object.freeze({accept:"*/*",origin:"https://www.youtube.com",referer:"https://www.youtube.com",DNT:"?1"}),uk=Object.freeze({accept:"*/*","accept-encoding":"gzip, deflate","content-type":"application/json"});var c={};D(c,{addRuntimeParser:()=>Ab,applyMutations:()=>YI,getDynamicParsers:()=>Uk,getParserByName:()=>Ym,hasParser:()=>q0,parse:()=>Ke,parseActions:()=>FI,parseArray:()=>ze,parseC:()=>LI,parseFormats:()=>Mb,parseItem:()=>se,parseLC:()=>Rb,parseRR:()=>X0,parseResponse:()=>jk,sanitizeClassName:()=>jm,setParserErrorHandler:()=>Fk,shouldIgnore:()=>BI});var Lr=class extends a{constructor(e){super(),this.audio_only_availability=e.audioOnlyAvailability}};n(Lr,"AudioOnlyPlayability");Lr.type="AudioOnlyPlayability";var Eh=Lr;var Fr=class extends a{constructor(e){super(),Reflect.has(e,"text")&&(this.text=new u(e.text).toString()),Reflect.has(e,"accessibility")&&Reflect.has(e.accessibility,"label")&&(this.label=e.accessibility.label),Reflect.has(e,"tooltip")&&(this.tooltip=e.tooltip),Reflect.has(e,"icon")&&Reflect.has(e.icon,"iconType")&&(this.icon_type=e.icon.iconType),Reflect.has(e,"isDisabled")&&(this.is_disabled=e.isDisabled),this.endpoint=new v(e.navigationEndpoint||e.serviceEndpoint||e.command)}};n(Fr,"Button");Fr.type="Button";var I=Fr;var Yr=class extends a{constructor(e){var i;super(),this.label=new u(e.label).toString(),this.selected=!!e.isSelected,Reflect.has(e,"int32Value")?this.value=e.int32Value:e.stringValue&&(this.value=e.stringValue),Reflect.has(e,"onSelectCommand")&&(this.endpoint=new v(e.onSelectCommand)),Reflect.has(e,"icon")&&(this.icon_type=(i=e.icon)===null||i===void 0?void 0:i.iconType),Reflect.has(e,"descriptionText")&&(this.description=new u(e.descriptionText))}};n(Yr,"DropdownItem");Yr.type="DropdownItem";var Ph=Yr;var Ur=class extends a{constructor(e){super(),this.label=e.label||"",this.entries=c.parseArray(e.entries,Ph)}};n(Ur,"Dropdown");Ur.type="Dropdown";var Mn=Ur;var jr=class extends a{constructor(e){super(),this.title=new u(e.dialogTitle).toString(),this.title_placeholder=e.titlePlaceholder||"",this.privacy_option=c.parseItem(e.privacyOption,Mn),this.create_button=c.parseItem(e.cancelButton,I),this.cancel_button=c.parseItem(e.cancelButton,I)}};n(jr,"CreatePlaylistDialog");jr.type="CreatePlaylistDialog";var Nh=jr;var Wr=class extends a{constructor(e){super(),this.popup=c.parseItem(e.popup),this.popup_type=e.popupType}};n(Wr,"OpenPopupAction");Wr.type="OpenPopupAction";var Ah=Wr;var Hr=class extends a{constructor(e){var i,o,s,r,l,p,f,h;super(),Reflect.has(e||{},"innertubeCommand")&&(e=e.innertubeCommand),Reflect.has(e||{},"openPopupAction")&&(this.open_popup=new Ah(e.openPopupAction));let _=Object.keys(e||{}).find(g=>g.endsWith("Endpoint")||g.endsWith("Command"));this.payload=_?Reflect.get(e,_):{},(Reflect.has(this.payload,"dialog")||Reflect.has(this.payload,"content"))&&(this.dialog=c.parseItem(this.payload.dialog||this.payload.content)),e!=null&&e.serviceEndpoint&&(e=e.serviceEndpoint),this.metadata={},!((o=(i=e==null?void 0:e.commandMetadata)===null||i===void 0?void 0:i.webCommandMetadata)===null||o===void 0)&&o.url&&(this.metadata.url=e.commandMetadata.webCommandMetadata.url),!((r=(s=e==null?void 0:e.commandMetadata)===null||s===void 0?void 0:s.webCommandMetadata)===null||r===void 0)&&r.webPageType&&(this.metadata.page_type=e.commandMetadata.webCommandMetadata.webPageType),!((p=(l=e==null?void 0:e.commandMetadata)===null||l===void 0?void 0:l.webCommandMetadata)===null||p===void 0)&&p.apiUrl?this.metadata.api_url=e.commandMetadata.webCommandMetadata.apiUrl.replace("/youtubei/v1/",""):_&&(this.metadata.api_url=this.getEndpoint(_)),!((h=(f=e==null?void 0:e.commandMetadata)===null||f===void 0?void 0:f.webCommandMetadata)===null||h===void 0)&&h.sendPost&&(this.metadata.send_post=e.commandMetadata.webCommandMetadata.sendPost),e!=null&&e.createPlaylistEndpoint&&e!=null&&e.createPlaylistEndpoint.createPlaylistDialog&&(this.dialog=c.parseItem(e==null?void 0:e.createPlaylistEndpoint.createPlaylistDialog,Nh))}getEndpoint(e){switch(e){case"browseEndpoint":return"/browse";case"watchEndpoint":return"/player";case"searchEndpoint":return"/search";case"watchPlaylistEndpoint":return"/next";case"liveChatItemContextMenuEndpoint":return"live_chat/get_item_context_menu"}}call(e,i){if(!e)throw new Error("An active caller must be provided");if(!this.metadata.api_url)throw new Error("Expected an api_url, but none was found, this is a bug.");return e.execute(this.metadata.api_url,Object.assign(Object.assign({},this.payload),i))}toURL(){if(!!this.metadata.url&&!!this.metadata.page_type)return this.metadata.page_type==="WEB_PAGE_TYPE_UNKNOWN"?this.metadata.url:`https://www.youtube.com${this.metadata.url}`}};n(Hr,"NavigationEndpoint");Hr.type="NavigationEndpoint";var v=Hr;var w=class{constructor(e){this.url=e.url,this.width=e.width,this.height=e.height}static fromResponse(e){return!e||!e.thumbnails?[]:e.thumbnails.map(i=>new w(i)).sort((i,o)=>o.width-i.width)}};n(w,"Thumbnail");var Ci=class{constructor(e){var i,o,s,r,l,p;this.text=((i=e.emoji)===null||i===void 0?void 0:i.emojiId)||((s=(o=e.emoji)===null||o===void 0?void 0:o.shortcuts)===null||s===void 0?void 0:s[0])||"",this.emoji={emoji_id:e.emoji.emojiId,shortcuts:((r=e.emoji)===null||r===void 0?void 0:r.shortcuts)||[],search_terms:((l=e.emoji)===null||l===void 0?void 0:l.searchTerms)||[],image:w.fromResponse(e.emoji.image),is_custom:!!(!((p=e.emoji)===null||p===void 0)&&p.isCustomEmoji)}}toString(){return this.text}toHTML(){let e=Rh(this.text);return`<img src="${this.emoji.image[0].url}" alt="${e}" title="${e}" style="display: inline-block; vertical-align: text-top; height: var(--yt-emoji-size, 1rem); width: var(--yt-emoji-size, 1rem);" loading="lazy" crossorigin="anonymous" />`}};n(Ci,"EmojiRun");var Ei=class{constructor(e){this.text=e.text,this.bold=Boolean(e.bold),this.italics=Boolean(e.italics),this.strikethrough=Boolean(e.strikethrough),Reflect.has(e,"navigationEndpoint")&&(this.endpoint=new v(e.navigationEndpoint)),this.attachment=e.attachment}toString(){return this.text}toHTML(){let e=[];this.bold&&e.push("b"),this.italics&&e.push("i"),this.strikethrough&&e.push("s");let i=Rh(this.text),s=`<span style="white-space: pre-wrap;">${e.map(r=>`<${r}>`).join("")+i+e.map(r=>`</${r}>`).join("")}</span>`;if(this.attachment&&this.attachment.element.type.imageType.image.sources.length){let{url:r}=this.attachment.element.type.imageType.image.sources[0];if(this.endpoint){let l=this.endpoint.toURL();if(l)return`<a href="${l}" class="yt-ch-link" display: block; width: fit-content; font-size: small;><img src="${r}" style="vertical-align: middle; height: ${this.attachment.element.properties.layoutProperties.height.value}px; width: ${this.attachment.element.properties.layoutProperties.width.value}px;">${s}</a>`}}if(this.endpoint){let r=this.endpoint.toURL();if(r)return`<a href="${r}">${s}</a>`}return s}};n(Ei,"TextRun");function Rh(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}n(Rh,"escape");var u=class{constructor(e){var i,o,s,r;typeof e=="object"&&e!==null&&Reflect.has(e,"runs")&&Array.isArray(e.runs)?(this.runs=e.runs.map(l=>l.emoji?new Ci(l):new Ei(l)),this.text=this.runs.map(l=>l.text).join("")):this.text=e==null?void 0:e.simpleText,typeof e=="object"&&e!==null&&Reflect.has(e,"navigationEndpoint")&&(this.endpoint=new v(e.navigationEndpoint)),typeof e=="object"&&e!==null&&Reflect.has(e,"titleNavigationEndpoint")&&(this.endpoint=new v(e.titleNavigationEndpoint)),this.endpoint||!((o=(i=this.runs)===null||i===void 0?void 0:i[0])===null||o===void 0)&&o.endpoint&&(this.endpoint=(r=(s=this.runs)===null||s===void 0?void 0:s[0])===null||r===void 0?void 0:r.endpoint)}static fromAttributed(e){let i=[],o=e.content,s=e.commandRuns,r=0;if(s){for(let l of s){let p=l.length,f=l.startIndex;if(f>r&&i.push({text:o.slice(r,f)}),Reflect.has(l,"onTap")){let h=null;if(Reflect.has(e,"attachmentRuns")){let _=e.attachmentRuns;for(let g of _)if(g.startIndex-2==f){h=g;break}}h?i.push({text:o.slice(f,f+p),navigationEndpoint:l.onTap,attachment:h}):i.push({text:o.slice(f,f+p),navigationEndpoint:l.onTap})}r=f+p}r<o.length&&i.push({text:o.slice(r)})}else i.push({text:o});return new u({runs:i})}toHTML(){return this.runs?this.runs.map(e=>e.toHTML()).join(""):this.text}isEmpty(){return this.text===void 0}toString(){return this.text||"N/A"}};n(u,"Text");var Jr=class extends a{constructor(e){super(),this.cards=c.parseArray(e.cards),this.header=new u(e.headerText),this.allow_teaser_dismiss=e.allowTeaserDismiss}};n(Jr,"CardCollection");Jr.type="CardCollection";var Mh=Jr;var Gr=class extends a{constructor(e){super(),this.elements=c.parseArray(e.elements),this.start_ms=e.startMs}};n(Gr,"Endscreen");Gr.type="Endscreen";var Vh=Gr;var zr=class extends a{constructor(e){super(),Reflect.has(e,"featuredChannel")&&(this.featured_channel={start_time_ms:e.featuredChannel.startTimeMs,end_time_ms:e.featuredChannel.endTimeMs,watermark:w.fromResponse(e.featuredChannel.watermark),channel_name:e.featuredChannel.channelName,endpoint:new v(e.featuredChannel.navigationEndpoint),subscribe_button:c.parseItem(e.featuredChannel.subscribeButton)}),this.allow_swipe_dismiss=e.allowSwipeDismiss,this.annotation_id=e.annotationId}};n(zr,"PlayerAnnotationsExpanded");zr.type="PlayerAnnotationsExpanded";var Oh=zr;var Kr=class extends a{constructor(e){super(),Reflect.has(e,"captionTracks")&&(this.caption_tracks=e.captionTracks.map(i=>({base_url:i.baseUrl,name:new u(i.name),vss_id:i.vssId,language_code:i.languageCode,kind:i.kind,is_translatable:i.isTranslatable}))),Reflect.has(e,"audioTracks")&&(this.audio_tracks=e.audioTracks.map(i=>({audio_track_id:i.audioTrackId,captions_initial_state:i.captionsInitialState,default_caption_track_index:i.defaultCaptionTrackIndex,has_default_track:i.hasDefaultTrack,visibility:i.visibility,caption_track_indices:i.captionTrackIndices}))),Reflect.has(e,"defaultAudioTrackIndex")&&(this.default_audio_track_index=e.defaultAudioTrackIndex),Reflect.has(e,"translationLanguages")&&(this.translation_languages=e.translationLanguages.map(i=>({language_code:i.languageCode,language_name:new u(i.languageName)})))}};n(Kr,"PlayerCaptionsTracklist");Kr.type="PlayerCaptionsTracklist";var Dh=Kr;var $r=class extends a{constructor(){super()}};n($r,"PlayerLiveStoryboardSpec");$r.type="PlayerLiveStoryboardSpec";var Bh=$r;var qr=class extends a{constructor(e){super();let i=e.spec.split("|"),o=new URL(i.shift());this.boards=i.map((s,r)=>{let[l,p,f,h,_,g,T,y]=s.split("#");o.searchParams.set("sigh",y);let C=Math.ceil(parseInt(f,10)/(parseInt(h,10)*parseInt(_,10)));return{template_url:o.toString().replace("$L",r).replace("$N",T),thumbnail_width:parseInt(l,10),thumbnail_height:parseInt(p,10),thumbnail_count:parseInt(f,10),interval:parseInt(g,10),columns:parseInt(h,10),rows:parseInt(_,10),storyboard_count:C}})}};n(qr,"PlayerStoryboardSpec");qr.type="PlayerStoryboardSpec";var mo=qr;var Xr=class extends a{constructor(e){super(),this.text=new u(e.text),this.alert_type=e.type}};n(Xr,"Alert");Xr.type="Alert";var Vn=Xr;var Qr=class extends a{constructor(e){super(),this.text=new u(e.text),this.alert_type=e.type,this.dismiss_button=c.parseItem(e.dismissButton,I)}};n(Qr,"AlertWithButton");Qr.type="AlertWithButton";var Lh=Qr;var Zr=class extends a{constructor(e){super(),this.placeholder_text=new u(e.placeholderText),this.max_character_limit=e.maxCharacterLimit}};n(Zr,"ClipCreationTextInput");Zr.type="ClipCreationTextInput";var Fh=Zr;var ea=class extends a{constructor(e){var i,o,s,r,l,p;super(),this.length_template=e.lengthTemplate,this.max_length_ms=e.maxLengthMs,this.min_length_ms=e.minLengthMs,this.default_length_ms=e.defaultLengthMs,this.window_size_ms=e.windowSizeMs,this.start_label=(o=(i=e.startAccessibility)===null||i===void 0?void 0:i.accessibilityData)===null||o===void 0?void 0:o.label,this.end_label=(r=(s=e.endAccessibility)===null||s===void 0?void 0:s.accessibilityData)===null||r===void 0?void 0:r.label,this.duration_label=(p=(l=e.durationAccessibility)===null||l===void 0?void 0:l.accessibilityData)===null||p===void 0?void 0:p.label}};n(ea,"ClipCreationScrubber");ea.type="ClipCreationScrubber";var Yh=ea;var ta=class extends a{constructor(e){super(),this.title=new u(e.title),this.body=new u(e.body)}};n(ta,"ClipAdState");ta.type="ClipAdState";var Uh=ta;var ia=class extends a{constructor(e){super(),this.user_avatar=w.fromResponse(e.userAvatar),this.title_input=c.parseItem(e.titleInput,[Fh]),this.scrubber=c.parseItem(e.scrubber,[Yh]),this.save_button=c.parseItem(e.saveButton,[I]),this.display_name=new u(e.displayName),this.publicity_label=e.publicityLabel,this.cancel_button=c.parseItem(e.cancelButton,[I]),this.ad_state_overlay=c.parseItem(e.adStateOverlay,[Uh]),this.external_video_id=e.externalVideoId,this.publicity_label_icon=e.publicityLabelIcon}};n(ia,"ClipCreation");ia.type="ClipCreation";var jh=ia;var oa=class extends a{constructor(e){super(),this.contents=c.parse(e.contents,!0,[jh])}};n(oa,"ClipSection");oa.type="ClipSection";var Wh=oa;var na=class extends a{constructor(e){super(),this.trigger=e.trigger,Reflect.has(e,"button")&&(this.button=c.parseItem(e.button,I)),this.endpoint=new v(e.continuationEndpoint)}};n(na,"ContinuationItem");na.type="ContinuationItem";var he=na;var sa=class extends a{constructor(e){super(),this.title=new u(e.title),this.visibility_button=c.parseItem(e.visibilityButton,I)}};n(sa,"EngagementPanelTitleHeader");sa.type="EngagementPanelTitleHeader";var Hh=sa;var ra=class extends a{constructor(e){super(),this.items=c.parseArray(e.items),this.top_level_buttons=c.parseArray(e.topLevelButtons),Reflect.has(e,"accessibility")&&Reflect.has(e.accessibility,"accessibilityData")&&(this.label=e.accessibility.accessibilityData.label)}get contents(){return this.items}};n(ra,"Menu");ra.type="Menu";var F=ra;var aa=class extends a{constructor(e){super(),this.info_text=new u(e.infoText),this.menu=c.parseItem(e.menu,F)}};n(aa,"MacroMarkersInfoItem");aa.type="MacroMarkersInfoItem";var Jh=aa;var ua=class extends a{constructor(e){super(),this.title=new u(e.title),this.time_description=new u(e.timeDescription),this.thumbnail=w.fromResponse(e.thumbnail),this.on_tap_endpoint=new v(e.onTap),this.layout=e.layout,this.is_highlighted=!!e.isHighlighted}};n(ua,"MacroMarkersListItem");ua.type="MacroMarkersListItem";var On=ua;var la=class extends a{constructor(e){super(),this.contents=c.parseArray(e.contents,[Jh,On]),this.sync_button_label=new u(e.syncButtonLabel)}};n(la,"MacroMarkersList");la.type="MacroMarkersList";var Gh=la;var ca=class extends a{constructor(e){super(),this.contents=c.parseArray(e.contents)}};n(ca,"ProductList");ca.type="ProductList";var zh=ca;var da=class extends a{constructor(e){super(),this.contents=c.parseArray(e.contents),Reflect.has(e,"targetId")&&(this.target_id=e.targetId),Reflect.has(e,"continuations")&&(Reflect.has(e.continuations[0],"nextContinuationData")?this.continuation=e.continuations[0].nextContinuationData.continuation:Reflect.has(e.continuations[0],"reloadContinuationData")&&(this.continuation=e.continuations[0].reloadContinuationData.continuation)),Reflect.has(e,"header")&&(this.header=c.parseItem(e.header)),Reflect.has(e,"subMenu")&&(this.sub_menu=c.parseItem(e.subMenu))}};n(da,"SectionList");da.type="SectionList";var Q=da;var pa=class extends a{constructor(e){var i;super(),this.show_more_text=new u(e.showMoreText),this.show_less_text=new u(e.showLessText),Reflect.has(e,"attributedDescriptionBodyText")&&(this.attributed_description_body_text=(i=e.attributedDescriptionBodyText)===null||i===void 0?void 0:i.content)}};n(pa,"ExpandableVideoDescriptionBody");pa.type="ExpandableVideoDescriptionBody";var Kh=pa;var fa=class extends a{constructor(e){super(),this.thumbnails=w.fromResponse(e.thumbnail),this.endpoint=new v(e.searchEndpoint),this.query=new u(e.query).toString()}};n(fa,"SearchRefinementCard");fa.type="SearchRefinementCard";var ho=fa;var ma=class extends a{constructor(e){super(),this.game=c.parseItem(e.game)}};n(ma,"GameCard");ma.type="GameCard";var $h=ma;var ha=class extends a{constructor(e){super(),this.visible_item_count=e.visibleItemCount,this.items=c.parseArray(e.items)}get contents(){return this.items}};n(ha,"HorizontalList");ha.type="HorizontalList";var qh=ha;var _a=class extends a{constructor(e){super(),Reflect.has(e,"header")&&(this.header={collapsed_title:new u(e.header.collapsedTitle),collapsed_thumbnail:w.fromResponse(e.header.collapsedThumbnail),collapsed_label:new u(e.header.collapsedLabel),expanded_title:new u(e.header.expandedTitle)}),this.expanded_content=c.parseItem(e.expandedContent,[Pi,qh]),this.expand_button=c.parseItem(e.expandButton,I),this.collapse_button=c.parseItem(e.collapseButton,I)}};n(_a,"ExpandableMetadata");_a.type="ExpandableMetadata";var Xh=_a;var va=class extends a{constructor(e){super(),Reflect.has(e,"icon")&&(this.icon_type=e.icon.iconType),Reflect.has(e,"style")&&(this.style=e.style),Reflect.has(e,"label")&&(this.label=e.label),(Reflect.has(e,"tooltip")||Reflect.has(e,"iconTooltip"))&&(this.tooltip=e.tooltip||e.iconTooltip)}};n(va,"MetadataBadge");va.type="MetadataBadge";var ot=va;var xa=class extends a{constructor(e){super(),this.text=new u(e.text).toString(),this.style=e.style}};n(xa,"ThumbnailOverlayTimeStatus");xa.type="ThumbnailOverlayTimeStatus";var _o=xa;var ga=class extends a{constructor(e){var i,o,s;super();let r=((i=e.thumbnailOverlays.find(l=>l.thumbnailOverlayTimeStatusRenderer))===null||i===void 0?void 0:i.thumbnailOverlayTimeStatusRenderer.text)||"N/A";this.id=e.videoId,this.title=new u(e.title),Reflect.has(e,"descriptionSnippet")&&(this.description_snippet=new u(e.descriptionSnippet)),Reflect.has(e,"detailedMetadataSnippets")&&(this.snippets=e.detailedMetadataSnippets.map(l=>({text:new u(l.snippetText),hover_text:new u(l.snippetHoverText)}))),this.expandable_metadata=c.parseItem(e.expandableMetadata,Xh),this.thumbnails=w.fromResponse(e.thumbnail),this.thumbnail_overlays=c.parseArray(e.thumbnailOverlays),Reflect.has(e,"richThumbnail")&&(this.rich_thumbnail=c.parseItem(e.richThumbnail)),this.author=new M(e.ownerText,e.ownerBadges,(s=(o=e.channelThumbnailSupportedRenderers)===null||o===void 0?void 0:o.channelThumbnailWithLinkRenderer)===null||s===void 0?void 0:s.thumbnail),this.badges=c.parseArray(e.badges,ot),this.endpoint=new v(e.navigationEndpoint),this.published=new u(e.publishedTimeText),this.view_count=new u(e.viewCountText),this.short_view_count=new u(e.shortViewCountText),Reflect.has(e,"upcomingEventData")&&(this.upcoming=new Date(Number(`${e.upcomingEventData.startTime}000`))),this.duration={text:e.lengthText?new u(e.lengthText).toString():new u(r).toString(),seconds:Le(e.lengthText?new u(e.lengthText).toString():new u(r).toString())},this.show_action_menu=!!e.showActionMenu,this.is_watched=!!e.isWatched,this.menu=c.parseItem(e.menu,F),Reflect.has(e,"searchVideoResultEntityKey")&&(this.search_video_result_entity_key=e.searchVideoResultEntityKey)}get description(){var e;return this.snippets?this.snippets.map(i=>i.text.toString()).join(""):((e=this.description_snippet)===null||e===void 0?void 0:e.toString())||""}get is_live(){var e;return this.badges.some(i=>{if(i.style==="BADGE_STYLE_TYPE_LIVE_NOW"||i.label==="LIVE")return!0})||((e=this.thumbnail_overlays.firstOfType(_o))===null||e===void 0?void 0:e.style)==="LIVE"}get is_upcoming(){return this.upcoming&&this.upcoming>new Date}get is_premiere(){return this.badges.some(e=>e.label==="PREMIERE")}get is_4k(){return this.badges.some(e=>e.label==="4K")}get has_captions(){return this.badges.some(e=>e.label==="CC")}get best_thumbnail(){return this.thumbnails[0]}};n(ga,"Video");ga.type="Video";var Dn=ga;var ba=class extends Dn{constructor(e){super(e)}};n(ba,"VideoCard");ba.type="VideoCard";var Qh=ba;var ya=class extends a{constructor(e){super(),this.image=e.image.sources.map(i=>new w(i)).sort((i,o)=>o.width-i.width),this.style=e.style}};n(ya,"ContentPreviewImageView");ya.type="ContentPreviewImageView";var Bn=ya;var wa=class extends a{constructor(e){var i;super(),!((i=e.image)===null||i===void 0)&&i.sources?this.image={sources:e.image.sources.map(o=>new w(o)).sort((o,s)=>s.width-o.width)}:this.image=c.parseItem(e.image,Bn),this.image_style=e.imageStyle,this.title=e.title,this.subtitle=e.subtitle,this.secondary_subtitle={content:e.secondarySubtitle.content},this.orientation=e.orientation,this.sizing_rule=e.sizingRule,this.overflow_menu_on_tap=new v(e.overflowMenuOnTap),this.overflow_menu_a11y_label=e.overflowMenuA11yLabel}};n(wa,"VideoAttributeView");wa.type="VideoAttributeView";var Ln=wa;var Ta=class extends a{constructor(e){super(),this.cards=c.parseArray(e.cards,[Ln,ho,On,$h,Qh]),this.header=c.parseItem(e.header),this.previous_button=c.parseItem(e.previousButton,I),this.next_button=c.parseItem(e.nextButton,I)}};n(Ta,"HorizontalCardList");Ta.type="HorizontalCardList";var Pi=Ta;var Sa=class extends a{constructor(e){super(),this.label=new u(e.label),this.value=new u(e.value),this.accessibility_text=e.accessibilityText}};n(Sa,"Factoid");Sa.type="Factoid";var Ni=Sa;var Ia=class extends a{constructor(e){super(),this.factoid=c.parseItem(e.factoid,Ni)}};n(Ia,"UploadTimeFactoid");Ia.type="UploadTimeFactoid";var Zh=Ia;var ka=class extends a{constructor(e){super(),this.view_count_entity_key=e.viewCountEntityKey,this.factoid=c.parseItem(e.factoid,[Ni]),this.view_count_type=e.viewCountType}};n(ka,"ViewCountFactoid");ka.type="ViewCountFactoid";var e_=ka;var Ca=class extends a{constructor(e){super(),this.title=new u(e.title),this.channel=new u(e.channel),this.channel_navigation_endpoint=new v(e.channelNavigationEndpoint),this.channel_thumbnail=w.fromResponse(e.channelThumbnail),this.publish_date=new u(e.publishDate),this.views=new u(e.views),this.factoids=c.parseArray(e.factoid,[Ni,e_,Zh])}};n(Ca,"VideoDescriptionHeader");Ca.type="VideoDescriptionHeader";var t_=Ca;var Ea=class extends a{constructor(e){super(),this.section_title=new u(e.sectionTitle),this.creator_videos_button=c.parseItem(e.creatorVideosButton,I),this.creator_about_button=c.parseItem(e.creatorAboutButton,I),this.section_subtitle=new u(e.sectionSubtitle),this.channel_avatar=w.fromResponse(e.channelAvatar),this.channel_endpoint=new v(e.channelEndpoint)}};n(Ea,"VideoDescriptionInfocardsSection");Ea.type="VideoDescriptionInfocardsSection";var i_=Ea;var Pa=class extends a{constructor(e){super(),this.title=new u(e.title),Reflect.has(e,"defaultMetadata")&&(this.default_metadata=new u(e.defaultMetadata)),Reflect.has(e,"expandedMetadata")&&(this.expanded_metadata=new u(e.expandedMetadata)),Reflect.has(e,"infoRowExpandStatusKey")&&(this.info_row_expand_status_key=e.infoRowExpandStatusKey)}};n(Pa,"InfoRow");Pa.type="InfoRow";var o_=Pa;var Na=class extends a{constructor(e){super(),this.id=e.videoId,this.thumbnails=w.fromResponse(e.thumbnail)||null,Reflect.has(e,"richThumbnail")&&(this.rich_thumbnail=c.parse(e.richThumbnail)),this.title=new u(e.title),this.author=new M(e.longBylineText,e.ownerBadges,e.channelThumbnail),this.view_count=new u(e.viewCountText),this.short_view_count=new u(e.shortViewCountText),this.published=new u(e.publishedTimeText),this.badges=c.parseArray(e.badges,ot),this.duration={text:new u(e.lengthText).toString(),seconds:Le(new u(e.lengthText).toString())},this.thumbnail_overlays=c.parseArray(e.thumbnailOverlays),this.endpoint=new v(e.navigationEndpoint),this.menu=c.parseItem(e.menu,F)}get best_thumbnail(){return this.thumbnails[0]}get is_fundraiser(){return this.badges.some(e=>e.label==="Fundraiser")}get is_live(){return this.badges.some(e=>{if(e.style==="BADGE_STYLE_TYPE_LIVE_NOW"||e.label==="LIVE")return!0})}get is_new(){return this.badges.some(e=>e.label==="New")}get is_premiere(){return this.badges.some(e=>e.style==="PREMIERE")}};n(Na,"CompactVideo");Na.type="CompactVideo";var Fn=Na;var Aa=class extends a{constructor(e){super(),this.info_rows=c.parseArray(e.infoRows,o_),this.video_lockup=c.parseItem(e.videoLockup,Fn)}};n(Aa,"CarouselLockup");Aa.type="CarouselLockup";var n_=Aa;var Ra=class extends a{constructor(e){super(),this.carousel_lockups=c.parseArray(e.carouselLockups,n_),this.section_title=new u(e.sectionTitle)}};n(Ra,"VideoDescriptionMusicSection");Ra.type="VideoDescriptionMusicSection";var Yn=Ra;var Ma=class extends a{constructor(e){super(),this.section_title=new u(e.sectionTitle),this.sub_header_text=new u(e.subHeaderText),this.primary_button=c.parseItem(e.primaryButton,I)}};n(Ma,"VideoDescriptionTranscriptSection");Ma.type="VideoDescriptionTranscriptSection";var Va=Ma;var Oa=class extends a{constructor(e){super(),this.thumbnail=w.fromResponse(e.thumbnail),this.title=new u(e.title),this.short_byline_text=new u(e.shortBylineText),this.video_count_short_text=new u(e.videoCountShortText),this.endpoint=new v(e.navigationEndpoint),this.thumbnail_width=e.thumbnailWidth,this.aspect_ratio=e.aspectRatio,this.max_lines_title=e.maxLinesTitle,this.max_lines_short_byline_text=e.maxLinesShortBylineText,this.overlay_position=e.overlayPosition}};n(Oa,"StructuredDescriptionPlaylistLockup");Oa.type="StructuredDescriptionPlaylistLockup";var s_=Oa;var Da=class extends a{constructor(e){super(),this.section_title=new u(e.sectionTitle),this.media_lockups=c.parseArray(e.mediaLockups,[s_])}};n(Da,"VideoDescriptionCourseSection");Da.type="VideoDescriptionCourseSection";var r_=Da;var Ba=class extends a{constructor(e){super(),this.title=new u(e.title),this.items=c.parseArray(e.items),Reflect.has(e,"endpoint")&&(this.endpoint=new v(e.endpoint))}get contents(){return this.items}};n(Ba,"ReelShelf");Ba.type="ReelShelf";var Un=Ba;var La=class extends a{constructor(e){super(),this.items=c.parseArray(e.items,[t_,Kh,Yn,i_,r_,Va,Va,Pi,Un])}};n(La,"StructuredDescriptionContent");La.type="StructuredDescriptionContent";var vo=La;var Fa=class extends a{constructor(e){super(),this.header=c.parseItem(e.header,Hh),this.content=c.parseItem(e.content,[Ln,Q,he,Wh,vo,Gh,zh]),this.panel_identifier=e.panelIdentifier,this.identifier=e.identifier?{surface:e.identifier.surface,tag:e.identifier.tag}:void 0,this.target_id=e.targetId,this.visibility=e.visibility}};n(Fa,"EngagementPanelSectionList");Fa.type="EngagementPanelSectionList";var jn=Fa;var Ya=class extends a{constructor(e){super(),this.title=new u(e.title).toString(),this.form_item_entity_key=e.formItemEntityKey,Reflect.has(e,"selectedIcon")&&(this.selected_icon_type=e.selectedIcon.iconType),Reflect.has(e,"selectedCommand")&&(this.endpoint=new v(e.selectedCommand)),this.selected=!!this.endpoint}};n(Ya,"MusicMultiSelectMenuItem");Ya.type="MusicMultiSelectMenuItem";var Pt=Ya;var a_,u_=class{constructor(e,i){var o,s,r,l,p,f;if(a_.set(this,void 0),i&&S(this,a_,i,"f"),this.itag=e.itag,this.mime_type=e.mimeType,this.is_type_otf=e.type==="FORMAT_STREAM_TYPE_OTF",this.bitrate=e.bitrate,this.average_bitrate=e.averageBitrate,this.width=e.width,this.height=e.height,this.init_range=e.initRange?{start:parseInt(e.initRange.start),end:parseInt(e.initRange.end)}:void 0,this.index_range=e.indexRange?{start:parseInt(e.indexRange.start),end:parseInt(e.indexRange.end)}:void 0,this.last_modified=new Date(Math.floor(parseInt(e.lastModified)/1e3)),this.content_length=parseInt(e.contentLength),this.quality=e.quality,this.quality_label=e.qualityLabel,this.fps=e.fps,this.url=e.url,this.cipher=e.cipher,this.signature_cipher=e.signatureCipher,this.audio_quality=e.audioQuality,this.approx_duration_ms=parseInt(e.approxDurationMs),this.audio_sample_rate=parseInt(e.audioSampleRate),this.audio_channels=e.audioChannels,this.loudness_db=e.loudnessDb,this.has_audio=!!e.audioBitrate||!!e.audioQuality,this.has_video=!!e.qualityLabel,this.color_info=e.colorInfo?{primaries:(o=e.colorInfo.primaries)===null||o===void 0?void 0:o.replace("COLOR_PRIMARIES_",""),transfer_characteristics:(s=e.colorInfo.transferCharacteristics)===null||s===void 0?void 0:s.replace("COLOR_TRANSFER_CHARACTERISTICS_",""),matrix_coefficients:(r=e.colorInfo.matrixCoefficients)===null||r===void 0?void 0:r.replace("COLOR_MATRIX_COEFFICIENTS_","")}:void 0,this.has_audio){let h=new URLSearchParams(this.cipher||this.signature_cipher),g=(l=new URLSearchParams(h.get("url")||this.url).get("xtags"))===null||l===void 0?void 0:l.split(":"),T=(p=g==null?void 0:g.find(y=>y.startsWith("acont=")))===null||p===void 0?void 0:p.split("=")[1];this.language=((f=g==null?void 0:g.find(y=>y.startsWith("lang=")))===null||f===void 0?void 0:f.split("=")[1])||null,this.is_dubbed=T==="dubbed",this.is_descriptive=T==="descriptive",this.is_original=T==="original"||!this.is_dubbed&&!this.is_descriptive,Reflect.has(e,"audioTrack")&&(this.audio_track={audio_is_default:e.audioTrack.audioIsDefault,display_name:e.audioTrack.displayName,id:e.audioTrack.id})}}decipher(e){if(!e)throw new x("Cannot decipher format, this session appears to have no valid player.");return e.decipher(this.url,this.signature_cipher,this.cipher,d(this,a_,"f"))}};n(u_,"Format");a_=new WeakMap;var l_=u_;var Ai=class{constructor(e){this.id=e.videoId,this.channel_id=e.channelId,this.title=e.title,this.duration=parseInt(e.lengthSeconds),this.keywords=e.keywords,this.is_owner_viewing=!!e.isOwnerViewing,this.short_description=e.shortDescription,this.thumbnail=w.fromResponse(e.thumbnail),this.allow_ratings=!!e.allowRatings,this.view_count=parseInt(e.viewCount),this.author=e.author,this.is_private=!!e.isPrivate,this.is_live=!!e.isLive,this.is_live_content=!!e.isLiveContent,this.is_upcoming=!!e.isUpcoming,this.is_post_live_dvr=!!e.isPostLiveDvr,this.is_crawlable=!!e.isCrawlable}};n(Ai,"VideoDetails");var Fm={};D(Fm,{AboutChannel:()=>p_,AboutChannelView:()=>d_,AccountChannel:()=>f_,AccountItemSection:()=>h_,AccountItemSectionHeader:()=>m_,AccountSectionList:()=>__,AddBannerToLiveChatCommand:()=>PT,AddChatItemAction:()=>Rv,AddLiveChatTickerItemAction:()=>NT,Alert:()=>Vn,AlertWithButton:()=>Lh,AnalyticsMainAppKeyMetrics:()=>Yy,AnalyticsRoot:()=>Uy,AnalyticsShortsCarouselCard:()=>jy,AnalyticsVideo:()=>S_,AnalyticsVodCarouselCard:()=>Wy,AnchoredSection:()=>G0,AppendContinuationItemsAction:()=>xo,AudioOnlyPlayability:()=>Eh,AuthorCommentBadge:()=>F_,AutomixPreviewVideo:()=>Ri,BackstageImage:()=>I_,BackstagePost:()=>Mi,BackstagePostThread:()=>Gy,BrowseFeedActions:()=>C_,BrowserMediaSession:()=>zy,Button:()=>I,ButtonView:()=>E_,C4TabbedHeader:()=>Vi,CallToActionButton:()=>Ky,Card:()=>$y,CardCollection:()=>Mh,CarouselHeader:()=>M_,CarouselItem:()=>qy,CarouselLockup:()=>n_,Channel:()=>V_,ChannelAboutFullMetadata:()=>Ou,ChannelAgeGate:()=>Xy,ChannelExternalLinkView:()=>c_,ChannelFeaturedContent:()=>Qy,ChannelHeaderLinks:()=>P_,ChannelHeaderLinksView:()=>N_,ChannelMetadata:()=>O_,ChannelMobileHeader:()=>Zy,ChannelOptions:()=>D_,ChannelOwnerEmptyState:()=>ew,ChannelSubMenu:()=>Wu,ChannelTagline:()=>A_,ChannelThumbnailWithLink:()=>tw,ChannelVideoPlayer:()=>iw,Chapter:()=>B_,ChildVideo:()=>ow,ChipCloud:()=>lt,ChipCloudChip:()=>_e,ClipAdState:()=>Uh,ClipCreation:()=>jh,ClipCreationScrubber:()=>Yh,ClipCreationTextInput:()=>Fh,ClipSection:()=>Wh,CollaboratorInfoCardContent:()=>nw,CollageHeroImage:()=>sw,Command:()=>rw,Comment:()=>$n,CommentActionButtons:()=>Hn,CommentDialog:()=>Qw,CommentReplies:()=>K_,CommentReplyDialog:()=>Y_,CommentSimplebox:()=>Q_,CommentThread:()=>Z_,CommentsEntryPointHeader:()=>X_,CommentsEntryPointTeaser:()=>q_,CommentsHeader:()=>qn,CommentsSimplebox:()=>$_,CompactChannel:()=>Zw,CompactLink:()=>Xn,CompactMix:()=>eT,CompactMovie:()=>tT,CompactPlaylist:()=>iT,CompactStation:()=>oT,CompactVideo:()=>Fn,ConfirmDialog:()=>nT,ContentMetadataView:()=>ev,ContentPreviewImageView:()=>Bn,ContinuationItem:()=>he,ConversationBar:()=>sT,CopyLink:()=>tv,CreatePlaylistDialog:()=>Nh,CreatorHeart:()=>k_,CtaGoToCreatorStudio:()=>Hy,DataModelSection:()=>T_,DecoratedPlayerBar:()=>sv,DefaultPromoPanel:()=>rT,DidYouMean:()=>rv,DimChatItemAction:()=>AT,DownloadButton:()=>aT,Dropdown:()=>Mn,DropdownItem:()=>Ph,DynamicTextView:()=>av,Element:()=>es,EmergencyOnebox:()=>uT,EmojiPicker:()=>z_,EmojiPickerCategory:()=>lT,EmojiPickerCategoryButton:()=>cT,EmojiPickerUpsellCategory:()=>dT,EndScreenPlaylist:()=>lv,EndScreenVideo:()=>cv,Endscreen:()=>Vh,EndscreenElement:()=>pT,EngagementPanelSectionList:()=>jn,EngagementPanelTitleHeader:()=>Hh,ExpandableMetadata:()=>Xh,ExpandableTab:()=>ts,ExpandableVideoDescriptionBody:()=>Kh,ExpandedShelfContents:()=>fT,Factoid:()=>Ni,FancyDismissibleDialog:()=>mT,FeedFilterChipBar:()=>pi,FeedNudge:()=>hT,FeedTabbedHeader:()=>dv,FlexibleActionsView:()=>pv,GameCard:()=>$h,GameDetails:()=>_T,Grid:()=>wo,GridChannel:()=>fv,GridHeader:()=>vT,GridMix:()=>xT,GridMovie:()=>gT,GridPlaylist:()=>mv,GridShow:()=>bT,GridVideo:()=>vv,GuideCollapsibleEntry:()=>yT,GuideCollapsibleSectionEntry:()=>wT,GuideDownloadsEntry:()=>TT,GuideEntry:()=>To,GuideSection:()=>is,GuideSubscriptionsSection:()=>xv,HashtagHeader:()=>gv,HashtagTile:()=>ST,HeatMarker:()=>iv,Heatmap:()=>ov,HeroPlaylistThumbnail:()=>IT,HighlightsCarousel:()=>gc,HistorySuggestion:()=>kT,HorizontalCardList:()=>Pi,HorizontalList:()=>qh,HorizontalMovieList:()=>CT,IconLink:()=>yv,IncludingResultsFor:()=>ET,InfoPanelContainer:()=>Tv,InfoPanelContent:()=>wv,InfoRow:()=>o_,InteractiveTabbedHeader:()=>Sv,ItemSection:()=>ve,ItemSectionHeader:()=>Iv,ItemSectionTab:()=>kv,ItemSectionTabbedHeader:()=>Cv,KidsBlocklistPicker:()=>NI,KidsBlocklistPickerItem:()=>fs,KidsCategoriesHeader:()=>z0,KidsCategoryTab:()=>ms,KidsHomeScreen:()=>K0,LikeButton:()=>Ev,LiveChat:()=>Pv,LiveChatActionPanel:()=>Vv,LiveChatAuthorBadge:()=>iS,LiveChatAutoModMessage:()=>RT,LiveChatBanner:()=>Av,LiveChatBannerHeader:()=>Nv,LiveChatBannerPoll:()=>MT,LiveChatDialog:()=>oS,LiveChatHeader:()=>Yv,LiveChatItemList:()=>Uv,LiveChatMembershipItem:()=>VT,LiveChatMessageInput:()=>nS,LiveChatPaidMessage:()=>OT,LiveChatPaidSticker:()=>DT,LiveChatParticipant:()=>jv,LiveChatParticipantsList:()=>Wv,LiveChatPlaceholderItem:()=>BT,LiveChatProductItem:()=>LT,LiveChatRestrictedParticipation:()=>FT,LiveChatTextMessage:()=>YT,LiveChatTickerPaidMessageItem:()=>Mv,LiveChatTickerPaidStickerItem:()=>UT,LiveChatTickerSponsorItem:()=>jT,LiveChatViewerEngagementMessage:()=>WT,MacroMarkersInfoItem:()=>Jh,MacroMarkersList:()=>Gh,MacroMarkersListItem:()=>On,MarkChatItemAsDeletedAction:()=>JT,MarkChatItemsByAuthorAsDeletedAction:()=>GT,Menu:()=>F,MenuNavigationItem:()=>Hv,MenuPopup:()=>sS,MenuServiceItem:()=>Oi,MenuServiceItemDownload:()=>rS,MerchandiseItem:()=>lS,MerchandiseShelf:()=>Kv,Message:()=>Ge,MetadataBadge:()=>ot,MetadataRow:()=>cS,MetadataRowContainer:()=>$v,MetadataRowHeader:()=>dS,MetadataScreen:()=>pS,MicroformatData:()=>qt,Mix:()=>fS,Movie:()=>mS,MovingThumbnail:()=>hS,MultiMarkersPlayerBar:()=>nv,MultiPageMenu:()=>aS,MultiPageMenuNotificationSection:()=>uS,MusicCardShelf:()=>Zv,MusicCardShelfHeaderBasic:()=>qv,MusicCarouselShelf:()=>Pe,MusicCarouselShelfBasicHeader:()=>e0,MusicDescriptionShelf:()=>Io,MusicDetailHeader:()=>ko,MusicDownloadStateBadge:()=>IS,MusicEditablePlaylistDetailHeader:()=>n0,MusicElementHeader:()=>up,MusicHeader:()=>Bi,MusicImmersiveHeader:()=>s0,MusicInlineBadge:()=>Xv,MusicItemThumbnailOverlay:()=>Xt,MusicLargeCardItemCarousel:()=>kS,MusicMenuItemDivider:()=>Jv,MusicMultiRowListItem:()=>t0,MusicMultiSelectMenu:()=>Gv,MusicMultiSelectMenuItem:()=>Pt,MusicNavigationButton:()=>os,MusicPlayButton:()=>Qv,MusicPlaylistShelf:()=>Co,MusicQueue:()=>rs,MusicResponsiveListItem:()=>Di,MusicResponsiveListItemFixedColumn:()=>i0,MusicResponsiveListItemFlexColumn:()=>o0,MusicShelf:()=>be,MusicSideAlignedItem:()=>a0,MusicSortFilterButton:()=>wp,MusicTastebuilderShelf:()=>l0,MusicTastebuilderShelfThumbnail:()=>u0,MusicThumbnail:()=>xt,MusicTwoRowItem:()=>ss,MusicVisualHeader:()=>c0,NavigationEndpoint:()=>v,Notification:()=>d0,OpenPopupAction:()=>Ah,PageHeader:()=>Li,PageHeaderView:()=>p0,PageIntroduction:()=>f0,PdgCommentChip:()=>U_,PivotButton:()=>m0,PlayerAnnotationsExpanded:()=>Oh,PlayerCaptionsTracklist:()=>Dh,PlayerControlsOverlay:()=>CS,PlayerErrorMessage:()=>ES,PlayerLegacyDesktopYpcOffer:()=>PS,PlayerLegacyDesktopYpcTrailer:()=>Bp,PlayerLiveStoryboardSpec:()=>Bh,PlayerMicroformat:()=>Vt,PlayerOverflow:()=>h0,PlayerOverlay:()=>Fi,PlayerOverlayAutoplay:()=>v0,PlayerStoryboardSpec:()=>mo,Playlist:()=>$t,PlaylistCustomThumbnail:()=>Qn,PlaylistHeader:()=>g0,PlaylistInfoCardContent:()=>NS,PlaylistMetadata:()=>b0,PlaylistPanel:()=>Qt,PlaylistPanelVideo:()=>fi,PlaylistPanelVideoWrapper:()=>r0,PlaylistSidebar:()=>AS,PlaylistSidebarPrimaryInfo:()=>y0,PlaylistSidebarSecondaryInfo:()=>w0,PlaylistVideo:()=>T0,PlaylistVideoList:()=>RS,PlaylistVideoThumbnail:()=>Zn,Poll:()=>MS,PollHeader:()=>HT,Post:()=>S0,PostMultiImage:()=>VS,ProductList:()=>zh,ProductListHeader:()=>OS,ProductListItem:()=>DS,ProfileColumn:()=>BS,ProfileColumnStats:()=>LS,ProfileColumnStatsEntry:()=>FS,ProfileColumnUserInfo:()=>YS,Quiz:()=>US,RecognitionShelf:()=>jS,ReelItem:()=>I0,ReelPlayerHeader:()=>k0,ReelPlayerOverlay:()=>WS,ReelShelf:()=>Un,RelatedChipCloud:()=>C0,RemoveBannerForLiveChatCommand:()=>zT,RemoveChatItemAction:()=>KT,RemoveChatItemByAuthorAction:()=>$T,ReplaceChatItemAction:()=>qT,ReplayChatItemAction:()=>XT,RichGrid:()=>Yi,RichItem:()=>HS,RichListHeader:()=>JS,RichMetadata:()=>_f,RichMetadataRow:()=>xf,RichSection:()=>GS,RichShelf:()=>E0,SearchBox:()=>zS,SearchFilter:()=>P0,SearchFilterGroup:()=>as,SearchFilterOptionsDialog:()=>KS,SearchHeader:()=>N0,SearchRefinementCard:()=>ho,SearchSubMenu:()=>A0,SearchSuggestion:()=>bv,SearchSuggestionsSection:()=>R0,SecondarySearchContainer:()=>$S,SectionList:()=>Q,SegmentedLikeDislikeButton:()=>Eo,SettingBoolean:()=>qS,SettingsCheckbox:()=>M0,SettingsOptions:()=>ls,SettingsSidebar:()=>V0,SettingsSwitch:()=>us,SharedPost:()=>O0,Shelf:()=>cs,ShowCustomThumbnail:()=>hv,ShowLiveChatActionPanelAction:()=>QT,ShowLiveChatDialogAction:()=>ZT,ShowLiveChatTooltipCommand:()=>eS,ShowingResultsFor:()=>D0,SimpleCardContent:()=>XS,SimpleCardTeaser:()=>QS,SimpleMenuHeader:()=>zv,SimpleTextSection:()=>ZS,SingleActionEmergencySupport:()=>eI,SingleColumnBrowseResults:()=>Zt,SingleColumnMusicWatchNextResults:()=>tI,SingleHeroImage:()=>iI,SlimOwner:()=>oI,SlimVideoMetadata:()=>B0,SortFilterSubMenu:()=>Nt,SponsorCommentBadge:()=>j_,StatRow:()=>Jy,StructuredDescriptionContent:()=>vo,StructuredDescriptionPlaylistLockup:()=>s_,SubFeedOption:()=>L0,SubFeedSelector:()=>nI,SubscribeButton:()=>Je,SubscriptionNotificationToggleButton:()=>R_,Tab:()=>xe,Tabbed:()=>sI,TabbedSearchResults:()=>F0,TextHeader:()=>rI,ThumbnailLandscapePortrait:()=>aI,ThumbnailOverlayBottomPanel:()=>_v,ThumbnailOverlayEndorsement:()=>uI,ThumbnailOverlayHoverText:()=>lI,ThumbnailOverlayInlineUnplayable:()=>cI,ThumbnailOverlayLoadingPreview:()=>dI,ThumbnailOverlayNowPlaying:()=>pI,ThumbnailOverlayPinking:()=>fI,ThumbnailOverlayPlaybackStatus:()=>mI,ThumbnailOverlayResumePlayback:()=>hI,ThumbnailOverlaySidePanel:()=>_I,ThumbnailOverlayTimeStatus:()=>_o,ThumbnailOverlayToggleButton:()=>vI,TimedMarkerDecoration:()=>xI,TitleAndButtonListHeader:()=>gI,ToggleButton:()=>Ve,ToggleMenuServiceItem:()=>bI,Tooltip:()=>yI,TopicChannelDetails:()=>wI,Transcript:()=>Wn,TranscriptFooter:()=>v_,TranscriptSearchBox:()=>x_,TranscriptSearchPanel:()=>w_,TranscriptSectionHeader:()=>g_,TranscriptSegment:()=>b_,TranscriptSegmentList:()=>y_,TwoColumnBrowseResults:()=>ei,TwoColumnSearchResults:()=>Y0,TwoColumnWatchNextResults:()=>ds,UniversalWatchCard:()=>j0,UpdateDateTextAction:()