"use strict"; /* eslint-disable */ var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // dist/src/platform/node.js var node_exports = {}; __export(node_exports, { Actions: () => Actions_default, AppendContinuationItemsAction: () => AppendContinuationItemsAction_default, ClientType: () => ClientType, Clients: () => clients_exports, Constants: () => Constants_exports, Continuation: () => Continuation, ContinuationCommand: () => ContinuationCommand, Endpoints: () => endpoints_exports, EventEmitter: () => EventEmitterLike_default, FormatUtils: () => FormatUtils_exports, Generator: () => generator_exports, GridContinuation: () => GridContinuation, HTTPClient: () => HTTPClient_default, Helpers: () => helpers_exports, Innertube: () => Innertube_default, ItemSectionContinuation: () => ItemSectionContinuation, LiveChatContinuation: () => LiveChatContinuation, Log: () => Log_default, Managers: () => managers_exports, Misc: () => misc_exports, Mixins: () => mixins_exports, MusicPlaylistShelfContinuation: () => MusicPlaylistShelfContinuation, MusicShelfContinuation: () => MusicShelfContinuation, NavigateAction: () => NavigateAction, OAuth: () => OAuth_default, Parser: () => parser_exports, Platform: () => Platform, Player: () => Player_default, PlaylistPanelContinuation: () => PlaylistPanelContinuation, Proto: () => proto_exports, ReloadContinuationItemsCommand: () => ReloadContinuationItemsCommand, SectionListContinuation: () => SectionListContinuation, Session: () => Session_default, ShowMiniplayerCommand: () => ShowMiniplayerCommand, Types: () => types_exports, UniversalCache: () => Cache_default, Utils: () => Utils_exports, YT: () => youtube_exports, YTKids: () => ytkids_exports, YTMusic: () => ytmusic_exports, YTNodes: () => nodes_exports, YTShorts: () => ytshorts_exports, default: () => node_default }); module.exports = __toCommonJS(node_exports); var import_tslib68 = require("tslib"); var import_web = require("stream/web"); var import_undici = require("undici"); // dist/src/utils/Utils.js var Utils_exports = {}; __export(Utils_exports, { ChannelError: () => ChannelError, InnertubeError: () => InnertubeError, MissingParamError: () => MissingParamError, OAuthError: () => OAuthError, ParsingError: () => ParsingError, Platform: () => Platform, PlayerError: () => PlayerError, SessionError: () => SessionError, base64ToU8: () => base64ToU8, concatMemos: () => concatMemos, debugFetch: () => debugFetch, deepCompare: () => deepCompare, escapeStringRegexp: () => escapeStringRegexp, generateRandomString: () => generateRandomString, generateSidAuth: () => generateSidAuth, getRandomUserAgent: () => getRandomUserAgent, getStringBetweenStrings: () => getStringBetweenStrings, hasKeys: () => hasKeys, isTextRun: () => isTextRun, streamToIterable: () => streamToIterable, throwIfMissing: () => throwIfMissing, timeToSeconds: () => timeToSeconds, u8ToBase64: () => u8ToBase64 }); var import_tslib55 = require("tslib"); // dist/src/parser/helpers.js var helpers_exports = {}; __export(helpers_exports, { Maybe: () => Maybe, Memo: () => Memo, SuperParsedResult: () => SuperParsedResult, YTNode: () => YTNode, observe: () => observe }); var import_tslib = require("tslib"); // dist/src/utils/Log.js var _a; var Log = class { static doLog(level, tag, args) { if (!this.log_map_[level] || !this.log_level_.includes(level)) return; const tags = [`[${this.YTJS_TAG}]`]; if (tag) tags.push(`[${tag}]`); this.log_map_[level](`${tags.join("")}:`, ...args || []); } static setLevel(...args) { this.log_level_ = args; } }; __name(Log, "Log"); _a = Log; Log.YTJS_TAG = "YOUTUBEJS"; Log.Level = { NONE: 0, ERROR: 1, WARNING: 2, INFO: 3, DEBUG: 4 }; Log.log_map_ = { [Log.Level.ERROR]: (...args) => console.error(...args), [Log.Level.WARNING]: (...args) => console.warn(...args), [Log.Level.INFO]: (...args) => console.info(...args), [Log.Level.DEBUG]: (...args) => console.debug(...args) }; Log.log_level_ = [Log.Level.WARNING]; Log.one_time_warnings_issued_ = /* @__PURE__ */ new Set(); Log.warnOnce = (id, ...args) => { if (_a.one_time_warnings_issued_.has(id)) return; _a.doLog(Log.Level.WARNING, id, args); _a.one_time_warnings_issued_.add(id); }; Log.warn = (tag, ...args) => _a.doLog(Log.Level.WARNING, tag, args); Log.error = (tag, ...args) => _a.doLog(Log.Level.ERROR, tag, args); Log.info = (tag, ...args) => _a.doLog(Log.Level.INFO, tag, args); Log.debug = (tag, ...args) => _a.doLog(Log.Level.DEBUG, tag, args); var Log_default = Log; // dist/src/parser/helpers.js var _YTNode_instances; var _YTNode_is; var _Maybe_instances; var _Maybe_TAG; var _Maybe_value; var _Maybe_checkPrimative; var _Maybe_assertPrimative; var _SuperParsedResult_result; var isObserved = Symbol("ObservedArray.isObserved"); var YTNode = class { constructor() { _YTNode_instances.add(this); this.type = this.constructor.type; } is(...types) { return types.some((type) => (0, import_tslib.__classPrivateFieldGet)(this, _YTNode_instances, "m", _YTNode_is).call(this, type)); } as(...types) { if (!this.is(...types)) { throw new ParsingError(`Cannot cast ${this.type} to one of ${types.map((t) => t.type).join(", ")}`); } return this; } hasKey(key) { return Reflect.has(this, key); } key(key) { if (!this.hasKey(key)) { throw new ParsingError(`Missing key ${key}`); } return new Maybe(this[key]); } }; __name(YTNode, "YTNode"); _YTNode_instances = /* @__PURE__ */ new WeakSet(), _YTNode_is = /* @__PURE__ */ __name(function _YTNode_is2(type) { return this.type === type.type; }, "_YTNode_is"); YTNode.type = "YTNode"; var Maybe = class { constructor(value) { _Maybe_instances.add(this); _Maybe_TAG.set(this, "Maybe"); _Maybe_value.set(this, void 0); (0, import_tslib.__classPrivateFieldSet)(this, _Maybe_value, value, "f"); } get typeof() { return typeof (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); } string() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "string"); } isString() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "string"); } number() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "number"); } isNumber() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "number"); } bigint() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "bigint"); } isBigint() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "bigint"); } boolean() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "boolean"); } isBoolean() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "boolean"); } symbol() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "symbol"); } isSymbol() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "symbol"); } undefined() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "undefined"); } isUndefined() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "undefined"); } null() { if ((0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f") !== null) throw new TypeError(`Expected null, got ${typeof (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f")}`); return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); } isNull() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f") === null; } object() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "object"); } isObject() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "object"); } function() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "function"); } isFunction() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "function"); } array() { if (!Array.isArray((0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"))) { throw new TypeError(`Expected array, got ${typeof (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f")}`); } return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); } arrayOfMaybe() { const arrayProps = []; return new Proxy(this.array(), { get(target, prop) { if (Reflect.has(arrayProps, prop)) { return Reflect.get(target, prop); } return new Maybe(Reflect.get(target, prop)); } }); } isArray() { return Array.isArray((0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f")); } node() { if (!((0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f") instanceof YTNode)) { throw new TypeError(`Expected YTNode, got ${(0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f").constructor.name}`); } return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); } isNode() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f") instanceof YTNode; } nodeOfType(...types) { return this.node().as(...types); } isNodeOfType(...types) { return this.isNode() && this.node().is(...types); } observed() { if (!this.isObserved()) { throw new TypeError(`Expected ObservedArray, got ${typeof (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f")}`); } return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); } isObserved() { var _a4; return (_a4 = (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f")) === null || _a4 === void 0 ? void 0 : _a4[isObserved]; } parsed() { if (!((0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f") instanceof SuperParsedResult)) { throw new TypeError(`Expected SuperParsedResult, got ${typeof (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f")}`); } return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); } isParsed() { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f") instanceof SuperParsedResult; } any() { Log_default.warn((0, import_tslib.__classPrivateFieldGet)(this, _Maybe_TAG, "f"), "This call is not meant to be used outside of debugging. Please use the specific type getter instead."); return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); } instanceof(type) { if (!this.isInstanceof(type)) { throw new TypeError(`Expected instance of ${type.name}, got ${(0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f").constructor.name}`); } return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); } isInstanceof(type) { return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f") instanceof type; } }; __name(Maybe, "Maybe"); _Maybe_TAG = /* @__PURE__ */ new WeakMap(), _Maybe_value = /* @__PURE__ */ new WeakMap(), _Maybe_instances = /* @__PURE__ */ new WeakSet(), _Maybe_checkPrimative = /* @__PURE__ */ __name(function _Maybe_checkPrimative2(type) { if (typeof (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f") !== type) { return false; } return true; }, "_Maybe_checkPrimative"), _Maybe_assertPrimative = /* @__PURE__ */ __name(function _Maybe_assertPrimative2(type) { if (!(0, import_tslib.__classPrivateFieldGet)(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, type)) { throw new TypeError(`Expected ${type}, got ${this.typeof}`); } return (0, import_tslib.__classPrivateFieldGet)(this, _Maybe_value, "f"); }, "_Maybe_assertPrimative"); var SuperParsedResult = class { constructor(result) { _SuperParsedResult_result.set(this, void 0); (0, import_tslib.__classPrivateFieldSet)(this, _SuperParsedResult_result, result, "f"); } get is_null() { return (0, import_tslib.__classPrivateFieldGet)(this, _SuperParsedResult_result, "f") === null; } get is_array() { return !this.is_null && Array.isArray((0, import_tslib.__classPrivateFieldGet)(this, _SuperParsedResult_result, "f")); } get is_node() { return !this.is_array; } array() { if (!this.is_array) { throw new TypeError("Expected an array, got a node"); } return (0, import_tslib.__classPrivateFieldGet)(this, _SuperParsedResult_result, "f"); } item() { if (!this.is_node) { throw new TypeError("Expected a node, got an array"); } return (0, import_tslib.__classPrivateFieldGet)(this, _SuperParsedResult_result, "f"); } }; __name(SuperParsedResult, "SuperParsedResult"); _SuperParsedResult_result = /* @__PURE__ */ new WeakMap(); function observe(obj) { return new Proxy(obj, { get(target, prop) { if (prop == "get") { return (rule, del_item) => target.find((obj2, index) => { const match = deepCompare(rule, obj2); if (match && del_item) { target.splice(index, 1); } return match; }); } if (prop == isObserved) { return true; } if (prop == "getAll") { return (rule, del_items) => target.filter((obj2, index) => { const match = deepCompare(rule, obj2); if (match && del_items) { target.splice(index, 1); } return match; }); } if (prop == "matchCondition") { return (condition) => target.find((obj2) => { return condition(obj2); }); } if (prop == "filterType") { return (...types) => { return observe(target.filter((node) => { if (node.is(...types)) return true; return false; })); }; } if (prop == "firstOfType") { return (...types) => { return target.find((node) => { if (node.is(...types)) return true; return false; }); }; } if (prop == "first") { return () => target[0]; } if (prop == "as") { return (...types) => { return observe(target.map((node) => { if (node.is(...types)) return node; throw new ParsingError(`Expected node of any type ${types.map((type) => type.type).join(", ")}, got ${node.type}`); })); }; } if (prop == "remove") { return (index) => target.splice(index, 1); } return Reflect.get(target, prop); } }); } __name(observe, "observe"); var Memo = class extends Map { getType(...types) { types = types.flat(); return observe(types.flatMap((type) => this.get(type.type) || [])); } }; __name(Memo, "Memo"); // dist/src/parser/misc.js var misc_exports = {}; __export(misc_exports, { Author: () => Author, ChildElement: () => ChildElement_default, EmojiRun: () => EmojiRun, Format: () => Format_default, Text: () => Text2, TextRun: () => TextRun, Thumbnail: () => Thumbnail, VideoDetails: () => VideoDetails }); // dist/src/utils/Constants.js var Constants_exports = {}; __export(Constants_exports, { CLIENTS: () => CLIENTS, INNERTUBE_HEADERS_BASE: () => INNERTUBE_HEADERS_BASE, OAUTH: () => OAUTH, STREAM_HEADERS: () => STREAM_HEADERS, URLS: () => URLS }); var URLS = 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/" }) }); var OAUTH = 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: /