/*! For license information please see hls.js.LICENSE.txt */
!function hy(py) {
    const my = this;
    var e, t;
    e = this,
    t = function() {
        "use strict";
        var he, Q, K, e = e => e && e.Math === Math && e, l = e("object" == typeof globalThis && globalThis) || e("object" == typeof window && window) || e("object" == typeof my && my) || e("object" == typeof global && global) || Function("return this")();
        class b extends Error {
            constructor(e, t, i, r, n, a) {
                super(n),
                this.type = e,
                this.details = t,
                this.fatal = i,
                this.response = r,
                this.handled = !1,
                a && (this.stack = a),
                n && (this._message = n)
            }
            get message() {
                return this._message || (this._message = this.constructor.name + ` code=` + this.response),
                this._message
            }
        }
        class pe extends b {
            constructor(e, t, i, r, n) {
                super(e, t, i, r, n),
                this.response = r
            }
        }
        class d extends b {
            constructor(e, t) {
                super(he.NETWORK_ERROR, Q.CERT_LOAD_ERROR, !1, e, t)
            }
        }
        const H = {
            PlaylistNotReceived: -12884,
            CryptResponseReceivedSlowly: -16833,
            LivePlaylistUpdateError: -12888,
            NoResponseFromMediaRequest: -12889,
            IncompatibleAsset: -12927,
            CorruptStream: -16041,
            InternalError: -12645,
            CantSwitchInTime: -12644,
            VideoDecoderBadDataErr: -12909,
            InsufficientDataAvailable: -12928,
            AllocationFailed: -12862,
            PlaylistErrorMissingEXTM3U: -12269,
            PlaylistErrorInvalidEntry: -12264,
            PlaylistErrorBadTargetDuration: -12271,
            NoValidAlternates: -12925,
            FormatError: -12642,
            ContentHasGap: -15419,
            UnsupportedKeySystemError: -6e4,
            EmptyLoadSourceError: -60001,
            UndefinedItemIdError: -60002,
            ManifestParseError: -60003,
            DemuxWorkerError: -60004,
            DecryptWorkerError: -60005,
            OutOfRangeSeekError: -60006,
            ExceptionInKeyLoadError: -60007,
            FragmentAbortError: -60008,
            ManifestTimeoutError: -60009,
            PlaylistTimeoutError: -60010,
            FragmentTimeoutError: -60011,
            IncompleteSessionData: -60012,
            SessionDataLoadTimeout: -60013,
            FailedDemuxerSanityCheck: -60014,
            InvalidADTSSamplingIndex: -60015,
            DemuxerNotFound: -60016,
            InvalidInitTimestamp: -60017,
            NoAVSamplesFound: -60018,
            NoTSSyncByteFound: -60019,
            PESDidNotStartWithADTS: -60020,
            NoADTSHeaderInPES: -60021,
            InvalidDolbyAudioMagic: -60022,
            FailedToAllocateVideoMdat: -60023,
            FailedToAllocateAudioMdat: -60024,
            InsufficientEC3Data: -60025,
            InvalidEC3Magic: -60026,
            ReservedStreamType: -60027,
            InsufficientAC3Data: -60028,
            InvalidAC3Magic: -60029,
            InvalidAC3SamplingRateCode: -60030,
            LivePlaylistTooFar: -60031,
            XhrError: -60032,
            UnsupportedMediaCodec: -60033,
            FilterOutBasedOnCaps: -60034,
            UnsupportedVideoDynamicRange: -60035,
            UnsupportedKeySystemAccess: -60036,
            SourceBufferRemoveError: -60037,
            SourceBufferAbortError: -60038,
            SourceBufferUpdatingError: -60039,
            ExceptionInLegacyEventHandler: -60040,
            ExceptionInKeyRequest: -60041,
            NoValidFirstAlternate: -60042,
            MixedLiveSyncDurationConfig: -60043,
            InvalidRequiredStartDuration: -60044,
            InvalidLoadImageIframe: -60045,
            NoSegmentDetailsEntity: -60046,
            NoSegmentDetails: -60047,
            InvalidMediaOptionType: -60048,
            IFrameVariantNotFound: -60049,
            MdatNotFound: -60050,
            DemuxRemuxProbeNotFound: -60051,
            ExpGolombNoAvailableBytes: -60052,
            createRPCWorkerNotBundled: -60053,
            createRPCServiceMissingFallbacks: -60054,
            RPCInlineInvokeCommandNotFound: -60055,
            RPCWorkerCommandNotFound: -60056,
            JSAESDecryptInvalidKey: -60057,
            InvalidAudioCodec: -60058,
            MismatchCodecFamily: -60059,
            TopologicalSortCycle: -60060,
            RankIdentifierComparisonError: -60061,
            URLParseError: -60062,
            NoIframeFragmentToPrefetch: -60063,
            NoVariantMediaOptionToPrefetch: -60064,
            NoFragmentFoundAtSearchPositionInPlaylist: -60065,
            WebVTTMalformedXTIMESTAMPMAP: -60066,
            PlayRejected: -60067,
            PlaylistErrorInvalidEXTXDEFINE: -61e3,
            PlaylistErrorMissingImportReference: -61001,
            PlaylistErrorInvalidSERVERURI: -61002,
            PlaylistErrorInvalidPATHWAYID: -61003,
            PlaylistErrorInvalidSCORE: -61004,
            KeySystemFailedToUpdateSession: -62e3,
            KeySystemFailedToGenerateLicenseRenewal: -62001,
            KeySystemFailedToGenerateLicenseRequest: -62002,
            KeySystemAbort: -62003,
            KeySystemUnexpectedStateTransition: -62004,
            KeySystemUnexpectedState: -62005,
            KeySystemCDMUnknownError: -62006,
            KeySystemRequestTimedOut: -62007,
            KeySystemUnexpectedMETHOD: -62008,
            KeySystemUnmatchedString: -62009,
            KeySystemInternalError: -62010,
            KeySystemOutputRestricted: -62011,
            KeySystemSetupError: -62012,
            KeySystemFailedToInitialize: -62013,
            KeySystemFailedToCreateSession: -62014,
            KeySystemUndefinedNavigator: -62015,
            KeySystemNoKeySystemsToTry: -62016,
            KeySystemNoConstructor: -62017,
            KeySystemNoKeySystemAccess: -62018,
            KeySystemCertificateLoadError: -62019,
            KeySystemFailedToReleaseLicense: -62020,
            KeySystemRequestMediaKeySystemAccessError: -62021,
            KeySystemSetServerCertificateError: -62022,
            KeySystemCouldNotCreateMediaKeySession: -62023,
            KeySystemCouldNotSetMediaKeys: -62024,
            KeySystemUndefinedChallenge: -62025,
            SBEmptyMediaSource: -63e3,
            SBNullCurrentInitSegmentInfo: -63001,
            SBNullCurrentSBEntity: -63002,
            SBNullSourceBuffer: -63003,
            SBNotInitialized: -63004
        };
        (e = he = he || {}).NETWORK_ERROR = "networkError",
        e.MEDIA_ERROR = "mediaError",
        e.MUX_ERROR = "muxError",
        e.KEY_SYSTEM_ERROR = "keySystemError",
        e.OTHER_ERROR = "otherError",
        (e = Q = Q || {}).MANIFEST_LOAD_ERROR = "manifestLoadError",
        e.MANIFEST_LOAD_TIMEOUT = "manifestLoadTimeOut",
        e.MANIFEST_PARSING_ERROR = "manifestParsingError",
        e.MANIFEST_INCOMPATIBLE_CODECS_ERROR = "manifestIncompatibleCodecsError",
        e.MANIFEST_INCOMPATIBLE_VIDEO_RANGE_ERROR = "manifestIncompatibleVideoRangeError",
        e.LEVEL_LOAD_ERROR = "levelLoadError",
        e.LEVEL_LOAD_TIMEOUT = "levelLoadTimeOut",
        e.LEVEL_SWITCH_ERROR = "levelSwitchError",
        e.AUDIO_TRACK_LOAD_ERROR = "audioTrackLoadError",
        e.AUDIO_TRACK_LOAD_TIMEOUT = "audioTrackLoadTimeOut",
        e.SUBTITLE_TRACK_LOAD_ERROR = "subtitleTrackLoadError",
        e.SUBTITLE_TRACK_LOAD_TIMEOUT = "subtitleTrackLoadTimeout",
        e.FRAG_LOAD_ERROR = "fragLoadError",
        e.FRAG_LOOP_LOADING_ERROR = "fragLoopLoadingError",
        e.FRAG_LOAD_TIMEOUT = "fragLoadTimeOut",
        e.FRAG_DECRYPT_ERROR = "fragDecryptError",
        e.FRAG_PARSING_ERROR = "fragParsingError",
        e.FRAG_ABORT_ERROR = "fragAbortError",
        e.REMUX_ALLOC_ERROR = "remuxAllocError",
        e.BUFFER_ADD_CODEC_ERROR = "bufferAddCodecError",
        e.BUFFER_APPEND_ERROR = "bufferAppendError",
        e.BUFFER_APPENDING_ERROR = "bufferAppendingError",
        e.BUFFER_STALLED_ERROR = "bufferStalledError",
        e.BUFFER_FULL_ERROR = "bufferFullError",
        e.BUFFER_SEEK_OVER_HOLE = "bufferSeekOverHole",
        e.BUFFER_NUDGE_ON_STALL = "bufferNudgeOnStall",
        e.SOURCE_BUFFER_ERROR = "sourceBufferError",
        e.INTERNAL_EXCEPTION = "internalException",
        e.WEBVTT_EXCEPTION = "webVTTException",
        e.KEY_LOAD_ERROR = "keyLoadError",
        e.KEY_LOAD_TIMEOUT = "keyLoadTimeOut",
        e.KEY_SYSTEM_GENERIC_ERROR = "keySystemGenericError",
        e.CERT_LOAD_ERROR = "certificateLoadError",
        e.CERT_LOAD_TIMEOUT = "certificateLoadTimeOut",
        e.SESSION_DATA_LOAD_ERROR = "sessionDataLoadError",
        e.SESSION_DATA_LOAD_TIMEOUT = "sessionDataLoadTimeOut",
        e.STEERING_MANIFEST_LOAD_ERROR = "steeringManifestLoadError",
        e.STEERING_MANIFEST_LOAD_TIMEOUT = "steeringManifestLoadTimeOut",
        e.STEERING_MANIFEST_PARSING_ERROR = "steeringManifestParsingError",
        e.INTERSTITIAL_ASSET_LIST_LOAD_ERROR = "interstitialAssetListLoadError",
        e.INTERSTITIAL_ASSET_LIST_LOAD_TIMEOUT = "interstitialAssetListLoadTimeout",
        e.INTERSTITIAL_ASSET_LIST_PARSING_ERROR = "interstitialAssetListParsingError",
        e.UNKNOWN = "";
        class j extends b {
            constructor(e, t, i, r) {
                super(he.OTHER_ERROR, Q.INTERNAL_EXCEPTION, e, t, i, r)
            }
        }
        class u {
            constructor() {
                this.t = [],
                this.o = [],
                this.l = [],
                this.h = null,
                this.p = null,
                this.m = null,
                this.g = null,
                this.t = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54],
                this.o = [new Uint32Array(256), new Uint32Array(256), new Uint32Array(256), new Uint32Array(256)],
                this.l = [new Uint32Array(256), new Uint32Array(256), new Uint32Array(256), new Uint32Array(256)],
                this.S = new Uint32Array(256),
                this.T = new Uint32Array(256),
                this.I = new Uint32Array(0),
                this.O()
            }
            M(e) {
                var t = new DataView(e)
                  , i = Math.floor(t.byteLength / 4)
                  , r = new Uint32Array(i);
                for (let e = 0; e < i; e++)
                    r[e] = t.getUint32(4 * e);
                return r
            }
            O() {
                const e = this["S"]
                  , t = this["T"]
                  , i = this["o"]
                  , r = i[0]
                  , n = i[1]
                  , a = i[2]
                  , s = i[3]
                  , o = this["l"]
                  , l = o[0]
                  , d = o[1]
                  , u = o[2]
                  , c = o[3]
                  , h = new Uint32Array(256);
                let p = 0
                  , m = 0
                  , f = 0;
                for (f = 0; f < 256; f++)
                    h[f] = f < 128 ? f << 1 : f << 1 ^ 283;
                for (f = 0; f < 256; f++) {
                    var g = (g = m ^ m << 1 ^ m << 2 ^ m << 3 ^ m << 4) >>> 8 ^ 255 & g ^ 99;
                    e[p] = g,
                    t[g] = p;
                    const o = h[p]
                      , f = h[o]
                      , v = h[f];
                    var y = 257 * h[g] ^ 16843008 * g;
                    r[p] = y << 24 | y >>> 8,
                    n[p] = y << 16 | y >>> 16,
                    a[p] = y << 8 | y >>> 24,
                    s[p] = y,
                    y = 16843009 * v ^ 65537 * f ^ 257 * o ^ 16843008 * p,
                    l[g] = y << 24 | y >>> 8,
                    d[g] = y << 16 | y >>> 16,
                    u[g] = y << 8 | y >>> 24,
                    c[g] = y,
                    p ? (p = o ^ h[h[h[v ^ o]]],
                    m ^= h[h[m]]) : p = m = 1
                }
            }
            expandKey(n) {
                var a = this.M(n);
                let e = !0
                  , t = 0;
                for (; t < a.length && e; )
                    e = a[t] === this.I[t],
                    t++;
                if (!e) {
                    this.I = a;
                    var s = this.h = a.length;
                    if (4 !== s && 6 !== s && 8 !== s)
                        throw new j(!1,H.JSAESDecryptInvalidKey,"Invalid aes key size=" + s);
                    var o = this.p = 4 * (s + 6 + 1);
                    let e, t;
                    var l = this.m = new Uint32Array(o)
                      , d = this.g = new Uint32Array(o)
                      , u = this.S
                      , c = this["t"]
                      , n = this["l"]
                      , h = n[0]
                      , p = n[1]
                      , m = n[2]
                      , f = n[3];
                    let i, r;
                    for (e = 0; e < o; e++)
                        e < s ? i = l[e] = a[e] : (r = i) && (e % s == 0 ? (r = u[(r = r << 8 | r >>> 24) >>> 24] << 24 | u[r >>> 16 & 255] << 16 | u[r >>> 8 & 255] << 8 | u[255 & r],
                        r ^= c[e / s | 0] << 24) : 6 < s && e % s == 4 && (r = u[r >>> 24] << 24 | u[r >>> 16 & 255] << 16 | u[r >>> 8 & 255] << 8 | u[255 & r]),
                        l[e] = i = (l[e - s] ^ r) >>> 0);
                    for (t = 0; t < o; t++)
                        e = o - t,
                        r = 3 & t ? l[e] : l[e - 4],
                        d[t] = t < 4 || e <= 4 ? r : h[u[r >>> 24]] ^ p[u[r >>> 16 & 255]] ^ m[u[r >>> 8 & 255]] ^ f[u[255 & r]],
                        d[t] = d[t] >>> 0
                }
            }
            A(e) {
                return e << 24 | (65280 & e) << 8 | (16711680 & e) >> 8 | e >>> 24
            }
            decrypt(e, t, i) {
                var r, n, a = this.h ? this.h + 6 : 0, s = this["g"], o = this.T, l = this["l"], d = l[0], u = l[1], c = l[2], h = l[3], l = this.M(i);
                let p = l[0]
                  , m = l[1]
                  , f = l[2]
                  , g = l[3];
                var y = new Int32Array(e)
                  , v = new Int32Array(y.length);
                let S, I, b, T, E, A, O, R, w, P, M, C, k, L;
                for (var N = this.A; t < y.length; ) {
                    for (w = N(y[t]),
                    P = N(y[t + 1]),
                    M = N(y[t + 2]),
                    C = N(y[t + 3]),
                    E = w ^ (null != (n = null == s ? void 0 : s[0]) ? n : 0),
                    A = C ^ (null != (n = null == s ? void 0 : s[1]) ? n : 0),
                    O = M ^ (null != (n = null == s ? void 0 : s[2]) ? n : 0),
                    R = P ^ (null != (n = null == s ? void 0 : s[3]) ? n : 0),
                    k = 4,
                    L = 1; L < a; L++)
                        S = d[E >>> 24] ^ u[A >> 16 & 255] ^ c[O >> 8 & 255] ^ h[255 & R] ^ (null != (r = null == s ? void 0 : s[k]) ? r : 0),
                        I = d[A >>> 24] ^ u[O >> 16 & 255] ^ c[R >> 8 & 255] ^ h[255 & E] ^ (null != (r = null == s ? void 0 : s[k + 1]) ? r : 0),
                        b = d[O >>> 24] ^ u[R >> 16 & 255] ^ c[E >> 8 & 255] ^ h[255 & A] ^ (null != (r = null == s ? void 0 : s[k + 2]) ? r : 0),
                        T = d[R >>> 24] ^ u[E >> 16 & 255] ^ c[A >> 8 & 255] ^ h[255 & O] ^ (null != (r = null == s ? void 0 : s[k + 3]) ? r : 0),
                        E = S,
                        A = I,
                        O = b,
                        R = T,
                        k += 4;
                    S = o[E >>> 24] << 24 ^ o[A >> 16 & 255] << 16 ^ o[O >> 8 & 255] << 8 ^ o[255 & R] ^ (null != (n = null == s ? void 0 : s[k]) ? n : 0),
                    I = o[A >>> 24] << 24 ^ o[O >> 16 & 255] << 16 ^ o[R >> 8 & 255] << 8 ^ o[255 & E] ^ (null != (n = null == s ? void 0 : s[k + 1]) ? n : 0),
                    b = o[O >>> 24] << 24 ^ o[R >> 16 & 255] << 16 ^ o[E >> 8 & 255] << 8 ^ o[255 & A] ^ (null != (n = null == s ? void 0 : s[k + 2]) ? n : 0),
                    T = o[R >>> 24] << 24 ^ o[E >> 16 & 255] << 16 ^ o[A >> 8 & 255] << 8 ^ o[255 & O] ^ (null != (n = null == s ? void 0 : s[k + 3]) ? n : 0),
                    k += 3,
                    v[t] = N(S ^ p),
                    v[t + 1] = N(T ^ m),
                    v[t + 2] = N(b ^ f),
                    v[t + 3] = N(I ^ g),
                    p = w,
                    m = P,
                    f = M,
                    g = C,
                    t += 4
                }
                return v.buffer
            }
            destroy() {
                this.I = new Uint32Array,
                this.h = null,
                this.p = null,
                this.S = new Uint32Array,
                this.T = new Uint32Array,
                this.o = [],
                this.l = [],
                this.m = null,
                this.g = null,
                this.t = []
            }
        }
        class n {
            constructor(e, t) {
                this.N = e,
                this.R = t,
                this.decrypt = (r, n, a, s, o) => t => {
                    const i = l.crypto;
                    if (null != o && o.useJSCrypto || null == i || !i.subtle) {
                        const a = new u;
                        var e;
                        a.expandKey(r);
                        const i = a.decrypt(s, 0, n);
                        e = o.plainTextLength ? i.slice(0, o.plainTextLength) : function(e) {
                            var t = new Uint8Array(e)
                              , i = t[e.byteLength - 1]
                              , r = e.byteLength - 1;
                            let n = 0;
                            if (1 <= i && i <= 16)
                                for (let e = r; e > r - i && t[e] === i; e--)
                                    n++;
                            return e = n === i ? e.slice(0, r - i + 1) : e
                        }(i),
                        t(e, void 0, [e])
                    } else
                        i.subtle.importKey("raw", r, a, !1, ["decrypt"]).then(e => i.subtle.decrypt({
                            name: a,
                            iv: n
                        }, e, s)).then(e => {
                            t(e, void 0, [e])
                        }
                        ).catch(e => t(void 0, e))
                }
                ,
                e.register("decrypt", this.decrypt)
            }
        }
        (e = K = K || {}).MEDIA_ATTACHING = "hlsMediaAttaching",
        e.MEDIA_ATTACHED = "hlsMediaAttached",
        e.MEDIA_DETACHING = "hlsMediaDetaching",
        e.MEDIA_DETACHED = "hlsMediaDetached",
        e.BUFFER_CREATED = "hlsBufferCreated",
        e.BUFFER_APPENDING = "hlsBufferAppending",
        e.BUFFER_APPENDED = "hlsBufferAppended",
        e.BUFFER_FLUSHED = "hlsBufferFlushed",
        e.MANIFEST_LOADING = "hlsManifestLoading",
        e.MANIFEST_LOADED = "hlsManifestLoaded",
        e.MANIFEST_PARSED = "hlsManifestParsed",
        e.LEVEL_SWITCHING = "hlsLevelSwitching",
        e.LEVEL_SWITCHED = "hlsLevelSwitched",
        e.LEVEL_LOADING = "hlsLevelLoading",
        e.LEVEL_LOADED = "hlsLevelLoaded",
        e.LEVEL_UPDATED = "hlsLevelUpdated",
        e.LEVELS_CHANGED = "hlsLevelsChanged",
        e.AUDIO_TRACKS_UPDATED = "hlsAudioTracksUpdated",
        e.AUDIO_TRACK_SWITCH = "hlsAudioTrackSwitch",
        e.AUDIO_TRACK_SWITCHED = "hlsAudioTrackSwitched",
        e.AUDIO_TRACK_LOADED = "hlsAudioTrackLoaded",
        e.SUBTITLE_TRACKS_UPDATED = "hlsSubtitleTracksUpdated",
        e.SUBTITLE_TRACKS_CREATED = "hlsSubtitleTracksCreated",
        e.SUBTITLE_TRACK_SWITCH = "hlsSubtitleTrackSwitch",
        e.INLINE_STYLES_PARSED = "hlsInlineStylesParsed",
        e.SESSION_DATA_COMPLETE = "hlsSessionDataComplete",
        e.FRAG_LOADING = "hlsFragLoading",
        e.FRAG_LOADED = "hlsFragLoaded",
        e.FRAG_BUFFERED = "hlsFragBuffered",
        e.FRAG_CHANGED = "hlsFragChanged",
        e.INTERNAL_ERROR = "hlsInternalError",
        e.ERROR = "hlsError",
        e.DESTROYING = "hlsDestroying",
        e.KEY_REQUEST_STARTED = "hlsKeyRequestStarted",
        e.LICENSE_CHALLENGE_CREATED = "hlsLicenseChallengeCreated",
        e.LICENSE_RELEASED = "hlsLicenseReleased",
        e.KEY_LOADED = "hlsKeyLoaded",
        e.UNRESOLVED_URI_LOADING = "hlsUnresolvedUriLoading",
        e.DESIRED_RATE_CHANGED = "hlsDesiredRateChanged",
        e.PLAYER_STATE_CHANGE = "hlsPlayerStateChange",
        e.SEEKING = "hlsSeeking",
        e.SEEKED = "hlsSeeked",
        e.STALLED = "hlsStalled",
        e.RESUME_FROM_STALL = "hlsResumeFromStall",
        e.READY_TO_PREFETCH_NEXT_ITEM = "hlsReadyToPrefetchNextItem",
        e.READY_FOR_NEXT_ITEM = "hlsReadyForNextItem",
        e.ITEM_TRANSITIONED = "hlsItemTransitioned",
        e.ITEM_PLAYING = "hlsItemPlaying",
        e.ITEM_EVICTED = "hlsItemEvicted",
        e.DATERANGE_UPDATED = "hlsDaterangeUpdated",
        e.INTERSTITIALS_UPDATED = "hlsInterstitialsUpdated",
        e.INTERSTITIAL_STARTED = "hlsInterstitialStarted",
        e.INTERSTITIAL_ASSET_STARTED = "hlsInterstitialAssetStarted",
        e.INTERSTITIAL_ASSET_ENDED = "hlsInterstitialAssetEnded",
        e.INTERSTITIAL_ENDED = "hlsInterstitialEnded",
        e.BUFFERED_TO_INTERSTITIAL_BOUNDARY = "hlsBufferedToInterstitialBoundary",
        e.OFFLINE_FAIRPLAY_DEVICE_CAPS = "hlsOfflineFairplayDeviceCaps";
        var E, L = K;
        (e = E = E || {}).FRAG_PARSING_INIT_SEGMENT = "hlsFragParsingInitSegment",
        e.FRAG_PARSING_DATA = "hlsFragParsingData",
        e.FRAG_PARSED = "hlsFragParsed",
        e.INIT_PTS_FOUND = "hlsInitPtsFound";
        class A extends b {
            constructor(e, t, i) {
                super(he.MEDIA_ERROR, Q.FRAG_PARSING_ERROR, e, t, i)
            }
        }
        class N extends b {
            constructor(e, t, i, r) {
                super(he.MUX_ERROR, Q.REMUX_ALLOC_ERROR, e, t, r),
                this.bytes = i
            }
        }
        function w(e) {
            return null != e && "baseTime"in e && "timescale"in e
        }
        function P(e) {
            return e.baseTime / e.timescale
        }
        function D(e, t) {
            return {
                baseTime: Math.floor(e * t),
                timescale: t
            }
        }
        function S(e, t) {
            return {
                baseTime: Math.floor(e.baseTime * t / e.timescale),
                timescale: t
            }
        }
        function M(e, t) {
            return w(e) && !w(t) || (w(e) || !w(t)) && P(e) > P(t) ? e : t
        }
        function x(e, t) {
            return (e.baseTime * t.timescale - t.baseTime * e.timescale) / (e.timescale * t.timescale)
        }
        function c(e, t) {
            return D(P(e) + t, e.timescale)
        }
        e = void 0 !== l.Buffer ? require("events").EventEmitter : class {
            constructor() {
                this.P = {}
            }
            C(e, t, i=!1) {
                return null == this.P[e] && (this.P[e] = []),
                i ? this.P[e].splice(0, 0, t) : this.P[e].push(t),
                this
            }
            D(e, t) {
                return null != this.P[e] && (this.P[e] = this.P[e].filter(e => e.listener !== t.listener),
                0 === this.P[e].length) && delete this.P[e],
                this
            }
            on(e, t) {
                return this.C(e, {
                    listener: t,
                    once: !1
                })
            }
            off(e, t) {
                return this.D(e, {
                    listener: t
                })
            }
            addListener(e, t) {
                return this.on(e, t)
            }
            once(e, t) {
                return this.C(e, {
                    listener: t,
                    once: !0
                })
            }
            removeListener(e, t) {
                return this.off(e, t)
            }
            removeAllListeners(e) {
                return e && delete this.P[e],
                this
            }
            setMaxListeners(e) {
                return this
            }
            getMaxListeners() {
                return 1 / 0
            }
            listeners(e) {
                return null == this.P[e] ? [] : this.P[e].map(e => e.listener)
            }
            rawListeners(e) {
                return this.listeners(e)
            }
            emit(e, ...t) {
                if (null == this.P[e])
                    return !1;
                let i = !1;
                for (const r of this.P[e]) {
                    try {
                        r.listener.apply(this, t)
                    } catch (e) {}
                    i = !0
                }
                return i
            }
            listenerCount(e) {
                return null == this.P[e] ? 0 : this.P[e].length
            }
            prependListener(e, t) {
                return this.C(e, {
                    listener: t,
                    once: !1
                }, !0)
            }
            prependOnceListener(e, t) {
                return this.C(e, {
                    listener: t,
                    once: !0
                }, !0)
            }
            eventNames() {
                return Object.keys(this.P)
            }
        }
        ;
        class a extends e {
            trigger(e, t) {
                this.emit(e, t)
            }
        }
        function re(e) {
            return "number" == typeof e && isFinite(e)
        }
        function F(e, t) {
            return re(e) ? e : t
        }
        function s(e, t) {
            var i = Object.assign({}, t);
            for (const r in t)
                if (r in e) {
                    const t = e[r];
                    re(t) && (i[r] = t)
                }
            return i
        }
        function B(n, a, s=e => !0) {
            const o = n.length;
            if (0 !== o) {
                let t, i = Number.NEGATIVE_INFINITY, r = NaN;
                for (let e = 0; e < o; e++) {
                    const o = n[e];
                    s(o) && (r = a(o)) >= i && (i = r,
                    t = o)
                }
                return t
            }
        }
        let me = !0;
        function f(e) {
            return e ? me ? "<redacted>" : e : "undefined"
        }
        function h(e) {
            if (!e)
                return e;
            if ("object" != typeof e)
                return e;
            if (Array.isArray(e))
                return e.map(h);
            if (e instanceof Set)
                return new Set(Array.from(e).map(h));
            var t, i, r = {};
            for ([t,i] of Object.entries(e))
                r[t] = h(i);
            return r
        }
        function fe(e) {
            return (" " + e).slice(1)
        }
        function p(t, e, i) {
            var r;
            return Array.isArray(e) && Array.isArray(i) && e.length && i.length && ([r,e] = null != (r = m(e, ([e]) => e <= t)) ? r : e[0],
            re(e = null != (i = null == (e = i[e - i[0].mediaSeqNum]) ? void 0 : e.start) ? i : NaN)) ? [r, e] : []
        }
        function m(t, i) {
            if (Array.isArray(t) && !(t.length < 1))
                for (let e = t.length - 1; 0 <= e; e--) {
                    var r = t[e];
                    if (i(r, e, t))
                        return r
                }
        }
        function g(e) {
            const a = new Map
              , s = []
              , o = new Set;
            return e.forEach(function(e) {
                var t = e[0]
                  , e = e[1];
                a.has(t) || a.set(t, {
                    id: t,
                    afters: []
                }),
                a.has(e) || a.set(e, {
                    id: e,
                    afters: []
                }),
                null != (t = a.get(t)) && t.afters.push(e)
            }),
            Array.from(a.keys()).forEach(e => {
                !function t(e, i) {
                    var r = a.get(e);
                    if (r) {
                        const n = r.id;
                        o.has(e) || ((i = Array.isArray(i) ? i : []).push(n),
                        o.add(e),
                        r.afters.forEach(function(e) {
                            if (0 <= i.indexOf(e))
                                throw new j(!1,H.TopologicalSortCycle,`Cycle detected :  ${e} is in ` + n);
                            t(e.toString(), i.map(function(e) {
                                return e
                            }))
                        }),
                        s.unshift(n))
                    }
                }(e, [])
            }
            ),
            s
        }
        function v(e, t) {
            return e.size === t.size && Object.values(e).every(e => t.has(e))
        }
        function U(e) {
            let t = 5381
              , i = e.length;
            for (; i; )
                t = 33 * t ^ e.charCodeAt(--i);
            return (t >>> 0).toString()
        }
        function _(e, t) {
            if (e === t)
                return !0;
            if (!e || !t)
                return !1;
            let i = Object.keys(e).length === Object.keys(t).length;
            for (const r of Object.keys(e))
                i = i && (isNaN(e[r]) && isNaN(t[r]) || e[r] === t[r]);
            return i
        }
        function V(e, t, i, r, n) {
            let a, s, o, l = 0;
            var d = navigator.userAgent.toLowerCase()
              , u = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350]
              , c = (a = 1 + ((192 & t[i + 2]) >>> 6),
            (60 & t[i + 2]) >>> 2);
            if (!(u.length - 1 < c))
                return s = (1 & t[i + 2]) << 2,
                s |= (192 & t[i + 3]) >>> 6,
                /firefox/i.test(d) ? 6 <= c ? (a = 5,
                o = new Array(4),
                l = c - 3) : (a = 2,
                o = new Array(2)) : -1 !== d.indexOf("android") ? (a = 2,
                o = new Array(2)) : (a = 5,
                o = new Array(4),
                l = r && (-1 !== r.indexOf("mp4a.40.29") || -1 !== r.indexOf("mp4a.40.5")) || !r && 6 <= c ? c - 3 : ((r && -1 !== r.indexOf("mp4a.40.2") || !r && 1 == s) && (a = 2,
                o = new Array(2)),
                c)),
                o[0] = a << 3,
                o[0] |= (14 & c) >> 1,
                o[1] |= (1 & c) << 7,
                o[1] |= s << 3,
                5 === a && (o[1] |= (14 & l) >> 1,
                o[2] = (1 & l) << 7,
                o[2] |= 8,
                o[3] = 0),
                {
                    esdsConfig: o,
                    samplerate: u[c],
                    channelCount: s,
                    segmentCodec: "aac",
                    codec: "mp4a.40." + a
                };
            {
                const t = new A(!0,H.InvalidADTSSamplingIndex,`invalid ADTS sampling index:` + c);
                e.trigger(L.INTERNAL_ERROR, t)
            }
        }
        class ge {
            constructor(e, t, i, r, n) {
                this.observer = e,
                this.remuxer = t,
                this.config = i,
                this.typeSupported = r,
                this.logger = n
            }
            static probe(e, t) {
                throw new j(!0,H.DemuxRemuxProbeNotFound)
            }
            resetTimeStamp(e) {}
            resetInitSegment(e, t, i, r) {}
            destroy() {}
        }
        class ye extends ge {
            constructor(e, t, i, r, n) {
                super(e, t, i, r, n),
                this.observer = e,
                this.remuxer = t,
                this.config = i,
                this.typeSupported = r,
                this.logger = n,
                this.esRemuxer = t
            }
        }
        class ve {
            constructor(e, t, i) {
                this.observer = e,
                this.config = t,
                this.logger = i
            }
            resetInitSegment() {}
            resetTimeStamp(e) {}
            destroy() {}
        }
        function Se(e) {
            return String.fromCharCode.apply(null, new Uint16Array(e))
        }
        function Ie(t) {
            var e = new ArrayBuffer(2 * t.length)
              , i = new Uint16Array(e);
            for (let e = 0; e < t.length; e++)
                i[e] = t.charCodeAt(e);
            return e
        }
        let be, Te, Ee = {
            strToUtf8array(e) {
                var t = unescape(encodeURIComponent(e))
                  , i = new Uint8Array(t.length);
                for (let e = 0; e < t.length; e++)
                    i[e] = t.charCodeAt(e);
                return i
            },
            utf8arrayToStr: e => String.fromCharCode.apply(null, Array.from(e)),
            str2ab: Ie,
            ab2str: Se
        };
        function Ae(e, t, i) {
            var r, n;
            return e instanceof Uint8Array && !t && null == i ? e : ArrayBuffer.isView(e) ? (r = e.byteOffset + (null != t ? t : 0),
            n = e.byteOffset + e.byteLength,
            n = null != i ? i : Math.max(0, n - r),
            new Uint8Array(e.buffer,r,n)) : new Uint8Array(e,t,i)
        }
        function Oe(e, t, i) {
            return e instanceof Uint8Array && !t && null == i ? new Uint8Array(e) : (e = Ae(e, t, i),
            (t = new Uint8Array(e.length)).set(e, 0),
            t)
        }
        "undefined" != typeof TextEncoder && "undefined" != typeof TextDecoder ? Ee = {
            strToUtf8array: e => (be = be || new TextEncoder).encode(e),
            utf8arrayToStr: e => (Te = Te || new TextDecoder("utf-8")).decode(e),
            str2ab: Ie,
            ab2str: Se
        } : "function" == typeof (null == ($e = l.Buffer) ? void 0 : $e.from) && (Ee = {
            strToUtf8array(e) {
                e = l.Buffer.from(e, "utf-8");
                return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)
            },
            utf8arrayToStr: e => l.Buffer.from(e).toString("utf-8"),
            str2ab: Ie,
            ab2str: Se
        });
        const Re = {
            name: "ID3"
        };
        class we {
            constructor(e, t) {
                this.R = t,
                this.L = new Uint8Array,
                this._ = !1,
                this.F = null,
                this.j = 0,
                this.U = [];
                let i, r, n, a, s = 0;
                for (; ; )
                    if (n = we.readUTF(e, s, 3),
                    s += 3,
                    "ID3" === n) {
                        this.B = e[s++],
                        this.$ = e[s++];
                        const t = e[s++];
                        128 & t && this.R.error(Re, "id3 tag is unsynchronized"),
                        64 & t && (this.V = !0),
                        i = we.readSynchSafeUint32(e.subarray(s, s + 4)),
                        r = (s += 4) + i,
                        this.V && (s += we.readSynchSafeUint32(e.subarray(s, s + 4))),
                        !re(this.minor) || 2 < this.minor ? this.q(e, s, r) : this.R.error(Re, "[id3] doesn't support older than v2.3 tags"),
                        s = r
                    } else {
                        if ("3DI" !== n)
                            return void ((a = s -= 3) && (this.j = a,
                            this.L = e.slice(0, a)));
                        s += 7
                    }
            }
            static isHeader(e, t) {
                return 73 === e[t] && 68 === e[t + 1] && 51 === e[t + 2] && e[t + 3] < 255 && e[t + 4] < 255 && e[t + 6] < 128 && e[t + 7] < 128 && e[t + 8] < 128 && e[t + 9] < 128
            }
            static readSynchSafeUint32(e) {
                return 2097152 * (127 & e[0]) + 16384 * (127 & e[1]) + 128 * (127 & e[2]) + (127 & e[3])
            }
            static readUTF(e, t, i) {
                let r = ""
                  , n = t;
                for (var a = t + i; r += String.fromCharCode(e[n++]),
                n < a; )
                    ;
                return r
            }
            K(e, t) {
                return e[t + 4] < 128 && e[t + 5] < 128 && e[t + 6] < 128 && e[t + 7] < 128
            }
            H(e) {
                return "TXXX" === e.type ? this.G(e) : "WXXX" === e.type ? this.W(e) : "PRIV" === e.type ? this.X(e) : "T" === e.type[0] ? this.Y(e) : {
                    key: e.type,
                    data: e.data
                }
            }
            G(e) {
                var t, i;
                if (!(re(e.size) && e.size < 2) && 3 === e.data[0])
                    return t = 1,
                    t += (i = null != (i = this.J(e.data.subarray(t))) ? i : "").length + 1,
                    {
                        key: "TXXX",
                        description: i,
                        data: null != (i = this.J(e.data.subarray(t))) ? i : ""
                    }
            }
            W(e) {
                var t, i;
                if (!(re(e.size) && e.size < 2) && 3 === e.data[0])
                    return t = 1,
                    t += (i = null != (i = this.J(e.data.subarray(t))) ? i : "").length + 1,
                    {
                        key: "WXXX",
                        description: i,
                        data: Ee.utf8arrayToStr(e.data.subarray(t))
                    }
            }
            Y(e) {
                var t;
                if (!(re(e.size) && e.size < 2) && 3 === e.data[0])
                    return t = e.data.subarray(1),
                    {
                        key: e.type,
                        data: null != (e = this.J(t)) ? e : ""
                    }
            }
            X(e) {
                var t;
                if (!(re(e.size) && e.size < 2))
                    return {
                        key: "PRIV",
                        info: t = null != (t = this.J(e.data)) ? t : "",
                        data: e.data.slice(t.length + 1)
                    }
            }
            Z(e, t, i, r, n) {
                var a = r + i;
                let s;
                return a <= n ? s = {
                    type: t,
                    data: e.slice(r, a)
                } : this.R.error(Re, `id3 frame ${t} size ${i} exceeded ` + n),
                s
            }
            q(e, t, i) {
                let r, n, a, s;
                for (; t + 8 <= i; ) {
                    if (!this.K(e, t))
                        return void this.R.error(Re, `[id3] illegal id3 frame @ offset ${t}. skip this id3 tag`);
                    if (r = we.readUTF(e, t, 4),
                    t += 4,
                    "" === r)
                        return;
                    if (0 === (n = we.readSynchSafeUint32(e.subarray(t, t + 4))))
                        return;
                    t += 4,
                    e[t++],
                    e[t++],
                    a = t;
                    var o = this.Z(e, r, n, a, i);
                    if (o) {
                        const e = this.H(o);
                        e && this.U.push(e)
                    }
                    if ("PRIV" === r)
                        if (53 === n && "com.apple.streaming.transportStreamTimestamp" === we.readUTF(e, t, 44)) {
                            t = t + 44 + 4;
                            const i = 1 & e[t++];
                            this._ = !0,
                            s = ((e[t++] << 23) + (e[t++] << 15) + (e[t++] << 7) + e[t++]) / 45,
                            i && (s += 47721858.84),
                            s = Math.round(s),
                            this.tt = s
                        } else
                            45 <= n && "com.apple.streaming.audioDescription" === we.readUTF(e, t, 36) ? (t += 37,
                            this.F = we.readUTF(e, t, 4),
                            t = t + 4 + (n - 41)) : t += n;
                    else
                        t += n
                }
            }
            J(e) {
                let t, i, r = "", n = 0;
                const a = e.length;
                for (; n < a; ) {
                    const a = e[n++];
                    switch (a >> 4) {
                    case 0:
                        return r;
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                        r += String.fromCharCode(a);
                        break;
                    case 12:
                    case 13:
                        t = e[n++],
                        r += String.fromCharCode((31 & a) << 6 | 63 & t);
                        break;
                    case 14:
                        t = e[n++],
                        i = e[n++],
                        r += String.fromCharCode((15 & a) << 12 | (63 & t) << 6 | (63 & i) << 0)
                    }
                }
            }
            get hasTimeStamp() {
                return this._
            }
            get timeStamp() {
                return this.tt
            }
            get audioType() {
                return this.F
            }
            get length() {
                return this.j
            }
            get payload() {
                return this.L
            }
            get frames() {
                return this.U
            }
            get minor() {
                return this.B
            }
            get revision() {
                return this.$
            }
        }
        var Pe = we;
        const Me = {
            name: "AACDemuxer"
        };
        class Ce extends ye {
            constructor() {
                super(...arguments),
                this.et = NaN
            }
            resetInitSegment(e, t) {
                this.it = void 0,
                this.nt = void 0,
                this.et = t
            }
            static probe(e, t) {
                let i, r;
                for (i = new Pe(e,t).length,
                r = Math.min(e.length - 1, i + 100); i < r; i++)
                    if (255 === e[i] && 240 == (246 & e[i + 1]))
                        return !0;
                return !1
            }
            append(e, t, i, r, n) {
                var a = new Pe(e,this.logger)
                  , s = a.hasTimeStamp && re(a.timeStamp) ? 90 * a.timeStamp : 9e4 * t;
                let o, l, d, u, c, h, p, m, f, g;
                for (a.length && (g = a.payload,
                a.frames.length && (f = a.frames),
                m = {
                    id3Samples: [{
                        pts: s,
                        dts: s,
                        data: g,
                        frames: f
                    }],
                    inputTimescale: 9e4
                }),
                d = a.length,
                h = e.length; d < h - 1 && (255 !== e[d] || 240 != (246 & e[d + 1])); d++)
                    ;
                if (!this.it && (this.it = V(this.observer, e, d, void 0, this.logger),
                !this.it))
                    throw "failed to parse adts config";
                if (!this.nt) {
                    const e = {
                        id: 258,
                        inputTimescale: 9e4,
                        timescale: NaN,
                        duration: this.et,
                        encrypted: !1,
                        keyTagInfo: n
                    }
                      , t = {
                        len: 0,
                        sequenceNumber: 0,
                        esSamples: []
                    };
                    this.nt = {
                        info: e,
                        parsingData: t,
                        type: "audio",
                        config: this.it
                    }
                }
                "zaac" !== a.audioType && "zach" !== a.audioType && "zacp" !== a.audioType || (this.nt.info.encrypted = !0),
                l = 0;
                for (var y = 9216e4 / this.it.samplerate; d + 5 < h && (u = 1 & e[d + 1] ? 7 : 9,
                o = (3 & e[d + 3]) << 11 | e[d + 4] << 3 | (224 & e[d + 5]) >>> 5,
                0 < (o -= u)) && d + u + o <= h; )
                    for (c = s + l * y,
                    p = {
                        unit: e.subarray(d + u, d + u + o),
                        pts: c,
                        dts: c,
                        keyTagInfo: n
                    },
                    this.nt.parsingData.esSamples.push(p),
                    this.nt.parsingData.len += o,
                    d += o + u,
                    l++; d < h - 1; d++) {
                        if (Pe.isHeader(e, d)) {
                            const t = new Pe(e.subarray(d),this.logger);
                            if (0 < t.length) {
                                d += t.length;
                                const e = t.hasTimeStamp && re(t.timeStamp) ? 90 * t.timeStamp : s;
                                null != m && m.id3Samples.push({
                                    pts: e,
                                    dts: e,
                                    data: t.payload,
                                    frames: t.frames
                                })
                            } else
                                this.logger.error(Me, `[id3] invalid length ` + h)
                        }
                        if (255 === e[d] && 240 == (246 & e[d + 1]))
                            break
                    }
                this.esRemuxer.remuxEsTracks(this.nt, void 0, m, void 0, t, i, r, n)
            }
        }
        class ke {
            bsReadAndUpdate(e, t, i) {
                e = this.st(e, t, i);
                return this.ot(t, i),
                null != e ? e : 0
            }
            bsWriteAndUpdate(e, t, i, r) {
                e = this.at(e, t, i, r);
                return this.ot(t, i),
                e
            }
            bsSkip(e, t) {
                this.ot(e, t)
            }
            st(i, r, n) {
                if (i && r) {
                    let t = r.byteOffset;
                    const a = r["usedBits"];
                    if (!(8 <= a || 32 < a + n)) {
                        let e;
                        const s = new Uint32Array(1)
                          , o = new Uint32Array(1)
                          , l = new Uint8Array(1);
                        if (!(8 <= a || 32 < n)) {
                            if (a) {
                                const r = 8 - a
                                  , s = n < r ? r - n : 0;
                                o[0] = 4278190080 >>> 32 - r,
                                e = (i[t] & o[0]) >>> s,
                                t += 1,
                                n -= r
                            }
                            for (; 0 < n; ) {
                                l[0] = i[t];
                                const r = Math.min(n, 8)
                                  , a = 8 - r;
                                o[0] = 4278190080 >>> 24 + a << a,
                                s[0] = (l[0] & o[0]) >> a,
                                e = e ? e << r | s[0] : s[0],
                                t += 1,
                                n -= r
                            }
                            return e
                        }
                    }
                }
            }
            at(t, i, r, n) {
                if (t && i) {
                    let e = i.byteOffset;
                    i = i["usedBits"];
                    if (!(8 <= i || 32 < i + r)) {
                        var a = new Uint32Array(1)
                          , s = new Uint32Array(1)
                          , o = new Uint32Array(1)
                          , l = new Uint8Array(1);
                        for (a[0] = n,
                        i && (s[0] = a[0] << 32 - r,
                        o[0] = 4278190080,
                        l[0] = (s[0] & o[0]) >>> 24 + i,
                        t[e] &= ~(o[0] >>> 24 + i),
                        t[e] |= l[0],
                        e += 1,
                        r -= 8 - i); 0 < r; ) {
                            s[0] = a[0] << 32 - r,
                            o[0] = 4278190080,
                            l[0] = (s[0] & o[0]) >>> 24;
                            const i = r < 0 ? 8 - r : 0;
                            t[e] &= ~(o[0] >>> 24 >>> i << i),
                            t[e] |= l[0],
                            r -= 8,
                            e += 1
                        }
                        return 0
                    }
                }
            }
            ot(e, t) {
                var i, r;
                !e || !t || 32 < e.usedBits + t || (r = e.usedBits % 8,
                i = Math.floor((r + t) / 8),
                r = (r + t) % 8,
                e.byteOffset += i,
                e.usedBits = r)
            }
        }
        function Le(e, t) {
            return 1536 / e.samplerate * t
        }
        function Ne(e, t, i, r) {
            let n;
            if (i + 8 > t.length)
                n = new A(!0,H.InsufficientAC3Data);
            else if (11 !== t[i] || 119 !== t[i + 1])
                n = new A(!0,H.InvalidAC3Magic);
            else {
                var a = t[i + 4] >> 6;
                if (!(3 <= a)) {
                    var s = 63 & t[i + 4]
                      , o = t[i + 6] >> 5;
                    let e = 0;
                    (2 == o || (1 & o && 1 != o && (e += 2),
                    4 & o)) && (e += 2);
                    var l = (t[i + 6] << 8 | t[i + 7]) >> 12 - e & 1
                      , d = [2, 1, 2, 3, 3, 4, 4, 5][o] + l
                      , u = t[i + 5] >> 3
                      , t = 7 & t[i + 5];
                    return {
                        samplerate: xe[a],
                        channelCount: d,
                        segmentCodec: "ac3",
                        codec: "ac-3",
                        extraData: a << 22 | u << 17 | t << 14 | o << 11 | l << 10 | s >> 1 << 5
                    }
                }
                n = new A(!0,H.InvalidAC3SamplingRateCode,`invalid ac-3 samplingRateCode:` + a)
            }
            e.trigger(L.INTERNAL_ERROR, n)
        }
        function De(e, t, i) {
            let r;
            if (i + 8 > t.length)
                r = new A(!0,H.InsufficientAC3Data);
            else if (11 !== t[i] || 119 !== t[i + 1])
                r = new A(!0,H.InvalidAC3Magic);
            else {
                var n = t[i + 4] >> 6;
                if (!(3 <= n))
                    return t = 63 & t[i + 4],
                    2 * Fe[3 * t + n];
                r = new A(!0,H.InvalidAC3SamplingRateCode,`invalid ac-3 samplingRateCode:` + n)
            }
            e.trigger(L.INTERNAL_ERROR, r)
        }
        const xe = [48e3, 44100, 32e3]
          , Fe = [64, 69, 96, 64, 70, 96, 80, 87, 120, 80, 88, 120, 96, 104, 144, 96, 105, 144, 112, 121, 168, 112, 122, 168, 128, 139, 192, 128, 140, 192, 160, 174, 240, 160, 175, 240, 192, 208, 288, 192, 209, 288, 224, 243, 336, 224, 244, 336, 256, 278, 384, 256, 279, 384, 320, 348, 480, 320, 349, 480, 384, 417, 576, 384, 418, 576, 448, 487, 672, 448, 488, 672, 512, 557, 768, 512, 558, 768, 640, 696, 960, 640, 697, 960, 768, 835, 1152, 768, 836, 1152, 896, 975, 1344, 896, 976, 1344, 1024, 1114, 1536, 1024, 1115, 1536, 1152, 1253, 1728, 1152, 1254, 1728, 1280, 1393, 1920, 1280, 1394, 1920];
        class Be extends ye {
            constructor() {
                super(...arguments),
                this.et = NaN
            }
            resetInitSegment(e, t) {
                this.it = void 0,
                this.nt = void 0,
                this.et = t
            }
            static probe(e, t) {
                var t = new Pe(e,t)
                  , i = t.length;
                return !!(t.hasTimeStamp && 11 === e[i] && 119 === e[i + 1] && (new ke).bsReadAndUpdate(e, {
                    byteOffset: i + 5,
                    usedBits: 0
                }, 5) < 16)
            }
            append(e, t, i, r, n) {
                var a, s = new Pe(e,this.logger), o = s.hasTimeStamp && re(s.timeStamp) ? 90 * s.timeStamp : NaN, l = e.byteLength;
                let d = 0
                  , u = s.length;
                if (this.it || (this.it = Ne(this.observer, e, u, this.logger)),
                !this.it)
                    throw "failed to parse ac3 config";
                if (!this.nt) {
                    const e = {
                        id: 258,
                        inputTimescale: 9e4,
                        timescale: NaN,
                        duration: this.et,
                        encrypted: !1,
                        keyTagInfo: n
                    }
                      , t = {
                        len: 0,
                        sequenceNumber: 0,
                        esSamples: []
                    };
                    this.nt = {
                        info: e,
                        parsingData: t,
                        type: "audio",
                        config: this.it
                    }
                }
                var c = Le(this.it, this.nt.info.inputTimescale);
                for ("zac3" === s.audioType && (this.nt.info.encrypted = !0); u < l; ) {
                    if (Pe.isHeader(e, u) && (u += new Pe(e.subarray(u),this.logger).length),
                    11 !== e[u] || 119 !== e[u + 1]) {
                        const e = new A(!0,H.InvalidAC3Magic);
                        return void this.observer.trigger(L.INTERNAL_ERROR, e)
                    }
                    const t = null != (a = De(this.observer, e, u)) ? a : NaN
                      , i = o + d * c
                      , r = {
                        unit: e.subarray(u, u + t),
                        pts: i,
                        dts: i,
                        keyTagInfo: n
                    };
                    this.nt.parsingData.esSamples.push(r),
                    this.nt.parsingData.len += t,
                    u += t,
                    d++
                }
                this.esRemuxer.remuxEsTracks(this.nt, void 0, {
                    id3Samples: [{
                        pts: o,
                        dts: o,
                        data: s.payload,
                        frames: s.frames
                    }],
                    inputTimescale: this.nt.info.inputTimescale
                }, void 0, t, i, r, n)
            }
        }
        var Ue = {
            getFrameLength: function(t, i, r, n) {
                var a = new ke;
                let s, o = !1, l = 0;
                for (; r < i.length; ) {
                    if (r + 8 > i.length)
                        return s = new A(!0,H.InsufficientEC3Data),
                        void t.trigger(L.INTERNAL_ERROR, s);
                    let e = 0;
                    if (Pe.isHeader(i, r) && (r += e = new Pe(i.subarray(r),n).length || 0),
                    11 !== i[r] || 119 !== i[r + 1])
                        return s = new A(!0,H.InvalidEC3Magic),
                        void t.trigger(L.INTERNAL_ERROR, s);
                    var d = {
                        byteOffset: r + 2,
                        usedBits: 0
                    }
                      , u = a.bsReadAndUpdate(i, d, 2)
                      , c = a.bsReadAndUpdate(i, d, 3);
                    if (0 === u || 2 === u)
                        if (!0 === o) {
                            if (0 === c)
                                break
                        } else
                            o = !0;
                    else if (1 !== u)
                        return s = new A(!0,H.ReservedStreamType),
                        void t.trigger(L.INTERNAL_ERROR, s);
                    c = 2 * (a.bsReadAndUpdate(i, d, 11) + 1);
                    r += c,
                    l += c + (e || 0)
                }
                return l
            },
            getAudioConfig: function(t, i, r, n) {
                var a = {
                    frmsiz: 0,
                    fscod: 0,
                    numblkscod: 0,
                    acmod: 0,
                    lfeon: 0,
                    bsid: 0,
                    strmtyp: 0,
                    substreamid: 0,
                    chanmape: 0,
                    chanmap: 0,
                    mixdef: 0,
                    mixdeflen: 0,
                    bsmod: 0
                }
                  , s = {
                    fscod: 0,
                    acmod: 0,
                    lfeon: 0,
                    bsid: 0,
                    bsmod: 0,
                    chan_loc: 0,
                    data_rate: 0,
                    num_ind_sub: 0,
                    num_dep_sub: [],
                    complexity_index_type_a: 0
                }
                  , o = new ke;
                let l, d = !1, u = 0;
                for (; r < i.length; ) {
                    if (r + 8 > i.length)
                        return l = new A(!0,H.InsufficientEC3Data),
                        void t.trigger(L.INTERNAL_ERROR, l);
                    let e = 0;
                    if (Pe.isHeader(i, r) && (r += e = new Pe(i.subarray(r),n).length || 0),
                    11 !== i[r] || 119 !== i[r + 1])
                        return l = new A(!0,H.InvalidEC3Magic),
                        void t.trigger(L.INTERNAL_ERROR, l);
                    const h = {
                        byteOffset: r + 2,
                        usedBits: 0
                    };
                    if (a.strmtyp = o.bsReadAndUpdate(i, h, 2),
                    a.substreamid = o.bsReadAndUpdate(i, h, 3),
                    0 === a.strmtyp || 2 === a.strmtyp) {
                        if (!0 === d) {
                            if (0 === a.substreamid)
                                break
                        } else
                            d = !0;
                        s.num_ind_sub++,
                        s.num_dep_sub.push(0)
                    } else {
                        if (1 !== a.strmtyp)
                            return l = new A(!0,H.ReservedStreamType),
                            void t.trigger(L.INTERNAL_ERROR, l);
                        s.num_dep_sub[s.num_ind_sub - 1]++
                    }
                    if (a.frmsiz = o.bsReadAndUpdate(i, h, 11),
                    a.fscod = o.bsReadAndUpdate(i, h, 2),
                    3 === a.fscod ? (o.bsSkip(h, 2),
                    a.numblkscod = 3) : a.numblkscod = o.bsReadAndUpdate(i, h, 2),
                    a.acmod = o.bsReadAndUpdate(i, h, 3),
                    a.lfeon = o.bsReadAndUpdate(i, h, 1),
                    a.bsid = o.bsReadAndUpdate(i, h, 5),
                    o.bsSkip(h, 5),
                    o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 8),
                    0 === a.acmod && (o.bsSkip(h, 5),
                    o.bsReadAndUpdate(i, h, 1)) && o.bsSkip(h, 8),
                    1 === a.strmtyp && (a.chanmape = o.bsReadAndUpdate(i, h, 1),
                    a.chanmape) && (a.chanmap = o.bsReadAndUpdate(i, h, 16)),
                    o.bsReadAndUpdate(i, h, 1) && (2 < a.acmod && o.bsSkip(h, 2),
                    1 & a.acmod && 2 < a.acmod && o.bsSkip(h, 6),
                    4 & a.acmod && o.bsSkip(h, 6),
                    a.lfeon && o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 5),
                    0 === a.strmtyp)) {
                        if (o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 6),
                        0 === a.acmod && o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 6),
                        o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 6),
                        a.mixdef = o.bsReadAndUpdate(i, h, 2),
                        1 === a.mixdef)
                            o.bsSkip(h, 5);
                        else if (2 === a.mixdef)
                            o.bsSkip(h, 12);
                        else if (3 === a.mixdef) {
                            a.mixdeflen = o.bsReadAndUpdate(i, h, 5),
                            o.bsReadAndUpdate(i, h, 1) && (o.bsSkip(h, 5),
                            o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1)) && (o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1)) && o.bsSkip(h, 4),
                            o.bsReadAndUpdate(i, h, 1) && (o.bsSkip(h, 5),
                            o.bsReadAndUpdate(i, h, 1)) && (o.bsSkip(h, 7),
                            o.bsReadAndUpdate(i, h, 1)) && o.bsSkip(h, 8);
                            const t = a.mixdeflen + 2 + (h.usedBits ? 1 : 0);
                            h.byteOffset += t
                        }
                        if (a.acmod < 2 && (o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 14),
                        0 === a.acmod) && o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 14),
                        o.bsReadAndUpdate(i, h, 1))
                            if (0 === a.numblkscod)
                                o.bsSkip(h, 5);
                            else
                                for (let e = 0; e < a.numblkscod; e++)
                                    o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 5)
                    }
                    if (a.bsmod = 0,
                    o.bsReadAndUpdate(i, h, 1) && (a.bsmod = o.bsReadAndUpdate(i, h, 3),
                    o.bsSkip(h, 2),
                    2 === a.acmod && o.bsSkip(h, 4),
                    6 <= a.acmod && o.bsSkip(h, 2),
                    o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 8),
                    0 === a.acmod && o.bsReadAndUpdate(i, h, 1) && o.bsSkip(h, 8),
                    a.fscod < 3) && o.bsSkip(h, 1),
                    0 === a.strmtyp && 3 !== a.numblkscod && o.bsSkip(h, 1),
                    2 === a.strmtyp && (3 === a.numblkscod ? 1 : o.bsReadAndUpdate(i, h, 1)) && o.bsReadAndUpdate(i, h, 6),
                    o.bsReadAndUpdate(i, h, 1)) {
                        const t = o.bsReadAndUpdate(i, h, 6);
                        if (0 === a.strmtyp && 0 === a.substreamid && 1 === t) {
                            const t = o.bsReadAndUpdate(i, h, 7)
                              , r = o.bsReadAndUpdate(i, h, 1)
                              , n = o.bsReadAndUpdate(i, h, 8);
                            0 === t && 1 === r && 1 <= n && n <= 16 && (s.complexity_index_type_a = n)
                        }
                    }
                    if (a.chanmape)
                        s.chan_loc |= a.chanmap;
                    else {
                        const t = [40960, 16384, 40960, 57344, 41472, 57856, 47104, 63488];
                        s.chan_loc |= t[a.acmod]
                    }
                    0 === a.strmtyp && (s.fscod = a.fscod,
                    s.bsid = a.bsid,
                    s.bsmod = a.bsmod,
                    s.acmod = a.acmod,
                    s.lfeon = a.lfeon),
                    s.chan_loc |= a.lfeon ? 1 : 0;
                    const p = 2 * (a.frmsiz + 1);
                    r += p,
                    u += p + (e || 0)
                }
                let c = 0;
                for (let e = 0; e < 16; e++)
                    s.chan_loc & 1 << e && c++;
                s.lfeon && c++;
                let h = 10 + 3 * s.num_ind_sub;
                const p = [48e3, 44100, 32e3][s.fscod];
                s.data_rate = p / 1536 * u * 8,
                h = 10 + 3 * s.num_ind_sub;
                for (let e = 0; e < s.num_ind_sub; e++)
                    0 < s.num_dep_sub[e] && h++;
                0 < s.complexity_index_type_a && (h += 2);
                var m = new Uint8Array(h)
                  , f = {
                    byteOffset: 0,
                    usedBits: 0
                };
                o.bsWriteAndUpdate(m, f, 32, h),
                o.bsWriteAndUpdate(m, f, 32, 1684366131),
                o.bsWriteAndUpdate(m, f, 13, s.data_rate),
                o.bsWriteAndUpdate(m, f, 3, s.num_ind_sub);
                for (let e = 0; e < s.num_ind_sub; e++)
                    o.bsWriteAndUpdate(m, f, 2, s.fscod),
                    o.bsWriteAndUpdate(m, f, 5, s.bsid),
                    o.bsWriteAndUpdate(m, f, 1, 0),
                    o.bsWriteAndUpdate(m, f, 1, 0 === e ? 0 : 1),
                    o.bsWriteAndUpdate(m, f, 3, s.bsmod),
                    o.bsWriteAndUpdate(m, f, 3, s.acmod),
                    o.bsWriteAndUpdate(m, f, 1, s.lfeon),
                    o.bsWriteAndUpdate(m, f, 3, 0),
                    o.bsWriteAndUpdate(m, f, 4, s.num_dep_sub[e]),
                    0 < s.num_dep_sub[e] ? o.bsWriteAndUpdate(m, f, 9, s.chan_loc) : o.bsWriteAndUpdate(m, f, 1, 0);
                return 0 < s.complexity_index_type_a && (o.bsWriteAndUpdate(m, f, 7, 0),
                o.bsWriteAndUpdate(m, f, 1, 1),
                o.bsWriteAndUpdate(m, f, 8, s.complexity_index_type_a)),
                {
                    samplerate: p,
                    channelCount: c,
                    segmentCodec: "ec3",
                    codec: "ec-3",
                    extraDataBytes: m
                }
            }
        };
        class _e extends ye {
            constructor() {
                super(...arguments),
                this.et = NaN
            }
            resetInitSegment(e, t) {
                this.it = void 0,
                this.nt = void 0,
                this.et = t
            }
            static probe(e, t) {
                var t = new Pe(e,t)
                  , i = t.length;
                return !(!t.hasTimeStamp || 11 !== e[i] || 119 !== e[i + 1] || 16 !== (new ke).bsReadAndUpdate(e, {
                    byteOffset: i + 5,
                    usedBits: 0
                }, 5))
            }
            append(e, t, i, r, n) {
                var a, s = new Pe(e,this.logger), o = s.hasTimeStamp && re(s.timeStamp) ? 90 * s.timeStamp : NaN, l = e.length;
                let d = 0
                  , u = s.length;
                if (this.it || (this.it = Ue.getAudioConfig(this.observer, e, u, this.logger)),
                !this.it)
                    throw "failed to parse ec-3 config";
                if (!this.nt) {
                    const e = {
                        id: 258,
                        inputTimescale: 9e4,
                        timescale: NaN,
                        duration: this.et,
                        encrypted: !1,
                        keyTagInfo: n
                    }
                      , t = {
                        len: 0,
                        sequenceNumber: 0,
                        esSamples: []
                    };
                    this.nt = {
                        info: e,
                        parsingData: t,
                        type: "audio",
                        config: this.it
                    }
                }
                var c = Le(this.it, this.nt.info.inputTimescale);
                for ("zec3" === s.audioType && (this.nt.info.encrypted = !0); u < l; ) {
                    const t = null != (a = Ue.getFrameLength(this.observer, e, u, this.logger)) ? a : NaN
                      , i = o + d * c
                      , r = {
                        unit: e.subarray(u, u + t),
                        pts: i,
                        dts: i,
                        keyTagInfo: n
                    };
                    this.nt.parsingData.esSamples.push(r),
                    this.nt.parsingData.len += t,
                    u += t,
                    d++
                }
                this.esRemuxer.remuxEsTracks(this.nt, void 0, {
                    id3Samples: [{
                        pts: o,
                        dts: o,
                        data: s.payload,
                        frames: s.frames
                    }],
                    inputTimescale: this.nt.info.inputTimescale
                }, void 0, t, i, r, n)
            }
        }
        const Ve = {
            BitratesMap: [32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160],
            SamplingRateMap: [44100, 48e3, 32e3, 22050, 24e3, 16e3, 11025, 12e3, 8e3],
            SamplesCoefficients: [[0, 72, 144, 12], [0, 0, 0, 0], [0, 72, 144, 12], [0, 144, 144, 12]],
            BytesInSlot: [0, 1, 1, 4],
            onFrame: function(e, t, i, r, n, a, s) {
                s += a * (10368e4 / r);
                e.esSamples.push({
                    unit: t,
                    pts: s,
                    dts: s
                }),
                e.len += t.length
            },
            onNoise: function(e, t) {},
            parseFrames: function(t, i, r, n, a, s, o) {
                var l, d, u, c;
                if (!(n < r + 2)) {
                    if (255 === i[r] || 224 == (224 & i[r + 1])) {
                        if (n < r + 24)
                            return -1;
                        const o = i[r + 1] >> 3 & 3
                          , e = i[r + 1] >> 1 & 3
                          , h = i[r + 2] >> 4 & 15
                          , p = i[r + 2] >> 2 & 3
                          , m = !!(2 & i[r + 2]);
                        if (1 != o && 0 != h && 15 != h && 3 != p)
                            return l = 1e3 * [32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160][14 * (3 == o ? 3 - e : 3 == e ? 3 : 4) + h - 1],
                            d = [44100, 48e3, 32e3, 22050, 24e3, 16e3, 11025, 12e3, 8e3][3 * (3 == o ? 0 : 2 == o ? 1 : 2) + p],
                            c = m ? 1 : 0,
                            u = i[r + 3] >> 6 == 3 ? 1 : 2,
                            n < r + (c = 3 == e ? (3 == o ? 12 : 6) * l / d + c << 2 : (3 == o ? 144 : 72) * l / d + c | 0) ? -1 : (Ve.onFrame(t, i.subarray(r, r + c), l, d, u, a, s),
                            c)
                    }
                    let e = r + 2;
                    for (; e < n; ) {
                        if (255 === i[e - 1] && 224 == (224 & i[e]))
                            return Ve.onNoise(i.subarray(r, e - 1), o),
                            e - r - 1;
                        e++
                    }
                }
                return -1
            },
            parse: function(e, t, i, r, n) {
                var a = t.length;
                let s, o = 0;
                for (; i < a && 0 < (s = Ve.parseFrames(e, t, i, a, o++, r, n)); )
                    i += s
            },
            getAudioConfig: function(e, t) {
                var i, r = e[t + 1] >> 3 & 3, n = e[t + 1] >> 1 & 3, a = e[t + 2] >> 4 & 15, s = e[t + 2] >> 2 & 3, o = e[t + 2] >> 1 & 1;
                if (1 != r && 0 != a && 15 != a && 3 != s)
                    return i = 3 == r ? 3 - n : 3 == n ? 3 : 4,
                    i = 1e3 * Ve.BitratesMap[14 * i + a - 1],
                    a = 3 == r ? 0 : 2 == r ? 1 : 2,
                    a = Ve.SamplingRateMap[3 * a + s],
                    s = e[t + 3] >> 6 == 3 ? 1 : 2,
                    e = Ve.SamplesCoefficients[r][n],
                    t = Ve.BytesInSlot[n],
                    {
                        segmentCodec: "mp3",
                        codec: "mp3",
                        samplerate: a,
                        channelCount: s,
                        frameLength: parseInt(e * i / a + o, 10) * t
                    }
            },
            isHeaderPattern: function(e, t) {
                return 255 === e[t] && 224 == (224 & e[t + 1]) && 0 != (6 & e[t + 1])
            },
            probe: function(t, i) {
                if (i + 1 < t.length && Ve.isHeaderPattern(t, i)) {
                    var r = 4
                      , n = Ve.getAudioConfig(t, i);
                    let e = r;
                    r = i + (e = n && n.frameLength ? n.frameLength : e);
                    if (r === t.length || r + 1 < t.length && Ve.isHeaderPattern(t, r))
                        return !0
                }
                return !1
            }
        };
        var Qe = Ve;
        class Ke extends ye {
            constructor() {
                super(...arguments),
                this.et = NaN
            }
            resetInitSegment(e, t) {
                this.it = void 0,
                this.nt = void 0,
                this.et = t
            }
            static probe(e, t) {
                t = new Pe(e,t);
                let i, r;
                if (t.hasTimeStamp)
                    for (i = t.length,
                    r = Math.min(e.length - 1, i + 100); i < r; i++)
                        if (Qe.probe(e, i))
                            return !0;
                return !1
            }
            append(e, t, i, r, n) {
                var a = new Pe(e,this.logger)
                  , s = a.hasTimeStamp && re(a.timeStamp) ? 90 * a.timeStamp : NaN;
                if (this.it || (this.it = Qe.getAudioConfig(e, a.length)),
                !this.it)
                    throw "unable to parse mp3 header";
                if (!this.nt) {
                    const e = {
                        id: 258,
                        inputTimescale: 9e4,
                        timescale: NaN,
                        duration: this.et,
                        encrypted: !1,
                        keyTagInfo: n
                    }
                      , t = {
                        len: 0,
                        sequenceNumber: 0,
                        esSamples: []
                    };
                    this.nt = {
                        info: e,
                        parsingData: t,
                        type: "audio",
                        config: this.it
                    }
                }
                Qe.parse(this.nt.parsingData, e, a.length, s, this.logger),
                this.esRemuxer.remuxEsTracks(this.nt, void 0, {
                    id3Samples: [{
                        pts: s,
                        dts: s,
                        data: a.payload,
                        frames: a.frames
                    }],
                    inputTimescale: 9e4
                }, void 0, t, i, r)
            }
        }
        function He(e, t) {
            if ("mp4a.40.2" === e) {
                if (1 === t)
                    return new Uint8Array([0, 200, 0, 128, 35, 128]);
                if (2 === t)
                    return new Uint8Array([33, 0, 73, 144, 2, 25, 0, 35, 128]);
                if (3 === t)
                    return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 142]);
                if (4 === t)
                    return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 128, 44, 128, 8, 2, 56]);
                if (5 === t)
                    return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 56]);
                if (6 === t)
                    return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 0, 178, 0, 32, 8, 224])
            } else {
                if (1 === t)
                    return new Uint8Array([1, 64, 34, 128, 163, 78, 230, 128, 186, 8, 0, 0, 0, 28, 6, 241, 193, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94]);
                if (2 === t)
                    return new Uint8Array([1, 64, 34, 128, 163, 94, 230, 128, 186, 8, 0, 0, 0, 0, 149, 0, 6, 241, 161, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94]);
                if (3 === t)
                    return new Uint8Array([1, 64, 34, 128, 163, 94, 230, 128, 186, 8, 0, 0, 0, 0, 149, 0, 6, 241, 161, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94])
            }
            return null
        }
        const je = Math.pow(2, 32) - 1;
        class C {
            static init() {
                let e;
                for (e in C.types = {
                    avc1: [],
                    avcC: [],
                    btrt: [],
                    dinf: [],
                    dref: [],
                    esds: [],
                    free: [],
                    ftyp: [],
                    hdlr: [],
                    mdat: [],
                    mdhd: [],
                    mdia: [],
                    mfhd: [],
                    minf: [],
                    moof: [],
                    moov: [],
                    mp4a: [],
                    ".mp3": [],
                    dac3: [],
                    "ac-3": [],
                    dec3: [],
                    "ec-3": [],
                    mvex: [],
                    mvhd: [],
                    pasp: [],
                    sdtp: [],
                    stbl: [],
                    stco: [],
                    stsc: [],
                    stsd: [],
                    stsz: [],
                    stts: [],
                    tfdt: [],
                    tfhd: [],
                    traf: [],
                    trak: [],
                    trun: [],
                    trex: [],
                    tkhd: [],
                    vmhd: [],
                    smhd: [],
                    uuid: [],
                    encv: [],
                    enca: [],
                    frma: [],
                    schm: [],
                    schi: [],
                    senc: [],
                    saio: [],
                    saiz: [],
                    sinf: [],
                    tenc: [],
                    sbgp: [],
                    seig: [],
                    sgpd: [],
                    pssh: []
                },
                C.types)
                    C.types.hasOwnProperty(e) && (C.types[e] = [e.charCodeAt(0), e.charCodeAt(1), e.charCodeAt(2), e.charCodeAt(3)]);
                var t = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 118, 105, 100, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 105, 100, 101, 111, 72, 97, 110, 100, 108, 101, 114, 0])
                  , i = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 115, 111, 117, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 111, 117, 110, 100, 72, 97, 110, 100, 108, 101, 114, 0])
                  , t = (C.HDLR_TYPES = {
                    video: t,
                    audio: i
                },
                new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 117, 114, 108, 32, 0, 0, 0, 1]))
                  , i = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0])
                  , i = (C.STTS = C.STSC = C.STCO = i,
                C.STSZ = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
                C.VMHD = new Uint8Array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]),
                C.SMHD = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]),
                C.STSD = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1]),
                new Uint8Array([105, 115, 111, 109]))
                  , r = new Uint8Array([97, 118, 99, 49])
                  , n = new Uint8Array([0, 0, 0, 1]);
                C.FTYP = C.box(C.types.ftyp, i, n, i, r),
                C.DINF = C.box(C.types.dinf, C.box(C.types.dref, t))
            }
            static set16(e, t, i) {
                return t[i] = e >> 8 & 255,
                t[i + 1] = 255 & e,
                i + 2
            }
            static set32(e, t, i) {
                return t[i] = e >> 24 & 255,
                t[i + 1] = e >> 16 & 255,
                t[i + 2] = e >> 8 & 255,
                t[i + 3] = 255 & e,
                i + 4
            }
            static box(e) {
                var t = Array.prototype.slice.call(arguments, 1);
                let i = 8
                  , r = t.length;
                for (var n = r; r--; )
                    i += t[r].byteLength;
                var a = new Uint8Array(i);
                for (a[0] = i >> 24 & 255,
                a[1] = i >> 16 & 255,
                a[2] = i >> 8 & 255,
                a[3] = 255 & i,
                a.set(e, 4),
                r = 0,
                i = 8; r < n; r++)
                    a.set(t[r], i),
                    i += t[r].byteLength;
                return a
            }
            static hdlr(e) {
                return C.box(C.types.hdlr, C.HDLR_TYPES[e])
            }
            static mdat(e) {
                return C.box(C.types.mdat, e)
            }
            static mdhd(e, t) {
                t *= e;
                var i = Math.floor(t / (je + 1))
                  , t = Math.floor(t % (je + 1));
                return C.box(C.types.mdhd, new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, 255 & e, i >> 24, i >> 16 & 255, i >> 8 & 255, 255 & i, t >> 24, t >> 16 & 255, t >> 8 & 255, 255 & t, 85, 196, 0, 0]))
            }
            static mdia(e) {
                var t = C.mdhd(e.info.timescale, e.info.duration)
                  , i = C.hdlr(e.type)
                  , e = C.minf(e);
                return C.box(C.types.mdia, t, i, e)
            }
            static mfhd(e) {
                return C.box(C.types.mfhd, new Uint8Array([0, 0, 0, 0, e >> 24, e >> 16 & 255, e >> 8 & 255, 255 & e]))
            }
            static minf(e) {
                return "audio" === e.type ? C.box(C.types.minf, C.box(C.types.smhd, C.SMHD), C.DINF, C.stbl(e)) : C.box(C.types.minf, C.box(C.types.vmhd, C.VMHD), C.DINF, C.stbl(e))
            }
            static moof(e, t, i=null) {
                C.types || C.init();
                e = C.traf(t, e, i);
                return C.box(C.types.moof, C.mfhd(t.sequenceNumber), e)
            }
            static moov(e) {
                let t = e.length;
                for (var i = []; t--; )
                    i[t] = C.trak(e[t]);
                return C.box.apply(null, [C.types.moov, C.mvhd(e[0].info.timescale, e[0].info.duration)].concat(i).concat(C.mvex(e)))
            }
            static mvex(e) {
                let t = e.length;
                for (var i = []; t--; )
                    i[t] = C.trex(e[t]);
                return C.box(C.types.mvex, ...i)
            }
            static mvhd(e, t) {
                t *= e;
                var i = Math.floor(t / (je + 1))
                  , t = Math.floor(t % (je + 1))
                  , e = new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, 255 & e, i >> 24, i >> 16 & 255, i >> 8 & 255, 255 & i, t >> 24, t >> 16 & 255, t >> 8 & 255, 255 & t, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255]);
                return C.box(C.types.mvhd, e)
            }
            static sdtp(e) {
                var t = e.samples || []
                  , i = new Uint8Array(4 + t.length);
                let r, n;
                for (n = 0; n < t.length; n++)
                    r = t[n].flags,
                    i[n + 4] = r.dependsOn << 4 | r.isDependedOn << 2 | r.hasRedundancy;
                return C.box(C.types.sdtp, i)
            }
            static stbl(e) {
                var e = C.stsd(e)
                  , t = C.box(C.types.stts, C.STTS)
                  , i = C.box(C.types.stsc, C.STSC)
                  , r = C.box(C.types.stsz, C.STSZ)
                  , n = C.box(C.types.stco, C.STCO);
                return C.box(C.types.stbl, e, t, i, r, n)
            }
            static avc1(e) {
                let t, i, r, n = [], a = [];
                var s = e.info.encrypted ? C.types.encv : C.types.avc1;
                for (t = 0; t < e.config.sps.length; t++)
                    i = e.config.sps[t],
                    r = i.byteLength,
                    n.push(r >>> 8 & 255),
                    n.push(255 & r),
                    n = n.concat(Array.prototype.slice.call(i));
                for (t = 0; t < e.config.pps.length; t++)
                    i = e.config.pps[t],
                    r = i.byteLength,
                    a.push(r >>> 8 & 255),
                    a.push(255 & r),
                    a = a.concat(Array.prototype.slice.call(i));
                var o = C.box(C.types.avcC, new Uint8Array([1, n[3], n[4], n[5], 255, 224 | e.config.sps.length].concat(n).concat([e.config.pps.length]).concat(a)))
                  , l = e.config.width
                  , d = e.config.height
                  , u = e.config.pixelRatio[0]
                  , c = e.config.pixelRatio[1]
                  , h = e.info.encrypted && e.info.keyTagInfo ? C.sinf(e.info.keyTagInfo, e.type, C.types.avc1) : new Uint8Array;
                return C.box(s, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, l >> 8 & 255, 255 & l, d >> 8 & 255, 255 & d, 0, 72, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 1, 18, 100, 97, 105, 108, 121, 109, 111, 116, 105, 111, 110, 47, 104, 108, 115, 46, 106, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 17, 17]), o, h, C.box(C.types.btrt, new Uint8Array([0, 28, 156, 128, 0, 45, 198, 192, 0, 45, 198, 192])), C.box(C.types.pasp, new Uint8Array([u >> 24, u >> 16 & 255, u >> 8 & 255, 255 & u, c >> 24, c >> 16 & 255, c >> 8 & 255, 255 & c])))
            }
            static esds(e) {
                var t = e.esdsConfig.length;
                return new Uint8Array([0, 0, 0, 0, 3, 23 + t, 0, 1, 0, 4, 15 + t, 64, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5].concat([t]).concat(e.esdsConfig).concat([6, 1, 2]))
            }
            static audioStsd(e) {
                var t = e.samplerate;
                return new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, e.channelCount, 0, 16, 0, 0, 0, 0, t >> 8 & 255, 255 & t, 0, 0])
            }
            static dac3(e) {
                e = e.extraData;
                return new Uint8Array([e >> 16 & 255, e >> 8 & 255, 255 & e])
            }
            static dec3(e) {
                return e.extraDataBytes
            }
            static mp4a(e, t) {
                let i = C.types.mp4a
                  , r = null;
                r = e.encrypted && e.keyTagInfo ? (i = C.types.enca,
                C.sinf(e.keyTagInfo, "audio", C.types.mp4a)) : new Uint8Array;
                e = C.audioStsd(t),
                t = C.box(C.types.esds, C.esds(t));
                return C.box(i, e, t, r)
            }
            static mp3(e) {
                return C.box(C.types[".mp3"], C.audioStsd(e))
            }
            static ac3(e, t) {
                let i = C.types["ac-3"]
                  , r = null;
                return r = e.encrypted && e.keyTagInfo ? (i = C.types.enca,
                C.sinf(e.keyTagInfo, "audio", C.types["ac-3"])) : new Uint8Array,
                C.box(i, C.audioStsd(t), C.box(C.types.dac3, C.dac3(t)), r)
            }
            static ec3(e, t) {
                let i = C.types["ec-3"]
                  , r = null;
                return r = e.encrypted && e.keyTagInfo ? (i = C.types.enca,
                C.sinf(e.keyTagInfo, "audio", C.types["ec-3"])) : new Uint8Array,
                C.box(i, C.audioStsd(t), C.box(C.types.dec3, C.dec3(t)), r)
            }
            static stsd(e) {
                if ("audio" !== e.type)
                    return C.box(C.types.stsd, C.STSD, C.avc1(e));
                if ("mp3" === e.config.segmentCodec && "mp3" === e.config.codec)
                    return C.box(C.types.stsd, C.STSD, C.mp3(e.config));
                if ("ac3" === e.config.segmentCodec)
                    return C.box(C.types.stsd, C.STSD, C.ac3(e.info, e.config));
                if ("ec3" === e.config.segmentCodec)
                    return C.box(C.types.stsd, C.STSD, C.ec3(e.info, e.config));
                if ("aac" === e.config.segmentCodec)
                    return C.box(C.types.stsd, C.STSD, C.mp4a(e.info, e.config));
                throw `unknown segmentCodec ` + e.config.segmentCodec
            }
            static tkhd(e) {
                var t = e.info.id
                  , i = e.info.duration * e.info.timescale
                  , r = Math.floor(i / (je + 1))
                  , i = Math.floor(i % (je + 1));
                let n = 0
                  , a = 0;
                return "video" === e.type && (n = e.config.width,
                a = e.config.height),
                C.box(C.types.tkhd, new Uint8Array([1, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, 255 & t, 0, 0, 0, 0, r >> 24, r >> 16 & 255, r >> 8 & 255, 255 & r, i >> 24, i >> 16 & 255, i >> 8 & 255, 255 & i, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, n >> 8 & 255, 255 & n, 0, 0, a >> 8 & 255, 255 & a, 0, 0]))
            }
            static traf(e, t, i=0) {
                var r = C.senc(e)
                  , n = C.sdtp(e)
                  , a = r.boxData
                  , s = a.length ? C.saio(76) : new Uint8Array
                  , r = a.length ? C.saiz(r.defaultSampleInfoSize, r.sampleInfoSizes) : new Uint8Array
                  , o = C.sbgp(e)
                  , l = C.sgpd(e)
                  , d = e.id
                  , u = Math.floor(t / (je + 1))
                  , t = Math.floor(t % (je + 1));
                return C.box(C.types.traf, C.box(C.types.tfhd, new Uint8Array([0, 2, 0, 0, d >> 24, d >> 16 & 255, d >> 8 & 255, 255 & d])), C.box(C.types.tfdt, new Uint8Array([1, 0, 0, 0, u >> 24, u >> 16 & 255, u >> 8 & 255, 255 & u, t >> 24, t >> 16 & 255, t >> 8 & 255, 255 & t])), a, s, r, o, l, C.trun(e, n.length + a.length + o.length + l.length + s.length + r.length + 16 + 20 + 8 + 16 + 8 + 8), n)
            }
            static trak(e) {
                if ("trakData"in e)
                    return e.trakData;
                e.info.duration = e.info.duration || 4294967295;
                var t = C.types.trak
                  , i = C.tkhd(e)
                  , e = C.mdia(e);
                return C.box(t, i, e)
            }
            static trex(e) {
                e = e.info.id;
                return C.box(C.types.trex, new Uint8Array([0, 0, 0, 0, e >> 24, e >> 16 & 255, e >> 8 & 255, 255 & e, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1]))
            }
            static trun(e, t) {
                var i = e.samples || []
                  , r = i.length
                  , e = 12 + 16 * r
                  , n = new Uint8Array(e);
                let a, s, o, l, d, u;
                for (n.set([1, 0, 15, 1, r >>> 24 & 255, r >>> 16 & 255, r >>> 8 & 255, 255 & r, (t += 8 + e) >>> 24 & 255, t >>> 16 & 255, t >>> 8 & 255, 255 & t], 0),
                a = 0; a < r; a++)
                    o = (s = i[a]).duration,
                    l = s.size,
                    d = s.flags,
                    u = s.cts,
                    n.set([o >>> 24 & 255, o >>> 16 & 255, o >>> 8 & 255, 255 & o, l >>> 24 & 255, l >>> 16 & 255, l >>> 8 & 255, 255 & l, d.isLeading << 2 | d.dependsOn, d.isDependedOn << 6 | d.hasRedundancy << 4 | d.paddingValue << 1 | d.isNonSync, 61440 & d.degradPrio, 15 & d.degradPrio, u >>> 24 & 255, u >>> 16 & 255, u >>> 8 & 255, 255 & u], 12 + 16 * a);
                return C.box(C.types.trun, n)
            }
            static initSegment(e) {
                C.types || C.init();
                var e = C.moov(e)
                  , t = new Uint8Array(C.FTYP.byteLength + e.byteLength);
                return t.set(C.FTYP),
                t.set(e, C.FTYP.byteLength),
                t
            }
            static saio(e) {
                e = e + 4 + 4;
                return C.box(C.types.saio, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, 255 & e]))
            }
            static saiz(e, t) {
                re(e) || (e = 0);
                var i = t.length
                  , t = 0 === e ? new Uint8Array(t) : new Uint8Array;
                return C.box(C.types.saiz, new Uint8Array([0, 0, 0, 0, e, i >> 24 & 255, i >> 16 & 255, i >> 8 & 255, 255 & i]), t)
            }
            static senc(t) {
                const i = t.samples || []
                  , e = i.length;
                let r = 0
                  , n = NaN
                  , a = !0;
                var s = [];
                if (!t.encrypted || e <= 0)
                    return {
                        boxData: new Uint8Array,
                        sampleInfoSizes: s,
                        defaultSampleInfoSize: 0
                    };
                t = t.defaultPerSampleIVSize || 0;
                for (const t of i)
                    t.subsamples && (r += t.subsamples.length);
                if (r <= 0)
                    return {
                        boxData: new Uint8Array,
                        sampleInfoSizes: s,
                        defaultSampleInfoSize: 0
                    };
                var o = new Uint8Array(2 * e + e * t + 6 * r + 4);
                let l = this.set32(e, o, 0);
                for (const t of i) {
                    const i = t.subsamples || [];
                    let e = 2;
                    t.iv && (o.set(t.iv, l),
                    l += t.iv.byteLength,
                    e += t.iv.byteLength),
                    l = this.set16(i.length, o, l);
                    for (const t of i)
                        l = this.set16(t[0], o, l),
                        l = this.set32(t[1], o, l),
                        e += 6;
                    s.push(e),
                    re(n) || (n = e),
                    a = a && n === e,
                    n = e
                }
                return {
                    boxData: C.box(C.types.senc, new Uint8Array([0, 0, 0, 2]), o),
                    defaultSampleInfoSize: a ? n : 0,
                    sampleInfoSizes: s
                }
            }
            static sinf(e, t, i) {
                return C.box(C.types.sinf, C.frma(i), C.schm(), C.schi(e, t))
            }
            static frma(e) {
                return C.box(C.types.frma, new Uint8Array(e))
            }
            static schm() {
                return C.box(C.types.schm, new Uint8Array([0, 0, 0, 0, 99, 98, 99, 115, 0, 1, 0, 0]))
            }
            static schi(e, t) {
                return C.box(C.types.schi, C.tenc(e, t))
            }
            static tenc(e, t) {
                let i = 0;
                "video" === t && (i = 25);
                t = new Uint8Array(17);
                if (t[0] = 16,
                e.iv && 16 === e.iv.byteLength && t.set(e.iv, 1),
                e.keyId)
                    return C.box(C.types.tenc, new Uint8Array([1, 0, 0, 0, 0, i, 1, 0]), e.keyId, t);
                throw "tenc: no key id found in decryptdata"
            }
            static sbgp(e) {
                return e.encrypted && 0 !== e.samples.length && e.samples[0].keyTagInfo ? (e = e.samples.length,
                C.box(C.types.sbgp, new Uint8Array([0, 0, 0, 0]), new Uint8Array(C.types.seig), new Uint8Array([0, 0, 0, 1, e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, 255 & e, 0, 1, 0, 1]))) : new Uint8Array
            }
            static sgpd(e) {
                if (!e.encrypted || 0 === e.samples.length || !e.samples[0].keyTagInfo)
                    return new Uint8Array;
                var t = e.samples[0].keyTagInfo;
                let i = 0;
                "video" === e.type && (i = 25);
                e = new Uint8Array(17);
                if (e[0] = 16,
                t.iv && e.set(t.iv, 1),
                t.keyId)
                    return C.box(C.types.sgpd, new Uint8Array([1, 0, 0, 0]), new Uint8Array(C.types.seig), new Uint8Array([0, 0, 0, 37, 0, 0, 0, 1]), new Uint8Array([0, i, 1, 0]), t.keyId, e);
                throw "sgpd: no keyid in decryptdata"
            }
            static pssh(e, t, i) {
                if (C.types || C.init(),
                !e)
                    throw new TypeError("Bad system id");
                if (16 !== e.byteLength)
                    throw new RangeError("Invalid system id");
                let r, n, a;
                if (t) {
                    r = 1,
                    n = new Uint8Array(16 * t.length);
                    for (let e = 0; e < t.length; e++) {
                        const i = t[e];
                        if (16 !== i.byteLength)
                            throw new RangeError("Invalid key");
                        n.set(i, 16 * e)
                    }
                } else
                    r = 0,
                    n = new Uint8Array;
                0 < r ? (a = new Uint8Array(4),
                t && 0 < t.length && new DataView(a.buffer).setUint32(0, t.length, !1)) : a = new Uint8Array;
                var s = new Uint8Array(4);
                return i && 0 < i.byteLength && new DataView(s.buffer).setUint32(0, i.byteLength, !1),
                C.box(C.types.pssh, new Uint8Array([r, 0, 0, 0]), e, a, n, s, i || new Uint8Array)
            }
        }
        var qe, Ge, $e, We, y = C;
        ($e = qe = qe || {})[$e.SDR = 0] = "SDR",
        $e[$e.HDR = 1] = "HDR",
        $e[$e.HDR10 = 2] = "HDR10",
        $e[$e.DolbyVision = 3] = "DolbyVision",
        $e[$e.HLG = 4] = "HLG",
        (t = Ge = Ge || {})[t.H264 = 16] = "H264",
        t[t.HEVC = 64] = "HEVC",
        t[t.VP09 = 65] = "VP09";
        const ze = new Set(["ac-3", "mp4a.a5", "mp4a.A5"])
          , Xe = new Set(["ec-3", "mp4a.a6", "mp4a.A6"])
          , Ye = ((t = We = We || {})[t.Family = 1] = "Family",
        t[t.Profile = 2] = "Profile",
        t[t.Compatibility = 3] = "Compatibility",
        t[t.Tier = 4] = "Tier",
        t[t.Level = 5] = "Level",
        /^([^.]+)\.([^.]+)(?:\.([^.])\.([a-zA-Z])([^.]+))?/i)
          , Je = /^mp4a\.40\.(.*)/
          , Ze = /^avc[13]\./
          , et = /^h(ev|vc)1\./
          , tt = /^dv(h1|he|a1|av)\./
          , it = /^vp09\./
          , rt = /^av01\./
          , nt = {
            aac: 1024,
            mp3: 1024,
            ac3: 1536,
            ec3: 1536
        }
          , q = {
            isAC3: e => ze.has(e),
            isEC3: e => Xe.has(e),
            isDolbyAtmos: (e, t) => q.isEC3(e) && q.isJOCChannels(t),
            isJOCChannels(e) {
                e = e.split("/");
                return 1 < e.length && void 0 !== e[1].split(",").find(e => "JOC" === e)
            },
            isAAC(e) {
                return Boolean(e && ("aac" === e || null !== (e = e.match(Je)) && "34" !== e[1]))
            },
            isMP3(e) {
                return Boolean(e && ("mp3" === e || null !== (e = e.match(Je)) && "34" === e[1]))
            },
            isAVC: e => Ze.test(e),
            isXHEAAC: function(e) {
                return "mp4a.40.42" === e
            },
            isALAC: function(e) {
                return "alac" === e
            },
            isFLAC: function(e) {
                return "fLaC" === e
            },
            isHEVC: e => et.test(e),
            isDolby: e => tt.test(e),
            isVP09: e => it.test(e),
            isAV1: e => rt.test(e),
            isCompatibleCodecString(e, t) {
                var e = e.split(",")
                  , t = t.split(",")
                  , i = e.filter(e => q.isVideoCodec(e))
                  , r = t.filter(e => q.isVideoCodec(e))
                  , e = e.filter(e => q.isAudioCodec(e))
                  , t = t.filter(e => q.isAudioCodec(e))
                  , i = 0 === i.length && 0 === r.length || i.length === r.length && q.isCompatibleVideoCodec(i[0], r[0])
                  , r = 0 === e.length && 0 === t.length || e.length === t.length && q.isCompatibleAudioCodec(e[0], t[0]);
                return i && r
            },
            isVideoCodec: e => q.isAVC(e) || q.isDolby(e) || q.isHEVC(e) || q.isVP09(e) || q.isAV1(e),
            isAudioCodec: e => q.isAC3(e) || q.isEC3(e) || q.isAAC(e) || q.isMP3(e),
            isCompatibleVideoCodec: (e, t) => Boolean(e && t && (e === t || q.isDolby(e) && q.isDolby(t) || q.isHEVC(e) && q.isHEVC(t) || q.isAVC(e) && q.isAVC(t) || q.isVP09(e) && q.isVP09(t) || q.isAV1(e) && q.isAV1(t))),
            isCompatibleAudioCodec: (e, t) => Boolean(e && t && (e === t || q.isAAC(e) && q.isAAC(t) || q.isAC3(e) && q.isAC3(t) || q.isEC3(e) && q.isEC3(t) || q.isMP3(e) && q.isMP3(t))),
            isCompatibleImmersiveAudioType: e => !("IMMERSIVE" === e || "BINAURAL" === e || "DOWNMIX" === e),
            getStickyAtmosStatus: (e, t, i) => e && t && i && q.isEC3(t) ? q.isJOCChannels(i) : null,
            getImmersiveAudioType(e) {
                e = e.split("/");
                return 2 < e.length && ("IMMERSIVE" === e[2] || "BINAURAL" === e[2] || "DOWNMIX" === e[2]) ? e[2] : "UNKNOWN"
            },
            getSegmentCodec(e) {
                let t;
                if (q.isAAC(e))
                    t = "aac";
                else if (q.isAC3(e))
                    t = "ac3";
                else if (q.isEC3(e))
                    t = "ec3";
                else {
                    if ("mp3" !== e)
                        throw new j(!1,H.InvalidAudioCodec,`invalid audio config, codec ` + e);
                    t = "mp3"
                }
                return t
            },
            getChannelCount(e) {
                return e && re(e = parseInt(e)) ? e : 0
            },
            avc1toavcoti(e) {
                var t, i = e.split(".");
                let r;
                return 2 < i.length ? (r = i.shift() + ".",
                r = (r += parseInt(null != (t = i.shift()) ? t : "").toString(16)) + ("000" + parseInt(null != (t = i.shift()) ? t : "").toString(16)).substr(-4)) : r = e,
                r
            },
            getDynamicRangeType(e, t) {
                let i = qe.SDR;
                return t && ("PQ" === e && q.isDolby(t) ? i = qe.DolbyVision : "PQ" === e && (q.isHEVC(t) || q.isVP09(t) || q.isAV1(t)) ? i = qe.HDR10 : "HLG" === e && (-1 !== t.indexOf("hvc1") || q.isVP09(t) || q.isAV1(t)) && (i = qe.HLG)),
                i
            },
            getCompressionType(e) {
                let t = Ge.H264;
                return q.isHEVC(e) || q.isDolby(e) ? t = Ge.HEVC : (q.isVP09(e) || q.isAV1(e)) && (t = Ge.VP09),
                t
            },
            isHigherCodecByFamily(e, t) {
                if (!e)
                    return !0;
                var i = Ye.exec(e)
                  , r = Ye.exec(t);
                if (!i || !r)
                    return !1;
                const n = i[We.Family]
                  , a = r[We.Family];
                if (n !== a)
                    throw new j(!1,H.MismatchCodecFamily,`mismatch in codec family current/new: ${n}/` + a);
                switch (n) {
                case "avc1":
                case "avc3":
                    return r[We.Profile] > i[We.Profile];
                case "vp09":
                case "av01":
                    return e < t;
                case "hvc1":
                case "hev1":
                    const n = "H" === i[We.Tier] ? 1 : 0
                      , a = "H" === r[We.Tier] ? 1 : 0;
                    return r[We.Profile] > i[We.Profile] || r[We.Compatibility] > i[We.Compatibility] || a > n || r[We.Level] > i[We.Level];
                case "dvh1":
                    return r[We.Profile] > i[We.Profile] || r[We.Compatibility] > i[We.Compatibility];
                default:
                    return !0
                }
            }
        };
        class at {
            static getTrack(e, t, i, r, n) {
                let a;
                switch (q.getSegmentCodec(i)) {
                case "aac":
                    var s = V(e, 1 === r ? new Uint8Array([255, 241, 92, 64, 1, 127, 252]) : new Uint8Array([255, 241, 92, 128, 1, 191, 252]), 0, i);
                    s && (a = {
                        type: "audio",
                        info: {
                            id: t,
                            timescale: s.samplerate,
                            duration: 0,
                            encrypted: !1,
                            keyTagInfo: void 0
                        },
                        config: s
                    });
                    break;
                case "ac3":
                case "ec3":
                    {
                        const i = Ne(e, new Uint8Array([11, 119, 69, 17, 128, 64, 47, 132]), 0);
                        i && (a = {
                            type: "audio",
                            info: {
                                id: t,
                                timescale: i.samplerate,
                                duration: 0,
                                encrypted: !1,
                                keyTagInfo: void 0
                            },
                            config: i
                        })
                    }
                }
                return a
            }
            static getSample(e, t) {
                let i;
                switch (e) {
                case "mp4a.40.2":
                case "mp4a.40.5":
                    i = 1 === t ? new Uint8Array([0, 208, 0, 7]) : new Uint8Array([33, 0, 3, 64, 104, 28]);
                    break;
                case "ac-3":
                case "ec-3":
                    i = new Uint8Array([11, 119, 69, 17, 128, 64, 47, 132, 41, 3, 253, 214, 124, 253, 243, 215, 233, 95, 185, 123, 78, 20, 40, 106, 97, 190, 74, 253, 43, 218, 208, 140, 191, 176, 144, 120, 214, 181, 44, 124, 129, 251, 91, 109, 187, 109, 198, 225, 43, 172, 116, 140, 176, 123, 38, 144, 211, 247, 225, 64, 29, 53, 175, 96, 16, 57, 121, 87, 78, 203, 81, 37, 7, 72, 228, 132, 37, 169, 38, 231, 97, 229, 247, 194, 208, 8, 12, 83, 74, 139, 137, 17, 22, 26, 221, 203, 107, 113, 94, 93, 75, 33, 208, 247, 146, 105, 39, 143, 6, 36, 1, 227, 108, 70, 11, 180, 152, 218, 182, 218, 209, 59, 85, 104, 201, 70, 37, 82, 219, 68, 55, 225, 144, 99, 149, 0, 119, 26, 14, 69, 164, 241, 204, 222, 81, 177, 142, 80, 20, 100, 97, 143, 101, 221, 140, 113, 31, 208, 124, 25, 64, 29, 49, 77, 140, 30, 155, 74, 214, 204, 138, 229, 109, 172, 95, 130, 70, 230, 134, 88, 59, 179, 212, 155, 232, 0, 0, 0, 0, 0, 173, 234])
                }
                return i
            }
            static getSegment(e, i, r, n) {
                if (e) {
                    var a = e.info["timescale"]
                      , s = e.config["segmentCodec"]
                      , o = at.getSample(e.config.codec, e.config.channelCount);
                    if (o) {
                        var l = []
                          , e = {
                            id: e.info.id,
                            sequenceNumber: i,
                            type: "audio",
                            encrypted: !1,
                            samples: l,
                            defaultPerSampleIVSize: 0
                        }
                          , d = nt[s]
                          , u = Math.ceil(n * a / d)
                          , i = {
                            baseTime: Math.round(u * d + r),
                            timescale: a
                        };
                        let t = 0;
                        var s = u * o.byteLength + 8
                          , c = new Uint8Array(s);
                        c[0] = s >> 24 & 255,
                        c[1] = s >> 16 & 255,
                        c[2] = s >> 8 & 255,
                        c[3] = 255 & s,
                        y.types || y.init(),
                        c.set(y.types.mdat, 4),
                        t += 8;
                        for (let e = 0; e < u; e++)
                            l.push({
                                duration: d,
                                size: o.byteLength,
                                cts: 0,
                                flags: {
                                    isLeading: 0,
                                    isDependedOn: 0,
                                    hasRedundancy: 0,
                                    degradPrio: 0,
                                    dependsOn: 1,
                                    isNonSync: 0,
                                    paddingValue: 0
                                }
                            }),
                            c.set(o, t),
                            t += o.byteLength;
                        n = y.moof(r, e),
                        a = new Uint8Array(n.byteLength + c.byteLength);
                        return a.set(n),
                        a.set(c, n.byteLength),
                        {
                            silentFragData: a,
                            endTs: i
                        }
                    }
                }
            }
        }
        let st = null;
        class ot extends ve {
            constructor(e, t, i, r, n, a) {
                super(e, t, n),
                this.lt = i,
                this.ut = a,
                this.ht = NaN,
                this.dt = NaN,
                this.ft = null,
                this.vt = null,
                this.yt = null,
                this.gt = !1,
                this.bt = !1,
                this.logger = n.child({
                    name: "EsRemuxer"
                });
                t = navigator.userAgent || "";
                if (null === st) {
                    const e = t.match(/Chrome\/(\d+)/i);
                    st = e ? parseInt(e[1]) : 0
                }
            }
            resetTimeStamp(e) {
                this.ht = this.dt = e,
                this.ft = this.vt = null
            }
            resetInitSegment() {
                this.St = void 0,
                this.wt = void 0
            }
            remuxEsTracks(n, a, e, s, o, l, d, u, c, h) {
                l || (this.bt = this.gt = !1);
                var l = this.bt
                  , p = this.gt
                  , m = n && 0 < n.parsingData.esSamples.length
                  , f = a && 0 < a.parsingData.esSamples.length;
                let g;
                var y = void 0 === c ? o : c;
                let v = y
                  , S = y;
                if (!this.St) {
                    if (n && n.config.codec && (this.ut = {
                        id: n.info.id,
                        codec: n.config.codec,
                        channelCount: n.config.channelCount
                    }),
                    a && h && this.ut) {
                        const n = at.getTrack(this.observer, this.ut.id, this.ut.codec, this.ut.channelCount, this.logger);
                        if (n) {
                            this.wt = Object.assign(Object.assign({}, n), {
                                info: Object.assign(Object.assign({}, n.info), {
                                    inputTimescale: 9e4
                                }),
                                parsingData: {
                                    len: 0,
                                    sequenceNumber: 0,
                                    esSamples: []
                                }
                            });
                            const e = Math.round(y * this.wt.info.timescale);
                            g = at.getSegment(this.wt, a.parsingData.sequenceNumber, e, h),
                            a.parsingData.sequenceNumber++
                        }
                    } else
                        this.wt = void 0;
                    this.updateInitPTSDTS(a, n, o),
                    this.generateIS(this.wt || n, a)
                }
                if (this.St) {
                    let i, r, t = null;
                    if (m && f && void 0 === c) {
                        const e = dt(a.parsingData.esSamples)
                          , s = (lt(n.parsingData.esSamples[0].pts, e) - e) / a.info.inputTimescale;
                        v += Math.max(0, s),
                        S += Math.max(0, -s)
                    }
                    if (a && h && this.wt && !g) {
                        const n = this.ht + Math.round((y + this.Tt) * this.wt.info.timescale);
                        g = at.getSegment(this.wt, a.parsingData.sequenceNumber, n, h)
                    }
                    if (m) {
                        if (re(n.info.timescale) || (this.updateInitPTSDTS(a, n, o),
                        this.generateIS(n, a)),
                        t = this.remuxAudio(n, v, p, d, f ? S : void 0, u),
                        f) {
                            let e;
                            t && (e = P(t.endPTS) - P(t.startPTS)),
                            re(a.info.timescale) || (this.updateInitPTSDTS(a, n, o),
                            this.generateIS(n, a)),
                            i = this.remuxVideo(a, S, l, e, h)
                        }
                    } else
                        (i = f ? this.remuxVideo(a, S, l, void 0, h) : i) && n && n.config.codec && (t = this.remuxEmptyAudio(n, v, p, d, f ? S : void 0, i, u));
                    if (g && i) {
                        let e = i.endDTS
                          , t = i.endPTS;
                        w(g.endTs) && re(g.endTs.baseTime) && (e = M(i.endDTS, g.endTs),
                        t = M(i.endPTS, g.endTs)),
                        this.ht = P(t),
                        this.dt = P(e),
                        r = {
                            data1: i.data1,
                            data2: g.silentFragData,
                            startDTS: i.startDTS,
                            startPTS: i.startPTS,
                            endDTS: e,
                            endPTS: t,
                            type: "audiovideo",
                            track: this.St
                        }
                    } else if (i && t)
                        r = {
                            data1: i.data1,
                            data2: t.data1,
                            startDTS: (y = i.startDTS,
                            m = t.startDTS,
                            P(y) < P(m) ? y : m),
                            startPTS: i.startPTS,
                            endDTS: i.endDTS,
                            endPTS: i.endPTS,
                            type: "audiovideo",
                            track: this.St,
                            dropped: i.dropped,
                            framesWithoutIDR: i.framesWithoutIDR,
                            firstKeyframePts: i.firstKeyframePts
                        };
                    else if (i)
                        r = {
                            data1: i.data1,
                            startDTS: i.startDTS,
                            startPTS: i.startPTS,
                            endDTS: i.endDTS,
                            endPTS: i.endPTS,
                            type: "video",
                            track: this.St,
                            dropped: i.dropped,
                            framesWithoutIDR: i.framesWithoutIDR,
                            firstKeyframePts: i.firstKeyframePts
                        };
                    else if (t)
                        r = {
                            data1: t.data1,
                            startDTS: t.startDTS,
                            startPTS: t.startPTS,
                            endDTS: t.endDTS,
                            endPTS: t.endPTS,
                            type: "audio",
                            track: this.St
                        };
                    else if (this.logger.error("Missing video and audio data"),
                    c) {
                        const n = D(c, 1);
                        r = {
                            data1: new Uint8Array(0),
                            startDTS: n,
                            startPTS: n,
                            endDTS: n,
                            endPTS: n,
                            type: "video",
                            track: this.St,
                            dropped: 1,
                            framesWithoutIDR: 1,
                            firstKeyframePts: n
                        }
                    }
                    r && (r.audioTrackInfo = this.ut),
                    null != s && s.captionSamples.length && r && this.remuxText(s, r),
                    null != (o = null == e ? void 0 : e.id3Samples) && o.length && r && this.remuxID3(e, r),
                    this.observer.trigger(E.FRAG_PARSING_DATA, r)
                } else
                    this.logger.error("failed to generate IS");
                this.observer.trigger(E.FRAG_PARSED)
            }
            updateInitPTSDTS(e, t, i) {
                let r = 1 / 0
                  , n = 1 / 0;
                const a = e ? e.parsingData.esSamples : []
                  , s = t ? t.parsingData.esSamples : [];
                if (!re(this.ht)) {
                    if (t && s.length && (r = n = s[0].pts - t.info.inputTimescale * i),
                    e && a.length && e.config.sps && e.config.pps) {
                        const t = e.info.inputTimescale
                          , s = dt(a)
                          , o = Math.round(t * i);
                        e.info.timescale = t,
                        r = Math.min(r, s - o),
                        n = Math.min(n, lt(a[0].dts, s) - o),
                        this.observer.trigger(E.INIT_PTS_FOUND, {
                            initPTS: D(r, t)
                        })
                    }
                    if (re(r) && re(n))
                        this.ht = r,
                        this.dt = n;
                    else {
                        const e = new A(!1,H.InvalidInitTimestamp);
                        this.observer.trigger(L.INTERNAL_ERROR, e)
                    }
                }
            }
            generateIS(e, t) {
                const i = t ? t.parsingData.esSamples : []
                  , r = this.lt;
                let n, a = "audio/mp4";
                if (e && t && i.length && t.config.sps && t.config.pps) {
                    const i = t.info.inputTimescale
                      , r = (t.info.timescale = i,
                    e.info.timescale = e.config.samplerate,
                    C.initSegment([t, e]));
                    n = {
                        type: "audiovideo",
                        container: "video/mp4",
                        codec: t.config.codec + `,` + e.config.codec,
                        initSegment: r
                    }
                } else if (e) {
                    e.info.timescale = e.config.samplerate,
                    "mp3" === e.config.segmentCodec && (r.mpeg ? (a = "audio/mpeg",
                    e.config.codec = "") : r.mp3 && (e.config.codec = "mp3"));
                    const t = "mp3" === e.config.segmentCodec && r.mpeg ? new Uint8Array : C.initSegment([e]);
                    n = {
                        type: "audio",
                        container: a,
                        codec: e.config.codec,
                        initSegment: t
                    }
                } else if (t && i.length && t.config.sps && t.config.pps) {
                    const e = t.info.inputTimescale
                      , i = (t.info.timescale = e,
                    C.initSegment([t]));
                    n = {
                        type: "video",
                        container: "video/mp4",
                        codec: t.config.codec,
                        initSegment: i
                    }
                }
                if (n) {
                    const e = {
                        track: this.St = n
                    };
                    this.observer.trigger(E.FRAG_PARSING_INIT_SEGMENT, e)
                } else {
                    const e = new A(!1,H.NoAVSamplesFound);
                    this.observer.trigger(L.INTERNAL_ERROR, e)
                }
            }
            remuxVideo(n, a, s, o, l) {
                var d;
                let u, i, e, c = 8, h = null != (f = this.yt) ? f : NaN, p = Number.POSITIVE_INFINITY, r = Number.NEGATIVE_INFINITY, t = n.parsingData.dropped, m = this.vt;
                var f = !s && !!this.config.forceKeyFrameOnDiscontinuity
                  , g = n.parsingData.esSamples
                  , y = n.info.inputTimescale
                  , v = []
                  , S = this.dt
                  , I = n.info.encrypted
                  , b = re(l);
                let T = g.length
                  , E = !1;
                s && null !== m || (m = a * y - (g[0].pts - lt(g[0].dts, g[0].pts)));
                for (let e = 0; e < T; e++) {
                    const a = g[e];
                    a.pts = lt(a.pts, m + S),
                    a.dts = lt(a.dts, m + S),
                    a.dts < g[0 < e ? e - 1 : e].dts && (E = !0)
                }
                E && g.sort(function(e, t) {
                    var i = e.dts - t.dts
                      , r = e.pts - t.pts;
                    return i || r || e.id - t.id
                });
                let A = NaN;
                var s = g.findIndex(e => e.key)
                  , f = (g[s] && (A = g[s].pts),
                f && (0 < s ? (g.splice(0, s),
                T = g.length,
                t += s) : -1 === s && (t += g.length)),
                (e = b ? (i = p = A = m = a * y,
                h = l * y / T,
                r = i + h * (T - 1)) : (i = g[0].dts,
                g[g.length - 1].dts)) - i)
                  , O = f ? Math.round(f / (T - 1)) : h || y / 30;
                i = Math.max(0, i);
                let R = 0
                  , w = 0;
                for (let e = 0; e < T; e++) {
                    const a = g[e]
                      , s = a.units
                      , o = s.length;
                    let t = 0;
                    for (let e = 0; e < o; e++)
                        t += s[e].data.length;
                    w += t,
                    R += o,
                    a.length = t,
                    a.dts = Math.max(a.dts, i),
                    b || (p = Math.min(a.pts, p),
                    r = Math.max(a.pts, r))
                }
                b || (e = g[T - 1].dts,
                r = Math.max(r, 0, p + O));
                l = w + 4 * R + 8;
                try {
                    u = new Uint8Array(l)
                } catch (n) {
                    const a = new N(!1,H.FailedToAllocateVideoMdat,l,`fail allocating video mdat ` + l);
                    return void this.observer.trigger(L.INTERNAL_ERROR, a)
                }
                var P = new DataView(u.buffer);
                P.setUint32(0, l),
                u.set(C.types.mdat, 4);
                let M = !1;
                for (let t = 0; t < T; t++) {
                    const a = g[t]
                      , s = a.units;
                    let i = 0;
                    const f = [];
                    let e, r = 0;
                    for (let e = 0, t = s.length; e < t; e++) {
                        const a = s[e]
                          , o = a.data
                          , d = a.data.byteLength;
                        if (P.setUint32(c, d),
                        c += 4,
                        u.set(o, c),
                        c += d,
                        i += 4 + d,
                        I)
                            if (d <= 48 || 1 !== a.type && 5 !== a.type)
                                r += 4 + d;
                            else {
                                let e = d - 32;
                                e % 16 == 0 && (e -= 16),
                                f.push([r + 36, e]),
                                r = d - 32 - e
                            }
                    }
                    if (0 < r && f.push([r, 0]),
                    b)
                        e = 0;
                    else {
                        if (t < T - 1)
                            h = g[t + 1].dts - a.dts;
                        else {
                            const s = this.config
                              , l = 0 < t ? a.dts - g[t - 1].dts : O;
                            if (s.stretchShortVideoTrack && null !== this.vt) {
                                const {maxBufferHole: n, maxSeekHole: f} = s
                                  , H = Math.floor(Math.min(null != (d = null != n ? n : f) ? d : NaN, null != f ? f : NaN) * y)
                                  , u = (o ? p + o * y : (null != (d = this.ft) ? d : NaN) + this.ht) - a.pts;
                                !(u > H) || (h = u - l) < 0 ? h = l : M = !0
                            } else
                                h = l
                        }
                        e = Math.round(a.pts - a.dts)
                    }
                    v.push({
                        size: i,
                        duration: h,
                        cts: e,
                        flags: {
                            isLeading: 0,
                            isDependedOn: 0,
                            hasRedundancy: 0,
                            degradPrio: 0,
                            dependsOn: a.key ? 2 : 1,
                            isNonSync: a.key ? 0 : 1,
                            paddingValue: 0
                        },
                        keyTagInfo: a.keyTagInfo,
                        subsamples: f
                    })
                }
                if (v.length && st && st < 70) {
                    const n = v[0].flags;
                    n.dependsOn = 2,
                    n.isNonSync = 0
                }
                a = e + h,
                this.vt = a - (b ? 0 : S),
                this.yt = M || !h ? O : h,
                this.bt = !0,
                f = {
                    sequenceNumber: n.parsingData.sequenceNumber++,
                    id: n.info.id,
                    type: n.type,
                    encrypted: n.info.encrypted,
                    samples: v,
                    defaultPerSampleIVSize: 0
                },
                l = C.moof(i + this.Tt * y, f),
                n.parsingData.esSamples = [],
                f = new Uint8Array(l.byteLength + u.byteLength);
                return f.set(l),
                f.set(u, l.byteLength),
                {
                    data1: f,
                    startPTS: D(p / y, y),
                    endPTS: D(r / y, y),
                    startDTS: D(i / y, y),
                    endDTS: D(a / y, y),
                    type: "video",
                    dropped: t,
                    framesWithoutIDR: s,
                    firstKeyframePts: D(A / y, y)
                }
            }
            remuxAudio(n, i, r, a, e, s) {
                var o;
                const t = n.info.inputTimescale
                  , l = t / n.info.timescale
                  , d = ("aac" === n.config.segmentCodec ? 1024 : "mp3" === n.config.segmentCodec ? 1152 : 1536) * l
                  , u = this.ht
                  , c = "mp3" === n.config.segmentCodec && this.lt.mpeg
                  , h = []
                  , p = n.info.encrypted
                  , m = void 0 !== e;
                let f, g, y = c ? 0 : 8;
                var v = new ke
                  , S = n.parsingData.esSamples;
                let I = this.ft || -1;
                const b = i * t
                  , T = S.length && 0 < I && (a && Math.abs(b - I) < 9e3 || Math.abs(lt(S[0].pts - u, b) - I) < 20 * d)
                  , E = this.gt = r = r || !!T;
                S.forEach(e => {
                    e.pts = e.dts = lt(e.pts, b + u)
                }
                ),
                E && -1 !== I || (I = 0 === e ? 0 : a && !m ? b : S[0].pts - u);
                let A = Math.max(0, I + u);
                if ("aac" === n.config.segmentCodec)
                    for (let i = 0, r = A; i < S.length; i++) {
                        const a = S[i]
                          , e = a.pts
                          , o = e - r
                          , H = o / t;
                        if (o <= -d && m)
                            0 === i && (A = r = e,
                            this.ft = A - u);
                        else if (o >= d && H < 1e4 && m) {
                            let t = Math.round(o / d);
                            (r = e - t * d) < 0 && (t--,
                            r += d),
                            0 === i && (A = r,
                            this.ft = A - u);
                            for (let e = 0; e < t; e++) {
                                let e = He(n.config.codec, n.config.channelCount);
                                e = e || a.unit.subarray(0),
                                S.splice(i, 0, {
                                    unit: e,
                                    pts: r,
                                    dts: r,
                                    keyTagInfo: s
                                }),
                                n.parsingData.len += e.length,
                                r += d,
                                i++
                            }
                        }
                        r += d
                    }
                let O, R = null, w = null, P = 0, M = S.length;
                for (; M--; )
                    P += S[M].unit.byteLength;
                for (let t = 0, e = S.length; t < e; t++) {
                    const r = S[t]
                      , a = r.unit;
                    let e = r.pts;
                    if (null !== w)
                        h[t - 1].duration = Math.round((e - w) / l);
                    else {
                        if (E && "aac" === n.config.segmentCodec && (e = A),
                        R = e,
                        !(0 < P))
                            return null;
                        P += y;
                        try {
                            O = new Uint8Array(P)
                        } catch (n) {
                            const i = new N(!1,H.FailedToAllocateAudioMdat,P,`fail allocating audio mdat ` + P);
                            return this.observer.trigger(L.INTERNAL_ERROR, i),
                            null
                        }
                        c || (new DataView(O.buffer).setUint32(0, P),
                        O.set(C.types.mdat, 4))
                    }
                    null != O && O.set(a, y);
                    const s = a.byteLength
                      , o = (y += s,
                    []);
                    if (p)
                        if ("ec3" === n.config.segmentCodec) {
                            let e = 0;
                            for (; e < a.byteLength; ) {
                                const i = 2 * (v.bsReadAndUpdate(a, {
                                    byteOffset: e + 2,
                                    usedBits: 5
                                }, 11) + 1)
                                  , r = (e += i,
                                Math.min(i, 16));
                                o.push([r, i - r])
                            }
                        } else {
                            const n = Math.min(s, 16);
                            o.push([n, s - n])
                        }
                    f = {
                        size: s,
                        cts: 0,
                        duration: 0,
                        flags: {
                            isLeading: 0,
                            isDependedOn: 0,
                            hasRedundancy: 0,
                            degradPrio: 0,
                            dependsOn: 1,
                            paddingValue: 0,
                            isNonSync: 0
                        },
                        keyTagInfo: r.keyTagInfo,
                        subsamples: o
                    },
                    h.push(f),
                    w = e
                }
                i = h.length;
                if (i) {
                    let e = h[i - 1].duration;
                    if (2 <= i && (e = h[i - 2].duration,
                    f) && (f.duration = e),
                    A = (null != w ? w : NaN) + l * e,
                    this.ft = A - u,
                    n.parsingData.len = 0,
                    c)
                        g = new Uint8Array;
                    else {
                        const i = {
                            sequenceNumber: n.parsingData.sequenceNumber++,
                            id: n.info.id,
                            type: n.type,
                            encrypted: n.info.encrypted,
                            samples: h,
                            defaultPerSampleIVSize: 0
                        };
                        g = C.moof(((null != R ? R : NaN) + this.Tt * t) / l, i)
                    }
                    const r = new Uint8Array(g.byteLength + (null != (o = null == O ? void 0 : O.byteLength) ? o : NaN))
                      , a = (r.set(g),
                    O && r.set(O, g.byteLength),
                    n.parsingData.esSamples = [],
                    {
                        data1: r,
                        startPTS: D((null != R ? R : NaN) / t, t),
                        endPTS: D(A / t, t),
                        startDTS: D((null != R ? R : NaN) / t, t),
                        endDTS: D(A / t, t),
                        type: "audio"
                    });
                    return this.gt = !0,
                    a
                }
                return null
            }
            remuxEmptyAudio(t, e, i, r, n, a, s) {
                var o = t.info.inputTimescale
                  , l = o / (t.config.samplerate || o)
                  , d = (null != (d = this.ft) ? d : NaN) + this.ht
                  , u = (1 ? d : P(a.startDTS) * o) + this.dt
                  , d = P(a.endDTS) * o + this.dt
                  , c = 1024 * l
                  , h = Math.ceil((d - u) / c)
                  , p = He(t.config.codec, t.config.channelCount);
                if (!p)
                    return this.logger.error("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!"),
                    null;
                var m = [];
                for (let e = 0; e < h; e++) {
                    const i = u + e * c;
                    m.push({
                        unit: p,
                        pts: i,
                        dts: i,
                        keyTagInfo: s
                    }),
                    t.parsingData.len += p.length
                }
                return t.parsingData.esSamples = m,
                this.remuxAudio(t, e, i, r, n, s)
            }
            remuxID3(t, e) {
                var i, r = t.id3Samples.length, n = t.inputTimescale;
                if (r) {
                    for (let e = 0; e < r; e++)
                        (i = t.id3Samples[e]).pts = i.pts / n,
                        i.dts = i.dts / n;
                    e.id3Samples = t.id3Samples
                }
                t.id3Samples = []
            }
            remuxText(t, e) {
                t.captionSamples.sort(function(e, t) {
                    return e.pts - t.pts
                });
                var i, r = t.captionSamples.length, n = t.inputTimescale;
                if (r) {
                    for (let e = 0; e < r; e++)
                        (i = t.captionSamples[e]).pts = i.pts / n;
                    e.captionData || (e.captionData = {}),
                    e.captionData.ts = t.captionSamples
                }
                t.captionSamples = []
            }
            get Tt() {
                var e;
                return null != (e = this.config.audioPrimingDelay) ? e : 0
            }
        }
        function lt(e, t) {
            var i;
            if (void 0 !== t)
                for (i = t < e ? -8589934592 : 8589934592; 4294967296 < Math.abs(e - t); )
                    e += i;
            return e
        }
        function dt(e) {
            return e.reduce( (e, t) => {
                var i = t.pts - e;
                return i < -4294967296 ? lt(e, t.pts) : 0 < i ? e : t.pts
            }
            , e[0].pts)
        }
        function ut(e, t=1 / 0) {
            if (!e)
                return "";
            var i = Array.isArray(e) ? e : new Uint8Array(ArrayBuffer.isView(e) ? e.buffer : e);
            let r, n = "";
            for (r = 0; r < i.length && r < t; r++) {
                let e = i[r].toString(16);
                e.length < 2 && (e = "0" + e),
                n += e
            }
            return n
        }
        const k = {
            bin2str: e => String.fromCharCode.apply(null, Array.from(e)),
            readUint16(e, t) {
                e = e[t] << 8 | e[t + 1];
                return e < 0 ? 65536 + e : e
            },
            readSint32: (e, t) => e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3],
            readUint32(e, t) {
                e = k.readSint32(e, t);
                return e < 0 ? 4294967296 + e : e
            },
            writeUint32(e, t, i) {
                e[t] = i >> 24,
                e[t + 1] = i >> 16 & 255,
                e[t + 2] = i >> 8 & 255,
                e[t + 3] = 255 & i
            },
            readUint64(e, t) {
                var i = k.readUint32(e, t);
                return (i *= Math.pow(2, 32)) + k.readUint32(e, t + 4)
            },
            writeUint64(e, t, i) {
                var r = Math.pow(2, 32) - 1
                  , n = Math.floor(i / (r + 1))
                  , i = Math.floor(i % (r + 1));
                k.writeUint32(e, t, n),
                k.writeUint32(e, t + 4, i)
            },
            findBox(e, t) {
                let i, r, n, a, s, o = [];
                if (!t.length)
                    return [];
                for (i = 0; i < e.byteLength; )
                    r = k.readUint32(e, i),
                    n = k.bin2str(e.subarray(i + 4, i + 8)),
                    a = 1 < r ? i + r : e.byteLength,
                    n === t[0] && (1 === t.length ? o.push(e.subarray(i + 8, a)) : (s = k.findBox(e.subarray(i + 8, a), t.slice(1))).length && (o = o.concat(s))),
                    i = a;
                return o
            },
            findBoxWithOffset(e, t, i, r) {
                let n, a, s, o, l, d = [];
                if (!i.length)
                    return [];
                for (n = 0; n < e.byteLength; )
                    a = k.readUint32(e, n),
                    s = k.bin2str(e.subarray(n + 4, n + 8)),
                    o = 1 < a ? n + a : e.byteLength,
                    s === i[0] && (r && r.push({
                        offset: n + t,
                        type: s,
                        size: a
                    }),
                    1 === i.length ? d.push({
                        offset: n + t,
                        type: s,
                        data: e.subarray(n + 8, o),
                        boxSize: a,
                        walkedPath: r ? r.slice(0) : void 0
                    }) : (l = k.findBoxWithOffset(e.subarray(n + 8, o), n + t + 8, i.slice(1), r ? r.slice(0) : void 0)).length && (d = d.concat(l),
                    r = r ? r.slice(0, -1) : void 0)),
                    n = o;
                return d
            }
        }
          , ct = {
            name: "MP4EncryptionRemuxer"
        };
        class ht extends ve {
            constructor(e, t, i, r, n) {
                super(e, t, n)
            }
            static _isCommonEncryptionInternal(e) {
                return Boolean(e && !("NONE" === e || "AES-128" === e))
            }
            static remuxInitSegment(c, h, p, m) {
                if (!p)
                    return c;
                let e = c;
                if (ht._isCommonEncryptionInternal(p.method)) {
                    const f = p.keyId;
                    let u = !1;
                    const g = [];
                    k.findBoxWithOffset(c, 0, ["moov", "trak"]).forEach(t => {
                        const o = t.data;
                        let l, i = 0;
                        const d = k.findBoxWithOffset(o, 0, ["mdia", "minf", "stbl", "stsd"], [])[0]
                          , e = d.data.subarray(8);
                        let r = !0
                          , n = k.findBoxWithOffset(e, d.offset + 16, ["enca"]);
                        0 === n.length && (r = !1,
                        n = k.findBoxWithOffset(e, d.offset + 16, ["encv"])),
                        n.forEach(a => {
                            let e = null
                              , s = null;
                            i = r ? (e = a.data.subarray(28),
                            l = "audio",
                            d.offset + 16 + 8 + 28) : (e = a.data.subarray(78),
                            l = "video",
                            d.offset + 16 + 8 + 78),
                            e && k.findBoxWithOffset(e, i, ["sinf"]).forEach(e => {
                                const t = e.data
                                  , i = k.findBox(t, ["frma"])[0]
                                  , r = k.findBox(t, ["schm"])[0];
                                if (i)
                                    if (r) {
                                        var n = k.bin2str(r.subarray(4, 8));
                                        if ("aac " === k.bin2str(i.subarray(0, 4)) && (y.types || y.init(),
                                        i.set(y.types.mp4a, 0)),
                                        "cbcs" === n || "cenc" === n) {
                                            m && m.push(t);
                                            const e = k.findBox(t, ["schi", "tenc"])[0];
                                            if (e) {
                                                const h = 8
                                                  , m = (e.subarray(h, h + 16),
                                                f && e.set(f, h),
                                                e[6])
                                                  , t = e[7];
                                                if (1 === m && 0 === t) {
                                                    const h = e[24];
                                                    0 < h && p.iv && h === p.iv.length && e.set(p.iv, 25)
                                                }
                                            }
                                        } else if ("cbc2" === n) {
                                            u = !0,
                                            y.types || y.init();
                                            const h = k.findBoxWithOffset(t, 0, ["frma"])[0]
                                              , m = y.box(y.types.schi, y.tenc(p, l))
                                              , f = y.box(y.types.sinf, t.subarray(h.offset, h.boxSize), y.schm(), m)
                                              , i = (s = y.box(y.types.trak, o.subarray(0, e.offset), f, o.subarray(e.offset + e.boxSize))).subarray(8)
                                              , r = f.byteLength - e.boxSize;
                                            d.walkedPath && (d.walkedPath.push({
                                                type: "stsd",
                                                offset: a.offset,
                                                size: a.boxSize
                                            }),
                                            d.walkedPath.forEach(e => {
                                                k.writeUint32(i, e.offset, e.size + r)
                                            }
                                            ))
                                        }
                                    } else
                                        h.error(ct, "missing schm box");
                                else
                                    h.error(ct, "missing frma box")
                            }
                            ),
                            s = s || c.subarray(t.offset, t.offset + t.boxSize),
                            g.push(s)
                        }
                        );
                        var a = k.findBoxWithOffset(o, 0, ["edts"])[0];
                        a && (y.types || y.init(),
                        o.set(y.types.free, a.offset + 4))
                    }
                    ),
                    u && (e = ht.remuxCbc2InitSegment(c, g, h) || c)
                }
                return e
            }
            static remuxCbc2InitSegment(e, t, i) {
                const r = k.findBoxWithOffset(e, 0, ["ftyp"])[0];
                if (!r)
                    return i.error(ct, "no ftyp found"),
                    new Uint8Array;
                var n = k.findBoxWithOffset(e, r.boxSize, ["moov"])[0];
                let a = []
                  , s = 0;
                for (; s < n.data.byteLength; ) {
                    const e = k.readUint32(n.data, s)
                      , i = k.bin2str(n.data.subarray(s + 4, s + 8))
                      , r = 1 < e ? s + e : n.data.byteLength;
                    "trak" === i ? t && (a = a.concat(t),
                    t = void 0) : a.push(n.data.subarray(s, r)),
                    s = r
                }
                var i = y.box(y.types.moov, ...a)
                  , o = new Uint8Array(r.boxSize + i.byteLength);
                return o.set(e.subarray(0, r.boxSize)),
                o.set(i, r.boxSize),
                o
            }
            static remuxOverflowSegment(i, e) {
                y.types || y.init();
                var t = k.findBoxWithOffset(i, 0, ["moof", "traf", "tfdt"], []);
                let r, n = i.byteLength;
                if (t.forEach(e => {
                    0 === e.data[0] && (n += 4)
                }
                ),
                n > i.byteLength) {
                    r = new Uint8Array(n);
                    let e = 0
                      , t = 0;
                    for (; t < i.byteLength; ) {
                        const n = k.readUint32(i, t)
                          , a = k.bin2str(i.subarray(t + 4, t + 8))
                          , s = 1 < n ? t + n : i.byteLength;
                        if ("moof" === a) {
                            const n = ht.remuxOverflowMoof(i.subarray(t + 8, s));
                            r.set(n, e),
                            e += n.byteLength
                        } else
                            r.set(i.subarray(t, s), e),
                            e += n;
                        t = s
                    }
                }
                return r || i
            }
            static remuxOverflowMoof(e) {
                let t = 0;
                for (var i = []; t < e.byteLength; ) {
                    const r = k.readUint32(e, t);
                    if ("traf" === k.bin2str(e.subarray(t + 4, t + 8))) {
                        const a = ht.remuxOverflowTraf(e.subarray(t + 8, t + r));
                        i.push(a)
                    } else
                        i.push(e.subarray(t, t + r));
                    t = 1 < r ? t + r : e.byteLength
                }
                const r = y.box(y.types.moof, ...i)
                  , a = r.byteLength - e.byteLength - 8;
                return k.findBoxWithOffset(r, 0, ["moof", "traf", "trun"], []).forEach(e => {
                    var t;
                    0 != (1 & e.data[3]) && (t = k.readUint32(e.data, 8),
                    k.writeUint32(e.data, 8, t + a))
                }
                ),
                k.findBoxWithOffset(r, 0, ["moof", "traf", "saio"], []).forEach(t => {
                    const i = 1 & t.data[0];
                    let r = 4;
                    1 & t.data[3] && (r += 8);
                    var n = k.readUint32(t.data, r);
                    if (r += 4,
                    i)
                        for (let e = 0; e < n; e++) {
                            const i = k.readUint64(t.data, r);
                            k.writeUint64(t.data, r, i + a),
                            r += 8
                        }
                    else
                        for (let e = 0; e < n; e++) {
                            const i = k.readUint32(t.data, r);
                            k.writeUint32(t.data, r, i + a),
                            r += 4
                        }
                }
                ),
                r
            }
            static remuxOverflowTraf(e) {
                let t = 0;
                for (var i = []; t < e.byteLength; ) {
                    var r, n = k.readUint32(e, t);
                    "tfdt" === k.bin2str(e.subarray(t + 4, t + 8)) && 0 === e[t + 8] ? (r = k.readUint32(e, t + 12),
                    r = y.box(y.types.tfdt, new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0, r >> 24, r >> 16 & 255, r >> 8 & 255, 255 & r])),
                    i.push(r)) : i.push(e.subarray(t, t + n)),
                    t = 1 < n ? t + n : e.byteLength
                }
                return y.box(y.types.traf, ...i)
            }
            remuxText(e, t) {
                e.captionSamples.sort(function(e, t) {
                    return e.pts - t.pts
                }),
                e.captionSamples.length && (t.captionData || (t.captionData = {}),
                t.captionData.mp4 = e.captionSamples),
                e.captionSamples = []
            }
            remuxIFrame(r, n, a, s, o) {
                if (n.samples && n.samples.length && n.samples[0].data) {
                    let e;
                    var l = y.moof(r * n.timescale, n, this.logger)
                      , d = new Uint8Array(l.byteLength + n.samples[0].data.byteLength + 8)
                      , l = (d.set(l),
                    k.writeUint32(d, l.byteLength, n.samples[0].data.byteLength + 8),
                    d.set(y.types.mdat, l.byteLength + 4),
                    d.set(n.samples[0].data, l.byteLength + 8),
                    n.sequenceNumber++,
                    n.timescale)
                      , u = D(r + s, l)
                      , l = D(r, l);
                    let t, i;
                    t = a ? (e = "audiovideo",
                    a.sequenceNumber = n.sequenceNumber,
                    n.sequenceNumber++,
                    (i = at.getSegment(a, a.sequenceNumber, r * a.info.timescale, s)) ? M(i.endTs, u) : u) : (e = "video",
                    u);
                    n = {
                        data1: d,
                        data2: null == i ? void 0 : i.silentFragData,
                        startPTS: l,
                        startDTS: l,
                        endPTS: t,
                        endDTS: t,
                        type: e,
                        dropped: 0,
                        track: o
                    };
                    this.observer.trigger(E.FRAG_PARSING_DATA, n),
                    this.observer.trigger(E.FRAG_PARSED)
                }
            }
            remuxEmsgAndRawData(e, t, i, r, n, a, s, o, l, d, u) {
                let c = "video";
                t && r ? c = "audiovideo" : t ? c = "audio" : r && (c = "video");
                t = Math.max(i, e),
                r = {
                    data1: d,
                    track: u,
                    startPTS: D(o, l),
                    startDTS: D(o, l),
                    endPTS: {
                        baseTime: NaN,
                        timescale: NaN
                    },
                    endDTS: {
                        baseTime: NaN,
                        timescale: NaN
                    },
                    largestVideoSampleSize: n,
                    type: c,
                    dropped: 0
                };
                return t && (r.endPTS = D(o + t, l),
                r.endDTS = D(o + t, l)),
                a && a.captionSamples.length && this.remuxText(a, r),
                s && 0 < s.id3Samples.length && this.remuxID3(s, r),
                this.observer.trigger(E.FRAG_PARSING_DATA, r),
                this.observer.trigger(E.FRAG_PARSED),
                r
            }
            remuxID3(t, e) {
                var i, r = t.id3Samples.length;
                if (r) {
                    for (let e = 0; e < r; e++)
                        (i = t.id3Samples[e]).pts = i.pts - 10,
                        i.dts = i.dts - 10;
                    e.id3Samples = [...t.id3Samples]
                }
                t.id3Samples = []
            }
        }
        const pt = Math.pow(2, 32) - 1
          , mt = Math.pow(2, 20) - 1
          , ft = {
            name: "MP4Demuxer"
        }
          , gt = /\/emsg[-/]ID3/i;
        class yt extends ge {
            constructor(e, t, i, r=0, n) {
                super(e, t, i, {}, n),
                this.It = !1,
                this.Ot = t,
                this.Tt = null != (e = i.audioPrimingDelay) ? e : 0
            }
            resetTimeStamp(e) {
                var t;
                re(e) ? null != (t = this.kt) && t.audio && !this.kt.video ? this.Mt = {
                    baseTime: Math.round(e * this.kt.audio.timescale / 9e4),
                    timescale: this.kt.audio.timescale
                } : this.Mt = {
                    baseTime: e,
                    timescale: 9e4
                } : this.Mt = void 0
            }
            static isHEVCFlavor(e) {
                var t;
                return !!e && ("hvc1" === (e = (t = e.indexOf(".")) < 0 ? e : e.substring(0, t)) || "hev1" === e || "chvc" === e || "qhvc" === e || "qhev" === e || "muxa" === e || "dvh1" === e || "dvhe" === e || "cdh1" === e || "qdh1" === e || "qdhe" === e)
            }
            resetInitSegment(t, i, r) {
                if (this.wt = void 0,
                t && t.byteLength) {
                    var r = ht.remuxInitSegment(t, this.logger, r)
                      , n = this.kt = yt.parseInitSegment(r, this.logger);
                    let e;
                    var a = n.audioCodec
                      , s = n.videoCodec;
                    if (n.audio && n.video ? e = {
                        type: "audiovideo",
                        container: "video/mp4",
                        codec: a + "," + s,
                        initSegment: r
                    } : (n.audio && a && (e = {
                        type: "audio",
                        container: "audio/mp4",
                        codec: a,
                        initSegment: r
                    }),
                    n.video && s && (e = {
                        type: "video",
                        container: "video/mp4",
                        codec: s,
                        initSegment: r
                    })),
                    n.video) {
                        const r = n.video
                          , o = t.subarray(r.trakOffset, r.trakOffset + r.trakSize);
                        this.Et = Object.assign(Object.assign({}, r), {
                            info: {
                                id: r.id,
                                timescale: r.timescale,
                                duration: i
                            },
                            trakData: o,
                            sequenceNumber: 0,
                            samples: []
                        }),
                        this.It = !q.isVP09(null != s ? s : "");
                        i = null != (t = n.caption) ? t : {};
                        this.At = Object.assign(Object.assign({}, i), {
                            sequenceNumber: 0,
                            captionSamples: []
                        })
                    }
                    if (n.audio && a && (this.Nt = Object.assign({}, n.audio)),
                    n.caption && (this.It = !1,
                    this.At = Object.assign(Object.assign({}, n.caption), {
                        sequenceNumber: 0,
                        captionSamples: []
                    })),
                    this.Rt = e) {
                        const t = {
                            track: e
                        };
                        this.observer.trigger(E.FRAG_PARSING_INIT_SEGMENT, t)
                    }
                }
            }
            static probe(e, t) {
                return 0 < k.findBox(e.subarray(0, Math.min(e.length, 512e3)), ["moof"]).length
            }
            static probeInitSegment(e) {
                return 0 < k.findBox(e.subarray(0, Math.min(e.length, 512e3)), ["moov", "trak"]).length
            }
            static parseHvcC(e, t) {
                let i;
                if (e && 1 === e[0]) {
                    const t = e[1];
                    i = {
                        profileSpace: t >> 6,
                        tierFlag: (32 & t) >> 5 ? "H" : "L",
                        profileIDC: 31 & t,
                        profileCompat: k.readUint32(e, 2),
                        constraintIndicator: e.subarray(6, 12),
                        levelIDC: e[12]
                    }
                }
                return i
            }
            static hvcCToCodecString(t, i) {
                const r = t + "." + (i.profileSpace ? String.fromCharCode(i.profileSpace + "A" - 1) : "") + i.profileIDC + "." + i.profileCompat.toString(16).toUpperCase() + "." + i.tierFlag + i.levelIDC;
                let n = "";
                for (let e = i.constraintIndicator.length - 1; 0 <= e; --e) {
                    const r = i.constraintIndicator[e];
                    if (0 !== r || "" !== n) {
                        const t = r.toString(16).toUpperCase();
                        n = "." + ("" === n ? t : t + n)
                    }
                }
                return r + n
            }
            static parseDvcC(e, t) {
                let i;
                return i = e ? {
                    versionMajor: e[0],
                    versionMinor: e[1],
                    profile: e[2] >> 1 & 127,
                    level: e[2] << 5 & 32 | e[3] >> 3 & 31
                } : i
            }
            static dvcCToCodecString(e, t) {
                return e + "." + yt.checkAndAddLeadingZero(t.profile) + "." + yt.checkAndAddLeadingZero(t.level)
            }
            static parseVpcC(e, t) {
                let i;
                return i = e ? {
                    profile: e[4],
                    level: e[5],
                    bitDepth: e[6] >> 4 & 15
                } : i
            }
            static vpcCToCodecString(e, t) {
                return e + "." + yt.checkAndAddLeadingZero(t.profile) + "." + yt.checkAndAddLeadingZero(t.level) + "." + yt.checkAndAddLeadingZero(t.bitDepth)
            }
            static parseAv1C(e, t) {
                let i;
                if (e) {
                    const t = e[1] >>> 3
                      , r = (64 & e[2]) >> 6
                      , n = (32 & e[2]) >> 5
                      , a = (8 & e[2]) >> 3
                      , s = (4 & e[2]) >> 2
                      , o = 3 & e[2];
                    i = {
                        profile: t,
                        level: 31 & e[1],
                        tierFlag: e[2] >>> 7 ? "H" : "M",
                        bitDepth: 2 == t && r ? n ? 12 : 10 : r ? 10 : 8,
                        monochrome: (16 & e[2]) >> 4,
                        chromaSubsampling: `` + a + s + o
                    }
                }
                return i
            }
            static av1CToCodecString(e, t) {
                var {profile: i, tierFlag: r, monochrome: n, chromaSubsampling: a} = t;
                return e + "." + i + "." + yt.checkAndAddLeadingZero(t.level) + r + "." + yt.checkAndAddLeadingZero(t.bitDepth) + "." + n + "." + a
            }
            static checkAndAddLeadingZero(e) {
                return (e < 10 ? "0" : "") + e
            }
            static parseInitSegment(e, d) {
                const u = {
                    foundLargeTimescale: !1,
                    tracksById: {}
                };
                return k.findBoxWithOffset(e, 0, ["moov", "trak"]).forEach(t => {
                    const i = t.data
                      , r = k.findBox(i, ["tkhd"])[0];
                    if (r) {
                        var n = 0 === r[0] ? 12 : 20
                          , n = k.readUint32(r, n)
                          , e = k.findBox(i, ["mdia", "mdhd"])[0];
                        if (e) {
                            var a = 0 === (o = e[0]) ? 12 : 20
                              , s = k.readUint32(e, a)
                              , o = (a += 4,
                            1e6 <= s && (u.foundLargeTimescale = !0),
                            0 === o ? k.readUint32(e, a) : 0)
                              , e = k.findBox(i, ["mdia", "hdlr"])[0];
                            if (e) {
                                const r = k.bin2str(e.subarray(8, 12))
                                  , l = {
                                    soun: "audio",
                                    vide: "video",
                                    clcp: "caption",
                                    subt: "ttml"
                                }[r] || r;
                                if (l) {
                                    const r = k.findBox(i, ["mdia", "minf", "stbl", "stsd"]);
                                    if (r.length) {
                                        const i = r[0];
                                        k.bin2str(i.subarray(12, 16));
                                        a = yt.parseStsd(i, d);
                                        let e;
                                        if ("caption" === l) {
                                            const t = Object.assign({
                                                id: n,
                                                type: l,
                                                timescale: s,
                                                duration: o,
                                                isTimingTrack: !1,
                                                sequenceNumber: 0,
                                                captionSamples: []
                                            }, a);
                                            u.caption = t,
                                            e = t
                                        } else if ("ttml" === l) {
                                            const t = Object.assign({
                                                id: n,
                                                type: "ttml",
                                                timescale: s,
                                                duration: o,
                                                sequenceNumber: 0
                                            }, a);
                                            e = t,
                                            u.ttml = t,
                                            u.ttmlCodec = t.codec
                                        } else {
                                            const d = Object.assign({
                                                id: n,
                                                type: l,
                                                timescale: s,
                                                duration: o,
                                                isTimingTrack: !0,
                                                trakOffset: t.offset,
                                                trakSize: t.boxSize,
                                                sequenceNumber: 0,
                                                samples: [],
                                                fragmentDuration: 0
                                            }, a);
                                            "video" === l ? (u.video = d,
                                            u.videoCodec = d.codec) : (u.audio = d,
                                            u.audioCodec = d.codec),
                                            e = d
                                        }
                                        u.tracksById[n] = e
                                    }
                                }
                            }
                        }
                    }
                }
                ),
                k.findBoxWithOffset(e, 0, ["moov", "mvex", "trex"]).forEach(e => {
                    var e = e.data
                      , t = k.readUint32(e, 4)
                      , e = k.readUint32(e, 16);
                    u.tracksById[t] && (u.tracksById[t].defaultSampleSize = e)
                }
                ),
                u
            }
            static parseStsd(e, t) {
                let r, i;
                const n = e.subarray(8);
                let a = k.bin2str(n.subarray(4, 8))
                  , s = null
                  , o = null;
                "enca" === a ? (s = k.findBox(n, ["enca"])[0],
                o = s.subarray(28)) : "encv" === a && (s = k.findBox(n, ["encv"])[0],
                o = s.subarray(78));
                e = !!o;
                let l;
                r = 0,
                o && k.findBox(o, ["sinf"]).forEach(e => {
                    const t = k.findBox(e, ["schm"])[0];
                    if (t) {
                        var i = k.bin2str(t.subarray(4, 8));
                        if ("cbcs" === i || "cenc" === i) {
                            const t = k.findBox(e, ["frma"])[0];
                            t && (a = k.bin2str(t));
                            i = k.findBox(e, ["schi", "tenc"])[0];
                            i && (r = i[7])
                        }
                    }
                }
                );
                var d = n.subarray(86);
                switch (a) {
                case "mp4a":
                    i = "mp4a.40.5";
                    break;
                case "ac-3":
                case "ec-3":
                case "alac":
                case "fLaC":
                case "c608":
                default:
                    i = a;
                    break;
                case "avc1":
                case "avc3":
                    i = a + ".640028";
                    break;
                case "hvc1":
                case "hev1":
                    const e = k.findBox(d, ["hvcC"])[0];
                    l = yt.parseHvcC(e, t),
                    i = l ? yt.hvcCToCodecString(a, l) : a + ".2.4.H150.B0";
                    break;
                case "dvh1":
                case "dvhe":
                    const r = k.findBox(d, ["dvcC"])[0];
                    l = yt.parseDvcC(r, t),
                    i = l ? yt.dvcCToCodecString(a, l) : a + ".05.01";
                    break;
                case "vp09":
                    const n = k.findBox(d, ["vpcC"])[0];
                    l = yt.parseVpcC(n, t),
                    i = l ? yt.vpcCToCodecString(a, l) : a;
                    break;
                case "av01":
                    const s = k.findBox(d, ["av1C"])[0];
                    l = yt.parseAv1C(s, t),
                    i = l ? yt.av1CToCodecString(a, l) : a
                }
                return {
                    codec: i,
                    encrypted: e,
                    defaultPerSampleIVSize: r
                }
            }
            static has32BitTfdts(e) {
                e = k.findBox(e, ["moof", "traf", "tfdt"]);
                let t = !1;
                return e.forEach(e => {
                    0 === e[0] && (t = !0)
                }
                ),
                t
            }
            static getStartDtsTs(i, e, t) {
                e = k.findBox(e, ["moof", "traf"]);
                let n, a = Number.MAX_SAFE_INTEGER;
                return e.map(function(t) {
                    return k.findBox(t, ["tfhd"]).forEach(e => {
                        e = k.readUint32(e, 4),
                        e = i.tracksById[e];
                        let r;
                        if (e) {
                            if (!e.isTimingTrack)
                                return 1 / 0;
                            r = e.timescale || 9e4;
                            e = k.findBox(t, ["tfdt"]).map(function(e) {
                                let t;
                                const i = e[0];
                                if (t = k.readUint32(e, 4),
                                1 === i) {
                                    const i = k.readUint32(e, 8);
                                    if (t === pt && i > pt - .5 * r)
                                        return 0;
                                    t = t * (pt + 1) + i
                                }
                                return t
                            }),
                            e = 0 < e.length ? e[0] : 1 / 0;
                            isFinite(e) && e / r < a && (a = e / r,
                            n = {
                                baseTime: e,
                                timescale: r
                            })
                        }
                    }
                    )
                }),
                n
            }
            static offsetStartDTS(r, e, l, n, d) {
                k.findBox(e, ["moof", "traf"]).map(function(i) {
                    return k.findBox(i, ["tfhd"]).map(function(e) {
                        const t = k.readUint32(e, 4)
                          , a = r.tracksById[t];
                        if (a) {
                            const s = a.timescale || 9e4
                              , o = "caption" === a.type ? 0 : n;
                            k.findBox(i, ["tfdt"]).map(function(t) {
                                const i = t[0]
                                  , r = a.type;
                                if (0 === i) {
                                    let e = k.readUint32(t, 4) - Math.round(l.baseTime * s / l.timescale);
                                    "video" === r && e < 0 && (e = 0),
                                    e += Math.round(o * s),
                                    e = Math.max(e, 0),
                                    k.writeUint32(t, 4, e)
                                } else {
                                    const i = k.readUint32(t, 4);
                                    i > mt && d.error(ft, `baseMediaDecodeTime larger than can be represented by float for upper 32 bits ` + i);
                                    let e = i;
                                    e = (e = (e *= Math.pow(2, 32)) + k.readUint32(t, 8)) - Math.round(l.baseTime * s / l.timescale),
                                    "video" === r && e < 0 && (e = 0),
                                    e += Math.round(o * s),
                                    e = Math.max(e, 0);
                                    const n = Math.floor(e / (pt + 1))
                                      , a = Math.floor(e % (pt + 1));
                                    k.writeUint32(t, 4, n),
                                    k.writeUint32(t, 8, a)
                                }
                            })
                        }
                    })
                })
            }
            static writeStartDTS(i, e, a, t) {
                k.findBox(e, ["moof", "traf"]).map(function(t) {
                    return k.findBox(t, ["tfhd"]).map(function(e) {
                        e = k.readUint32(e, 4),
                        e = i.tracksById[e];
                        if (e) {
                            const r = e.timescale || 9e4
                              , n = Math.round(a * r) / r;
                            k.findBox(t, ["tfdt"]).map(function(e) {
                                var t, i;
                                0 === e[0] ? k.writeUint32(e, 4, n * r) : (i = n * r,
                                i = Math.max(i, 0),
                                t = Math.floor(i / (pt + 1)),
                                i = Math.floor(i % (pt + 1)),
                                k.writeUint32(e, 4, t),
                                k.writeUint32(e, 8, i))
                            })
                        }
                    })
                })
            }
            static parseSAIO(e, t) {
                let i = 0
                  , r = 0;
                var n = e[0]
                  , a = (r += 4,
                0 != (1 & k.readUint32(e, 0)) && (r += 8),
                16777215 & k.readUint32(e, r));
                return 1 == a ? (r += 4,
                i = k.readUint32(e, r),
                1 === n && (r += 4,
                i = (i *= Math.pow(2, 32)) + k.readUint32(e, r))) : t.error(ft, `saio entry count error, count is: ` + a),
                i
            }
            static parseSAIZ(e) {
                let t = 0
                  , i = 0;
                return i += 4,
                0 != (1 & k.readUint32(e, 0)) && (i += 8),
                t = e[i],
                i++,
                i += 4,
                t = 0 === t ? e[i] : t
            }
            static parseSubsample(e, t) {
                var i = {
                    subsamples: []
                };
                let r = 0;
                for (e && (i.iv = t.subarray(0, e),
                r += e),
                r += 2; r + 6 <= t.byteLength; ) {
                    const e = k.readUint16(t, r);
                    r += 2;
                    var n = k.readUint32(t, r);
                    r += 4,
                    i.subsamples.push([e, n])
                }
                return i
            }
            static isSEIMessage(e, t) {
                return e ? 39 === t || 40 === t : 6 === t
            }
            static parseCLCPSample(e, t, i, r) {
                let n = 0;
                var a = [];
                let s = 0;
                for (; n < i; ) {
                    var o = t + n;
                    const r = k.readUint32(e, o);
                    o += 4;
                    var l = k.bin2str(e.subarray(o, o + 4));
                    if (o += 4,
                    "cdat" !== l)
                        break;
                    {
                        const t = r - 8
                          , d = e.subarray(o, o + t);
                        s += t,
                        a.push(d),
                        n += r
                    }
                }
                return {
                    cdatList: a,
                    cdatTotalSize: s
                }
            }
            static parseSamples(e, S, I, b, T, E, A) {
                const O = I.timescale
                  , c = I.id;
                let R, w = e, P = 0, M = !1, C = 0;
                return k.findBoxWithOffset(S, 0, ["moof"]).map(function(e) {
                    const t = e.data
                      , u = e.offset;
                    k.findBox(t, ["traf"]).map(function(d) {
                        var e = k.findBox(d, ["tfdt"]).map(function(e) {
                            let t;
                            var i = e[0];
                            return t = k.readUint32(e, 4),
                            (t = 1 === i ? (t *= Math.pow(2, 32)) + k.readUint32(e, 8) : t) / O
                        })[0];
                        return void 0 !== e && (w = e),
                        k.findBox(d, ["tfhd"]).map(function(e) {
                            var t = k.readUint32(e, 4)
                              , i = 16777215 & k.readUint32(e, 0)
                              , r = 0 != (1 & i);
                            let g = 0;
                            var n = 0 != (2 & i)
                              , a = 0 != (8 & i);
                            let y = 0;
                            var s = 0 != (16 & i);
                            let v = 0;
                            var o = 0 != (32 & i)
                              , i = !r && 0 != (131072 & i);
                            let l = 8;
                            if (re(I.defaultSampleSize) && (v = I.defaultSampleSize),
                            t === c) {
                                if (r ? (g = k.readUint32(e, l),
                                l += 4,
                                g = (g *= Math.pow(2, 32)) + k.readUint32(e, l),
                                l += 4) : i && (g = u),
                                n && (k.readUint32(e, l),
                                l += 4),
                                a && (y = k.readUint32(e, l),
                                l += 4),
                                s && (v = k.readUint32(e, l),
                                l += 4),
                                o && (k.readUint32(e, l),
                                l += 4),
                                "video" === I.type) {
                                    let t = 0
                                      , i = 0;
                                    k.findBox(d, ["saio"]).map(function(e) {
                                        t = yt.parseSAIO(e, A)
                                    }),
                                    k.findBox(d, ["saiz"]).map(function(e) {
                                        i = yt.parseSAIZ(e)
                                    }),
                                    t && i && (R = yt.parseSubsample(I.defaultPerSampleIVSize, S.subarray(g + t, g + t + i))),
                                    M = yt.isHEVCFlavor(I.codec)
                                }
                                k.findBox(d, ["trun"]).map(function(i) {
                                    var t = i[0]
                                      , e = 16777215 & k.readUint32(i, 0)
                                      , r = 0 != (1 & e);
                                    let n = 0;
                                    var a = 0 != (4 & e)
                                      , s = 0 != (256 & e);
                                    let o = 0;
                                    var l = 0 != (512 & e);
                                    let d = 0;
                                    var u = 0 != (1024 & e)
                                      , c = 0 != (2048 & e);
                                    let h = 0;
                                    var p = k.readUint32(i, 4);
                                    let m = 8
                                      , f = (r && (n = k.readSint32(i, m),
                                    m += 4),
                                    a && (m += 4),
                                    n + g);
                                    for (let e = 0; e < p && (E < 0 || P < E); e++) {
                                        if (s ? (o = k.readUint32(i, m),
                                        m += 4) : o = y,
                                        l ? (d = k.readUint32(i, m),
                                        m += 4) : d = v,
                                        d > C && (C = d),
                                        u && (m += 4),
                                        c && (h = 0 === t ? k.readUint32(i, m) : k.readSint32(i, m),
                                        m += 4),
                                        "video" === I.type) {
                                            if (re(b))
                                                I.samples.push({
                                                    data: S.subarray(f, f + d),
                                                    size: d,
                                                    duration: b * O,
                                                    cts: 0,
                                                    flags: {
                                                        isLeading: 0,
                                                        isDependedOn: 0,
                                                        hasRedundancy: 0,
                                                        degradPrio: 0,
                                                        dependsOn: 2,
                                                        isNonSync: 0,
                                                        paddingValue: 0
                                                    },
                                                    subsamples: R ? R.subsamples : [],
                                                    iv: R ? R.iv : void 0
                                                });
                                            else if (I.fragmentDuration += o,
                                            T) {
                                                let e = 0;
                                                for (; e < d; ) {
                                                    const b = k.readUint32(S, f)
                                                      , T = (f += 4,
                                                    31 & S[f]);
                                                    if (I.seiSamples || (I.seiSamples = []),
                                                    yt.isSEIMessage(M, T)) {
                                                        const i = S.subarray(f, f + b);
                                                        I.seiSamples.push({
                                                            pts: w + h / O,
                                                            type: T,
                                                            data: i,
                                                            sampleOffset: f,
                                                            naluSize: b
                                                        })
                                                    }
                                                    f += b,
                                                    e += b + 4
                                                }
                                            }
                                        } else if ("audio" === I.type)
                                            I.fragmentDuration += o;
                                        else if ("caption" === I.type) {
                                            const {cdatList: i, cdatTotalSize: b} = yt.parseCLCPSample(S, f, d, A);
                                            if (f += d,
                                            i.length) {
                                                let t = new Uint8Array;
                                                if (1 === i.length)
                                                    t = new Uint8Array(i[0]);
                                                else if (1 < i.length) {
                                                    let e = 0;
                                                    t = new Uint8Array(b);
                                                    for (const b of i)
                                                        t.set(b, e),
                                                        e += b.length
                                                }
                                                I.captionSamples.push({
                                                    type: 3,
                                                    pts: w,
                                                    bytes: t
                                                })
                                            }
                                        }
                                        P++,
                                        w += o / O
                                    }
                                })
                            }
                        })
                    })
                }),
                C
            }
            static parseEmsg(e, t) {
                let i, r, n, a, s, o = "", l = "", d = 0;
                if (0 === e[0]) {
                    for (; "\0" !== k.bin2str(e.subarray(d, d + 1)); )
                        o += k.bin2str(e.subarray(d, d + 1)),
                        d += 1;
                    for (o += k.bin2str(e.subarray(d, d + 1)),
                    d += 1; "\0" !== k.bin2str(e.subarray(d, d + 1)); )
                        l += k.bin2str(e.subarray(d, d + 1)),
                        d += 1;
                    l += k.bin2str(e.subarray(d, d + 1)),
                    d += 1,
                    i = k.readUint32(e, 12),
                    r = k.readUint32(e, 16),
                    a = k.readUint32(e, 20),
                    s = k.readUint32(e, 24),
                    d = 28
                } else {
                    d += 4,
                    i = k.readUint32(e, d),
                    d += 4;
                    const t = k.readUint32(e, d)
                      , r = (d += 4,
                    k.readUint32(e, d));
                    for (d += 4,
                    n = Math.pow(2, 32) * t + r,
                    Number.isSafeInteger(n) || (n = Number.MAX_SAFE_INTEGER),
                    a = k.readUint32(e, d),
                    d += 4,
                    s = k.readUint32(e, d),
                    d += 4; "\0" !== k.bin2str(e.subarray(d, d + 1)); )
                        o += k.bin2str(e.subarray(d, d + 1)),
                        d += 1;
                    for (o += k.bin2str(e.subarray(d, d + 1)),
                    d += 1; "\0" !== k.bin2str(e.subarray(d, d + 1)); )
                        l += k.bin2str(e.subarray(d, d + 1)),
                        d += 1;
                    l += k.bin2str(e.subarray(d, d + 1)),
                    d += 1
                }
                return {
                    schemeIdUri: o,
                    value: l,
                    timeScale: i,
                    presentationTime: n,
                    presentationTimeDelta: r,
                    eventDuration: a,
                    id: s,
                    payload: e.subarray(d, e.byteLength)
                }
            }
            static extractID3PayloadCreateID3Track(e, t, i, r) {
                const n = new Pe(e.payload,r)
                  , a = new Uint8Array(e.payload)
                  , s = a.byteLength;
                let o = 0
                  , l = 0
                  , d = NaN;
                if (re(e.presentationTime) ? d = e.presentationTime / e.timeScale : re(e.presentationTimeDelta) && (d = t + e.presentationTimeDelta / e.timeScale),
                re(d)) {
                    const c = e.eventDuration
                      , h = a.subarray(0, 10)
                      , p = k.bin2str(h.subarray(l, l + 3));
                    l += 3,
                    "ID3" !== p && r.error(ft, "No ID3 tag found when extracting ID3 payload"),
                    l += 2;
                    var t = a.subarray(l, l + 1)
                      , e = 64 & t[0]
                      , u = 16 & t[0];
                    if (l += 1,
                    Pe.readSynchSafeUint32(a.subarray(l, l + 4)),
                    l += 4,
                    e) {
                        const e = Pe.readSynchSafeUint32(a.subarray(l, l + 4));
                        l = l + 4 + e
                    }
                    for (; l + 2 < s; ) {
                        k.bin2str(a.subarray(l, l + 4)),
                        l += 4;
                        const t = Pe.readSynchSafeUint32(a.subarray(l, l + 4))
                          , s = (l += 4,
                        d + o * c)
                          , h = {
                            data: a,
                            pts: s,
                            dts: s,
                            keyTagInfo: void 0,
                            frames: n.frames
                        };
                        i.id3Samples.push(h),
                        l += t,
                        o++,
                        u && ("DI3" !== k.bin2str(a.subarray(l, l + 3)) && r.error(ft, "End should be DI3 if footer present in extracting ID3 payload"),
                        l = l + 3 + 7)
                    }
                } else
                    r.error(ft, "No pts found in emsg info when extracting ID3 payload")
            }
            append(e, t, i, r, n, a, s) {
                let o = this.kt
                  , l = 0
                  , d = 0
                  , u = !1
                  , c = !1
                  , h = 0;
                if (void 0 === o && (this.resetInitSegment(e, 0),
                o = this.kt),
                o) {
                    var p = this.Mt
                      , m = yt.getStartDtsTs(o, e, this.logger)
                      , p = (p || (this.Mt = p = m ? {
                        baseTime: m.baseTime - Math.round(t * m.timescale),
                        timescale: m.timescale
                    } : {
                        baseTime: NaN,
                        timescale: NaN
                    },
                    this.observer.trigger(E.INIT_PTS_FOUND, {
                        initPTS: p
                    })),
                    o.foundLargeTimescale && yt.has32BitTfdts(e) && !s && (e = ht.remuxOverflowSegment(e, this.logger)),
                    k.findBox(e, ["emsg"]));
                    if (o.video && o.video.encrypted && k.findBox(e, ["moof", "traf"]).find(function(e) {
                        return Boolean(k.findBox(e, ["senc"])[0] || k.findBox(e, ["saiz"])[0] && k.findBox(e, ["saio"])[0])
                    }),
                    s) {
                        const t = this.Et.timescale
                          , i = (s = Math.ceil(s * t) / t,
                        m ? this.Tt + P(m) : NaN);
                        if (this.Et && this.Nt && !this.wt) {
                            const e = at.getTrack(this.observer, this.Nt.id, this.Nt.codec, 2, this.logger);
                            if (!e)
                                throw `unable to create silent audio track for codec ` + this.Nt.codec;
                            this.wt = Object.assign(Object.assign({}, e), {
                                sequenceNumber: 0
                            });
                            const t = y.initSegment([this.Et, this.wt])
                              , i = (this.Rt = {
                                type: "audiovideo",
                                container: "video/mp4",
                                codec: this.wt.config.codec + "," + this.Et.codec,
                                initSegment: t
                            },
                            {
                                track: this.Rt
                            });
                            this.observer.trigger(E.FRAG_PARSING_INIT_SEGMENT, i)
                        }
                        yt.parseSamples(i, e, this.Et, s, !1, 1, this.logger),
                        this.Rt && this.Ot.remuxIFrame(i, this.Et, this.wt, s, this.Rt),
                        this.Et.samples = []
                    } else {
                        s = m ? P(m) - this.Tt : NaN,
                        s = Math.max(0, s);
                        if (p && 0 < p.length) {
                            const e = p.map(e => {
                                e = yt.parseEmsg(e, this.logger);
                                return !this.Pt && gt.test(e.schemeIdUri) && (this.Pt = {
                                    id3Samples: [],
                                    inputTimescale: 9e4
                                }),
                                e
                            }
                            )
                              , i = this.Pt;
                            i && e.map(e => {
                                yt.extractID3PayloadCreateID3Track(e, t, i, this.logger)
                            }
                            )
                        }
                        (this.Et && (h = yt.parseSamples(s, e, this.Et, void 0, this.It, -1, this.logger),
                        l = this.Et.fragmentDuration / this.Et.timescale,
                        u = !0,
                        this.Et.fragmentDuration = 0,
                        this.At) && (this.It ? (yt.extractSEICaptionsFromNALu(this.Et.seiSamples, this.At),
                        this.Et.seiSamples = []) : yt.parseSamples(s, e, this.At, void 0, !1, Number.MAX_SAFE_INTEGER, this.logger)),
                        this.Nt && (yt.parseSamples(s, e, this.Nt, void 0, !1, -1, this.logger),
                        d = this.Nt.fragmentDuration / this.Nt.timescale,
                        c = !0,
                        this.Nt.fragmentDuration = 0),
                        this.Rt) ? (this.Ot.remuxEmsgAndRawData(d, c, l, u, h, this.At, this.Pt, s, null != (p = null == m ? void 0 : m.timescale) ? p : NaN, e, this.Rt),
                        this.Pt && (this.Pt.id3Samples = [])) : this.logger.error("missing remuxedInitDataTrack")
                    }
                } else
                    this.logger.error("mp4-demuxer > append > missing initData")
            }
            static extractSEICaptionsFromNALu(s, o) {
                if (s) {
                    for (let a = 0; a < s.length; ++a) {
                        var l = s[a]
                          , d = l.pts;
                        let t = 0
                          , e = (t++,
                        0)
                          , i = 0
                          , r = !1
                          , n = 0;
                        for (; !r && t < l.data.length; ) {
                            for (e = 0; !(t >= l.data.length) && (n = l.data[t++],
                            e += n,
                            255 === n); )
                                ;
                            for (i = 0; !(t >= l.data.length) && (n = l.data[t++],
                            i += n,
                            255 === n); )
                                ;
                            const s = l.data.length - t;
                            if (4 === e && t < l.data.length) {
                                if (r = !0,
                                181 === l.data[t++]) {
                                    const s = k.readUint16(l.data, t);
                                    if (t += 2,
                                    49 === s) {
                                        const s = k.readUint32(l.data, t);
                                        if (t += 4,
                                        1195456820 === s && 3 === l.data[t++]) {
                                            const s = l.data[t++];
                                            t++;
                                            var u = 31 & s
                                              , c = [];
                                            if (64 & s)
                                                for (let e = 0; e < u; e++) {
                                                    const s = l.data[t++];
                                                    if (s === (252 & s)) {
                                                        const o = 3 & s;
                                                        if (0 == o || 1 == o) {
                                                            const s = l.data[t++]
                                                              , o = l.data[t++];
                                                            c.push(s),
                                                            c.push(o)
                                                        }
                                                    } else
                                                        t += 2
                                                }
                                            0 < c.length && o.captionSamples.push({
                                                type: 3,
                                                pts: d,
                                                bytes: c
                                            })
                                        }
                                    }
                                }
                            } else if (i < s)
                                t += i;
                            else if (i > s)
                                break
                        }
                    }
                    return o
                }
            }
        }
        const vt = {
            name: "ExpGolomb"
        };
        class St {
            constructor(e, t) {
                this.Ct = e,
                this.R = t,
                this.Dt = e.byteLength,
                this.xt = 0,
                this.Lt = 0
            }
            get bytesAvailable() {
                return this.Dt
            }
            loadWord() {
                var e = this.Ct
                  , t = this.Dt
                  , i = e.byteLength - t
                  , r = new Uint8Array(4)
                  , t = Math.min(4, t);
                if (0 === t)
                    throw new j(!1,H.ExpGolombNoAvailableBytes);
                r.set(e.subarray(i, i + t)),
                this.xt = new DataView(r.buffer).getUint32(0),
                this.Lt = 8 * t,
                this.Dt -= t
            }
            skipBits(e) {
                var t;
                this.Lt > e || (t = (e -= this.Lt) >> 3,
                e -= t >> 3,
                this.Dt -= t,
                this.loadWord()),
                this.xt <<= e,
                this.Lt -= e
            }
            readBits(e) {
                var t = Math.min(this.Lt, e)
                  , i = this.xt >>> 32 - t;
                return 32 < e && this.R.error(vt, "Cannot read more than 32 bits at a time"),
                this.Lt -= t,
                0 < this.Lt ? this.xt <<= t : 0 < this.Dt && this.loadWord(),
                0 < (t = e - t) && this.Lt ? i << t | this.readBits(t) : i
            }
            skipLZ() {
                let e;
                for (e = 0; e < this.Lt; ++e)
                    if (0 != (this.xt & 2147483648 >>> e))
                        return this.xt <<= e,
                        this.Lt -= e,
                        e;
                return this.loadWord(),
                e + this.skipLZ()
            }
            skipUEG() {
                this.skipBits(1 + this.skipLZ())
            }
            skipEG() {
                this.skipBits(1 + this.skipLZ())
            }
            readUEG() {
                var e = this.skipLZ();
                return this.readBits(e + 1) - 1
            }
            readEG() {
                var e = this.readUEG();
                return 1 & e ? 1 + e >>> 1 : -1 * (e >>> 1)
            }
            readBoolean() {
                return 1 === this.readBits(1)
            }
            readUByte() {
                return this.readBits(8)
            }
            readUShort() {
                return this.readBits(16)
            }
            readUInt() {
                return this.readBits(32)
            }
            skipScalingList(e) {
                let t, i, r = 8, n = 8;
                for (t = 0; t < e; t++)
                    0 !== n && (i = this.readEG(),
                    n = (r + i + 256) % 256),
                    r = 0 === n ? r : n
            }
            readSPS() {
                let e, t, i, r = 0, n = 0, a = 0, s = 0;
                var o = this.readUByte.bind(this)
                  , l = this.readBits.bind(this)
                  , d = this.readUEG.bind(this)
                  , u = this.readBoolean.bind(this)
                  , c = this.skipBits.bind(this)
                  , h = this.skipEG.bind(this)
                  , p = this.skipUEG.bind(this)
                  , m = this.skipScalingList.bind(this)
                  , f = (o(),
                o());
                if (l(5),
                c(3),
                o(),
                p(),
                100 === f || 110 === f || 122 === f || 244 === f || 44 === f || 83 === f || 86 === f || 118 === f || 128 === f) {
                    const e = d();
                    if (3 === e && c(1),
                    p(),
                    p(),
                    c(1),
                    u())
                        for (t = 3 !== e ? 8 : 12,
                        i = 0; i < t; i++)
                            u() && m(i < 6 ? 16 : 64)
                }
                p();
                f = d();
                if (0 === f)
                    d();
                else if (1 === f)
                    for (c(1),
                    h(),
                    h(),
                    e = d(),
                    i = 0; i < e; i++)
                        h();
                p(),
                c(1);
                f = d(),
                p = d(),
                l = l(1);
                0 === l && c(1),
                c(1),
                u() && (r = d(),
                n = d(),
                a = d(),
                s = d());
                let g = [1, 1];
                if (u() && u())
                    switch (o()) {
                    case 1:
                        g = [1, 1];
                        break;
                    case 2:
                        g = [12, 11];
                        break;
                    case 3:
                        g = [10, 11];
                        break;
                    case 4:
                        g = [16, 11];
                        break;
                    case 5:
                        g = [40, 33];
                        break;
                    case 6:
                        g = [24, 11];
                        break;
                    case 7:
                        g = [20, 11];
                        break;
                    case 8:
                        g = [32, 11];
                        break;
                    case 9:
                        g = [80, 33];
                        break;
                    case 10:
                        g = [18, 11];
                        break;
                    case 11:
                        g = [15, 11];
                        break;
                    case 12:
                        g = [64, 33];
                        break;
                    case 13:
                        g = [160, 99];
                        break;
                    case 14:
                        g = [4, 3];
                        break;
                    case 15:
                        g = [3, 2];
                        break;
                    case 16:
                        g = [2, 1];
                        break;
                    case 255:
                        g = [o() << 8 | o(), o() << 8 | o()]
                    }
                return {
                    width: Math.ceil(16 * (f + 1) - 2 * r - 2 * n),
                    height: (2 - l) * (p + 1) * 16 - (l ? 2 : 4) * (a + s),
                    pixelRatio: g
                }
            }
            readSliceType() {
                return this.readUByte(),
                this.readUEG(),
                this.readUEG()
            }
        }
        const It = 9e4;
        class bt extends ye {
            constructor(e, t, i, r, n) {
                super(e, t, i, r, n),
                this._t = !1,
                this.Ft = !1,
                this.Ut = !1
            }
            static probe(e, t) {
                return 376 <= e.length && 71 === e[0] && 71 === e[188]
            }
            resetInitSegment(e, t, i) {
                this._t = !1,
                this.Bt = -1;
                var i = {
                    id: -1,
                    inputTimescale: It,
                    timescale: NaN,
                    duration: 0,
                    encrypted: null != i && i.isEncrypted,
                    keyTagInfo: i
                }
                  , r = {
                    len: 0,
                    sequenceNumber: 0
                };
                this.$t = {
                    info: Object.assign({}, i),
                    parsingData: Object.assign(Object.assign({}, r), {
                        esSamples: new Array,
                        dropped: 0
                    }),
                    config: {},
                    container: "video/mp2t",
                    type: "video"
                },
                this.Vt = {
                    info: Object.assign({}, i),
                    parsingData: Object.assign(Object.assign({}, r), {
                        esSamples: new Array
                    }),
                    container: "video/mp2t",
                    type: "audio"
                },
                this.Pt = {
                    id: -1,
                    inputTimescale: It,
                    id3Samples: []
                },
                this.qt = {
                    inputTimescale: It,
                    captionSamples: []
                },
                this.Kt = t,
                e && 0 !== e.length && bt.probe(e, this.logger) ? this.Ht = e : this.Ht = void 0
            }
            append(e, t, i, r, n, a, s) {
                this.Ut = i,
                this.Ft = void 0 !== s,
                !i && this.Vt && (this.Vt.audioLastPTS = void 0,
                this.Vt.audioOverFlow = void 0,
                this.Vt.overflowMissingBytes = void 0);
                var o = this.Ht;
                o && (this.zt(o, n),
                this.Ht = void 0),
                this.zt(e, n),
                this.Qt(t, i, r, n, a, s)
            }
            zt(e, t) {
                var i = this.$t
                  , r = this.Vt
                  , n = this.Pt;
                let a, s, o, l, d, u = this._t, c = i.info.id, h = r.info.id, p = n.id, m = this.Bt, f = i.pesData, g = r.pesData, y = n.pesData, v = !1, S = e.length;
                for (S -= S % 188,
                a = 0; a < S; a += 188) {
                    if (71 !== e[a]) {
                        const e = new A(!1,H.NoTSSyncByteFound);
                        return void this.observer.trigger(L.INTERNAL_ERROR, e)
                    }
                    if (s = !!(64 & e[a + 1]),
                    o = ((31 & e[a + 1]) << 8) + e[a + 2],
                    1 < (48 & e[a + 3]) >> 4) {
                        if ((l = a + 5 + e[a + 4]) === a + 188)
                            continue
                    } else
                        l = a + 4;
                    switch (o) {
                    case c:
                        s && (f && (d = this._parsePES(f)) && this._parseAVCPES(d, !1),
                        f = {
                            data: [],
                            size: 0,
                            keyTagInfo: t
                        }),
                        f && (f.data.push(e.subarray(l, a + 188)),
                        f.size += a + 188 - l);
                        break;
                    case h:
                        if (s && !this.Ft) {
                            if (g && (d = this._parsePES(g)))
                                switch (r.segmentCodec) {
                                case "aac":
                                    this._parseAACPES(d);
                                    break;
                                case "mp3":
                                    this._parseMPEGPES(d);
                                    break;
                                case "ac3":
                                case "ec3":
                                    this._parseDolbyPES(d)
                                }
                            g = {
                                data: [],
                                size: 0,
                                keyTagInfo: t
                            }
                        }
                        g && (g.data.push(e.subarray(l, a + 188)),
                        g.size += a + 188 - l);
                        break;
                    case p:
                        s && (y && (d = this._parsePES(y)) && n.id3Samples.push(d),
                        y = {
                            data: [],
                            size: 0
                        }),
                        y && (y.data.push(e.subarray(l, a + 188)),
                        y.size += a + 188 - l);
                        break;
                    case 0:
                        s && (l += e[l] + 1),
                        m = this.Bt = this._parsePAT(e, l);
                        break;
                    case m:
                        s && (l += e[l] + 1);
                        const o = this._parsePMT(e, l, this.typeSupported);
                        0 < (c = o.avcId) && (i.info.id = c,
                        i.info.encrypted = o.videoEncrypted),
                        0 < (h = o.audioId) && (r.info.id = h,
                        r.segmentCodec = o.audioSegmentCodec,
                        r.info.encrypted = o.audioEncrypted),
                        0 < (p = o.id3Id) && (n.id = p),
                        v && !u && (v = !1,
                        a = -188),
                        u = this._t = !0;
                        break;
                    case 17:
                    case 8191:
                        break;
                    default:
                        v = !0
                    }
                }
                if (f && (d = this._parsePES(f)) ? (this._parseAVCPES(d, !0),
                i.pesData = void 0) : i.pesData = f,
                g && (d = this._parsePES(g))) {
                    switch (r.segmentCodec) {
                    case "aac":
                        this._parseAACPES(d);
                        break;
                    case "mp3":
                        this._parseMPEGPES(d);
                        break;
                    case "ac3":
                    case "ec3":
                        this._parseDolbyPES(d)
                    }
                    r.pesData = void 0
                } else
                    r.pesData = g;
                y && (d = this._parsePES(y)) ? (n.id3Samples.push(d),
                n.pesData = void 0) : n.pesData = y
            }
            Qt(e, t, i, r, n, a) {
                var s = this.$t
                  , o = this.Vt
                  , l = this.Pt;
                let d, u;
                o.config && o.segmentCodec && (d = {
                    type: "audio",
                    info: o.info,
                    config: o.config,
                    parsingData: o.parsingData
                });
                var c, o = s.config;
                "string" == typeof (c = o).codec && Array.isArray(c.sps) && Array.isArray(c.pps) && "number" == typeof c.width && "number" == typeof c.height && Array.isArray(c.pixelRatio) && (u = {
                    type: "video",
                    info: s.info,
                    config: o,
                    parsingData: s.parsingData
                }),
                this.esRemuxer.remuxEsTracks(d, u, l, this.qt, e, t, i, r, n, a)
            }
            destroy() {
                this.Kt = 0
            }
            _parsePAT(e, t) {
                return (31 & e[t + 10]) << 8 | e[t + 11]
            }
            _parsePMT(e, t, i) {
                var r, n = {
                    audioId: -1,
                    avcId: -1,
                    id3Id: -1,
                    audioEncrypted: !1,
                    videoEncrypted: !1
                }, a = t + 3 + ((15 & e[t + 1]) << 8 | e[t + 2]) - 4;
                for (t += 12 + ((15 & e[t + 10]) << 8 | e[t + 11]); t < a; ) {
                    switch (r = (31 & e[t + 1]) << 8 | e[t + 2],
                    e[t]) {
                    case 207:
                        n.audioEncrypted = !0;
                    case 15:
                        -1 === n.audioId && (n.audioId = r,
                        n.audioSegmentCodec = "aac");
                        break;
                    case 21:
                        -1 === n.id3Id && (n.id3Id = r);
                        break;
                    case 219:
                        n.videoEncrypted = !0;
                    case 27:
                        -1 === n.avcId && (n.avcId = r);
                        break;
                    case 3:
                    case 4:
                        !0 !== i.mpeg && !0 !== i.mp3 || -1 === n.audioId && (n.audioId = r,
                        n.audioSegmentCodec = "mp3");
                        break;
                    case 193:
                        n.audioEncrypted = !0;
                    case 129:
                        !0 === i.ac3 && -1 === n.audioId && (n.audioId = r,
                        n.audioSegmentCodec = "ac3");
                        break;
                    case 194:
                        n.audioEncrypted = !0;
                    case 135:
                        !0 === i.ec3 && -1 === n.audioId && (n.audioId = r,
                        n.audioSegmentCodec = "ec3")
                    }
                    t += 5 + ((15 & e[t + 3]) << 8 | e[t + 4])
                }
                return n
            }
            _parsePES(e) {
                let i, t, r, n, a, s, o = 0;
                var l = e.data
                  , d = e.keyTagInfo;
                let u = NaN
                  , c = NaN;
                if (e && 0 !== e.size) {
                    for (; l[0].length < 19 && 1 < l.length; ) {
                        const e = new Uint8Array(l[0].length + l[1].length);
                        e.set(l[0]),
                        e.set(l[1], l[0].length),
                        l[0] = e,
                        l.splice(1, 1)
                    }
                    if (1 === ((i = l[0])[0] << 16) + (i[1] << 8) + i[2] && !((r = (i[4] << 8) + i[5]) && r > e.size - 6)) {
                        192 & (t = i[7]) && (u = 536870912 * (14 & i[9]) + 4194304 * (255 & i[10]) + 16384 * (254 & i[11]) + 128 * (255 & i[12]) + (254 & i[13]) / 2,
                        64 & t ? (c = 536870912 * (14 & i[14]) + 4194304 * (255 & i[15]) + 16384 * (254 & i[16]) + 128 * (255 & i[17]) + (254 & i[18]) / 2,
                        54e5 < u - c && (u = c)) : c = u),
                        n = i[8],
                        s = n + 9,
                        e.size -= s,
                        a = new Uint8Array(e.size);
                        for (let t = 0, e = l.length; t < e; t++) {
                            let e = (i = l[t]).byteLength;
                            if (s) {
                                if (s > e) {
                                    s -= e;
                                    continue
                                }
                                i = i.subarray(s),
                                e -= s,
                                s = 0
                            }
                            a.set(i, o),
                            o += e
                        }
                        return r && (r -= n + 3),
                        {
                            data: a,
                            pts: u,
                            dts: c,
                            len: r,
                            keyTagInfo: d
                        }
                    }
                }
            }
            pushAccesUnit(e, t) {
                var i, r, n = e.avcSample;
                n && n.units.length && n.frame && !this.Ht && (r = (i = e.parsingData.esSamples).length,
                (!0 === n.key || e.config.sps && (r || this.Ut)) && (n.id = r,
                n.keyTagInfo = t,
                e.info.encrypted) && n.units.forEach(e => {
                    if (48 < e.data.byteLength)
                        switch (e.type) {
                        case 1:
                        case 5:
                            e.data = this.discardEPB(e.data)
                        }
                }
                ),
                r || isFinite(n.pts) ? i.push(n) : e.parsingData.dropped++)
            }
            _parseAVCPES(a, e) {
                if (!a.data)
                    throw "invalid pes data";
                const s = this.Kt
                  , o = this.$t
                  , l = this.qt
                  , t = this._parseAVCNALu(a.data);
                let d, u, c, h = o.avcSample;
                const p = a.keyTagInfo;
                a.data = void 0,
                t.forEach(n => {
                    switch (n.type) {
                    case 1:
                        if (h && !this.Ft) {
                            u = !0,
                            h.frame = !0;
                            const a = n.data;
                            if (4 < a.length) {
                                const n = new St(a,this.logger).readSliceType();
                                2 !== n && 4 !== n && 7 !== n && 9 !== n || (h.key = !0)
                            }
                        }
                        break;
                    case 5:
                        u = !0,
                        h || (h = this._createAVCSample(!0, a.pts, a.dts, ""),
                        o.avcSample = h),
                        h && (h.key = !0,
                        h.frame = !0);
                        break;
                    case 6:
                        u = !0,
                        (d = new St(this.discardEPB(n.data),this.logger)).readUByte();
                        let e = 0
                          , t = 0
                          , i = !1
                          , r = 0;
                        for (; !i && 1 < d.bytesAvailable; ) {
                            for (e = 0; r = d.readUByte(),
                            e += r,
                            255 === r; )
                                ;
                            for (t = 0; r = d.readUByte(),
                            t += r,
                            255 === r; )
                                ;
                            if (4 === e && 0 !== d.bytesAvailable) {
                                if (i = !0,
                                181 === d.readUByte() && 49 === d.readUShort() && 1195456820 === d.readUInt() && 3 === d.readUByte()) {
                                    const n = d.readUByte()
                                      , s = 31 & n
                                      , o = [n, d.readUByte()];
                                    for (c = 0; c < s; c++)
                                        o.push(d.readUByte()),
                                        o.push(d.readUByte()),
                                        o.push(d.readUByte());
                                    this._insertSampleInOrder(l.captionSamples, {
                                        type: 3,
                                        pts: a.pts,
                                        bytes: o
                                    })
                                }
                            } else if (t < d.bytesAvailable)
                                for (c = 0; c < t; c++)
                                    d.readUByte()
                        }
                        break;
                    case 7:
                        if (u = !0,
                        !o.config.sps) {
                            const a = (d = new St(n.data,this.logger)).readSPS()
                              , l = (o.config.width = a.width,
                            o.config.height = a.height,
                            o.config.pixelRatio = a.pixelRatio,
                            o.config.sps = [n.data],
                            o.info.duration = s,
                            n.data.subarray(1, 4));
                            let t = "avc1.";
                            for (c = 0; c < 3; c++) {
                                let e = l[c].toString(16);
                                e.length < 2 && (e = "0" + e),
                                t += e
                            }
                            o.config.codec = t
                        }
                        break;
                    case 8:
                        u = !0,
                        o.config.pps || (o.config.pps = [n.data]);
                        break;
                    case 9:
                        u = !0,
                        h && this.pushAccesUnit(o, p),
                        h = this._createAVCSample(!1, a.pts, a.dts, ""),
                        o.avcSample = h;
                        break;
                    case 12:
                        u = !0;
                        break;
                    default:
                        u = !1
                    }
                    h && u && h.units.push(n)
                }
                ),
                e && h && (this.pushAccesUnit(o, p),
                o.avcSample = void 0)
            }
            _createAVCSample(e, t, i, r) {
                return {
                    id: NaN,
                    key: e,
                    pts: t,
                    dts: i,
                    units: new Array,
                    debug: r
                }
            }
            _insertSampleInOrder(t, i) {
                var r = t.length;
                if (0 < r) {
                    if (i.pts >= t[r - 1].pts)
                        t.push(i);
                    else
                        for (let e = r - 1; 0 <= e; e--)
                            if (i.pts < t[e].pts) {
                                t.splice(e, 0, i);
                                break
                            }
                } else
                    t.push(i)
            }
            _getLastNalUnit() {
                const e = this.$t;
                let t, i = e.avcSample;
                if (!i || 0 === i.units.length) {
                    const t = e.parsingData.esSamples;
                    i = t[t.length - 1]
                }
                if (i) {
                    const e = i.units;
                    t = e[e.length - 1]
                }
                return t
            }
            _parseAVCNALu(e) {
                const t = e.byteLength;
                let i, r, n = 0;
                var a = this.$t;
                let s = a.naluState || 0;
                var o = s
                  , l = [];
                let d, u, c, h = -1;
                for (-1 === s && (h = 0,
                c = 31 & e[0],
                s = 0,
                n = 1); n < t; )
                    if (i = e[n++],
                    s)
                        if (1 !== s)
                            if (i)
                                if (1 === i) {
                                    if (0 <= h)
                                        d = {
                                            data: e.subarray(h, n - s - 1),
                                            type: c
                                        },
                                        l.push(d);
                                    else {
                                        const t = this._getLastNalUnit();
                                        if (t && (o && n <= 4 - o && t.state && (t.data = t.data.subarray(0, t.data.byteLength - o)),
                                        0 < (r = n - s - 1))) {
                                            const i = new Uint8Array(t.data.byteLength + r);
                                            i.set(t.data, 0),
                                            i.set(e.subarray(0, r), t.data.byteLength),
                                            t.data = i,
                                            t.state = 0
                                        }
                                    }
                                    s = n < t ? (u = 31 & e[n],
                                    h = n,
                                    c = u,
                                    0) : -1
                                } else
                                    s = 0;
                            else
                                s = 3;
                        else
                            s = i ? 0 : 2;
                    else
                        s = i ? 0 : 1;
                if (0 <= h && 0 <= s && (d = {
                    data: e.subarray(h, t),
                    type: c,
                    state: s
                },
                l.push(d)),
                0 === l.length) {
                    const t = this._getLastNalUnit();
                    if (t) {
                        const i = new Uint8Array(t.data.byteLength + e.byteLength);
                        i.set(t.data, 0),
                        i.set(e, t.data.byteLength),
                        t.data = i
                    }
                }
                return a.naluState = s,
                l
            }
            discardEPB(e) {
                var t = e.byteLength
                  , i = [];
                let r = 1;
                for (; r < t - 2; )
                    0 === e[r] && 0 === e[r + 1] && 3 === e[r + 2] ? (i.push(r + 2),
                    r += 2) : r++;
                if (0 === i.length)
                    return e;
                var n = t - i.length
                  , a = new Uint8Array(n);
                let s = 0;
                for (r = 0; r < n; s++,
                r++)
                    s === i[0] && (s++,
                    i.shift()),
                    a[r] = e[s];
                return a
            }
            _parseAACPES(i) {
                const r = this.Vt
                  , {audioLastPTS: n, audioOverFlow: a, parsingData: {esSamples: s}} = r
                  , o = i.keyTagInfo;
                let l, d, u = i.data, c = 0;
                if (a) {
                    const i = r.overflowMissingBytes || 0
                      , l = (r.audioOverFlow = void 0,
                    r.overflowMissingBytes = -1,
                    a.byteLength);
                    if (i <= 0) {
                        const i = new Uint8Array(l + u.byteLength);
                        i.set(a, 0),
                        i.set(u, l),
                        u = i
                    } else if (void 0 !== n) {
                        const r = l - i
                          , d = (a.set(u.subarray(0, i), r),
                        {
                            unit: a,
                            pts: n,
                            dts: n,
                            keyTagInfo: o
                        });
                        s.push(d),
                        c = i
                    }
                }
                for (l = c,
                d = u.length; l < d - 1 && (255 !== u[l] || 240 != (246 & u[l + 1])); l++)
                    ;
                if (l !== c) {
                    let e, t;
                    const n = l < d - 1;
                    if (t = n ? (e = `AAC PES did not start with ADTS header,offset:` + l,
                    H.PESDidNotStartWithADTS) : (e = "No ADTS header found in AAC PES",
                    H.NoADTSHeaderInPES),
                    !n) {
                        const a = new A(!n,t,e);
                        return void this.observer.trigger(L.INTERNAL_ERROR, a)
                    }
                }
                if (!r.config) {
                    const i = V(this.observer, u, l, void 0, this.logger);
                    if (!i)
                        throw "unable to parse adts header";
                    r.config = i
                }
                var h = 9216e4 / r.config.samplerate;
                let p;
                if (isFinite(i.pts))
                    p = i.pts;
                else {
                    if (!a || void 0 === n || !s.length)
                        return;
                    p = n + h
                }
                i = void 0 !== n && s.length ? p - (n + h) : 0;
                void 0 !== n && 1 < Math.abs(i) && (p = n + h);
                let m = n
                  , f = 0;
                for (; l < d; ) {
                    let e;
                    const n = 1 & u[l + 1] ? 7 : 9;
                    let t;
                    if (l + n <= d) {
                        const i = (3 & u[l + 3]) << 11 | u[l + 4] << 3 | (224 & u[l + 5]) >>> 5;
                        t = Math.max(0, i - n)
                    }
                    if (!n || !t) {
                        (e = new Uint8Array(d - l)).set(u.subarray(l, d), 0),
                        r.audioOverFlow = e;
                        break
                    }
                    {
                        m = p + f * h;
                        const H = t + n
                          , c = Math.max(0, l + H - d);
                        if (r.overflowMissingBytes = c) {
                            (e = new Uint8Array(H - n)).set(u.subarray(l + n, u.length), 0),
                            r.audioOverFlow = e;
                            break
                        }
                        {
                            const c = {
                                unit: e = u.subarray(l + n, l + H),
                                pts: m,
                                dts: m,
                                keyTagInfo: o
                            };
                            for (s.push(c),
                            r.parsingData.len += t,
                            f++,
                            l += H; l < d - 1 && (255 !== u[l] || 240 != (246 & u[l + 1])); l++)
                                ;
                        }
                    }
                }
                r.audioLastPTS = m
            }
            _parseMPEGPES(e) {
                var t;
                "mp3" === (null == (t = this.Vt) ? void 0 : t.segmentCodec) && Qe.parse(this.Vt.parsingData, e.data, 0, e.pts, this.logger)
            }
            _parseDolbyPES(e) {
                var t, i = this.Vt, r = this.Kt;
                let n = e.data
                  , a = e.pts;
                var s = e.keyTagInfo;
                let o = 0
                  , l = 0
                  , d = i.audioOverFlow;
                var u = i.audioLastPTS;
                if (!i.config) {
                    let e;
                    if ("ac3" === i.segmentCodec ? e = Ne(this.observer, n, l, this.logger) : "ec3" === i.segmentCodec && (e = Ue.getAudioConfig(this.observer, n, l, this.logger)),
                    !e)
                        throw "unable to parse dolby header";
                    i.config = e
                }
                if ("ac3" !== i.config.segmentCodec && "ec3" !== i.config.segmentCodec)
                    throw "unexpected config type";
                var c = 1536 / i.config.samplerate * i.info.inputTimescale;
                if (d) {
                    const e = new Uint8Array(d.byteLength + n.byteLength);
                    e.set(d, 0),
                    e.set(n, d.byteLength),
                    n = e
                }
                var h = n.length;
                if (d && u) {
                    const e = u + c;
                    1 < Math.abs(e - a) && (a = e)
                }
                let p = 0;
                for (; l + p <= h; ) {
                    if (11 !== n[l] || 119 !== n[l + 1]) {
                        const e = new A(!0,H.InvalidDolbyAudioMagic);
                        return void this.observer.trigger(L.INTERNAL_ERROR, e)
                    }
                    "ac3" === i.segmentCodec ? p = null != (t = De(this.observer, n, l)) ? t : NaN : "ec3" === i.segmentCodec && (p = null != (t = Ue.getFrameLength(this.observer, n, l, this.logger)) ? t : NaN);
                    const e = a + o * c
                      , d = (i.audioLastPTS = e,
                    {
                        unit: n.subarray(l, l + p),
                        pts: e,
                        dts: e,
                        keyTagInfo: s
                    });
                    i.parsingData.esSamples.push(d),
                    i.info.duration = r,
                    i.parsingData.len += p,
                    l += p,
                    o++
                }
                d = l < h ? n.subarray(l, h) : void 0,
                i.audioOverFlow = d
            }
        }
        var Tt, Et = bt;
        class At extends a {
            constructor(e, t, i, r) {
                super(),
                this.lt = e,
                this.Gt = t,
                this.Wt = i,
                this.R = r
            }
            destroy() {
                this.removeAllListeners();
                var e = this.Xt
                  , t = this.Yt;
                e && e.destroy(),
                t && t.destroy()
            }
            push(i, r, n, a, s, o, l, d, u, c, h, p, m) {
                if (i) {
                    let e = this.Xt
                      , t = this.Yt;
                    var f = i;
                    if (!e || !t || (s || o) && (null == (i = this.Jt) || !i.call(this, f, this.R))) {
                        const {lt: i, Gt: r} = this
                          , n = [{
                            demux: yt,
                            remux: ht
                        }, {
                            demux: Et,
                            remux: ot
                        }, {
                            demux: _e,
                            remux: ot
                        }, {
                            demux: Be,
                            remux: ot
                        }, {
                            demux: Ce,
                            remux: ot
                        }, {
                            demux: Ke,
                            remux: ot
                        }];
                        for (const a of n) {
                            const n = a.demux["probe"];
                            if (n(f, this.R)) {
                                t = new a.remux(this,r,i,this.Wt,this.R,m),
                                e = new a.demux(this,t,r,i,this.R),
                                this.Jt = n;
                                break
                            }
                        }
                        if (!e || !t) {
                            const i = new A(!0,H.DemuxerNotFound);
                            return void this.trigger(L.INTERNAL_ERROR, i)
                        }
                        this.Yt = t,
                        this.Xt = e
                    }
                    i = !this.Zt || r && "NONE" !== r.method && (this.Zt.uri !== r.uri || this.Zt.iv !== r.iv);
                    if (this.Zt = r,
                    s || o || i) {
                        const i = n ? new Uint8Array(n) : void 0;
                        e.resetInitSegment(i, d, r, s),
                        t.resetInitSegment()
                    }
                    if (s) {
                        const i = c ? P(c) : void 0;
                        e.resetTimeStamp(i),
                        t.resetTimeStamp(i)
                    }
                    e.append(f, a, l, u, r, h, p)
                }
            }
        }
        function Ot() {
            let e = Date.now() + `-` + Math.random();
            return "undefined" != typeof performance && "function" == typeof performance.now && (e += `-` + performance.now()),
            e
        }
        class Rt {
            constructor(e, t) {
                this.N = e,
                this.R = t,
                this.init = (t, n, a) => e => {
                    const i = Ot()
                      , r = this.te[i] = new At(t,n,a,this.R);
                    [E.INIT_PTS_FOUND, E.FRAG_PARSING_INIT_SEGMENT, E.FRAG_PARSING_DATA, E.FRAG_PARSED, L.INTERNAL_ERROR].forEach(t => {
                        r.on(t, e => this.N.invoke("demuxer.event", [i, t, e])( () => {}
                        ))
                    }
                    ),
                    e(i)
                }
                ,
                this.push = (i, r, n, a, s, o, l, d, u, c, h, p, m, f) => e => {
                    var t = this.te[i];
                    t ? (t.push(r, n, a, s, o, l, d, u, c, h, p, m, f),
                    e()) : e(void 0, `Demuxer with id "${i}" does not exist on push`)
                }
                ,
                this.destroy = i => e => {
                    var t = this.te[i];
                    t ? (t.destroy(),
                    delete this.te[i],
                    e()) : this.R.error(`Demuxer with id "${i}" does not exist on destroy`)
                }
                ,
                this.te = {},
                e.register("demuxer.init", this.init),
                e.register("demuxer.push", this.push),
                e.register("demuxer.destroy", this.destroy)
            }
        }
        class wt {
            constructor(e) {
                this.ee = e,
                this.handlers = {},
                this.deferers = {},
                this._messageHandler = e => {
                    var {type: e, id: t, command: i, args: r, result: n, error: a} = e.data;
                    if (e === Tt.Invoke)
                        try {
                            if (null == this.handlers[i])
                                throw new j(!1,H.RPCWorkerCommandNotFound,`command ${i} not found`);
                            null != r && this.handlers[i](...r)(this.ie.bind(this, t, i))
                        } catch (a) {
                            this.ie(t, i, null, new j(!1,H.RPCWorkerCommandNotFound,`command ${i} not found`))
                        }
                    else
                        e === Tt.Result && null != this.deferers[t] && (this.deferers[t](n, a),
                        delete this.deferers[t])
                }
                ,
                e.addEventListener("message", this._messageHandler)
            }
            register(e, t) {
                return null == this.handlers[e] && (this.handlers[e] = t,
                !0)
            }
            unregister(e) {
                return null == this.handlers[e] && (delete this.handlers[e],
                !0)
            }
            invoke(i, r, n) {
                return (e=wt._fallbackCallback) => {
                    var t = Ot()
                      , e = (this.deferers[t] = e,
                    {
                        type: Tt.Invoke,
                        id: t,
                        command: i,
                        args: r
                    });
                    this.ne(e, n)
                }
            }
            teardown(e) {
                this.ee.removeEventListener("message", this._messageHandler),
                e()
            }
            ie(e, t, i, r, n) {
                r instanceof Error && (r = `[${r.name}] ${r.message}
` + r.stack);
                e = {
                    type: Tt.Result,
                    id: e,
                    command: t,
                    result: i,
                    error: r
                };
                this.ne(e, n)
            }
            ne(e, t=[]) {
                this.ee.postMessage(e, t.map(e => ArrayBuffer.isView(e) ? e.buffer : e).filter(e => void 0 !== e))
            }
        }
        wt._fallbackCallback = (e, t) => {
            if (null != t)
                throw t
        }
        ,
        (t = Tt = Tt || {})[t.Invoke = 0] = "Invoke",
        t[t.Result = 1] = "Result",
        ArrayBuffer.isView || (ArrayBuffer.isView = function(e) {
            return null !== e && "object" == typeof e && e.buffer instanceof ArrayBuffer
        }
        ),
        void 0 !== py && py && (t = new wt(l),
        ir = (n => {
            const t = (i=[]) => {
                const r = {};
                return ["fatal", "error", "warn", "info", "debug", "trace", "qe"].forEach(e => {
                    return r[e] = (t = e,
                    (...e) => {
                        n.invoke("logger.log", [i, t, ...e])( (e, t) => {
                            if (null != t)
                                throw t
                        }
                        )
                    }
                    );
                    var t
                }
                ),
                r.child = e => t([...i, e]),
                r
            }
            ;
            return t()
        }
        )(t),
        new n(t,ir),
        new Rt(t,ir));
        var Pt = {
            type: null,
            entityIds: null,
            skip: !1,
            payload: null
        }
          , Mt = !1;
        function Ct(e, t, i) {
            kt(e, t, i),
            Mt = !0
        }
        function kt(e, t, i) {
            !1 === Mt && (Pt.type = e,
            Pt.entityIds = t,
            Pt.payload = i)
        }
        function Lt(e, t) {
            return e.hasOwnProperty(t)
        }
        function Nt(e) {
            return Array.isArray(e)
        }
        function Dt(e) {
            return e.hasOwnProperty("active")
        }
        function xt(e) {
            return Nt(e)
        }
        function Ft(e) {
            var t, i, {active: e, ids: r, entities: n} = e;
            return xt(e) ? (t = r,
            (i = (r = e).filter(e => -1 < t.indexOf(e))).length === r.length ? r : i) : !1 === Lt(n, e) ? null : e
        }
        function Bt(t, e) {
            var i, r = Object.keys(t);
            return Object.getOwnPropertySymbols && (i = Object.getOwnPropertySymbols(t),
            e && (i = i.filter(function(e) {
                return Object.getOwnPropertyDescriptor(t, e).enumerable
            })),
            r.push.apply(r, i)),
            r
        }
        function I(r) {
            for (var e = 1; e < arguments.length; e++) {
                var n = null != arguments[e] ? arguments[e] : {};
                e % 2 ? Bt(Object(n), !0).forEach(function(e) {
                    var t, i;
                    t = r,
                    i = n[e = e],
                    e in t ? Object.defineProperty(t, e, {
                        value: i,
                        enumerable: !0,
                        configurable: !0,
                        writable: !0
                    }) : t[e] = i
                }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(n)) : Bt(Object(n)).forEach(function(e) {
                    Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(n, e))
                })
            }
            return r
        }
        function Ut(e) {
            e = function(e) {
                if ("object" != typeof e || null === e)
                    return e;
                var t = e[Symbol.toPrimitive];
                if (void 0 === t)
                    return String(e);
                t = t.call(e, "string");
                if ("object" != typeof t)
                    return t;
                throw new TypeError("@@toPrimitive must return a primitive value.")
            }(e);
            return "symbol" == typeof e ? e : String(e)
        }
        function _t(e) {
            return null == e
        }
        function Vt(e) {
            return _t(e) ? [] : Array.isArray(e) ? e : [e]
        }
        function Qt(e, t, i) {
            i = 2 < arguments.length && void 0 !== i ? i : {},
            t = Vt(t),
            e = e || [];
            return i.prepend ? [...t, ...e] : [...e, ...t]
        }
        function Kt(e) {
            return "function" == typeof e
        }
        function Ht(t) {
            return function(e) {
                if (Kt(null == e ? void 0 : e.lift))
                    return e.lift(function(e) {
                        try {
                            return t(e, this)
                        } catch (e) {
                            this.error(e)
                        }
                    });
                throw new TypeError("Unable to lift unknown Observable type")
            }
        }
        var jt = function(e, t) {
            return (jt = Object.setPrototypeOf || {
                __proto__: []
            }instanceof Array && function(e, t) {
                e.__proto__ = t
            }
            || function(e, t) {
                for (var i in t)
                    Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i])
            }
            )(e, t)
        };
        function qt(e, t) {
            if ("function" != typeof t && null !== t)
                throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
            function i() {
                this.constructor = e
            }
            jt(e, t),
            e.prototype = null === t ? Object.create(t) : (i.prototype = t.prototype,
            new i)
        }
        function Gt(e, t, i, r) {
            var n, a = arguments.length, s = a < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, i) : r;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
                s = Reflect.decorate(e, t, i, r);
            else
                for (var o = e.length - 1; 0 <= o; o--)
                    (n = e[o]) && (s = (a < 3 ? n(s) : 3 < a ? n(t, i, s) : n(t, i)) || s);
            3 < a && s && Object.defineProperty(t, i, s)
        }
        function $t(e, t) {
            if ("object" == typeof Reflect && "function" == typeof Reflect.metadata)
                return Reflect.metadata(e, t)
        }
        function Wt(r, n) {
            var a, s, o, l = {
                label: 0,
                sent: function() {
                    if (1 & o[0])
                        throw o[1];
                    return o[1]
                },
                trys: [],
                ops: []
            }, e = {
                next: t(0),
                throw: t(1),
                return: t(2)
            };
            return "function" == typeof Symbol && (e[Symbol.iterator] = function() {
                return this
            }
            ),
            e;
            function t(i) {
                return function(e) {
                    var t = [i, e];
                    if (a)
                        throw new TypeError("Generator is already executing.");
                    for (; l; )
                        try {
                            if (a = 1,
                            s && (o = 2 & t[0] ? s.return : t[0] ? s.throw || ((o = s.return) && o.call(s),
                            0) : s.next) && !(o = o.call(s, t[1])).done)
                                return o;
                            switch (s = 0,
                            (t = o ? [2 & t[0], o.value] : t)[0]) {
                            case 0:
                            case 1:
                                o = t;
                                break;
                            case 4:
                                return l.label++,
                                {
                                    value: t[1],
                                    done: !1
                                };
                            case 5:
                                l.label++,
                                s = t[1],
                                t = [0];
                                continue;
                            case 7:
                                t = l.ops.pop(),
                                l.trys.pop();
                                continue;
                            default:
                                if (!((o = 0 < (o = l.trys).length && o[o.length - 1]) || 6 !== t[0] && 2 !== t[0])) {
                                    l = 0;
                                    continue
                                }
                                if (3 === t[0] && (!o || t[1] > o[0] && t[1] < o[3]))
                                    l.label = t[1];
                                else if (6 === t[0] && l.label < o[1])
                                    l.label = o[1],
                                    o = t;
                                else {
                                    if (!(o && l.label < o[2])) {
                                        o[2] && l.ops.pop(),
                                        l.trys.pop();
                                        continue
                                    }
                                    l.label = o[2],
                                    l.ops.push(t)
                                }
                            }
                            t = n.call(r, l)
                        } catch (e) {
                            t = [6, e],
                            s = 0
                        } finally {
                            a = o = 0
                        }
                    if (5 & t[0])
                        throw t[1];
                    return {
                        value: t[0] ? t[1] : void 0,
                        done: !0
                    }
                }
            }
        }
        function zt(e) {
            var t = "function" == typeof Symbol && Symbol.iterator
              , i = t && e[t]
              , r = 0;
            if (i)
                return i.call(e);
            if (e && "number" == typeof e.length)
                return {
                    next: function() {
                        return {
                            value: (e = e && r >= e.length ? void 0 : e) && e[r++],
                            done: !e
                        }
                    }
                };
            throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.")
        }
        function Xt(e, t) {
            var i = "function" == typeof Symbol && e[Symbol.iterator];
            if (!i)
                return e;
            var r, n, a = i.call(e), s = [];
            try {
                for (; (void 0 === t || 0 < t--) && !(r = a.next()).done; )
                    s.push(r.value)
            } catch (e) {
                n = {
                    error: e
                }
            } finally {
                try {
                    r && !r.done && (i = a.return) && i.call(a)
                } finally {
                    if (n)
                        throw n.error
                }
            }
            return s
        }
        function Yt(e, t) {
            for (var i = 0, r = t.length, n = e.length; i < r; i++,
            n++)
                e[n] = t[i];
            return e
        }
        function Jt(e) {
            return this instanceof Jt ? (this.v = e,
            this) : new Jt(e)
        }
        var Zt = function(e) {
            return e && "number" == typeof e.length && "function" != typeof e
        };
        function ei(e) {
            return Kt(null == e ? void 0 : e.then)
        }
        function ti(e) {
            e = e(function(e) {
                Error.call(e),
                e.stack = (new Error).stack
            });
            return e.prototype = Object.create(Error.prototype),
            e.prototype.constructor = e
        }
        var ii = ti(function(t) {
            return function(e) {
                t(this),
                this.message = e ? e.length + " errors occurred during unsubscription:\n" + e.map(function(e, t) {
                    return t + 1 + ") " + e.toString()
                }).join("\n  ") : "",
                this.name = "UnsubscriptionError",
                this.errors = e
            }
        });
        function ri(e, t) {
            e && 0 <= (t = e.indexOf(t)) && e.splice(t, 1)
        }
        si.prototype.unsubscribe = function() {
            var e, t, i, r, n;
            if (!this.closed) {
                this.closed = !0;
                var a = this._parentage;
                if (a)
                    if (this._parentage = null,
                    Array.isArray(a))
                        try {
                            for (var s = zt(a), o = s.next(); !o.done; o = s.next())
                                o.value.remove(this)
                        } catch (t) {
                            e = {
                                error: t
                            }
                        } finally {
                            try {
                                o && !o.done && (t = s.return) && t.call(s)
                            } finally {
                                if (e)
                                    throw e.error
                            }
                        }
                    else
                        a.remove(this);
                a = this.initialTeardown;
                if (Kt(a))
                    try {
                        a()
                    } catch (e) {
                        n = e instanceof ii ? e.errors : [e]
                    }
                a = this._finalizers;
                if (a) {
                    this._finalizers = null;
                    try {
                        for (var l = zt(a), d = l.next(); !d.done; d = l.next()) {
                            var u = d.value;
                            try {
                                li(u)
                            } catch (e) {
                                n = null != n ? n : [],
                                e instanceof ii ? n = Yt(Yt([], Xt(n)), Xt(e.errors)) : n.push(e)
                            }
                        }
                    } catch (e) {
                        i = {
                            error: e
                        }
                    } finally {
                        try {
                            d && !d.done && (r = l.return) && r.call(l)
                        } finally {
                            if (i)
                                throw i.error
                        }
                    }
                }
                if (n)
                    throw new ii(n)
            }
        }
        ,
        si.prototype.add = function(e) {
            var t;
            if (e && e !== this)
                if (this.closed)
                    li(e);
                else {
                    if (e instanceof si) {
                        if (e.closed || e._hasParent(this))
                            return;
                        e._addParent(this)
                    }
                    (this._finalizers = null != (t = this._finalizers) ? t : []).push(e)
                }
        }
        ,
        si.prototype._hasParent = function(e) {
            var t = this._parentage;
            return t === e || Array.isArray(t) && t.includes(e)
        }
        ,
        si.prototype._addParent = function(e) {
            var t = this._parentage;
            this._parentage = Array.isArray(t) ? (t.push(e),
            t) : t ? [t, e] : e
        }
        ,
        si.prototype._removeParent = function(e) {
            var t = this._parentage;
            t === e ? this._parentage = null : Array.isArray(t) && ri(t, e)
        }
        ,
        si.prototype.remove = function(e) {
            var t = this._finalizers;
            t && ri(t, e),
            e instanceof si && e._removeParent(this)
        }
        ,
        si.EMPTY = ((t = new si).closed = !0,
        t);
        var ni = si
          , ai = ni.EMPTY;
        function si(e) {
            this.initialTeardown = e,
            this.closed = !1,
            this._parentage = null,
            this._finalizers = null
        }
        function oi(e) {
            return e instanceof ni || e && "closed"in e && Kt(e.remove) && Kt(e.add) && Kt(e.unsubscribe)
        }
        function li(e) {
            Kt(e) ? e() : e.unsubscribe()
        }
        var di, ui, ci = {
            onUnhandledError: null,
            onStoppedNotification: null,
            Promise: void 0,
            useDeprecatedSynchronousErrorHandling: !1,
            useDeprecatedNextContext: !1
        }, hi = {
            setTimeout: (ui = function(e, t) {
                for (var i = [], r = 2; r < arguments.length; r++)
                    i[r - 2] = arguments[r];
                var n = hi.delegate;
                return null != n && n.setTimeout ? n.setTimeout.apply(n, Yt([e, t], Xt(i))) : setTimeout.apply(void 0, Yt([e, t], Xt(i)))
            }
            ,
            mi.toString = function() {
                return ui.toString()
            }
            ,
            mi),
            clearTimeout: (di = function(e) {
                var t = hi.delegate;
                return ((null == t ? void 0 : t.clearTimeout) || clearTimeout)(e)
            }
            ,
            pi.toString = function() {
                return di.toString()
            }
            ,
            pi),
            delegate: void 0
        };
        function pi(e) {
            return di.apply(this, arguments)
        }
        function mi(e, t) {
            return ui.apply(this, arguments)
        }
        function fi(t) {
            hi.setTimeout(function() {
                var e = ci.onUnhandledError;
                if (!e)
                    throw t;
                e(t)
            })
        }
        function gi() {}
        var yi = vi("C", void 0, void 0);
        function vi(e, t, i) {
            return {
                kind: e,
                value: t,
                error: i
            }
        }
        var Si = null;
        function Ii(e) {
            if (ci.useDeprecatedSynchronousErrorHandling) {
                var t = !Si;
                if (t && (Si = {
                    errorThrown: !1,
                    error: null
                }),
                e(),
                t) {
                    var t = Si
                      , i = t.errorThrown
                      , t = t.error;
                    if (Si = null,
                    i)
                        throw t
                }
            } else
                e()
        }
        qt(Ai, bi = ni),
        Ai.create = function(e, t, i) {
            return new Pi(e,t,i)
        }
        ,
        Ai.prototype.next = function(e) {
            this.isStopped ? Li(vi("N", e, void 0), this) : this._next(e)
        }
        ,
        Ai.prototype.error = function(e) {
            this.isStopped ? Li(vi("E", void 0, e), this) : (this.isStopped = !0,
            this._error(e))
        }
        ,
        Ai.prototype.complete = function() {
            this.isStopped ? Li(yi, this) : (this.isStopped = !0,
            this._complete())
        }
        ,
        Ai.prototype.unsubscribe = function() {
            this.closed || (this.isStopped = !0,
            bi.prototype.unsubscribe.call(this),
            this.destination = null)
        }
        ,
        Ai.prototype._next = function(e) {
            this.destination.next(e)
        }
        ,
        Ai.prototype._error = function(e) {
            try {
                this.destination.error(e)
            } finally {
                this.unsubscribe()
            }
        }
        ,
        Ai.prototype._complete = function() {
            try {
                this.destination.complete()
            } finally {
                this.unsubscribe()
            }
        }
        ;
        var bi, Ti = Ai, Ei = Function.prototype.bind;
        function Ai(e) {
            var t = bi.call(this) || this;
            return t.isStopped = !1,
            e ? oi(t.destination = e) && e.add(t) : t.destination = Ni,
            t
        }
        function Oi(e, t) {
            return Ei.call(e, t)
        }
        Ci.prototype.next = function(e) {
            var t = this.partialObserver;
            if (t.next)
                try {
                    t.next(e)
                } catch (e) {
                    ki(e)
                }
        }
        ,
        Ci.prototype.error = function(e) {
            var t = this.partialObserver;
            if (t.error)
                try {
                    t.error(e)
                } catch (e) {
                    ki(e)
                }
            else
                ki(e)
        }
        ,
        Ci.prototype.complete = function() {
            var e = this.partialObserver;
            if (e.complete)
                try {
                    e.complete()
                } catch (e) {
                    ki(e)
                }
        }
        ;
        var Ri, wi = Ci, Pi = (qt(Mi, Ri = Ti),
        Mi);
        function Mi(e, t, i) {
            var r = Ri.call(this) || this
              , i = Kt(e) || !e ? {
                next: null != e ? e : void 0,
                error: null != t ? t : void 0,
                complete: null != i ? i : void 0
            } : r && ci.useDeprecatedNextContext ? ((t = Object.create(e)).unsubscribe = function() {
                return r.unsubscribe()
            }
            ,
            {
                next: e.next && Oi(e.next, t),
                error: e.error && Oi(e.error, t),
                complete: e.complete && Oi(e.complete, t)
            }) : e;
            return r.destination = new wi(i),
            r
        }
        function Ci(e) {
            this.partialObserver = e
        }
        function ki(e) {
            fi(e)
        }
        function Li(e, t) {
            var i = ci.onStoppedNotification;
            i && hi.setTimeout(function() {
                return i(e, t)
            })
        }
        var Ni = {
            closed: !0,
            next: gi,
            error: function(e) {
                throw e
            },
            complete: gi
        }
          , Di = "function" == typeof Symbol && Symbol.observable || "@@observable";
        function xi(e) {
            return e
        }
        function Fi(t) {
            return 0 === t.length ? xi : 1 === t.length ? t[0] : function(e) {
                return t.reduce(function(e, t) {
                    return t(e)
                }, e)
            }
        }
        Bi.prototype.lift = function(e) {
            var t = new Bi;
            return t.source = this,
            t.operator = e,
            t
        }
        ,
        Bi.prototype.subscribe = function(e, t, i) {
            var r, n = this, a = (r = e) && r instanceof Ti || r && Kt(r.next) && Kt(r.error) && Kt(r.complete) && oi(r) ? e : new Pi(e,t,i);
            return Ii(function() {
                var e = n.operator
                  , t = n.source;
                a.add(e ? e.call(a, t) : t ? n._subscribe(a) : n._trySubscribe(a))
            }),
            a
        }
        ,
        Bi.prototype._trySubscribe = function(t) {
            try {
                return this._subscribe(t)
            } catch (e) {
                t.error(e)
            }
        }
        ,
        Bi.prototype.forEach = function(r, e) {
            var n = this;
            return new (e = Ui(e))(function(e, t) {
                var i = new Pi({
                    next: function(e) {
                        try {
                            r(e)
                        } catch (e) {
                            t(e),
                            i.unsubscribe()
                        }
                    },
                    error: t,
                    complete: e
                });
                n.subscribe(i)
            }
            )
        }
        ,
        Bi.prototype._subscribe = function(e) {
            var t;
            return null == (t = this.source) ? void 0 : t.subscribe(e)
        }
        ,
        Bi.prototype[Di] = function() {
            return this
        }
        ,
        Bi.prototype.pipe = function() {
            for (var e = [], t = 0; t < arguments.length; t++)
                e[t] = arguments[t];
            return Fi(e)(this)
        }
        ,
        Bi.prototype.toPromise = function(e) {
            var r = this;
            return new (e = Ui(e))(function(e, t) {
                var i;
                r.subscribe(function(e) {
                    return i = e
                }, function(e) {
                    return t(e)
                }, function() {
                    return e(i)
                })
            }
            )
        }
        ,
        Bi.create = function(e) {
            return new Bi(e)
        }
        ;
        var G = Bi;
        function Bi(e) {
            e && (this._subscribe = e)
        }
        function Ui(e) {
            return null != (e = null != e ? e : ci.Promise) ? e : Promise
        }
        function _i(e) {
            return Kt(e[Di])
        }
        function Vi(e) {
            return Symbol.asyncIterator && Kt(null == e ? void 0 : e[Symbol.asyncIterator])
        }
        function Qi(e) {
            return new TypeError("You provided " + (null !== e && "object" == typeof e ? "an invalid object" : "'" + e + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")
        }
        var Ki = "function" == typeof Symbol && Symbol.iterator ? Symbol.iterator : "@@iterator";
        function Hi(e) {
            return Kt(null == e ? void 0 : e[Ki])
        }
        function ji(n) {
            var a, s, e, t = this, i = arguments;
            if (Symbol.asyncIterator)
                return a = function() {
                    var t, i, r;
                    return Wt(this, function(e) {
                        switch (e.label) {
                        case 0:
                            t = n.getReader(),
                            e.label = 1;
                        case 1:
                            e.trys.push([1, , 9, 10]),
                            e.label = 2;
                        case 2:
                            return [4, Jt(t.read())];
                        case 3:
                            return i = e.sent(),
                            r = i.value,
                            i.done ? [4, Jt(void 0)] : [3, 5];
                        case 4:
                            return [2, e.sent()];
                        case 5:
                            return [4, Jt(r)];
                        case 6:
                            return [4, e.sent()];
                        case 7:
                            return e.sent(),
                            [3, 2];
                        case 8:
                            return [3, 10];
                        case 9:
                            return t.releaseLock(),
                            [7];
                        case 10:
                            return [2]
                        }
                    })
                }
                .apply(t, i || []),
                s = [],
                e = {},
                r("next"),
                r("throw"),
                r("return"),
                e[Symbol.asyncIterator] = function() {
                    return this
                }
                ,
                e;
            throw new TypeError("Symbol.asyncIterator is not defined.");
            function r(r) {
                a[r] && (e[r] = function(i) {
                    return new Promise(function(e, t) {
                        1 < s.push([r, i, e, t]) || o(r, i)
                    }
                    )
                }
                )
            }
            function o(e, t) {
                try {
                    (i = a[e](t)).value instanceof Jt ? Promise.resolve(i.value.v).then(l, d) : u(s[0][2], i)
                } catch (e) {
                    u(s[0][3], e)
                }
                var i
            }
            function l(e) {
                o("next", e)
            }
            function d(e) {
                o("throw", e)
            }
            function u(e, t) {
                e(t),
                s.shift(),
                s.length && o(s[0][0], s[0][1])
            }
        }
        function qi(e) {
            return Kt(null == e ? void 0 : e.getReader)
        }
        function Gi(e) {
            if (e instanceof G)
                return e;
            if (null != e) {
                if (_i(e))
                    return n = e,
                    new G(function(e) {
                        var t = n[Di]();
                        if (Kt(t.subscribe))
                            return t.subscribe(e);
                        throw new TypeError("Provided object does not correctly implement Symbol.observable")
                    }
                    );
                if (Zt(e))
                    return r = e,
                    new G(function(e) {
                        for (var t = 0; t < r.length && !e.closed; t++)
                            e.next(r[t]);
                        e.complete()
                    }
                    );
                if (ei(e))
                    return i = e,
                    new G(function(t) {
                        i.then(function(e) {
                            t.closed || (t.next(e),
                            t.complete())
                        }, function(e) {
                            return t.error(e)
                        }).then(null, fi)
                    }
                    );
                if (Vi(e))
                    return $i(e);
                if (Hi(e))
                    return s = e,
                    new G(function(e) {
                        var t, i;
                        try {
                            for (var r = zt(s), n = r.next(); !n.done; n = r.next()) {
                                var a = n.value;
                                if (e.next(a),
                                e.closed)
                                    return
                            }
                        } catch (e) {
                            t = {
                                error: e
                            }
                        } finally {
                            try {
                                n && !n.done && (i = r.return) && i.call(r)
                            } finally {
                                if (t)
                                    throw t.error
                            }
                        }
                        e.complete()
                    }
                    );
                if (qi(e))
                    return $i(ji(e))
            }
            var s, i, r, n;
            throw Qi(e)
        }
        function $i(e) {
            return new G(function(t) {
                !function(i, r) {
                    var n, a, s, o, l, e = this, d = function() {
                        var t;
                        return Wt(this, function(e) {
                            switch (e.label) {
                            case 0:
                                e.trys.push([0, 5, 6, 11]),
                                n = function(s) {
                                    var e, t;
                                    if (Symbol.asyncIterator)
                                        return (t = s[Symbol.asyncIterator]) ? t.call(s) : (s = zt(s),
                                        e = {},
                                        i("next"),
                                        i("throw"),
                                        i("return"),
                                        e[Symbol.asyncIterator] = function() {
                                            return this
                                        }
                                        ,
                                        e);
                                    throw new TypeError("Symbol.asyncIterator is not defined.");
                                    function i(a) {
                                        e[a] = s[a] && function(n) {
                                            return new Promise(function(e, t) {
                                                var i, r;
                                                i = e,
                                                e = t,
                                                r = (n = s[a](n)).done,
                                                t = n.value,
                                                Promise.resolve(t).then(function(e) {
                                                    i({
                                                        value: e,
                                                        done: r
                                                    })
                                                }, e)
                                            }
                                            )
                                        }
                                    }
                                }(i),
                                e.label = 1;
                            case 1:
                                return [4, n.next()];
                            case 2:
                                if ((a = e.sent()).done)
                                    return [3, 4];
                                if (t = a.value,
                                r.next(t),
                                r.closed)
                                    return [2];
                                e.label = 3;
                            case 3:
                                return [3, 1];
                            case 4:
                                return [3, 11];
                            case 5:
                                return t = e.sent(),
                                s = {
                                    error: t
                                },
                                [3, 11];
                            case 6:
                                return e.trys.push([6, , 9, 10]),
                                a && !a.done && (o = n.return) ? [4, o.call(n)] : [3, 8];
                            case 7:
                                e.sent(),
                                e.label = 8;
                            case 8:
                                return [3, 10];
                            case 9:
                                if (s)
                                    throw s.error;
                                return [7];
                            case 10:
                                return [7];
                            case 11:
                                return r.complete(),
                                [2]
                            }
                        })
                    };
                    return new (l = (l = void 0) || Promise)(function(i, t) {
                        function r(e) {
                            try {
                                a(d.next(e))
                            } catch (e) {
                                t(e)
                            }
                        }
                        function n(e) {
                            try {
                                a(d.throw(e))
                            } catch (e) {
                                t(e)
                            }
                        }
                        function a(e) {
                            var t;
                            e.done ? i(e.value) : ((t = e.value)instanceof l ? t : new l(function(e) {
                                e(t)
                            }
                            )).then(r, n)
                        }
                        a((d = d.apply(e, [])).next())
                    }
                    )
                }(e, t).catch(function(e) {
                    return t.error(e)
                })
            }
            )
        }
        function Wi(e, t, i, r, n) {
            return new tr(e,t,i,r,n)
        }
        qt(mr, er = Ti),
        mr.prototype.unsubscribe = function() {
            var e;
            this.shouldUnsubscribe && !this.shouldUnsubscribe() || (e = this.closed,
            er.prototype.unsubscribe.call(this),
            e) || null != (e = this.onFinalize) && e.call(this)
        }
        ;
        var zi, Xi, Yi, Ji, Zi, er, tr = mr, ir = (qt(pr, Zi = ni),
        pr.prototype.schedule = function(e, t) {
            return this
        }
        ,
        pr), rr = {
            setInterval: (Ji = function(e, t) {
                for (var i = [], r = 2; r < arguments.length; r++)
                    i[r - 2] = arguments[r];
                var n = rr.delegate;
                return null != n && n.setInterval ? n.setInterval.apply(n, Yt([e, t], Xt(i))) : setInterval.apply(void 0, Yt([e, t], Xt(i)))
            }
            ,
            hr.toString = function() {
                return Ji.toString()
            }
            ,
            hr),
            clearInterval: (Yi = function(e) {
                var t = rr.delegate;
                return ((null == t ? void 0 : t.clearInterval) || clearInterval)(e)
            }
            ,
            cr.toString = function() {
                return Yi.toString()
            }
            ,
            cr),
            delegate: void 0
        }, t = (qt(ur, Xi = ir),
        ur.prototype.schedule = function(e, t) {
            var i;
            return void 0 === t && (t = 0),
            this.closed || (this.state = e,
            e = this.id,
            i = this.scheduler,
            null != e && (this.id = this.recycleAsyncId(i, e, t)),
            this.pending = !0,
            this.delay = t,
            this.id = null != (e = this.id) ? e : this.requestAsyncId(i, this.id, t)),
            this
        }
        ,
        ur.prototype.requestAsyncId = function(e, t, i) {
            return void 0 === i && (i = 0),
            rr.setInterval(e.flush.bind(e, this), i)
        }
        ,
        ur.prototype.recycleAsyncId = function(e, t, i) {
            if (null != (i = void 0 === i ? 0 : i) && this.delay === i && !1 === this.pending)
                return t;
            null != t && rr.clearInterval(t)
        }
        ,
        ur.prototype.execute = function(e, t) {
            if (this.closed)
                return new Error("executing a cancelled action");
            this.pending = !1;
            e = this._execute(e, t);
            if (e)
                return e;
            !1 === this.pending && null != this.id && (this.id = this.recycleAsyncId(this.scheduler, this.id, null))
        }
        ,
        ur.prototype._execute = function(e, t) {
            var i, r = !1;
            try {
                this.work(e)
            } catch (e) {
                r = !0,
                i = e || new Error("Scheduled action threw falsy error")
            }
            if (r)
                return this.unsubscribe(),
                i
        }
        ,
        ur.prototype.unsubscribe = function() {
            var e, t, i;
            this.closed || (e = this.id,
            i = (t = this.scheduler).actions,
            this.work = this.state = this.scheduler = null,
            this.pending = !1,
            ri(i, this),
            null != e && (this.id = this.recycleAsyncId(t, e, null)),
            this.delay = null,
            Xi.prototype.unsubscribe.call(this))
        }
        ,
        ur), nr = {
            now: function() {
                return (nr.delegate || Date).now()
            },
            delegate: void 0
        }, ar = (dr.prototype.schedule = function(e, t, i) {
            return void 0 === t && (t = 0),
            new this.schedulerActionCtor(this,e).schedule(i, t)
        }
        ,
        dr.now = nr.now,
        dr), i = (qt(lr, zi = ar),
        lr.prototype.flush = function(e) {
            var t, i = this.actions;
            if (this._active)
                i.push(e);
            else {
                this._active = !0;
                do {
                    if (t = e.execute(e.state, e.delay))
                        break
                } while (e = i.shift());
                if (this._active = !1,
                t) {
                    for (; e = i.shift(); )
                        e.unsubscribe();
                    throw t
                }
            }
        }
        ,
        lr), sr = new i(t), or = sr;
        function lr(e, t) {
            e = zi.call(this, e, t = void 0 === t ? ar.now : t) || this;
            return e.actions = [],
            e._active = !1,
            e
        }
        function dr(e, t) {
            void 0 === t && (t = dr.now),
            this.schedulerActionCtor = e,
            this.now = t
        }
        function ur(e, t) {
            var i = Xi.call(this, e, t) || this;
            return i.scheduler = e,
            i.work = t,
            i.pending = !1,
            i
        }
        function cr(e) {
            return Yi.apply(this, arguments)
        }
        function hr(e, t) {
            return Ji.apply(this, arguments)
        }
        function pr(e, t) {
            return Zi.call(this) || this
        }
        function mr(t, i, e, r, n, a) {
            var s = er.call(this, t) || this;
            return s.onFinalize = n,
            s.shouldUnsubscribe = a,
            s._next = i ? function(e) {
                try {
                    i(e)
                } catch (e) {
                    t.error(e)
                }
            }
            : er.prototype._next,
            s._error = r ? function(e) {
                try {
                    r(e)
                } catch (e) {
                    t.error(e)
                } finally {
                    this.unsubscribe()
                }
            }
            : er.prototype._error,
            s._complete = e ? function() {
                try {
                    e()
                } catch (e) {
                    t.error(e)
                } finally {
                    this.unsubscribe()
                }
            }
            : er.prototype._complete,
            s
        }
        function fr(e) {
            return e && Kt(e.schedule)
        }
        function gr(e) {
            return e instanceof Date && !isNaN(e)
        }
        function yr(r, e, n) {
            void 0 === r && (r = 0),
            void 0 === n && (n = or);
            var a = -1;
            return null != e && (fr(e) ? n = e : a = e),
            new G(function(e) {
                var t = gr(r) ? +r - n.now() : r
                  , i = 0;
                return n.schedule(function() {
                    e.closed || (e.next(i++),
                    0 <= a ? this.schedule(void 0, a) : e.complete())
                }, t = t < 0 ? 0 : t)
            }
            )
        }
        function vr(e, t) {
            return void 0 === t && (t = sr),
            l = function() {
                return yr(e, t)
            }
            ,
            Ht(function(e, t) {
                function i() {
                    var e;
                    null != s && s.unsubscribe(),
                    s = null,
                    n && (n = !1,
                    e = a,
                    a = null,
                    t.next(e)),
                    o && t.complete()
                }
                function r() {
                    s = null,
                    o && t.complete()
                }
                var n = !1
                  , a = null
                  , s = null
                  , o = !1;
                e.subscribe(Wi(t, function(e) {
                    n = !0,
                    a = e,
                    s || Gi(l()).subscribe(s = Wi(t, i, r))
                }, function() {
                    o = !0,
                    n && s && !s.closed || t.complete()
                }))
            });
            var l
        }
        function Sr(e) {
            return e[e.length - 1]
        }
        function Ir(e) {
            return Kt(Sr(e)) ? e.pop() : void 0
        }
        function br(e) {
            return fr(Sr(e)) ? e.pop() : void 0
        }
        function Tr(e, t, i, r, n) {
            void 0 === r && (r = 0),
            void 0 === n && (n = !1);
            t = t.schedule(function() {
                i(),
                n ? e.add(this.schedule(null, r)) : this.unsubscribe()
            }, r);
            if (e.add(t),
            !n)
                return t
        }
        function $(s) {
            return Ht(function(t, i) {
                var r, n = null, a = !1, n = t.subscribe(Wi(i, void 0, void 0, function(e) {
                    r = Gi(s(e, $(s)(t))),
                    n ? (n.unsubscribe(),
                    n = null,
                    r.subscribe(i)) : a = !0
                }));
                a && (n.unsubscribe(),
                n = null,
                r.subscribe(i))
            })
        }
        var Er = Array.isArray
          , Ar = Object.getPrototypeOf
          , Or = Object.prototype
          , Rr = Object.keys;
        function wr(e) {
            if (1 === e.length) {
                var t, i = e[0];
                if (Er(i))
                    return {
                        args: i,
                        keys: null
                    };
                if (i && "object" == typeof i && Ar(i) === Or)
                    return {
                        args: (t = Rr(i)).map(function(e) {
                            return i[e]
                        }),
                        keys: t
                    }
            }
            return {
                args: e,
                keys: null
            }
        }
        function Pr(i, r) {
            return void 0 === r && (r = 0),
            Ht(function(e, t) {
                e.subscribe(Wi(t, function(e) {
                    return Tr(t, i, function() {
                        t.next(e)
                    }, r)
                }, function() {
                    return Tr(t, i, function() {
                        t.complete()
                    }, r)
                }, function(e) {
                    return Tr(t, i, function() {
                        t.error(e)
                    }, r)
                }))
            })
        }
        function Mr(i, r) {
            return void 0 === r && (r = 0),
            Ht(function(e, t) {
                t.add(i.schedule(function() {
                    return e.subscribe(t)
                }, r))
            })
        }
        function Cr(i, r) {
            if (i)
                return new G(function(t) {
                    Tr(t, r, function() {
                        var e = i[Symbol.asyncIterator]();
                        Tr(t, r, function() {
                            e.next().then(function(e) {
                                e.done ? t.complete() : t.next(e.value)
                            })
                        }, 0, !0)
                    })
                }
                );
            throw new Error("Iterable cannot be null")
        }
        function kr(e, t) {
            if (null != e) {
                if (_i(e))
                    return s = t,
                    Gi(e).pipe(Mr(s), Pr(s));
                if (Zt(e))
                    return r = e,
                    n = t,
                    new G(function(e) {
                        var t = 0;
                        return n.schedule(function() {
                            t === r.length ? e.complete() : (e.next(r[t++]),
                            e.closed || this.schedule())
                        })
                    }
                    );
                if (ei(e))
                    return s = t,
                    Gi(e).pipe(Mr(s), Pr(s));
                if (Vi(e))
                    return Cr(e, t);
                if (Hi(e))
                    return i = e,
                    a = t,
                    new G(function(r) {
                        var n;
                        return Tr(r, a, function() {
                            n = i[Ki](),
                            Tr(r, a, function() {
                                var e, t, i;
                                try {
                                    t = (e = n.next()).value,
                                    i = e.done
                                } catch (e) {
                                    return r.error(e)
                                }
                                i ? r.complete() : r.next(t)
                            }, 0, !0)
                        }),
                        function() {
                            return Kt(null == n ? void 0 : n.return) && n.return()
                        }
                    }
                    );
                if (qi(e))
                    return t = t,
                    Cr(ji(e), t)
            }
            var i, a, r, n, s;
            throw Qi(e)
        }
        function Lr(e, t) {
            return t ? kr(e, t) : Gi(e)
        }
        function W(r, n) {
            return Ht(function(e, t) {
                var i = 0;
                e.subscribe(Wi(t, function(e) {
                    t.next(r.call(n, e, i++))
                }))
            })
        }
        var Nr = Array.isArray;
        function Dr(i) {
            return W(function(e) {
                return t = i,
                Nr(e = e) ? t.apply(void 0, Yt([], Xt(e))) : t(e);
                var t
            })
        }
        function xr(e, r) {
            return e.reduce(function(e, t, i) {
                return e[t] = r[i],
                e
            }, {})
        }
        function Fr() {
            for (var e = [], t = 0; t < arguments.length; t++)
                e[t] = arguments[t];
            var o, l, d, i = br(e), r = Ir(e), n = wr(e), a = n.args, s = n.keys;
            return 0 === a.length ? Lr([], i) : (n = new G((o = a,
            l = i,
            void 0 === (d = s ? function(e) {
                return xr(s, e)
            }
            : xi) && (d = xi),
            function(s) {
                Br(l, function() {
                    for (var e = o.length, r = new Array(e), n = e, a = e, t = 0; t < e; t++)
                        !function(i) {
                            Br(l, function() {
                                var e = Lr(o[i], l)
                                  , t = !1;
                                e.subscribe(Wi(s, function(e) {
                                    r[i] = e,
                                    t || (t = !0,
                                    a--),
                                    a || s.next(d(r.slice()))
                                }, function() {
                                    --n || s.complete()
                                }))
                            }, s)
                        }(t)
                }, s)
            }
            )),
            r ? n.pipe(Dr(r)) : n)
        }
        function Br(e, t, i) {
            e ? Tr(i, e, t) : t()
        }
        function Ur(e, i, r, n, a, s, o, t) {
            function l(e) {
                s && i.next(e),
                c++;
                var t = !1;
                Gi(r(e, h++)).subscribe(Wi(i, function(e) {
                    null != a && a(e),
                    s ? m(e) : i.next(e)
                }, function() {
                    t = !0
                }, void 0, function() {
                    if (t)
                        try {
                            c--;
                            for (; u.length && c < n; )
                                !function() {
                                    var e = u.shift();
                                    o ? Tr(i, o, function() {
                                        l(e)
                                    }) : l(e)
                                }();
                            p()
                        } catch (e) {
                            i.error(e)
                        }
                }))
            }
            var d, u = [], c = 0, h = 0, p = function() {
                !d || u.length || c || i.complete()
            }, m = function(e) {
                return c < n ? l(e) : u.push(e)
            };
            return e.subscribe(Wi(i, m, function() {
                d = !0,
                p()
            })),
            function() {
                null != t && t()
            }
        }
        function _r(n, a, i) {
            return void 0 === i && (i = 1 / 0),
            Kt(a) ? _r(function(i, r) {
                return W(function(e, t) {
                    return a(i, e, r, t)
                })(Gi(n(i, r)))
            }, i) : ("number" == typeof a && (i = a),
            Ht(function(e, t) {
                return Ur(e, t, n, i)
            }))
        }
        function Vr(s, t, o, l, d) {
            return function(e, i) {
                var r = o
                  , n = t
                  , a = 0;
                e.subscribe(Wi(i, function(e) {
                    var t = a++;
                    n = r ? s(n, e, t) : (r = !0,
                    e),
                    l && i.next(n)
                }, d && function() {
                    r && i.next(n),
                    i.complete()
                }
                ))
            }
        }
        function Qr(e, t) {
            return Ht(Vr(e, t, 2 <= arguments.length, !1, !0))
        }
        function Kr(e, t) {
            return e.push(t),
            e
        }
        function Hr() {
            return Ht(function(e, t) {
                Qr(Kr, [])(e).subscribe(t)
            })
        }
        var jr = Array.isArray;
        function qr(e) {
            return 1 === e.length && jr(e[0]) ? e[0] : e
        }
        function Gr(e) {
            return _r(xi, e = void 0 === e ? 1 / 0 : e)
        }
        function $r(e, t) {
            return Kt(t) ? _r(e, t, 1) : _r(e, 1)
        }
        var Wr, zr, Xr = ti(function(e) {
            return function() {
                e(this),
                this.name = "ObjectUnsubscribedError",
                this.message = "object unsubscribed"
            }
        }), z = (qt(Zr, zr = G),
        Zr.prototype.lift = function(e) {
            var t = new Yr(this,this);
            return t.operator = e,
            t
        }
        ,
        Zr.prototype._throwIfClosed = function() {
            if (this.closed)
                throw new Xr
        }
        ,
        Zr.prototype.next = function(n) {
            var a = this;
            Ii(function() {
                var t, e;
                if (a._throwIfClosed(),
                !a.isStopped) {
                    a.currentObservers || (a.currentObservers = Array.from(a.observers));
                    try {
                        for (var i = zt(a.currentObservers), r = i.next(); !r.done; r = i.next())
                            r.value.next(n)
                    } catch (e) {
                        t = {
                            error: e
                        }
                    } finally {
                        try {
                            r && !r.done && (e = i.return) && e.call(i)
                        } finally {
                            if (t)
                                throw t.error
                        }
                    }
                }
            })
        }
        ,
        Zr.prototype.error = function(t) {
            var i = this;
            Ii(function() {
                if (i._throwIfClosed(),
                !i.isStopped) {
                    i.hasError = i.isStopped = !0,
                    i.thrownError = t;
                    for (var e = i.observers; e.length; )
                        e.shift().error(t)
                }
            })
        }
        ,
        Zr.prototype.complete = function() {
            var t = this;
            Ii(function() {
                if (t._throwIfClosed(),
                !t.isStopped) {
                    t.isStopped = !0;
                    for (var e = t.observers; e.length; )
                        e.shift().complete()
                }
            })
        }
        ,
        Zr.prototype.unsubscribe = function() {
            this.isStopped = this.closed = !0,
            this.observers = this.currentObservers = null
        }
        ,
        Object.defineProperty(Zr.prototype, "observed", {
            get: function() {
                var e;
                return 0 < (null == (e = this.observers) ? void 0 : e.length)
            },
            enumerable: !1,
            configurable: !0
        }),
        Zr.prototype._trySubscribe = function(e) {
            return this._throwIfClosed(),
            zr.prototype._trySubscribe.call(this, e)
        }
        ,
        Zr.prototype._subscribe = function(e) {
            return this._throwIfClosed(),
            this._checkFinalizedStatuses(e),
            this._innerSubscribe(e)
        }
        ,
        Zr.prototype._innerSubscribe = function(e) {
            var t = this
              , i = this
              , r = i.hasError
              , n = i.isStopped
              , a = i.observers;
            return r || n ? ai : (this.currentObservers = null,
            a.push(e),
            new ni(function() {
                t.currentObservers = null,
                ri(a, e)
            }
            ))
        }
        ,
        Zr.prototype._checkFinalizedStatuses = function(e) {
            var t = this
              , i = t.hasError
              , r = t.thrownError
              , t = t.isStopped;
            i ? e.error(r) : t && e.complete()
        }
        ,
        Zr.prototype.asObservable = function() {
            var e = new G;
            return e.source = this,
            e
        }
        ,
        Zr.create = function(e, t) {
            return new Yr(e,t)
        }
        ,
        Zr), Yr = (qt(Jr, Wr = z),
        Jr.prototype.next = function(e) {
            var t, i;
            null != (i = null == (t = this.destination) ? void 0 : t.next) && i.call(t, e)
        }
        ,
        Jr.prototype.error = function(e) {
            var t, i;
            null != (i = null == (t = this.destination) ? void 0 : t.error) && i.call(t, e)
        }
        ,
        Jr.prototype.complete = function() {
            var e, t;
            null != (t = null == (e = this.destination) ? void 0 : e.complete) && t.call(e)
        }
        ,
        Jr.prototype._subscribe = function(e) {
            var t;
            return null != (t = null == (t = this.source) ? void 0 : t.subscribe(e)) ? t : ai
        }
        ,
        Jr);
        function Jr(e, t) {
            var i = Wr.call(this) || this;
            return i.destination = e,
            i.source = t,
            i
        }
        function Zr() {
            var e = zr.call(this) || this;
            return e.closed = !1,
            e.currentObservers = null,
            e.observers = [],
            e.isStopped = !1,
            e.hasError = !1,
            e.thrownError = null,
            e
        }
        function en() {
            for (var e = [], t = 0; t < arguments.length; t++)
                e[t] = arguments[t];
            return Gr(1)(Lr(e, br(e)))
        }
        var X = new G(function(e) {
            return e.complete()
        }
        );
        function tn(r) {
            return r <= 0 ? function() {
                return X
            }
            : Ht(function(e, t) {
                var i = 0;
                e.subscribe(Wi(t, function(e) {
                    ++i <= r && (t.next(e),
                    r <= i) && t.complete()
                }))
            })
        }
        function rn(e) {
            return W(function() {
                return e
            })
        }
        function nn(i, t) {
            return t ? function(e) {
                return en(t.pipe(tn(1), Ht(function(e, t) {
                    e.subscribe(Wi(t, gi))
                })), e.pipe(nn(i)))
            }
            : _r(function(e, t) {
                return i(e, t).pipe(tn(1), rn(e))
            })
        }
        function Y() {
            for (var e = [], t = 0; t < arguments.length; t++)
                e[t] = arguments[t];
            return Lr(e, br(e))
        }
        function R(e, t) {
            function i(e) {
                return e.error(r())
            }
            var r = Kt(e) ? e : function() {
                return e
            }
            ;
            return new G(t ? function(e) {
                return t.schedule(i, 0, e)
            }
            : i)
        }
        function J(a, s) {
            return void 0 === s && (s = xi),
            a = null != a ? a : an,
            Ht(function(e, i) {
                var r, n = !0;
                e.subscribe(Wi(i, function(e) {
                    var t = s(e);
                    !n && a(r, t) || (n = !1,
                    r = t,
                    i.next(e))
                }))
            })
        }
        function an(e, t) {
            return e === t
        }
        function Z(r, n) {
            return Ht(function(e, t) {
                var i = 0;
                e.subscribe(Wi(t, function(e) {
                    return r.call(n, e, i++) && t.next(e)
                }))
            })
        }
        function sn(a, n) {
            return n ? function(e) {
                return e.pipe(sn(function(i, r) {
                    return Gi(a(i, r)).pipe(W(function(e, t) {
                        return n(i, e, r, t)
                    }))
                }))
            }
            : Ht(function(e, t) {
                var i = 0
                  , r = null
                  , n = !1;
                e.subscribe(Wi(t, function(e) {
                    r || (r = Wi(t, void 0, function() {
                        r = null,
                        n && t.complete()
                    }),
                    Gi(a(e, i++)).subscribe(r))
                }, function() {
                    n = !0,
                    r || t.complete()
                }))
            })
        }
        function on(i, r, n) {
            return r = ((r = void 0 === r ? 1 / 0 : r) || 0) < 1 ? 1 / 0 : r,
            Ht(function(e, t) {
                return Ur(e, t, i, r, void 0, !0, n)
            })
        }
        function ee(i) {
            return Ht(function(e, t) {
                try {
                    e.subscribe(t)
                } finally {
                    t.add(i)
                }
            })
        }
        function ln(t) {
            return t <= 0 ? function() {
                return X
            }
            : Ht(function(e, a) {
                var s = [];
                e.subscribe(Wi(a, function(e) {
                    s.push(e),
                    t < s.length && s.shift()
                }, function() {
                    var e, t;
                    try {
                        for (var i = zt(s), r = i.next(); !r.done; r = i.next()) {
                            var n = r.value;
                            a.next(n)
                        }
                    } catch (t) {
                        e = {
                            error: t
                        }
                    } finally {
                        try {
                            r && !r.done && (t = i.return) && t.call(i)
                        } finally {
                            if (e)
                                throw e.error
                        }
                    }
                    a.complete()
                }, void 0, function() {
                    s = null
                }))
            })
        }
        function dn() {
            return Ht(function(e, i) {
                var r, n = !1;
                e.subscribe(Wi(i, function(e) {
                    var t = r;
                    r = e,
                    n && i.next([t, e]),
                    n = !0
                }))
            })
        }
        qt(vn, hn = z),
        Object.defineProperty(vn.prototype, "value", {
            get: function() {
                return this.getValue()
            },
            enumerable: !1,
            configurable: !0
        }),
        vn.prototype._subscribe = function(e) {
            var t = hn.prototype._subscribe.call(this, e);
            return t.closed || e.next(this._value),
            t
        }
        ,
        vn.prototype.getValue = function() {
            var e = this.hasError
              , t = this.thrownError
              , i = this._value;
            if (e)
                throw t;
            return this._throwIfClosed(),
            i
        }
        ,
        vn.prototype.next = function(e) {
            hn.prototype.next.call(this, this._value = e)
        }
        ;
        var un, cn, hn, pn = vn, mn = (qt(yn, cn = z),
        yn.prototype._checkFinalizedStatuses = function(e) {
            var t = this
              , i = t.hasError
              , r = t._hasValue
              , n = t._value
              , a = t.thrownError
              , s = t.isStopped
              , t = t._isComplete;
            i ? e.error(a) : (s || t) && (r && e.next(n),
            e.complete())
        }
        ,
        yn.prototype.next = function(e) {
            this.isStopped || (this._value = e,
            this._hasValue = !0)
        }
        ,
        yn.prototype.complete = function() {
            var e = this._hasValue
              , t = this._value;
            this._isComplete || (this._isComplete = !0,
            e && cn.prototype.next.call(this, t),
            cn.prototype.complete.call(this))
        }
        ,
        yn), fn = (qt(gn, un = z),
        gn.prototype.next = function(e) {
            var t = this
              , i = t.isStopped
              , r = t._buffer
              , n = t._infiniteTimeWindow
              , a = t._timestampProvider
              , t = t._windowTime;
            i || (r.push(e),
            n) || r.push(a.now() + t),
            this._trimBuffer(),
            un.prototype.next.call(this, e)
        }
        ,
        gn.prototype._subscribe = function(e) {
            this._throwIfClosed(),
            this._trimBuffer();
            for (var t = this._innerSubscribe(e), i = this._infiniteTimeWindow, r = this._buffer.slice(), n = 0; n < r.length && !e.closed; n += i ? 1 : 2)
                e.next(r[n]);
            return this._checkFinalizedStatuses(e),
            t
        }
        ,
        gn.prototype._trimBuffer = function() {
            var e = this._bufferSize
              , t = this._timestampProvider
              , i = this._buffer
              , r = this._infiniteTimeWindow
              , n = (r ? 1 : 2) * e;
            if (e < 1 / 0 && n < i.length && i.splice(0, i.length - n),
            !r) {
                for (var a = t.now(), s = 0, o = 1; o < i.length && i[o] <= a; o += 2)
                    s = o;
                s && i.splice(0, s + 1)
            }
        }
        ,
        gn);
        function gn(e, t, i) {
            void 0 === e && (e = 1 / 0),
            void 0 === t && (t = 1 / 0),
            void 0 === i && (i = nr);
            var r = un.call(this) || this;
            return r._bufferSize = e,
            r._windowTime = t,
            r._timestampProvider = i,
            r._buffer = [],
            r._infiniteTimeWindow = !0,
            r._infiniteTimeWindow = t === 1 / 0,
            r._bufferSize = Math.max(1, e),
            r._windowTime = Math.max(1, t),
            r
        }
        function yn() {
            var e = null !== cn && cn.apply(this, arguments) || this;
            return e._value = null,
            e._hasValue = !1,
            e._isComplete = !1,
            e
        }
        function vn(e) {
            var t = hn.call(this) || this;
            return t._value = e,
            t
        }
        function Sn() {
            for (var t, e = [], i = 0; i < arguments.length; i++)
                e[i] = arguments[i];
            return 1 === (e = qr(e)).length ? Gi(e[0]) : new G((t = e,
            function(r) {
                for (var n = [], e = 0; n && !r.closed && e < t.length; e++)
                    !function(i) {
                        n.push(Gi(t[i]).subscribe(Wi(r, function(e) {
                            if (n) {
                                for (var t = 0; t < n.length; t++)
                                    t !== i && n[t].unsubscribe();
                                n = null
                            }
                            r.next(e)
                        })))
                    }(e)
            }
            ))
        }
        function In(e) {
            var t = (e = (e = void 0 === e ? 1 / 0 : e) && "object" == typeof e ? e : {
                count: e
            }).count
              , d = void 0 === t ? 1 / 0 : t
              , u = e.delay
              , t = e.resetOnSuccess
              , i = void 0 !== t && t;
            return d <= 0 ? xi : Ht(function(e, s) {
                var o, l = 0;
                !function n() {
                    var a = !1;
                    o = e.subscribe(Wi(s, function(e) {
                        i && (l = 0),
                        s.next(e)
                    }, void 0, function(e) {
                        var t, i, r;
                        l++ < d ? (t = function() {
                            o ? (o.unsubscribe(),
                            o = null,
                            n()) : a = !0
                        }
                        ,
                        null != u ? (i = "number" == typeof u ? yr(u) : Gi(u(e, l)),
                        r = Wi(s, function() {
                            r.unsubscribe(),
                            t()
                        }, function() {
                            s.complete()
                        }),
                        i.subscribe(r)) : t()) : s.error(e)
                    })),
                    a && (o.unsubscribe(),
                    o = null,
                    n())
                }()
            })
        }
        function bn(s) {
            return Ht(function(e, i) {
                var r, n, a = !1;
                !function t() {
                    r = e.subscribe(Wi(i, void 0, void 0, function(e) {
                        n || (n = new z,
                        s(n).subscribe(Wi(i, function() {
                            return r ? t() : a = !0
                        }))),
                        n && n.next(e)
                    })),
                    a && (r.unsubscribe(),
                    r = null,
                    a = !1,
                    t())
                }()
            })
        }
        function Tn(e) {
            var t = (e = void 0 === e ? {} : e).connector
              , h = void 0 === t ? function() {
                return new z
            }
            : t
              , t = e.resetOnError
              , p = void 0 === t || t
              , t = e.resetOnComplete
              , m = void 0 === t || t
              , t = e.resetOnRefCountZero
              , f = void 0 === t || t;
            return function(e) {
                function r() {
                    var e = n;
                    c(),
                    null != e && e.unsubscribe()
                }
                var n, a, s, o = 0, l = !1, d = !1, u = function() {
                    null != a && a.unsubscribe(),
                    a = void 0
                }, c = function() {
                    u(),
                    n = s = void 0,
                    l = d = !1
                };
                return Ht(function(e, t) {
                    o++,
                    d || l || u();
                    var i = s = null != s ? s : h();
                    t.add(function() {
                        0 != --o || d || l || (a = En(r, f))
                    }),
                    i.subscribe(t),
                    !n && 0 < o && (n = new Pi({
                        next: function(e) {
                            return i.next(e)
                        },
                        error: function(e) {
                            d = !0,
                            u(),
                            a = En(c, p, e),
                            i.error(e)
                        },
                        complete: function() {
                            l = !0,
                            u(),
                            a = En(c, m),
                            i.complete()
                        }
                    }),
                    Gi(e).subscribe(n))
                })(e)
            }
        }
        function En(e, t) {
            for (var i, r = [], n = 2; n < arguments.length; n++)
                r[n - 2] = arguments[n];
            if (!0 !== t) {
                if (!1 !== t)
                    return i = new Pi({
                        next: function() {
                            i.unsubscribe(),
                            e()
                        }
                    }),
                    t.apply(void 0, Yt([], Xt(r))).subscribe(i)
            } else
                e()
        }
        function An(e, t, i) {
            var r, n, a = !1;
            return e && "object" == typeof e ? (r = e.bufferSize,
            n = void 0 === r ? 1 / 0 : r,
            r = e.windowTime,
            t = void 0 === r ? 1 / 0 : r,
            a = void 0 !== (r = e.refCount) && r,
            i = e.scheduler) : n = null != e ? e : 1 / 0,
            Tn({
                connector: function() {
                    return new fn(n,t,i)
                },
                resetOnError: !0,
                resetOnComplete: !1,
                resetOnRefCountZero: a
            })
        }
        function On(i) {
            return Z(function(e, t) {
                return i <= t
            })
        }
        function Rn() {
            for (var i = [], e = 0; e < arguments.length; e++)
                i[e] = arguments[e];
            var r = br(i);
            return Ht(function(e, t) {
                (r ? en(i, e, r) : en(i, e)).subscribe(t)
            })
        }
        function te(l, d) {
            return Ht(function(e, n) {
                function a() {
                    t && !s && n.complete()
                }
                var s = null
                  , o = 0
                  , t = !1;
                e.subscribe(Wi(n, function(t) {
                    null != s && s.unsubscribe();
                    var i = 0
                      , r = o++;
                    Gi(l(t, r)).subscribe(s = Wi(n, function(e) {
                        return n.next(d ? d(t, e, r, i++) : e)
                    }, function() {
                        s = null,
                        a()
                    }))
                }, function() {
                    t = !0,
                    a()
                }))
            })
        }
        function wn(e, t) {
            return Kt(t) ? te(function() {
                return e
            }, t) : te(function() {
                return e
            })
        }
        function Pn(i) {
            return Ht(function(e, t) {
                Gi(i).subscribe(Wi(t, function() {
                    return t.complete()
                }, gi)),
                t.closed || e.subscribe(t)
            })
        }
        function Mn(n, a) {
            return void 0 === a && (a = !1),
            Ht(function(e, i) {
                var r = 0;
                e.subscribe(Wi(i, function(e) {
                    var t = n(e, r++);
                    (t || a) && i.next(e),
                    t || i.complete()
                }))
            })
        }
        function ie(e, t, i) {
            var n = Kt(e) || t || i ? {
                next: e,
                error: t,
                complete: i
            } : e;
            return n ? Ht(function(e, i) {
                null != (t = n.subscribe) && t.call(n);
                var t, r = !0;
                e.subscribe(Wi(i, function(e) {
                    var t;
                    null != (t = n.next) && t.call(n, e),
                    i.next(e)
                }, function() {
                    var e;
                    r = !1,
                    null != (e = n.complete) && e.call(n),
                    i.complete()
                }, function(e) {
                    var t;
                    r = !1,
                    null != (t = n.error) && t.call(n, e),
                    i.error(e)
                }, function() {
                    var e;
                    r && null != (e = n.unsubscribe) && e.call(n),
                    null != (e = n.finalize) && e.call(n)
                }))
            }) : xi
        }
        var Cn = {
            leading: !0,
            trailing: !1
        };
        function kn(e, t, i) {
            void 0 === i && (i = Cn);
            var h, p = yr(e, t = void 0 === t ? sr : t);
            return void 0 === (h = i) && (h = Cn),
            Ht(function(e, t) {
                function i() {
                    var e;
                    a && (a = !1,
                    e = s,
                    s = null,
                    t.next(e),
                    l || c())
                }
                var r = h.leading
                  , n = h.trailing
                  , a = !1
                  , s = null
                  , o = null
                  , l = !1
                  , d = function() {
                    null != o && o.unsubscribe(),
                    o = null,
                    n && (i(),
                    l) && t.complete()
                }
                  , u = function() {
                    o = null,
                    l && t.complete()
                }
                  , c = function(e) {
                    return o = Gi(p).subscribe(Wi(t, d, u))
                };
                e.subscribe(Wi(t, function(e) {
                    a = !0,
                    s = e,
                    o && !o.closed || (r ? i : c)()
                }, function() {
                    l = !0,
                    n && a && o && !o.closed || t.complete()
                }))
            })
        }
        var Ln = ti(function(t) {
            return function(e) {
                void 0 === e && (e = null),
                t(this),
                this.message = "Timeout has occurred",
                this.name = "TimeoutError",
                this.info = e
            }
        });
        function Nn(e, t) {
            var e = gr(e) ? {
                first: e
            } : "number" == typeof e ? {
                each: e
            } : e
              , o = e.first
              , l = e.each
              , i = e.with
              , d = void 0 === i ? Dn : i
              , i = e.scheduler
              , u = void 0 === i ? null != t ? t : sr : i
              , t = e.meta
              , c = void 0 === t ? null : t;
            if (null == o && null == l)
                throw new TypeError("No timeout provided.");
            return Ht(function(e, t) {
                function i(e) {
                    r = Tr(t, u, function() {
                        try {
                            s.unsubscribe(),
                            Gi(d({
                                meta: c,
                                lastValue: n,
                                seen: a
                            })).subscribe(t)
                        } catch (e) {
                            t.error(e)
                        }
                    }, e)
                }
                var r, n = null, a = 0, s = e.subscribe(Wi(t, function(e) {
                    null != r && r.unsubscribe(),
                    a++,
                    t.next(n = e),
                    0 < l && i(l)
                }, void 0, void 0, function() {
                    null != r && r.closed || null == r || r.unsubscribe(),
                    n = null
                }));
                a || i(null != o ? "number" == typeof o ? o : +o - u.now() : l)
            })
        }
        function Dn(e) {
            throw new Ln(e)
        }
        function xn() {
            for (var o = [], e = 0; e < arguments.length; e++)
                o[e] = arguments[e];
            var l = Ir(o);
            return Ht(function(e, i) {
                for (var t = o.length, r = new Array(t), n = o.map(function() {
                    return !1
                }), a = !1, s = 0; s < t; s++)
                    !function(t) {
                        Gi(o[t]).subscribe(Wi(i, function(e) {
                            r[t] = e,
                            !a && !n[t] && (n[t] = !0,
                            a = n.every(xi)) && (n = null)
                        }, gi))
                    }(s);
                e.subscribe(Wi(i, function(e) {
                    a && (e = Yt([e], Xt(r)),
                    i.next(l ? l.apply(void 0, Yt([], Xt(e))) : e))
                }))
            })
        }
        var Fn = "id";
        function Bn(e) {
            return Nt(e) && 0 === e.length
        }
        function Un(e) {
            return "function" == typeof e
        }
        function _n() {
            return J( (i, e) => i === e || !(!Nt(i) || !Nt(e)) && (!(!Bn(i) || !Bn(e)) || i.length === e.length && !1 === e.some( (e, t) => i[t] !== e)))
        }
        function Vn(e) {
            var t = typeof e;
            return null != e && ("object" == t || "function" == t)
        }
        function Qn(e, t, i) {
            var r, n, a = 2 < arguments.length && void 0 !== i ? i : Fn, i = Un(t) ? (n = t,
            function() {
                return !n(...arguments)
            }
            ) : (r = Vt(t),
            e => !1 === r.includes(Vn(e) ? e[a] : e));
            if (Array.isArray(e))
                return e.filter(i)
        }
        function Kn(e, t, i, r) {
            var n, a, s = 3 < arguments.length && void 0 !== r ? r : Fn;
            return a = Un(t) ? t : (n = Vt(t),
            e => !0 === n.includes(Vn(e) ? e[s] : e)),
            e.map( (e, t) => !0 === a(e, t) ? Vn(e) ? I(I({}, e), i) : i : e)
        }
        var Hn, jn = 1, qn = {};
        function Gn(e) {
            return e in qn && (delete qn[e],
            !0)
        }
        var $n = {
            setImmediate: function() {
                for (var e = [], t = 0; t < arguments.length; t++)
                    e[t] = arguments[t];
                var i = $n.delegate;
                return ((null == i ? void 0 : i.setImmediate) || function(e) {
                    var t = jn++;
                    return qn[t] = !0,
                    (Hn = Hn || Promise.resolve()).then(function() {
                        return Gn(t) && e()
                    }),
                    t
                }
                ).apply(void 0, Yt([], Xt(e)))
            },
            clearImmediate: function(e) {
                var t = $n.delegate;
                return ((null == t ? void 0 : t.clearImmediate) || function(e) {
                    Gn(e)
                }
                )(e)
            },
            delegate: void 0
        }
          , r = (qt(ra, Jn = t),
        ra.prototype.requestAsyncId = function(e, t, i) {
            return null !== (i = void 0 === i ? 0 : i) && 0 < i ? Jn.prototype.requestAsyncId.call(this, e, t, i) : (e.actions.push(this),
            e._scheduled || (e._scheduled = $n.setImmediate(e.flush.bind(e, void 0))))
        }
        ,
        ra.prototype.recycleAsyncId = function(e, t, i) {
            if (null != (i = void 0 === i ? 0 : i) ? 0 < i : 0 < this.delay)
                return Jn.prototype.recycleAsyncId.call(this, e, t, i);
            var i = e.actions;
            null != t && (null == (i = i[i.length - 1]) ? void 0 : i.id) !== t && ($n.clearImmediate(t),
            e._scheduled = void 0)
        }
        ,
        ra);
        qt(ia, Yn = i),
        ia.prototype.flush = function(e) {
            this._active = !0;
            var t = this._scheduled;
            this._scheduled = void 0;
            var i, r = this.actions;
            e = e || r.shift();
            do {
                if (i = e.execute(e.state, e.delay))
                    break
            } while ((e = r[0]) && e.id === t && r.shift());
            if (this._active = !1,
            i) {
                for (; (e = r[0]) && e.id === t && r.shift(); )
                    e.unsubscribe();
                throw i
            }
        }
        ;
        var Wn = new ia(r)
          , r = (qt(ta, Xn = t),
        ta.prototype.schedule = function(e, t) {
            return 0 < (t = void 0 === t ? 0 : t) ? Xn.prototype.schedule.call(this, e, t) : (this.delay = t,
            this.state = e,
            this.scheduler.flush(this),
            this)
        }
        ,
        ta.prototype.execute = function(e, t) {
            return 0 < t || this.closed ? Xn.prototype.execute.call(this, e, t) : this._execute(e, t)
        }
        ,
        ta.prototype.requestAsyncId = function(e, t, i) {
            return null != (i = void 0 === i ? 0 : i) && 0 < i || null == i && 0 < this.delay ? Xn.prototype.requestAsyncId.call(this, e, t, i) : (e.flush(this),
            0)
        }
        ,
        ta);
        qt(ea, zn = i);
        var zn, Xn, Yn, Jn, Zn = new ea(r);
        function ea() {
            return null !== zn && zn.apply(this, arguments) || this
        }
        function ta(e, t) {
            var i = Xn.call(this, e, t) || this;
            return i.scheduler = e,
            i.work = t,
            i
        }
        function ia() {
            return null !== Yn && Yn.apply(this, arguments) || this
        }
        function ra(e, t) {
            var i = Jn.call(this, e, t) || this;
            return i.scheduler = e,
            i.work = t,
            i
        }
        function na(t) {
            return new G(function(e) {
                Gi(t()).subscribe(e)
            }
            )
        }
        function aa() {
            for (var e = [], t = 0; t < arguments.length; t++)
                e[t] = arguments[t];
            var i = Ir(e)
              , r = wr(e)
              , s = r.args
              , o = r.keys
              , r = new G(function(e) {
                var t = s.length;
                if (t)
                    for (var r = new Array(t), n = t, a = t, i = 0; i < t; i++)
                        !function(t) {
                            var i = !1;
                            Gi(s[t]).subscribe(Wi(e, function(e) {
                                i || (i = !0,
                                a--),
                                r[t] = e
                            }, function() {
                                return n--
                            }, void 0, function() {
                                n && i || (a || e.next(o ? xr(o, r) : r),
                                e.complete())
                            }))
                        }(i);
                else
                    e.complete()
            }
            );
            return i ? r.pipe(Dr(i)) : r
        }
        var sa = ["addListener", "removeListener"]
          , oa = ["addEventListener", "removeEventListener"]
          , la = ["on", "off"];
        function da(i, r, n, e) {
            if (Kt(n) && (e = n,
            n = void 0),
            e)
                return da(i, r, n).pipe(Dr(e));
            var e = Xt(Kt(i.addEventListener) && Kt(i.removeEventListener) ? oa.map(function(t) {
                return function(e) {
                    return i[t](r, e, n)
                }
            }) : Kt(i.addListener) && Kt(i.removeListener) ? sa.map(ua(i, r)) : Kt(i.on) && Kt(i.off) ? la.map(ua(i, r)) : [], 2)
              , t = e[0]
              , a = e[1];
            if (!t && Zt(i))
                return _r(function(e) {
                    return da(e, r, n)
                })(Gi(i));
            if (t)
                return new G(function(i) {
                    function e() {
                        for (var e = [], t = 0; t < arguments.length; t++)
                            e[t] = arguments[t];
                        return i.next(1 < e.length ? e : e[0])
                    }
                    return t(e),
                    function() {
                        return a(e)
                    }
                }
                );
            throw new TypeError("Invalid event target")
        }
        function ua(i, r) {
            return function(t) {
                return function(e) {
                    return i[t](r, e)
                }
            }
        }
        function ca(r, n, e) {
            return e ? ca(r, n).pipe(Dr(e)) : new G(function(i) {
                function e() {
                    for (var e = [], t = 0; t < arguments.length; t++)
                        e[t] = arguments[t];
                    return i.next(1 === e.length ? e[0] : e)
                }
                var t = r(e);
                return Kt(n) ? function() {
                    return n(e, t)
                }
                : void 0
            }
            )
        }
        function ha(e, t, i) {
            return na(function() {
                return e() ? t : i
            })
        }
        function ne() {
            for (var e = [], t = 0; t < arguments.length; t++)
                e[t] = arguments[t];
            var i = br(e)
              , r = "number" == typeof Sr(r = e) ? r.pop() : 1 / 0
              , n = e;
            return n.length ? 1 === n.length ? Gi(n[0]) : Gr(r)(Lr(n, i)) : X
        }
        var pa = new G(gi);
        function ma(e) {
            return Fr(e).pipe(vr(0))
        }
        var fa = {
            resettable: !1,
            ttl: null,
            producerFn: void 0
        };
        function ga(e) {
            return !1 === _t(e)
        }
        var ya, va, Sa = new z, Ia = new fn(50,5e3), ba = new z, Ta = "undefined" != typeof window, Ea = {}, Aa = {}, Oa = (Ta && (window.$$stores = Ea,
        window.$$queries = Aa),
        (t = ya = ya || {}).ASC = "asc",
        t.DESC = "desc",
        (i = va = va || {}).Set = "Set",
        i.Add = "Add",
        i.Update = "Update",
        i.Remove = "Remove",
        !0);
        function Ra(e) {
            return void 0 === e
        }
        function wa(e, t) {
            var i, r = {};
            for (i of Object.keys(e))
                r[i] = t(e[i]);
            return r
        }
        function Pa(t) {
            Object.freeze(t);
            var i = "function" == typeof t
              , r = Object.prototype.hasOwnProperty;
            return Object.getOwnPropertyNames(t).forEach(function(e) {
                !r.call(t, e) || i && ("caller" === e || "callee" === e || "arguments" === e) || null === t[e] || "object" != typeof t[e] && "function" != typeof t[e] || Object.isFrozen(t[e]) || Pa(t[e])
            }),
            t
        }
        function Ma(e) {
            return null != e && "false" !== "".concat(e)
        }
        function Ca(e) {
            return Ma(e) && "Object" === e.constructor.name
        }
        var ka = new z
          , La = new pn(!1)
          , Na = {
            activeTransactions: 0,
            batchTransaction: null
        };
        function Da() {
            return 0 < Na.activeTransactions
        }
        function ae(e, t) {
            t = 1 < arguments.length && void 0 !== t ? t : void 0;
            Da() || (Na.batchTransaction = new z),
            Na.activeTransactions++,
            La.next(!0);
            try {
                return e.apply(t)
            } finally {
                Ct("@Transaction"),
                0 == --Na.activeTransactions && (Na.batchTransaction.next(!0),
                Na.batchTransaction.complete(),
                La.next(!1),
                ka.next(!0))
            }
        }
        function xa() {
            return function(e, t, i) {
                var r = i.value;
                return i.value = function() {
                    for (var e = arguments.length, t = new Array(e), i = 0; i < e; i++)
                        t[i] = arguments[i];
                    return ae( () => r.apply(this, t), this)
                }
                ,
                i
            }
        }
        function Fa(t) {
            return function(e) {
                return e.pipe(ie(e => ae( () => t(e))))
            }
        }
        class Ba {
            constructor(e) {
                this.options = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {},
                this.inTransaction = !1,
                this.cache = {
                    active: new pn(!1),
                    ttl: null
                },
                this.onInit(e)
            }
            setLoading() {
                var t = 0 < arguments.length && void 0 !== arguments[0] && arguments[0];
                t !== this._value().loading && (Oa && kt("Set Loading"),
                this._setState(e => I(I({}, e), {}, {
                    loading: t
                })))
            }
            setHasCache(e) {
                var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {
                    restartTTL: !1
                };
                e !== this.cache.active.value && this.cache.active.next(e),
                t.restartTTL && (e = this.getCacheTTL()) && (null !== this.cache.ttl && clearTimeout(this.cache.ttl),
                this.cache.ttl = setTimeout( () => this.setHasCache(!1), e))
            }
            getValue() {
                return this.storeValue
            }
            setError(t) {
                t !== this._value().error && (Oa && kt("Set Error"),
                this._setState(e => I(I({}, e), {}, {
                    error: t
                })))
            }
            _select(t) {
                return this.store.asObservable().pipe(W(e => t(e.state)), J())
            }
            _value() {
                return this.storeValue
            }
            _cache() {
                return this.cache.active
            }
            get config() {
                return this.constructor.akitaConfig || {}
            }
            get storeName() {
                return this.config.storeName || this.options.storeName || this.options.name
            }
            get deepFreeze() {
                return this.config.deepFreezeFn || this.options.deepFreezeFn || Pa
            }
            get cacheConfig() {
                return this.config.cache || this.options.cache
            }
            get _producerFn() {
                return this.config.producerFn || this.options.producerFn || fa.producerFn
            }
            get resettable() {
                return (ga(this.config.resettable) ? this.config : this.options).resettable
            }
            _setState(e) {
                var t, i = !(1 < arguments.length && void 0 !== arguments[1]) || arguments[1];
                Un(e) ? (t = e(this._value()),
                this.storeValue = Oa ? this.deepFreeze(t) : t) : this.storeValue = e,
                this.store ? Da() ? this.handleTransaction() : this.dispatch(this.storeValue, i) : (this.store = new pn({
                    state: this.storeValue
                }),
                Oa && this.store.subscribe(e => {
                    var t, e = e["action"];
                    e && (t = this.storeName,
                    ba.next({
                        storeName: t,
                        action: e
                    }))
                }
                ))
            }
            reset() {
                this.isResettable() && (Oa && kt("Reset"),
                this._setState( () => Object.assign({}, this._initialState)),
                this.setHasCache(!1))
            }
            update(e) {
                Oa && kt("Update");
                var t = this._value()
                  , e = Un(e) ? Un(this._producerFn) ? this._producerFn(t, e) : e(t) : e
                  , e = this.akitaPreUpdate(t, I(I({}, t), e))
                  , t = Ca(t) ? e : new t.constructor(e);
                this._setState(t)
            }
            updateStoreConfig(e) {
                this.options = I(I({}, this.options), e)
            }
            akitaPreUpdate(e, t) {
                return t
            }
            destroy() {
                var e;
                Ta && window.hmrEnabled || this !== Ea[this.storeName] || (delete Ea[this.storeName],
                e = this.storeName,
                Sa.next(e),
                this.setHasCache(!1),
                this.cache.active.complete(),
                this.store.complete())
            }
            onInit(e) {
                var t, i;
                (Ea[this.storeName] = this)._setState( () => e),
                t = this.storeName,
                Ia.next(t),
                this.isResettable() && (this._initialState = e),
                Oa && (t = this.storeName,
                i = this.constructor.name,
                t || console.error("@StoreConfig({ name }) is missing in ".concat(i)))
            }
            dispatch(e) {
                var t = void 0;
                1 < arguments.length && void 0 !== arguments[1] && !arguments[1] || (t = Pt,
                Mt = !1),
                this.store.next({
                    state: e,
                    action: t
                })
            }
            watchTransaction() {
                (Na.batchTransaction ? Na.batchTransaction.asObservable() : Y(!0)).subscribe( () => {
                    this.inTransaction = !1,
                    this.dispatch(this._value())
                }
                )
            }
            isResettable() {
                return !1 !== this.resettable && (this.resettable || fa.resettable)
            }
            handleTransaction() {
                this.inTransaction || (this.watchTransaction(),
                this.inTransaction = !0)
            }
            getCacheTTL() {
                return this.cacheConfig && this.cacheConfig.ttl || fa.ttl
            }
        }
        class Ua extends Ba {
            constructor() {
                var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}
                  , t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
                super(I(I({}, {
                    entities: {},
                    ids: [],
                    loading: !0,
                    error: null
                }), e), t),
                this.options = t,
                this.entityActions = new z,
                this.entityIdChanges = new z
            }
            get selectEntityAction$() {
                return this.entityActions.asObservable()
            }
            get selectEntityIdChanges$() {
                return this.entityIdChanges.asObservable()
            }
            get idKey() {
                return this.config.idKey || this.options.idKey || Fn
            }
            set(t) {
                var i, r = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
                _t(t) || (Oa && kt("Set Entity"),
                i = this.akitaPreAddEntity === Ua.prototype.akitaPreAddEntity,
                this.setHasCache(!0, {
                    restartTTL: !0
                }),
                this._setState(e => {
                    e = function(e) {
                        var t, {state: e, entities: a, idKey: i, preAddEntity: r, isNativePreAdd: n} = e, n = (i = Nt(a) ? (t = (i = function(e, t) {
                            var i, r = {
                                entities: {},
                                ids: []
                            };
                            for (i of a) {
                                var n = t(i);
                                r.entities[n[e]] = n,
                                r.ids.push(n[e])
                            }
                            return r
                        }(i, r)).entities,
                        i.ids) : a.entities && a.ids ? (t = n ? a.entities : wa(a.entities, r),
                        a.ids) : (t = n ? a : wa(a, r),
                        Object.keys(t).map(e => isNaN(e) ? e : Number(e))),
                        I(I({}, e), {}, {
                            entities: t,
                            ids: i,
                            loading: !1
                        }));
                        return Dt(e) && (n.active = Ft(n)),
                        n
                    }({
                        state: e,
                        entities: t,
                        idKey: this.idKey,
                        preAddEntity: this.akitaPreAddEntity.bind(this),
                        isNativePreAdd: i
                    });
                    return !1 === Ra(r.activeId) && (e.active = r.activeId),
                    e
                }
                ),
                this.hasInitialUIState() && this.handleUICreation(),
                this.entityActions.next({
                    type: va.Set,
                    ids: this.ids
                }))
            }
            add(e) {
                var t, i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {
                    loading: !1
                }, e = Vt(e);
                Bn(e) || (t = function(e) {
                    var t, i, r, {state: n, entities: e, idKey: a, options: s={}, preAddEntity: o} = e, l = {}, d = [], u = !1;
                    for (t of e)
                        !1 === Lt(n.entities, t[a]) && (l[r = (i = o(t))[a]] = i,
                        s.prepend ? d.unshift(r) : d.push(r),
                        u = !0);
                    return u ? {
                        newState: I(I({}, n), {}, {
                            entities: I(I({}, n.entities), l),
                            ids: s.prepend ? [...d, ...n.ids] : [...n.ids, ...d]
                        }),
                        newIds: d
                    } : null
                }({
                    state: this._value(),
                    preAddEntity: this.akitaPreAddEntity.bind(this),
                    entities: e,
                    idKey: this.idKey,
                    options: i
                })) && (Oa && kt("Add Entity"),
                t.newState.loading = i.loading,
                this._setState( () => t.newState),
                this.hasInitialUIState() && this.handleUICreation(!0),
                this.entityActions.next({
                    type: va.Add,
                    ids: t.newIds
                }))
            }
            update(t, y) {
                var v, S;
                Ra(y) ? super.update(t) : Bn(S = Un(t) ? this.ids.filter(e => t(this.entities[e])) : _t(t) ? this.ids : Vt(t)) || (Oa && kt("Update Entity", S),
                this._setState(e => {
                    var t, i, r, n, a, {state: s, ids: e, idKey: o, newStateOrFn: l, preUpdateEntity: d, producerFn: u, onEntityIdChanges: c} = e = {
                        idKey: this.idKey,
                        ids: S,
                        preUpdateEntity: this.akitaPreUpdateEntity.bind(this),
                        state: e,
                        newStateOrFn: y,
                        producerFn: this._producerFn,
                        onEntityIdChanges: (e, t) => {
                            v = {
                                oldId: e,
                                newId: t
                            },
                            this.entityIdChanges.next(I(I({}, v), {}, {
                                pending: !0
                            }))
                        }
                    }, h = {}, p = !1;
                    for (t of e)
                        !1 !== Lt(s.entities, t) && (i = s.entities[t],
                        a = void 0,
                        n = (a = Un(l) ? Un(u) ? u(i, l) : l(i) : l).hasOwnProperty(o) && a[o] !== i[o],
                        r = t,
                        n && (p = !0,
                        r = a[o]),
                        n = I(I({}, i), a),
                        a = Ca(i) ? n : new (Ca(a) ? i : a).constructor(n),
                        h[r] = d(i, a));
                    var m, f = s.ids, g = s.entities;
                    return p && ([m] = e,
                    g = function(e, t) {
                        if (null == e)
                            return {};
                        var i, r = function(e, t) {
                            if (null == e)
                                return {};
                            for (var i, r = {}, n = Object.keys(e), a = 0; a < n.length; a++)
                                i = n[a],
                                0 <= t.indexOf(i) || (r[i] = e[i]);
                            return r
                        }(e, t);
                        if (Object.getOwnPropertySymbols)
                            for (var n = Object.getOwnPropertySymbols(e), a = 0; a < n.length; a++)
                                i = n[a],
                                0 <= t.indexOf(i) || Object.prototype.propertyIsEnumerable.call(e, i) && (r[i] = e[i]);
                        return r
                    }(s.entities, [m].map(Ut)),
                    f = s.ids.map(e => e === m ? r : e),
                    c(m, r)),
                    I(I({}, s), {}, {
                        entities: I(I({}, g), h),
                        ids: f
                    })
                }
                ),
                v && this.entityIdChanges.next(I(I({}, v), {}, {
                    pending: !1
                })),
                this.entityActions.next({
                    type: va.Update,
                    ids: S
                }))
            }
            upsert(e, i, r) {
                var t = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : {}
                  , e = Vt(e)
                  , n = t => e => Lt(this.entities, e) === t
                  , a = Un(r) ? t.baseClass : r ? r.baseClass : void 0
                  , s = Un(a)
                  , t = e.filter(n(!0))
                  , e = e.filter(n(!1)).map(e => {
                    var t = "function" == typeof i ? i({}) : i
                      , t = I(I({}, Un(r) ? r(e, t) : t), {}, {
                        [this.idKey]: e
                    });
                    return s ? new a(t) : t
                }
                );
                this.update(t, i),
                this.add(e),
                Oa && Ct("Upsert Entity")
            }
            upsertMany(e) {
                var t, i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {}, r = [], n = [], a = {};
                for (t of e) {
                    var s, o = this.akitaPreCheckEntity(t), l = o[this.idKey];
                    Lt(this.entities, l) ? (s = this._value().entities[l],
                    l = I(I({}, this._value().entities[l]), o),
                    l = i.baseClass ? new i.baseClass(l) : l,
                    l = (s = this.akitaPreUpdateEntity(s, l))[this.idKey],
                    a[l] = s,
                    n.push(l)) : (s = i.baseClass ? new i.baseClass(o) : o,
                    o = (l = this.akitaPreAddEntity(s))[this.idKey],
                    r.push(o),
                    a[o] = l)
                }
                Oa && Ct("Upsert Many"),
                this._setState(e => I(I({}, e), {}, {
                    ids: r.length ? [...e.ids, ...r] : e.ids,
                    entities: I(I({}, e.entities), a),
                    loading: !!i.loading
                })),
                n.length && this.entityActions.next({
                    type: va.Update,
                    ids: n
                }),
                r.length && this.entityActions.next({
                    type: va.Add,
                    ids: r
                }),
                r.length && this.hasUIStore() && this.handleUICreation(!0)
            }
            replace(e, t) {
                var i = Vt(e);
                if (!Bn(i)) {
                    var r, n = {};
                    for (r of i)
                        n[r] = I(I({}, t), {}, {
                            [this.idKey]: r
                        });
                    Oa && kt("Replace Entity", e),
                    this._setState(e => I(I({}, e), {}, {
                        entities: I(I({}, e.entities), n)
                    }))
                }
            }
            move(e, t) {
                var i = this.ids.slice();
                i.splice(t < 0 ? i.length + t : t, 0, i.splice(e, 1)[0]),
                Oa && kt("Move Entity"),
                this._setState(e => I(I({}, e), {}, {
                    entities: I({}, e.entities),
                    ids: i
                }))
            }
            remove(t) {
                var s, e;
                Bn(this.ids) || (e = ga(t),
                Bn(s = Un(t) ? this.ids.filter(e => t(this.entities[e])) : e ? Vt(t) : this.ids)) || (Oa && kt("Remove Entity", s),
                this._setState(e => {
                    var {state: e, ids: t} = {
                        state: e,
                        ids: s
                    };
                    if (_t(t))
                        return I(I({}, a = e), {}, {
                            entities: {},
                            ids: [],
                            active: xt(a.active) ? [] : null
                        });
                    var i, r = e.entities, n = {};
                    for (i of e.ids)
                        !1 === t.includes(i) && (n[i] = r[i]);
                    var a = I(I({}, e), {}, {
                        entities: n,
                        ids: e.ids.filter(e => !1 === t.includes(e))
                    });
                    return Dt(e) && (a.active = Ft(a)),
                    a
                }
                ),
                e || this.setHasCache(!1),
                this.handleUIRemove(s),
                this.entityActions.next({
                    type: va.Remove,
                    ids: s
                }))
            }
            updateActive(e) {
                var t = Vt(this.active);
                Oa && kt("Update Active", t),
                this.update(t, e)
            }
            setActive(e) {
                e = function(e, t, i) {
                    var r;
                    if (Nt(e))
                        r = e;
                    else if (Vn(e)) {
                        if (_t(i))
                            return;
                        e = Object.assign({
                            wrap: !0
                        }, e);
                        var n = t.indexOf(i);
                        if (e.prev) {
                            var a = 0 === n;
                            if (a && !e.wrap)
                                return;
                            r = a ? t[t.length - 1] : t[n - 1]
                        } else if (e.next) {
                            a = t.length === n + 1;
                            if (a && !e.wrap)
                                return;
                            r = a ? t[0] : t[n + 1]
                        }
                    } else {
                        if (e === i)
                            return;
                        r = e
                    }
                    return r
                }(e, this.ids, this.active);
                void 0 !== e && (Oa && kt("Set Active", e),
                this._setActive(e))
            }
            addActive(e) {
                var i = Vt(e);
                Bn(i) || i.every(e => -1 < this.active.indexOf(e)) || (Oa && kt("Add Active", e),
                this._setState(e => {
                    var t = Array.from(new Set([...e.active, ...i]));
                    return I(I({}, e), {}, {
                        active: t
                    })
                }
                ))
            }
            removeActive(e) {
                var t = Vt(e);
                Bn(t) || t.some(e => -1 < this.active.indexOf(e)) && (Oa && kt("Remove Active", e),
                this._setState(e => I(I({}, e), {}, {
                    active: Array.isArray(e.active) ? e.active.filter(e => -1 === t.indexOf(e)) : null
                })))
            }
            toggleActive(e) {
                var e = Vt(e)
                  , t = t => e => this.active.includes(e) === t
                  , i = e.filter(t(!0))
                  , e = e.filter(t(!1));
                this.removeActive(i),
                this.addActive(e),
                Oa && Ct("Toggle Active")
            }
            createUIStore() {
                var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}
                  , t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {}
                  , i = {
                    name: "UI/".concat(this.storeName),
                    idKey: this.idKey
                };
                return this.ui = new _a(e,I(I({}, i), t)),
                this.ui
            }
            destroy() {
                super.destroy(),
                this.ui instanceof Ua && this.ui.destroy(),
                this.entityActions.complete()
            }
            akitaPreUpdateEntity(e, t) {
                return t
            }
            akitaPreAddEntity(e) {
                return e
            }
            akitaPreCheckEntity(e) {
                return e
            }
            get ids() {
                return this._value().ids
            }
            get entities() {
                return this._value().entities
            }
            get active() {
                return this._value().active
            }
            _setActive(t) {
                this._setState(e => I(I({}, e), {}, {
                    active: t
                }))
            }
            handleUICreation() {
                var e = 0 < arguments.length && void 0 !== arguments[0] && arguments[0]
                  , t = this.ids
                  , i = Un(this.ui._akitaCreateEntityFn)
                  , r = e => {
                    var e = this.entities[e]
                      , t = i ? this.ui._akitaCreateEntityFn(e) : this.ui._akitaCreateEntityFn;
                    return I({
                        [this.idKey]: e[this.idKey]
                    }, t)
                }
                  , t = (e ? this.ids.filter(e => Ra(this.ui.entities[e])) : t).map(r);
                e ? this.ui.add(t) : this.ui.set(t)
            }
            hasInitialUIState() {
                return this.hasUIStore() && !1 === Ra(this.ui._akitaCreateEntityFn)
            }
            handleUIRemove(e) {
                this.hasUIStore() && this.ui.remove(e)
            }
            hasUIStore() {
                return this.ui instanceof _a
            }
        }
        Gt([xa(), $t("design:type", Function), $t("design:paramtypes", [Object, Object, Object, Object]), $t("design:returntype", void 0)], Ua.prototype, "upsert", null),
        Gt([xa(), $t("design:type", Function), $t("design:paramtypes", ["function" == typeof (r = "undefined" != typeof T && T) ? r : Object]), $t("design:returntype", void 0)], Ua.prototype, "toggleActive", null);
        class _a extends Ua {
            constructor() {
                super(0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}, 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {})
            }
            setInitialEntityState(e) {
                this._akitaCreateEntityFn = e
            }
        }
        var Va = e => e.pipe(Z(e => null != e));
        function Qa(e) {
            return "string" == typeof e
        }
        class Ka {
            constructor(e) {
                this.store = e,
                this.__store__ = e,
                Oa && (Aa[e.storeName] = this)
            }
            select(t) {
                var e, n;
                if (Un(t))
                    e = t;
                else if (Qa(t))
                    e = e => e[t];
                else {
                    if (Array.isArray(t))
                        return this.store._select(e => e).pipe(J((n = t,
                        function(t, i) {
                            var r = Un(n[0]);
                            return !1 === n.some(e => r ? e(t) !== e(i) : t[e] !== i[e])
                        }
                        )), W(i => Un(t[0]) ? t.map(e => e(i)) : t.reduce( (e, t) => (e[t] = i[t],
                        e), {})));
                    e = e => e
                }
                return this.store._select(e)
            }
            selectLoading() {
                return this.select(e => e.loading)
            }
            selectError() {
                return this.select(e => e.error)
            }
            getValue() {
                return this.store._value()
            }
            selectHasCache() {
                return this.store._cache().asObservable()
            }
            getHasCache() {
                return this.store._cache().value
            }
            get config() {
                return this.constructor.akitaQueryConfig
            }
        }
        function Ha(t, i) {
            return function(e) {
                e = e[t];
                if (!Ra(e))
                    return i ? Qa(i) ? e[i] : i(e) : e
            }
        }
        class ja extends Ka {
            constructor(e) {
                var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
                super(e),
                this.options = t,
                this.__store__ = e
            }
            selectAll() {
                var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {
                    asObject: !1
                };
                return this.select(e => e.entities).pipe(W( () => this.getAll(e)))
            }
            getAll() {
                var e, t, c = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {
                    asObject: !1,
                    filterBy: void 0,
                    limitTo: void 0
                };
                return (c.asObject ? function(e) {
                    var r = {}
                      , {filterBy: n, limitTo: a} = c
                      , {ids: s, entities: o} = e;
                    if (!n && !a)
                        return o;
                    e = !1 === _t(a);
                    if (n && e)
                        for (var l = 0, t = 0, i = s.length; t < i && !function(t) {
                            if (l === a)
                                return 1;
                            var e = s[t]
                              , i = o[e];
                            Vt(n).every(e => e(i, t)) && (r[e] = i,
                            l++)
                        }(t); t++)
                            ;
                    else
                        for (var d = Math.min(a || s.length, s.length), u = 0; u < d; u++)
                            !function(t) {
                                var e = s[t]
                                  , i = o[e];
                                if (!n)
                                    return r[e] = i;
                                Vt(n).every(e => e(i, t)) && (r[e] = i)
                            }(u);
                    return r
                }
                : (e = c,
                t = this.config || this.options,
                e.sortBy = e.sortBy || t && t.sortBy,
                e.sortByOrder = e.sortByOrder || t && t.sortByOrder,
                function(i) {
                    for (var r, e = [], {ids: n, entities: a} = i, {filterBy: s, limitTo: t, sortBy: o, sortByOrder: l} = c, d = 0; d < n.length; d++)
                        !function(t) {
                            var i = a[n[t]];
                            if (!s)
                                return e.push(i);
                            Vt(s).every(e => e(i, t)) && e.push(i)
                        }(d);
                    o && (r = Un(o) ? o : function(r, e) {
                        var n = 1 < arguments.length && void 0 !== e ? e : ya.ASC;
                        return function(e, t) {
                            var i;
                            return e.hasOwnProperty(r) && t.hasOwnProperty(r) ? (e = "string" == typeof e[r] ? e[r].toUpperCase() : e[r],
                            i = 0,
                            (t = "string" == typeof t[r] ? t[r].toUpperCase() : t[r]) < e ? i = 1 : e < t && (i = -1),
                            n == ya.DESC ? -1 * i : i) : 0
                        }
                    }(o, l),
                    e = e.sort( (e, t) => r(e, t, i)));
                    o = Math.min(t || e.length, e.length);
                    return o === e.length ? e : e.slice(0, o)
                }
                ))(this.getValue())
            }
            selectMany(e, i) {
                return e && e.length ? this.select(e => e.entities).pipe(W(t => {
                    return n = e => Ha(e, i)(t),
                    e.reduce( (e, t, i, r) => {
                        t = n(t);
                        return void 0 !== t && e.push(t),
                        e
                    }
                    , []);
                    var n
                }
                ), _n()) : Y([])
            }
            selectEntity(e, t) {
                var i = e;
                return Un(e) && (i = function(e, t) {
                    for (var i of Object.keys(t))
                        if (!0 === e(t[i]))
                            return i
                }(e, this.getValue().entities)),
                this.select(e => e.entities).pipe(W(Ha(i, t)), J())
            }
            getEntity(e) {
                return this.getValue().entities[e]
            }
            selectActiveId() {
                return this.select(e => e.active)
            }
            getActiveId() {
                return this.getValue().active
            }
            selectActive(t) {
                return Nt(this.getActive()) ? this.selectActiveId().pipe(te(e => this.selectMany(e, t))) : this.selectActiveId().pipe(te(e => this.selectEntity(e, t)))
            }
            getActive() {
                var e = this.getActiveId();
                return Nt(e) ? e.map(e => this.getValue().entities[e]) : Ma(e) ? this.getEntity(e) : void 0
            }
            selectCount(e) {
                return this.select(e => e.entities).pipe(W( () => this.getCount(e)))
            }
            getCount(e) {
                return (Un(e) ? this.getAll().filter(e) : this.getValue().ids).length
            }
            selectLast(e) {
                return this.selectAt(e => e[e.length - 1], e)
            }
            selectFirst(e) {
                return this.selectAt(e => e[0], e)
            }
            selectEntityAction(e) {
                var t, i;
                return _t(e) ? this.store.selectEntityAction$ : (t = Nt(e) ? e => e : e => {
                    e = e["ids"];
                    return e
                }
                ,
                i = Vt(e),
                this.store.selectEntityAction$.pipe(Z(e => {
                    e = e["type"];
                    return i.includes(e)
                }
                ), W(e => t(e))))
            }
            hasEntity(e) {
                return _t(e) ? 0 < this.getValue().ids.length : Un(e) ? this.getAll().some(e) : Nt(e) ? e.every(e => e in this.getValue().entities) : e in this.getValue().entities
            }
            hasActive(e) {
                var t = this.getValue().active
                  , i = ga(e);
                return Array.isArray(t) ? i ? t.includes(e) : 0 < t.length : i ? t === e : ga(t)
            }
            createUIQuery() {
                this.ui = new qa(this.__store__.ui)
            }
            selectAt(e, t) {
                return this.select(e => e.ids).pipe(W(e), J(), te(e => this.selectEntity(e, t)))
            }
        }
        class qa extends ja {
            constructor(e) {
                super(e)
            }
        }
        function Ga() {
            return Math.random().toString(36).slice(2)
        }
        t = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : void 0 !== my ? my : {};
        const $a = ["SDR", "PQ", "HLG"];
        function Wa(e) {
            return "bitrate"in e
        }
        const za = /^(?:[^\/;?#]+:)?(?:\/\/)?([^\/\;?#]*)/
          , Xa = /^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/
          , Ya = /^([^\/;?#]*)(.*)$/
          , Ja = /(?:\/|^)\.(?=\/)/g
          , Za = /(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g
          , es = {
            buildAbsoluteURL: function(e, t, i) {
                if (i = i || {},
                e = e.trim(),
                0 === (t = t.trim()).length) {
                    if (!i.alwaysNormalize)
                        return e;
                    const t = es.parseURL(e);
                    if (t)
                        return t.path = es.normalizePath(null != (r = t.path) ? r : ""),
                        es.buildURLFromParts(t);
                    throw new j(!0,H.URLParseError)
                }
                var r = es.parseURL(t);
                if (!r)
                    throw new j(!0,H.URLParseError);
                if (r.scheme)
                    return i.alwaysNormalize ? (r.path = es.normalizePath(null != (n = r.path) ? n : ""),
                    es.buildURLFromParts(r)) : t;
                var n = es.parseURL(e);
                if (!n)
                    throw new j(!0,H.URLParseError);
                if (!n.netLoc && n.path && "/" !== n.path[0]) {
                    const e = Ya.exec(n.path);
                    n.netLoc = null == e ? void 0 : e[1],
                    n.path = null == e ? void 0 : e[2]
                }
                n.netLoc && !n.path && (n.path = "/");
                var a = {
                    scheme: n.scheme,
                    netLoc: r.netLoc,
                    path: null,
                    params: r.params,
                    query: r.query,
                    fragment: r.fragment
                };
                if (!r.netLoc && (a.netLoc = n.netLoc,
                "/" !== (null == (t = r.path) ? void 0 : t[0])))
                    if (r.path) {
                        const e = n.path
                          , t = (null == e ? void 0 : e.substring(0, e.lastIndexOf("/") + 1)) + r.path;
                        a.path = es.normalizePath(t)
                    } else
                        a.path = n.path,
                        r.params || (a.params = n.params,
                        r.query) || (a.query = n.query);
                return null === a.path && (a.path = i.alwaysNormalize ? es.normalizePath(null != (e = r.path) ? e : "") : r.path),
                es.buildURLFromParts(a)
            },
            parseURL: function(e) {
                e = Xa.exec(e);
                return e ? {
                    scheme: e[1] || "",
                    netLoc: e[2] || "",
                    path: e[3] || "",
                    params: e[4] || "",
                    query: e[5] || "",
                    fragment: e[6] || ""
                } : null
            },
            normalizePath: function(e) {
                for (e = e.split("").reverse().join("").replace(Ja, ""); e.length !== (e = e.replace(Za, "")).length; )
                    ;
                return e.split("").reverse().join("")
            },
            buildURLFromParts: function(e) {
                return e.scheme + e.netLoc + e.path + e.params + e.query + e.fragment
            },
            getHostName: function(e) {
                if (e)
                    return null != (e = (e = za.exec(e)) && e[1]) ? e : ""
            },
            getBaseURL: function(e) {
                return (e = e && es.parseURL(e)) ? e.scheme + e.netLoc + e.path : null
            }
        };
        var ts, is, rs, ns, as, se, oe, ss, le, os, ls, O, ds, us = es;
        function cs(e) {
            return null != e && !e.startsWith("http://") && !e.startsWith("https://")
        }
        function hs(e) {
            return null != e && (0 === e.indexOf("//") || -1 !== e.indexOf("://") && -1 !== e.indexOf(".") && -1 !== e.indexOf("/") && !(e.indexOf(":") > e.indexOf("/")) && e.indexOf("://") < e.indexOf("."))
        }
        function ps(e, t) {
            return cs(e) ? es.buildAbsoluteURL(t, e, {
                alwaysNormalize: !0
            }) : es.buildAbsoluteURL(e, "", {
                alwaysNormalize: !0
            })
        }
        function ms(e) {
            return null != e && !cs(e) && null != (e = es.getHostName(e)) ? e : null
        }
        const fs = [".*.itunes.apple.com"]
          , gs = {
            deviceName: "&xapdn=",
            deviceModel: "&xapdm=",
            language: "&xapdl=",
            dsid: "&xapdsid=",
            subs: "&xapsub="
        };
        function ys(e, t) {
            return null == e || null == t || e === t
        }
        function vs(e, t) {
            var i, r, n = Wa(e), a = Wa(t), i = ms(e.url), r = t.url;
            return (!i || i === ms(r)) && (!n && !a || n && a && ys(e.pathwayID, t.pathwayID))
        }
        (i = ts = ts || {})[i.DOVI = 4] = "DOVI",
        i[i.HEVC = 3] = "HEVC",
        i[i.VP09 = 2] = "VP09",
        i[i.AVC = 1] = "AVC",
        i[i.UNKNOWN = 0] = "UNKNOWN",
        (r = is = is || {})[r.PQ = 3] = "PQ",
        r[r.HLG = 2] = "HLG",
        r[r.SDR = 1] = "SDR",
        r[r.UNKNOWN = 0] = "UNKNOWN",
        (i = rs = rs || {})[i.ALAC = 7] = "ALAC",
        i[i.FLAC = 6] = "FLAC",
        i[i.EC3 = 5] = "EC3",
        i[i.AC3 = 4] = "AC3",
        i[i.XHEAAC = 3] = "XHEAAC",
        i[i.AAC = 2] = "AAC",
        i[i.MP3 = 1] = "MP3",
        i[i.UNKNOWN = 0] = "UNKNOWN",
        (r = ns = ns || {})[r.VALID = 1] = "VALID",
        r[r.INVALID = 0] = "INVALID",
        (i = as = as || {})[i.DO_NOTHING = 0] = "DO_NOTHING",
        i[i.FLUSH_ALL = 1] = "FLUSH_ALL",
        i[i.RESET_MEDIASOURCE = 2] = "RESET_MEDIASOURCE";
        const Ss = ["via", "x-apple-request-uuid"]
          , Is = ["fragLoadPolicy", "keyLoadPolicy", "certLoadPolicy", "playlistLoadPolicy", "manifestLoadPolicy", "steeringManifestLoadPolicy", "preloadHintLoadPolicy"]
          , bs = {
            maxNumRetry: 4,
            retryDelayMs: 0,
            maxRetryDelayMs: 0
        }
          , Ts = {
            maxNumRetry: 6,
            retryDelayMs: 1e3,
            maxRetryDelayMs: 8e3
        }
          , Es = {
            maxNumRetry: 0,
            retryDelayMs: 0,
            maxRetryDelayMs: 0
        }
          , As = {
            maxNumRetry: 0,
            retryDelayMs: 0,
            maxRetryDelayMs: 0
        }
          , Os = {
            maxNumRetry: 0,
            retryDelayMs: 0,
            maxRetryDelayMs: 0
        }
          , Rs = {
            default: {
                maxTimeToFirstByteMs: 5e3,
                maxLoadTimeMs: 2e4,
                autoRetry: !1,
                timeoutRetry: Os,
                errorRetry: Os
            },
            interstitial: {
                maxTimeToFirstByteMs: 5e3,
                maxLoadTimeMs: 2e4,
                autoRetry: !1,
                timeoutRetry: Os,
                errorRetry: Os
            },
            customURL: {
                maxTimeToFirstByteMs: 1e4,
                maxLoadTimeMs: 2e4,
                autoRetry: !1,
                timeoutRetry: Os,
                errorRetry: Os
            }
        }
          , ws = {
            maxNumRetry: 8,
            retryDelayMs: 1e3,
            maxRetryDelayMs: 2e4,
            backoff: "linear"
        }
          , Ps = Object.assign(Object.assign({}, ws), {
            maxNumRetry: 1
        })
          , Ms = {
            default: {
                maxTimeToFirstByteMs: 5e3,
                maxLoadTimeMs: 2e4,
                autoRetry: !1,
                timeoutRetry: Ps,
                errorRetry: ws
            },
            interstitial: {
                maxTimeToFirstByteMs: 5e3,
                maxLoadTimeMs: 2e4,
                autoRetry: !1,
                timeoutRetry: Ps,
                errorRetry: ws
            },
            customURL: {
                maxTimeToFirstByteMs: 1e4,
                maxLoadTimeMs: 2e4,
                autoRetry: !1,
                timeoutRetry: Ps,
                errorRetry: ws
            }
        }
          , Cs = {
            supportedStorebagVersion: "0.0.0",
            testGroupId: ""
        }
          , ks = Object.assign(Object.assign({
            enableContentSteering: !1,
            enableBoss: !0,
            startPosition: NaN,
            debug: !1,
            debugLevel: "info",
            buildType: void 0,
            attemptErrorRecovery: !1,
            abrTrickplayLevelLocked: !1,
            minFramesBeforeSwitchingLevel: 11,
            minTargetDurations: 3,
            maxBufferLength: 60,
            maxBufferHole: .5,
            maxSeekHole: 2,
            nudgeFromEventSeek: !0,
            jaggedSeekTolerance: 0,
            discontinuitySeekTolerance: 2,
            bufferedSegmentEjectionToleranceMs: .5,
            almostDryBufferSec: .5,
            maxTotalDurationTolerance: .1,
            changeType: !1,
            preferManagedMediaSource: !0,
            lowBufferThreshold: .5,
            lowBufferWatchdogPeriod: .5,
            highBufferWatchdogPeriod: 3,
            seekWatchdogPeriod: 5,
            nudgeOffset: .1,
            nudgeMaxRetry: 3,
            maxFragLookUpTolerance: .2,
            liveSyncDurationCount: 3,
            liveSyncDuration: void 0,
            liveMaxUnchangedPlaylistRefresh: 3,
            liveEdgeForZeroStartPositon: !1,
            liveAllowTrickplay: !1,
            livePlaylistUpdateStaleness: 2,
            liveAllowLowLatencyPlayback: !1,
            livePreloadHintCacheAge: 6,
            allowFastSwitchUp: !1,
            desiredIframeFPS: 8,
            leftMediaTimeToAutoPause: 10,
            startTargetDurationFactor: .9,
            minRequiredStartDuration: 4,
            minRequiredStartDurationLLHLS: 2,
            maxRequiredStartDuration: 15,
            instantBwDurationFactor: .5,
            enableWorker: !0,
            enableWebCrypto: !0,
            keySystemPreference: void 0,
            useMultipleKeySessions: !1,
            enablePlayReadyKeySystem: !1,
            useMediaKeySystemAccessFilter: !1,
            playReadyMessageFormat: "utf16",
            widevineProactiveRenewal: !0,
            livePlaylistRefreshDelay: 2500,
            liveMinPlayingBufferLen: 5,
            enableIFramePreloading: !0,
            enableItemPreloading: !1,
            enableInterstitialPlayback: !1,
            livePlaylistPreloadDelayMs: 250,
            allowInterstitialAssetListDownload: !0,
            allowServerGeneratedInterstitials: !0,
            forcePauseOnInterstitialBoundary: !1,
            adjustedSeekToleranceMs: 500,
            enablePartialInterstitialPlaybackForLiveEdge: !1,
            useMediaCapabilities: !1,
            enableID3Cues: !0,
            certLoadPolicy: Rs,
            keyLoadPolicy: Ms,
            manifestLoadPolicy: {
                default: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 2e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 2,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 1,
                        retryDelayMs: 1e3,
                        maxRetryDelayMs: 8e3
                    }
                },
                interstitial: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 2e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 0,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 0,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    }
                },
                customURL: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 1e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 2,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 1,
                        retryDelayMs: 1e3,
                        maxRetryDelayMs: 8e3
                    }
                }
            },
            trickPlaybackConfig: {
                enabled: !0,
                minIframeDuration: 8
            },
            minSteeringRunway: 2,
            partialAppendDurationSec: 0,
            replaceItemAction: as.RESET_MEDIASOURCE
        }, Cs), {
            playlistLoadPolicy: {
                default: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 2e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 2,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 2,
                        retryDelayMs: 1e3,
                        maxRetryDelayMs: 8e3
                    }
                },
                interstitial: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 2e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 0,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 0,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    }
                },
                customURL: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 1e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 2,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 2,
                        retryDelayMs: 1e3,
                        maxRetryDelayMs: 8e3
                    }
                }
            },
            fragLoadPolicy: {
                default: {
                    maxTimeToFirstByteMs: 5e3,
                    autoRetry: !1,
                    timeoutRetry: bs,
                    errorRetry: Ts,
                    forceContentLenCheckIfNoHeader: !1,
                    reportCDNServer: !0
                },
                interstitial: {
                    maxTimeToFirstByteMs: 5e3,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 0,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 0,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    forceContentLenCheckIfNoHeader: !1,
                    reportCDNServer: !0
                },
                customURL: {
                    maxTimeToFirstByteMs: 1e4,
                    autoRetry: !1,
                    timeoutRetry: bs,
                    errorRetry: Ts,
                    reportCDNServer: !0
                }
            },
            steeringManifestLoadPolicy: {
                default: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 2e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 2,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 1,
                        retryDelayMs: 1e3,
                        maxRetryDelayMs: 8e3
                    }
                },
                interstitial: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 2e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 0,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 0,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    }
                },
                customURL: {
                    maxTimeToFirstByteMs: 1e4,
                    maxLoadTimeMs: 1e4,
                    autoRetry: !1,
                    timeoutRetry: {
                        maxNumRetry: 2,
                        retryDelayMs: 0,
                        maxRetryDelayMs: 0
                    },
                    errorRetry: {
                        maxNumRetry: 1,
                        retryDelayMs: 1e3,
                        maxRetryDelayMs: 8e3
                    }
                }
            },
            preloadHintLoadPolicy: {
                default: {
                    maxTimeToFirstByteMs: 3e3,
                    autoRetry: !1,
                    timeoutRetry: Es,
                    errorRetry: As,
                    forceContentLenCheckIfNoHeader: !1,
                    reportCDNServer: !0
                },
                interstitial: {
                    maxTimeToFirstByteMs: 3e3,
                    autoRetry: !1,
                    timeoutRetry: Es,
                    errorRetry: As,
                    forceContentLenCheckIfNoHeader: !1,
                    reportCDNServer: !0
                },
                customURL: {
                    maxTimeToFirstByteMs: 3e3,
                    autoRetry: !1,
                    timeoutRetry: Es,
                    errorRetry: As,
                    reportCDNServer: !0
                }
            },
            maxNumAddLevelToPenaltyBox: 4,
            firstAudioMustOverlapVideoStart: !1,
            keyMinHoldTimeBeforeCleanup: 15e3,
            appendErrorMaxRetry: 3,
            xhrSetup: void 0,
            audioPrimingDelay: 0,
            enableCEA708Captions: !0,
            customTextTrackCueRenderer: !1,
            enableWebVTT: !0,
            captionsTextTrack1Label: "English",
            captionsTextTrack1LanguageCode: "en",
            captionsTextTrack2Label: "Spanish",
            captionsTextTrack2LanguageCode: "es",
            condenseSubtitleTrack: !1,
            nativeTextTrackChangeHandling: !0,
            earlyFragTolerance: 7,
            vttConcurrentLoadCount: 1,
            trottleCheckInterval: 2e3,
            subtitleLeadTime: 30,
            lateTolerance: 2,
            dynamicTextTrackCreation: !1,
            stretchShortVideoTrack: !1,
            forceKeyFrameOnDiscontinuity: !0,
            abrAlgorithm: "default",
            abrBandWidthFactor: .95,
            abrBandWidthUpFactor: .9,
            abrSamplePeriodMs: 200,
            maxStarvationDelay: 4,
            useStickyAtmosFilter: !1,
            enableRtcReporting: !1,
            rtcIntervalTimeout: 3e5,
            rtcLogHistoryNumLines: 0,
            rtcLogHistoryMaxLineLength: 200,
            rtcExcludeKeysList: [],
            useHTTPPlaybackSessionId: !1,
            warmupCdms: !1,
            createDummySessionOnStart: !1,
            maintainMediaKeysBetweenSessions: !0,
            enablePerformanceLogging: !1,
            rtcErrStackNumLines: 0,
            overridePlaybackRate: !1,
            nativeControlsEnabled: !1,
            useCustomMediaFunctions: !0,
            seekEventThrottleMs: 150,
            timeAccuracyThresholdSeconds: .25,
            contentGapPlaythroughIntervalSeconds: .5,
            enableAdaptiveStartup: !0,
            bandwidthHistoryWindowSize: 12e4,
            bandwidthHistoryTTL: 6e5,
            bandwidthHistoryAggregationMethod: "quadratic-time-weighted",
            defaultTargetDuration: 10,
            defaultPartTargetDuration: 1,
            targetStartupMs: 4e3,
            bandwidthHistoryStorageKey: "AppleHLS-bandwidth-estimation",
            storageKeyPrefix: "AppleHLS-",
            storage: {
                get: "undefined" == typeof localStorage ? void 0 : localStorage.getItem.bind(localStorage),
                set: "undefined" == typeof localStorage ? void 0 : localStorage.setItem.bind(localStorage)
            },
            minFragmentCount: 1,
            minPlaylistCount: 1,
            enableQueryParamsForITunes: !1,
            gapless: !1,
            supportGaplessVideo: !1,
            useViewportSizeForLevelCap: !1,
            statDefaults: {
                playlistLoadTimeMs: 500,
                playlistParseTimeMs: 50,
                fragParseTimeMs: 100,
                fragBufferCreationDelayMs: 200,
                dataFragAppendMs: 100,
                initFragAppendMs: 100
            },
            disableVideoCodecList: new Set([]),
            disableAudioCodecList: new Set([rs.ALAC, rs.FLAC, rs.XHEAAC]),
            useHighestVideoCodecPrivate: !0,
            sessionDataAutoLoad: {
                "com.apple.hls.chapters": !0,
                "_hls.localized-rendition-names": !0
            },
            canUseNetworkResourcesForLiveStreamingWhilePaused: !1,
            liveResumeAtWindowStart: !1,
            liveOldCueRemovalOffsetSec: 600
        });
        function Ls(e) {
            var t;
            return null != (t = e.serviceName) ? t : e.itemId
        }
        const Ns = {
            itemId: "Nah",
            mediaOptionId: "Nah"
        }
          , de = Object.assign(Object.assign({}, Ns), {
            mediaOptionType: void 0
        })
          , Ds = e => {
            var {itemId: e, mediaOptionId: t} = e;
            return "Nah" !== e && "Nah" !== t
        }
        ;
        function xs(e) {
            return null != e && null != e.relativeUrl
        }
        const Fs = (e, t) => e.itemId === t.itemId && e.mediaOptionId === t.mediaOptionId
          , Bs = ((r = se = se || {})[r.Variant = 0] = "Variant",
        r[r.AltAudio = 1] = "AltAudio",
        r[r.Subtitle = 2] = "Subtitle",
        ["variant", "altAudio", "subtitle"])
          , Us = [se.Variant, se.AltAudio, se.Subtitle]
          , _s = [se.Variant, se.AltAudio]
          , Vs = ((i = oe = oe || {})[i.Variant = 0] = "Variant",
        i[i.AltAudio = 1] = "AltAudio",
        ["variant", "altAudio"]);
        function Qs(e) {
            switch (e) {
            case se.Variant:
                return oe.Variant;
            case se.AltAudio:
                return oe.AltAudio;
            default:
                return null
            }
        }
        function Ks(e) {
            return e === oe.Variant ? se.Variant : se.AltAudio
        }
        (r = ss = ss || {})[r.Primary = 0] = "Primary",
        r[r.Interstitial = 1] = "Interstitial";
        class Hs {
            constructor(e=0) {
                this.re = e,
                this.se = []
            }
            recordLogs(e) {
                this.re && (e = {
                    timestampMs: e.ts,
                    messages: e.messages,
                    level: e.level.value
                },
                this.se.push(e),
                this.se.length > this.re) && this.se.shift()
            }
            getLogs() {
                return this.se
            }
        }
        (i = le = le || {})[i.ContentSteeringPathwayCloner = 0] = "ContentSteeringPathwayCloner",
        i[i.PlatformFilter = 1] = "PlatformFilter",
        i[i.PermanentRemovalFilter = 2] = "PermanentRemovalFilter",
        i[i.PenaltyBoxFilter = 3] = "PenaltyBoxFilter",
        i[i.PathwayPenaltyBoxFilter = 4] = "PathwayPenaltyBoxFilter",
        i[i.CompatibleIdsFilter = 5] = "CompatibleIdsFilter",
        i[i.HDRFilter = 6] = "HDRFilter",
        i[i.ViewportFilter = 7] = "ViewportFilter",
        i[i.HDCPFilter = 8] = "HDCPFilter",
        i[i.MatchingPathwayFilter = 9] = "MatchingPathwayFilter",
        i[i.PathwayFilter = 10] = "PathwayFilter",
        i[i.ImageVariantFilter = 11] = "ImageVariantFilter",
        i[i.MediaFilterBasedOnMode = 12] = "MediaFilterBasedOnMode",
        i[i.BitrateFilter = 13] = "BitrateFilter",
        i[i.SdrOnlyFilter = 14] = "SdrOnlyFilter",
        i[i.NonIframeOnlyFilter = 15] = "NonIframeOnlyFilter",
        i[i.IframeOnlyFilter = 16] = "IframeOnlyFilter",
        i[i.ValidFallbackFilter = 17] = "ValidFallbackFilter",
        i[i.ValidAlternatesFilter = 18] = "ValidAlternatesFilter",
        i[i.ErrorHandlingValidAlternatesFilter = 19] = "ErrorHandlingValidAlternatesFilter",
        i[i.HostRankFilter = 20] = "HostRankFilter",
        i[i.MediaFilteringBasedOnImageIframes = 21] = "MediaFilteringBasedOnImageIframes",
        i[i.PathwayRankSelector = 22] = "PathwayRankSelector",
        i[i.LowerPivotQualitySelector = 23] = "LowerPivotQualitySelector",
        i[i.HigherPivotQualitySelector = 24] = "HigherPivotQualitySelector",
        i[i.LowerQualitySelector = 25] = "LowerQualitySelector",
        i[i.HigherQualitySelector = 26] = "HigherQualitySelector",
        i[i.PivotAudioGroupSelector = 27] = "PivotAudioGroupSelector",
        i[i.StartUpTimeSelector = 28] = "StartUpTimeSelector",
        i[i.FirstLevelSelector = 29] = "FirstLevelSelector",
        i[i.FallbackSelector = 30] = "FallbackSelector",
        i[i.QualitySelector = 31] = "QualitySelector",
        i[i.BestAbrLevelSelector = 32] = "BestAbrLevelSelector",
        i[i.GenericTransformer = 33] = "GenericTransformer",
        (r = os = os || {})[r.ABR = 0] = "ABR",
        r[r.ABRLowestLevel = 1] = "ABRLowestLevel",
        r[r.ABRIframe = 2] = "ABRIframe",
        r[r.ABRIframeLowestLevel = 3] = "ABRIframeLowestLevel",
        r[r.ErrorHandling = 4] = "ErrorHandling",
        r[r.FirstSelection = 5] = "FirstSelection",
        r[r.ImageVariant = 6] = "ImageVariant",
        r[r.ErrorHandlingSdrOnly = 7] = "ErrorHandlingSdrOnly",
        r[r.CompatibleOptions = 8] = "CompatibleOptions";
        class js {
            constructor(e, t={}) {
                this.variants = e,
                this.generation = t
            }
        }
        (i = ls = ls || {})[i.NO = 0] = "NO",
        i[i.YES = 1] = "YES",
        (r = O = O || {}).UNKNOWN = "unkn",
        r.VIDEO = "vide",
        r.AUDIO = "soun",
        r.SUBTITLE = "sbtl",
        r.CLOSEDCAPTION = "clcp",
        (i = ds = ds || {}).LowBandwidth = "LowBandwidth",
        i.HighBandwidth = "HighBandwidth",
        i.PreferredListChanged = "PreferredListChanged",
        i.IframeModeChange = "IframeModeChange",
        i.None = "",
        i.Seek = "Seek";
        class qs {
            constructor() {
                this.oe = null,
                this.ae = null,
                this.le = null
            }
            get forward() {
                var e;
                return 0 < (null != (e = null == (e = this.timeline) ? void 0 : e.rate) ? e : 0)
            }
            get isStarted() {
                return Boolean(this.oe)
            }
            start(e) {
                this.le = null,
                this.ae = Object.assign({}, e);
                const t = {
                    rootTimeSeconds: performance.now() / 1e3,
                    rate: 1
                };
                this.oe = {
                    timeline: t,
                    getCurrentTime: () => ({
                        seconds: performance.now() / 1e3,
                        timeline: t
                    })
                }
            }
            pause() {
                this.isStarted && (this.le = this.getCurrentTime())
            }
            stop() {
                this.pause(),
                this.oe = null,
                this.ae = null
            }
            get timeline() {
                return this.ae
            }
            getCurrentTime() {
                var e, t, i;
                return this.le || (this.oe && (e = this.oe.getCurrentTime()) && this.timeline ? (t = this.timeline,
                i = e.timeline,
                {
                    seconds: (e.seconds - i.rootTimeSeconds) / i.rate * t.rate + t.rootTimeSeconds,
                    timeline: t
                }) : null)
            }
        }
        class Gs extends Error {
            constructor(e, t) {
                super(e),
                this.statusCode = t
            }
            get isAuthOrCorsError() {
                return 401 === this.statusCode || 403 === this.statusCode || 407 === this.statusCode || 0 === this.statusCode
            }
        }
        class $s extends b {
            constructor(e, t, i, r, n) {
                super(he.NETWORK_ERROR, e, t, i, n),
                this.isTimeout = r,
                this.response = i
            }
        }
        class Ws extends $s {
            constructor(e, t, i, r) {
                super(i ? Q.MANIFEST_LOAD_TIMEOUT : Q.MANIFEST_LOAD_ERROR, e, t, i, r)
            }
        }
        class zs extends $s {
            constructor(e, t, i, r, n, a, s) {
                super(function(e) {
                    switch (r) {
                    case se.Variant:
                        return e ? Q.LEVEL_LOAD_TIMEOUT : Q.LEVEL_LOAD_ERROR;
                    case se.AltAudio:
                        return e ? Q.AUDIO_TRACK_LOAD_TIMEOUT : Q.AUDIO_TRACK_LOAD_ERROR;
                    case se.Subtitle:
                        return e ? Q.SUBTITLE_TRACK_LOAD_TIMEOUT : Q.SUBTITLE_TRACK_LOAD_ERROR
                    }
                    return Q.UNKNOWN
                }(i), e, t, i, s),
                this.mediaOptionType = r,
                this.mediaOptionId = n,
                this.url = a
            }
        }
        class Xs extends $s {
            constructor(e, t, i) {
                super(Q.SESSION_DATA_LOAD_ERROR, e, t, !1, i)
            }
        }
        class Ys extends $s {
            constructor(e, t, i, r, n, a) {
                super(i ? Q.FRAG_LOAD_TIMEOUT : Q.FRAG_LOAD_ERROR, e, t, i, a),
                this.mediaOptionId = r.mediaOptionId,
                this.mediaOptionType = r.mediaOptionType,
                this.stats = n
            }
        }
        class Js extends Ln {
            constructor(e, t) {
                super(),
                this.message = e,
                this.stats = t
            }
        }
        class Zs extends $s {
            constructor(e, t, i) {
                super(Q.FRAG_ABORT_ERROR, !1, i, !1),
                this.candidateMediaOptions = t,
                this.mediaOptionId = e.mediaOptionId,
                this.mediaOptionType = e.mediaOptionType
            }
        }
        function eo(e, t) {
            return !e.url || cs(e.url) ? t.customURL : t.default
        }
        function to(e, t) {
            let i;
            return i = e instanceof $s ? e.isTimeout ? t.timeoutRetry : t.errorRetry : i
        }
        function io(t) {
            return e => e.pipe($(e => {
                if (e instanceof Js)
                    throw new Ws(t,H.ManifestTimeoutError,!0);
                if (e instanceof Gs)
                    throw new Ws(t,e.statusCode,!1,e.message);
                throw e
            }
            ))
        }
        function ro(t, i, r, n) {
            return e => e.pipe($(e => {
                if (e instanceof Js)
                    throw new zs(r,H.PlaylistTimeoutError,!0,t,i,n);
                if (e instanceof Gs)
                    throw new zs(r,e.statusCode,!1,t,i,n,e.message);
                throw e
            }
            ))
        }
        function no(t, i) {
            return e => e.pipe($(e => {
                if (e instanceof Js)
                    throw new Ys(i,H.FragmentTimeoutError,!0,t,e.stats);
                if (e instanceof Gs)
                    throw new Ys(i,e.statusCode,!1,t,void 0,e.message);
                throw e
            }
            ))
        }
        function ao(e) {
            var t = e.type
              , i = e.liveOrEvent;
            let r = "VOD";
            "EVENT" === t && i ? r = "EVENT" : t && 0 !== t.length && "LIVE" !== t || !i || (r = "LIVE"),
            e.type !== r && (e.type = r)
        }
        function so(e, t, i, r, n) {
            t = oo(e, t, r);
            return i.load(e, t).pipe($(e => e instanceof Gs && e.isAuthOrCorsError ? R(new Gs(`Tried to recover via customUrl, but got auth or cors error: originalStatus=${n.statusCode} retryStatus=` + e.statusCode,e.statusCode)) : R(e)))
        }
        function oo(e, t, i) {
            var e = e["extendMaxTTFB"]
              , {maxLoadTimeMs: r, maxTimeToFirstByteMs: n} = t
              , r = (null != r ? r : 0) - (performance.now() - i)
              , e = re(e) && 0 < e ? e : n - (performance.now() - i);
            return Object.assign(Object.assign({}, t), {
                maxLoadTimeMs: r,
                maxTimeToFirstByteMs: e
            })
        }
        const lo = /(\d+)-(\d+)\/(\d+)/
          , uo = /^CDN-Server:/im
          , co = /^Age/im
          , ho = /^$/;
        function po(g, y) {
            return na(function() {
                const e = g["extendMaxTTFB"]
                  , {maxTimeToFirstByteMs: i, maxLoadTimeMs: t} = y
                  , n = new mn;
                let r, a, s, o = new XMLHttpRequest;
                const l = {
                    trequest: performance.now(),
                    tfirst: NaN,
                    tload: NaN,
                    loaded: 0,
                    total: NaN,
                    complete: !1
                }
                  , d = [{
                    name: "readystatechange",
                    listener: function() {
                        3 <= this.readyState && isNaN(l.tfirst) && (l.tfirst = performance.now(),
                        clearTimeout(r))
                    }
                }, {
                    name: "loadend",
                    listener: function() {
                        if (l.complete = !0,
                        200 <= this.status && this.status < 300) {
                            l.tload = performance.now(),
                            l.contentType = this.getResponseHeader("Content-Type") || void 0;
                            var e = this.getAllResponseHeaders();
                            if (y.reportCDNServer && uo.test(e) && (l.cdnServer = this.getResponseHeader("CDN-Server") || void 0),
                            l.contentLength = y.forceContentLenCheckIfNoHeader ? function(e) {
                                let t;
                                var i = e.getResponseHeader("Content-Encoding")
                                  , r = e.getResponseHeader("Transfer-Encoding")
                                  , i = !i || i && "identity" === i.toLowerCase()
                                  , r = !r || r && "identity" === r.toLowerCase();
                                return i && r && (re(t = function(e) {
                                    e = lo.exec(e || "");
                                    return e ? parseInt(e[2]) - parseInt(e[1]) + 1 : void 0
                                }(e.getResponseHeader("Content-Range"))) || (t = parseInt(null != (i = e.getResponseHeader("Content-Length")) ? i : ""))),
                                t
                            }(this) : void 0,
                            i = this,
                            (r = g).collectServerInstanceInfo && (r.serverInstanceInfo = {},
                            r.collectServerInstanceInfo.forEach(e => {
                                var t = i.getResponseHeader(e);
                                t && r.serverInstanceInfo && (r.serverInstanceInfo[e] = t)
                            }
                            )),
                            "arraybuffer" === g.responseType)
                                l.loaded = this.response.byteLength;
                            else if (l.loaded = this.responseText.length,
                            co.test(e)) {
                                const g = this.getResponseHeader("Age");
                                l.age = g ? parseInt(g) : NaN
                            } else
                                l.age = NaN;
                            l.total = l.loaded,
                            g.checkContentLength && (0 === l.total || re(l.contentLength) && l.total != l.contentLength) && n.error(new Gs("Network error",this.status));
                            e = [this, l];
                            n.next(e)
                        } else
                            n.error(new Gs("Network error",this.status));
                        var i, r;
                        n.complete(),
                        ho.test("")
                    }
                }, {
                    name: "progress",
                    listener: function(e) {
                        l.loaded = e.loaded,
                        e.lengthComputable && (l.total = e.total)
                    }
                }]
                  , u = g.onProgress;
                if (u) {
                    const y = u.cb
                      , e = u.samplePeriodMs
                      , i = u.getData;
                    if (re(e))
                        s = setInterval(function() {
                            let t = !1;
                            try {
                                t = y(g.url, o.status, l, i ? o.response : void 0)
                            } catch (e) {
                                t = !0,
                                n.error(e)
                            }
                            t && clearInterval(s)
                        }, e);
                    else {
                        const e = function() {
                            let t = !1;
                            try {
                                t = y(g.url, this.status, l, i ? this.response : void 0)
                            } catch (e) {
                                t = !0,
                                n.error(e)
                            }
                            t && this.removeEventListener("progress", e)
                        };
                        d.push({
                            name: "progress",
                            listener: e
                        })
                    }
                }
                for (const {name: g, listener: y} of d)
                    o.addEventListener(g, y);
                var {url: c, method: h, byteRangeOffset: p, responseType: m, body: f} = g;
                g.mimeType && o.overrideMimeType(g.mimeType);
                try {
                    const y = g.xhrSetup;
                    o.open(h, g.url, !0),
                    y && y(o, c)
                } catch (e) {
                    n.error(new Gs(e.message,o.status))
                }
                if (o.responseType = m,
                p && re(p.start) && re(p.end) && 0 <= p.start && p.end > p.start) {
                    const {start: g, end: y} = p;
                    o.setRequestHeader("Range", `bytes=${g}-` + (y - 1))
                }
                if (g.headers)
                    for (const [y,e] of Object.entries(g.headers))
                        o.setRequestHeader(y, e);
                if ("POST" === h && f ? o.send(f) : o.send(),
                isFinite(i) && 0 < i) {
                    const g = re(e) && 0 < e ? e : i;
                    r = setTimeout( () => {
                        re(l.tfirst) || n.error(new Js("TTFB Timeout",l))
                    }
                    , g)
                }
                return re(t) && 0 < t && (a = setTimeout( () => {
                    re(l.tload) || n.error(new Js("Max load timeout",l))
                }
                , t)),
                n.pipe($(function(e) {
                    if (e instanceof b)
                        throw e;
                    if (e instanceof Ln)
                        throw new Js(e.message,l);
                    if (e instanceof Gs)
                        throw e;
                    throw new Gs(e.message,H.XhrError)
                }), ee( () => {
                    o.abort(),
                    clearTimeout(r),
                    clearTimeout(a),
                    clearInterval(s);
                    for (var {name: e, listener: t} of d)
                        o.removeEventListener(e, t);
                    o = void 0
                }
                ))
            })
        }
        function mo(t) {
            return e => e.pipe(W(e => {
                return [e.data.response.data, e.stats, null != (e = t.serverInstanceInfo) ? e : {}]
            }
            ))
        }
        function fo(t, i, r) {
            const n = Object.assign(Object.assign({}, t), {
                method: "GET",
                responseType: "arraybuffer"
            });
            if (cs(n.url))
                return r.load(n, i).pipe(mo(n));
            {
                const t = performance.now()
                  , e = po(n, i).pipe(W( ([e,t]) => {
                    return [e.response, t, null != (e = n.serverInstanceInfo) ? e : {}]
                }
                ));
                return e.pipe($(e => {
                    if (e instanceof Gs && e.isAuthOrCorsError)
                        return so(n, i, r, t, e).pipe(mo(n));
                    throw e
                }
                ))
            }
        }
        const go = (r, e, t, i, n, a, s, o, l) => {
            var {relativeUrl: d, byteRangeOffset: u, keyTagInfo: c, iframe: h, isInitSegment: p} = r
              , e = us.buildAbsoluteURL(e, d, {
                alwaysNormalize: !0
            })
              , c = null != (d = null == c ? void 0 : c.method) ? d : "NONE"
              , {start: d, end: m} = null != u ? u : {}
              , i = eo({
                url: e
            }, i);
            let f, g = d, y = m, v = !1, S = re(d) || re(m) ? u : void 0;
            if ("AES-128" === c && m && (h || p)) {
                const r = m - (null != d ? d : 0);
                r % 16 && (y = m + (16 - r % 16)),
                re(d) && 0 !== d && (v = !0,
                g = d - 16),
                re(g) && re(y) && (S = {
                    start: g,
                    end: y
                })
            }
            return o && re(r.mediaSeqNum) && r.mediaOptionType === se.Variant && (f = [],
            null != (u = i.reportHTTPResponseHeaders) && u.forEach(function(e) {
                Ss.includes(e) && Array.isArray(f) && f.push(e)
            }),
            0 === f.length) && (f = void 0),
            fo({
                url: e,
                byteRangeOffset: S,
                checkContentLength: !0,
                extendMaxTTFB: l,
                collectServerInstanceInfo: f,
                onProgress: s,
                xhrSetup: t.xhrSetup
            }, i, n).pipe(W( ([e,t,i]) => {
                if (v) {
                    const t = e;
                    r.keyTagInfo && (r.keyTagInfo.iv = new Uint8Array(t.slice(0, 16))),
                    e = t.slice(16)
                }
                return {
                    mediaFragment: r,
                    loadedData: Ae(e),
                    bwSample: t,
                    serverInfo: i
                }
            }
            ), no(r, !1))
        }
          , yo = {
            search: function(e, t) {
                let i, r, n = 0, a = (null == e ? void 0 : e.length) - 1;
                for (; n <= a; ) {
                    var s = t(r = e[i = (n + a) / 2 | 0]);
                    if (0 < s)
                        n = i + 1;
                    else {
                        if (!(s < 0))
                            return r;
                        a = i - 1
                    }
                }
            }
        };
        var vo, So, Io, bo, To, Eo = yo;
        (r = vo = vo || {})[r.Preroll = 0] = "Preroll",
        r[r.Midroll = 1] = "Midroll",
        r[r.Postroll = 2] = "Postroll",
        (i = So = So || {})[i.None = 0] = "None",
        i[i.Out = 1] = "Out",
        i[i.In = 2] = "In",
        i[i.InOut = 3] = "InOut",
        (r = Io = Io || {})[r.None = 0] = "None",
        r[r.Skip = 1] = "Skip",
        r[r.Jump = 4] = "Jump",
        r[r.SkipJump = 5] = "SkipJump";
        class Ao extends Ka {
            constructor(e) {
                super(e),
                this.store = e,
                this.interstitials$ = this.select("interstitials"),
                this.pastInterstitials$ = this.select("pastInterstitials"),
                this.interstitialAssets$ = this.select("interstitialAssets"),
                this.activeInterstitialId$ = this.select("activeInterstitialId"),
                this.activeInterstitialAssetId$ = this.select("activeInterstitialAssetId"),
                this.playingInterstitialId$ = this.select("playingInterstitialId"),
                this.playingInterstitialAssetId$ = this.select("playingInterstitialAssetId")
            }
            getInterstitialForId(t) {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.interstitials.find(e => e.identifier === t)) ? e : null
            }
            getInterstitialAssetForId(t) {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.interstitialAssets.find(e => e.identifier === t)) ? e : null
            }
            get interstitials() {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.interstitials) ? e : []
            }
            get pastInterstitials() {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.pastInterstitials) ? e : []
            }
            get interstitialAssets() {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.interstitialAssets) ? e : []
            }
            get activeInterstitialId() {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.activeInterstitialId) ? e : null
            }
            get activeInterstitialAssetId() {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.activeInterstitialAssetId) ? e : null
            }
            get playingInterstitialId() {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.playingInterstitialId) ? e : null
            }
            get playingInterstitialAssetId() {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.playingInterstitialAssetId) ? e : null
            }
            get playableInterstitials$() {
                return this.interstitials$.pipe(W(e => e.filter(e => this.ue(e))))
            }
            get playableInterstitials() {
                return this.interstitials.filter(e => this.ue(e))
            }
            get playableInterstitialsForSeek() {
                return this.interstitials.filter(e => !e.hasPlayed || e.hasPlayed && !e.playOnce).reverse()
            }
            get realCurrentTimeOffsetMap() {
                var e;
                return null != (e = null == (e = this.getValue()) ? void 0 : e.realCurrentTimeOffsetMap) ? e : {}
            }
            ue(e) {
                var t = !e.hasPlayed || e.hasPlayed && !e.playOnce
                  , e = this.pastInterstitials.includes(e.identifier);
                return !(!t || e)
            }
        }
        class Oo extends Ba {
            constructor() {
                super({
                    interstitials: [],
                    interstitialAssets: [],
                    pastInterstitials: [],
                    activeInterstitialId: null,
                    activeInterstitialAssetId: null,
                    playingInterstitialId: null,
                    playingInterstitialAssetId: null,
                    realCurrentTimeOffsetMap: {}
                }, {
                    name: "interstitials",
                    resettable: !0
                })
            }
        }
        class Ro {
            constructor(e) {
                this.ce = e,
                this.he = new Ao(e)
            }
            get interstitialQuery() {
                return this.he
            }
            addInterstitials(e) {
                const t = this.he.interstitials.reduce( (e, t) => (e[t.identifier] = !0,
                e), {})
                  , i = e.filter(e => !t[e.identifier]);
                this.ce.update( ({interstitials: e}) => ({
                    interstitials: Qt(e, i)
                }))
            }
            updateInterstitial(t, i) {
                this.ce.update( ({interstitials: e}) => ({
                    interstitials: Kn(e, t, i, "identifier")
                }))
            }
            removeInterstitials(t) {
                this.ce.update( ({interstitials: e}) => ({
                    interstitials: Qn(e, t, "identifier")
                }))
            }
            addInterstitialToPastEvents(t) {
                this.ce.update( ({pastInterstitials: e}) => ({
                    pastInterstitials: function(e, t, i, r) {
                        var n = 3 < arguments.length && void 0 !== r ? r : Fn
                          , a = Vn(i);
                        return e.some(e => a ? e[n] === t : e === t) ? Kn(e, t, i, n) : Qt(e, a ? I(I({}, i), {}, {
                            [n]: t
                        }) : i)
                    }(e, t, t, "identifier")
                }))
            }
            removeInterstitialsFromPastEvents(t) {
                this.ce.update( ({pastInterstitials: e}) => ({
                    pastInterstitials: Qn(e, t, "identifier")
                }))
            }
            removeInterstitialsFromPastEventsFromTime(r) {
                var e = this.he.interstitials.reduce( (e, t) => {
                    var i;
                    return P(null != (i = t.startTime) ? i : {
                        baseTime: 0,
                        timescale: 1
                    }) >= r && t.cueType === vo.Midroll && e.push(t.identifier),
                    e
                }
                , new Array);
                this.removeInterstitialsFromPastEvents(e)
            }
            addInterstitialAsset(t) {
                this.interstitialQuery.interstitialAssets.find(e => e.identifier === t.identifier) || this.ce.update( ({interstitialAssets: e}) => ({
                    interstitialAssets: Qt(e, t)
                }))
            }
            updateInterstitialAsset(t, i) {
                this.ce.update( ({interstitialAssets: e}) => ({
                    interstitialAssets: Kn(e, t, i, "identifier")
                }))
            }
            removeInterstitialAssets(t) {
                this.ce.update( ({interstitialAssets: e}) => ({
                    interstitialAssets: Qn(e, t, "identifier")
                }))
            }
            setActiveInterstitialId(t) {
                t && !this.he.interstitials.find(e => e.identifier === t) || this.ce.update({
                    activeInterstitialId: t
                })
            }
            setPlayingInterstitialId(t) {
                t && !this.he.interstitials.find(e => e.identifier === t) || this.ce.update({
                    playingInterstitialId: t
                })
            }
            setActiveInterstitialAssetId(t) {
                t && !this.he.interstitialAssets.find(e => e.identifier === t) || this.ce.update({
                    activeInterstitialAssetId: t
                })
            }
            setPlayingInterstitialAssetId(t) {
                t && !this.he.interstitialAssets.find(e => e.identifier === t) || this.ce.update({
                    playingInterstitialAssetId: t
                })
            }
            updateRealCurrentTimeOffsetMap(e, t) {
                var i = Object.assign({}, this.he.realCurrentTimeOffsetMap);
                i[e] = t,
                this.ce.update({
                    realCurrentTimeOffsetMap: i
                })
            }
            destroy() {
                this.ce.destroy()
            }
            reset() {
                this.ce.reset()
            }
        }
        function wo(e) {
            return new pe(he.MEDIA_ERROR,Q.INTERSTITIAL_ASSET_LIST_PARSING_ERROR,!1,H.FormatError,e)
        }
        function Po() {
            return e => e.pipe(W(e => ({
                responseText: e.data.response.data.toString(),
                responseURL: e.data.response.uri,
                stats: e.stats
            })))
        }
        const Mo = (t, i, e, r, n) => {
            const a = Object.assign(Object.assign({}, t), {
                method: "GET",
                responseType: "text",
                extendMaxTTFB: e
            });
            if (cs(a.url))
                return r.load(a, i).pipe(Po());
            {
                const t = performance.now();
                return po(a, i).pipe(W( ([e,t]) => ({
                    responseText: e.responseText,
                    responseURL: e.responseURL,
                    stats: t
                })), $(e => {
                    if (e instanceof Gs && e.isAuthOrCorsError)
                        return so(a, i, r, t, e).pipe(Po());
                    throw e
                }
                ))
            }
        }
        ;
        function Co(e) {
            var t;
            let i = null != (t = null == e ? void 0 : e.duration) ? t : 0;
            if (e) {
                const t = P(e.resumptionOffset);
                re(t) && (i = t)
            }
            return i
        }
        function ko(e) {
            e = /interstitial:(.*):asset/.exec(e);
            return e && 1 < e.length ? e[1] : null
        }
        function Lo(e, t) {
            return !(null == (e = e) || e.length < 1) && -1 < (i = e.findIndex(e => e.itemId === t)) ? {
                element: e[i],
                index: i
            } : {
                element: null,
                index: -1
            };
            var i
        }
        function No(e) {
            return !!e && -1 === e.indexOf("interstitial")
        }
        function Do(e) {
            var {method: t, isEncrypted: i, uri: r, format: n, formatversions: a} = e;
            return {
                method: t,
                isEncrypted: i,
                uri: r,
                format: n,
                formatversions: a,
                iv: e.ivBuf ? new Uint8Array(e.ivBuf) : null,
                keyId: e.keyIdBuf ? new Uint8Array(e.keyIdBuf) : null,
                key: e.keyBuf ? new Uint8Array(e.keyBuf) : null,
                pssh: e.psshBuf ? new Uint8Array(e.psshBuf) : null
            }
        }
        function xo(e) {
            return null != (e = null == e ? void 0 : e.mediaOptionKeys.map(e => e.mediaOptionId)) ? e : []
        }
        (i = bo = bo || {}).MustRequestResponse = "MustRequestResponse",
        i.WaitingForKeyResponse = "WaitingForKeyResponse",
        i.GotKeyResponse = "GotKeyResponse";
        class Fo extends $s {
            constructor(e, t, i=[], r) {
                super(Q.KEY_LOAD_TIMEOUT, !1, t, !0, r),
                this.keyuri = e,
                this.response = t,
                this.mediaOptionIds = i
            }
        }
        (r = To = To || {})[r.InvalidState = 0] = "InvalidState",
        r[r.Abort = 1] = "Abort",
        r[r.OutputRestricted = 2] = "OutputRestricted",
        r[r.AlreadyFailedKey = 3] = "AlreadyFailedKey",
        r[r.HttpError = 4] = "HttpError",
        r[r.InternalError = 5] = "InternalError",
        r[r.LicenseServerError = 6] = "LicenseServerError",
        r[r.InsufficientCPC = 7] = "InsufficientCPC";
        class Bo extends $s {
            constructor(e, t, i, r, n=!1, a=[], s) {
                super(Q.KEY_LOAD_ERROR, n, t, !1, s),
                this.keyuri = e,
                this.isOkToRetry = i,
                this.keyErrorReason = r,
                this.mediaOptionIds = a
            }
        }
        class Uo extends b {
            constructor(e, t, i, r, n) {
                super(he.OTHER_ERROR, Q.KEY_SYSTEM_GENERIC_ERROR, r, t, n),
                this.keyuri = e,
                this.response = t,
                this.keysystemstring = i,
                this.fatal = r
            }
        }
        function _o(e, t) {
            return e instanceof Bo ? new Bo(e.keyuri,e.response,e.isOkToRetry,e.keyErrorReason,e.fatal,t,e.message) : e instanceof Fo ? new Fo(e.keyuri,e.response,t,e.message) : e ? new j(e.fatal,H.ExceptionInKeyRequest,e.message,e.stack) : void 0
        }
        const Vo = {
            id: "fairplaystreaming",
            systemStringPrefix: "com.apple.fps",
            keyFormatString: "com.apple.streamingkeydelivery",
            securityLevels: {
                AppleBaseline: 0,
                AppleMain: 1,
                Main: 1,
                Baseline: 0
            }
        }
          , Qo = {
            id: "playready",
            systemStringPrefix: "com.microsoft.playready",
            keyFormatString: "com.microsoft.playready",
            securityLevels: {
                SL2000: 0,
                SL3000: 1
            }
        }
          , Ko = {
            id: "widevine",
            systemStringPrefix: "com.widevine.alpha",
            keyFormatString: "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",
            securityLevels: {
                WIDEVINE_SOFTWARE: 0,
                WIDEVINE_HARDWARE: 1
            }
        };
        function Ho(e) {
            return e.replace(/\+/g, "-").replace(/\//g, "_").replace(/\=+$/, "")
        }
        class jo {
            static strToBase64Encode(e) {
                return btoa(e)
            }
            static base64DecodeToStr(e) {
                return atob(e)
            }
            static base64Encode(e) {
                return btoa(String.fromCharCode(...e))
            }
            static base64UrlEncode(e) {
                return Ho(jo.base64Encode(e))
            }
            static base64Decode(e) {
                return Uint8Array.from(atob(e), e => e.charCodeAt(0))
            }
        }
        class qo {
            static strToBase64Encode(e) {
                return l.Buffer.from(e).toString("base64")
            }
            static base64DecodeToStr(e) {
                return l.Buffer.from(e, "base64").toString()
            }
            static base64Encode(e) {
                return l.Buffer.from(e).toString("base64")
            }
            static base64UrlEncode(e) {
                return Ho(qo.base64Encode(e))
            }
            static base64Decode(e) {
                e = l.Buffer.from(e, "base64");
                return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)
            }
        }
        var Go, $o, Wo, zo, Xo = void 0 !== l.Buffer ? qo : jo;
        const Yo = {
            avc1: "video/mp4",
            avc3: "video/mp4",
            dvav: "video/mp4",
            dva1: "video/mp4",
            hev1: "video/mp4",
            hvc1: "video/mp4",
            dvh1: "video/mp4",
            dvhe: "video/mp4"
        }
          , Jo = {
            mp4a: "audio/mp4",
            "ac-3": "audio/mp4",
            "ec-3": "audio/mp4"
        };
        function Zo(e) {
            function t(e, t, i) {
                var r = e[t];
                e[t] = e[i],
                e[i] = r
            }
            t(e, 0, 3),
            t(e, 1, 2),
            t(e, 4, 5),
            t(e, 6, 7)
        }
        function el(e) {
            const t = e.split(":");
            let i = null;
            if ("data" === t[0] && 2 === t.length) {
                const e = t[1].split(";")
                  , a = e[e.length - 1].split(",");
                if (2 === a.length) {
                    const t = "base64" === a[0]
                      , s = a[1];
                    i = t ? (e.splice(-1, 1),
                    Xo.base64Decode(s)) : (r = s,
                    r = Ee.strToUtf8array(r).subarray(0, 16),
                    (n = new Uint8Array(16)).set(r, 16 - r.length),
                    n)
                }
            }
            var r, n;
            return i
        }
        const tl = function(e, t) {
            const r = {
                videoCapabilities: [],
                audioCapabilities: []
            };
            return e && e.forEach(e => {
                var t, i = e.split(".")[0].trim();
                i in Yo && null != (t = r.videoCapabilities) && t.push({
                    contentType: Yo[i] + ";codecs=" + e,
                    robustness: ""
                })
            }
            ),
            t && t.forEach(e => {
                var t, i = e.split(".")[0].trim();
                i in Jo && null != (t = r.audioCapabilities) && t.push({
                    contentType: Jo[i] + ";codecs=" + e,
                    robustness: ""
                })
            }
            ),
            r
        };
        let il = {};
        class rl {
            constructor(e, t="", i=null, r=null, n=[]) {
                if (this.method = e,
                this.uri = t,
                this.iv = i,
                this.format = r,
                this.formatversions = n,
                this.key = null,
                this.keyId = null,
                this.pssh = null,
                this.isEncrypted = this.method && "NONE" !== this.method,
                this.formatversions && 0 !== this.formatversions.length || (this.formatversions = [1]),
                this.isEncrypted) {
                    var a = el(this.uri);
                    if (a)
                        switch (r) {
                        case Qo.keyFormatString:
                            {
                                this.format = Qo.keyFormatString,
                                this.pssh = a;
                                const e = new Uint16Array(a.buffer,a.byteOffset,a.byteLength / 2)
                                  , t = String.fromCharCode.apply(null, Array.from(e))
                                  , i = t.substring(t.indexOf("<"), t.length)
                                  , r = (new DOMParser).parseFromString(i, "text/xml").getElementsByTagName("KID")[0];
                                if (r) {
                                    var s;
                                    if (s = r.childNodes[0] ? r.childNodes[0].nodeValue : r.getAttribute("VALUE")) {
                                        const t = Xo.base64Decode(s).subarray(0, 16);
                                        Zo(t),
                                        this.keyId = t
                                    }
                                }
                                break
                            }
                        case Ko.keyFormatString:
                            this.format = Ko.keyFormatString,
                            22 <= (this.pssh = a).length && (this.keyId = a.subarray(a.length - 22, a.length - 6));
                            break;
                        case Vo.keyFormatString:
                            this.format = Vo.keyFormatString;
                        default:
                            {
                                let e = a.subarray(0, 16);
                                if (16 !== e.length) {
                                    const t = new Uint8Array(16);
                                    t.set(e, 16 - e.length),
                                    e = t
                                }
                                this.keyId = e;
                                break
                            }
                        }
                    if (!this.keyId || 16 !== this.keyId.byteLength) {
                        let e = il[this.uri];
                        if (!e) {
                            const t = Object.keys(il).length % Number.MAX_SAFE_INTEGER;
                            e = new Uint8Array(16),
                            new DataView(e.buffer,12,4).setUint32(0, t),
                            il[this.uri] = e
                        }
                        this.keyId = e
                    }
                }
            }
            get keyTagInfo() {
                var {method: e, isEncrypted: t, uri: i, iv: r, keyId: n, key: a, format: s, formatversions: o, pssh: l} = this;
                return {
                    method: e,
                    isEncrypted: t,
                    uri: i,
                    iv: r,
                    keyId: n,
                    key: a,
                    format: s,
                    formatversions: o,
                    pssh: l
                }
            }
            static clearKeyUriToKeyIdMap() {
                il = {}
            }
        }
        const ue = Y(void 0)
          , nl = Y(null);
        function ce(e, t, i=1) {
            return e.pipe(Z(t), tn(i))
        }
        const al = ["clearkey", "fairplaystreaming", "playready", "widevine"];
        (i = Go = Go || {}).NONE = "NONE",
        i.GET_REQUEST_INFO = "GET_REQUEST_INFO",
        i.GET_CHALLENGE = "GET_CHALLENGE",
        i.GET_KEY_RESPONSE = "GET_KEY_RESPONSE",
        i.PROCESS_LICENSE = "PROCESS_LICENSE";
        class o {
        }
        o.PlayEnded = 6101,
        o.Periodic = 6110,
        o.PlayStalled = 6103,
        o.KeySessionComplete = 6104,
        o.PlayLikelyToKeepUp = 6105,
        o.PlayRateChanged = 6106,
        o.PlayError = 6107,
        o.MediaEngineStalled = 6108,
        o.SwitchComplete = 6109,
        o.VariantEnded = 6111,
        o.SeekComplete = 6112,
        o.InterstitialStarted = 6121,
        o.InterstitialAssetStarted = 6122,
        o.InterstitialAssetEnded = 6123,
        o.InterstitialEnded = 6124,
        o.NwError = 6202,
        o.DebugInfo = 6203,
        o.ErrorRecovery = 6204,
        (r = $o = $o || {})[r.RequestMediaKeySystemAccess = 0] = "RequestMediaKeySystemAccess",
        r[r.CreateMediaKeys = 1] = "CreateMediaKeys",
        r[r.SetMediaKeys = 2] = "SetMediaKeys",
        r[r.SetServerCertificate = 3] = "SetServerCertificate",
        r[r.CreateSession = 4] = "CreateSession",
        r[r.GenerateRequest = 5] = "GenerateRequest",
        r[r.Update = 6] = "Update";
        const sl = {
            avc1: 1,
            avc3: 1,
            hvc1: {
                SDR: 2,
                HLG: 10,
                PQ: 11
            },
            hev1: {
                SDR: 2,
                HLG: 10,
                PQ: 11
            },
            vp09: {
                SDR: 3,
                HLG: 14,
                PQ: 13
            },
            av01: {
                SDR: 4,
                HLG: 15,
                PQ: 16
            },
            dvh1: {
                PQ: 12
            }
        };
        class ol extends e {
            trigger(e, t) {
                try {
                    this.emit(e, e, t),
                    "hlsFragLoadProgress" !== e.toString() && (("hlsInternalError" === e || "hlsError" === e) && t && t.length && JSON.stringify(t[0], ["fatal", "details", "reason"]),
                    e.toString())
                } catch (e) {}
            }
        }
        class ll {
            constructor(e, t) {
                this.target = e,
                this._this = t
            }
            eventWithOptions(e, t, i, r=this._this) {
                let n;
                return n = t ? da(this.target, e, t) : da(this.target, e),
                this.target instanceof ol && (n = n.pipe(W( ([,e]) => e))),
                i && (r && (i = i.bind(r)),
                n = n.pipe(ie(i))),
                n
            }
            event(e, t, i=this._this) {
                return this.eventWithOptions(e, void 0, t, i)
            }
            listen(e, t, i, r=this._this) {
                return this.event(e, i, r).pipe(Pn(t)).subscribe()
            }
        }
        function dl(e, t) {
            return new ll(e,t)
        }
        function ul(e, t, i) {
            var r;
            return {
                currentTarget: null != (r = null == i ? void 0 : i.currentTarget) ? r : e,
                target: null != (r = null == i ? void 0 : i.target) ? r : e,
                type: t
            }
        }
        class cl {
            constructor(e, t, i, r) {
                this.session = e,
                this.onkeystatuseschange = t,
                this.onkeymessage = i,
                this.R = r,
                this.de = new pn(!1),
                this.fe = new pn(!1);
                e = dl(this.session);
                e.listen("keystatuseschange", this.de.pipe(Z(e => !0 === e)), this.onkeystatuseschange),
                e.listen("message", this.fe.pipe(Z(e => !0 === e)), this.onkeymessage)
            }
            get isClosing() {
                return this.de.value
            }
            get isClosed() {
                return this.fe.value
            }
            destroy() {
                this.de.next(!0);
                const e = this.session;
                return Lr(e.remove().catch(e => {}
                ).then( () => e.close()).catch(e => {}
                )).pipe(ie( () => {
                    this.de.next(!1),
                    this.fe.next(!0)
                }
                ), ee( () => {
                    this.de.next(!1),
                    this.fe.next(!0)
                }
                ))
            }
        }
        class hl {
            constructor(e, t=null) {
                this.decryptdata = e,
                this.ve = new pn(Go.NONE),
                this.destroy$ = new z,
                this.pe = null,
                this.session = null,
                this.me = !1,
                this.oldSessions = [],
                this.session = t
            }
            get requestState() {
                return this.ve.value
            }
            get onKeyRequestState$() {
                return this.ve
            }
            destroy() {
                this.destroy$.next(),
                this.clearRenewal()
            }
            abort() {
                var e;
                this.requestState !== Go.NONE && (e = new Bo(this.decryptdata.uri,H.KeySystemAbort,!0,To.Abort),
                this.error(e))
            }
            get licenseChallenge() {
                return this.ye
            }
            get shouldReuseSession() {
                return this.me
            }
            cacheChallenge(e, t) {
                this.ye = e,
                this.me = t
            }
            clearChallenge() {
                this.ye = void 0
            }
            clearRenewal() {
                var e;
                null != (e = this.renewal) && e.unsubscribe(),
                this.renewal = void 0
            }
            setKeyRequestState(e) {
                if (e === Go.GET_REQUEST_INFO && this.clearRenewal(),
                this.pe) {
                    const t = new Bo(this.decryptdata.uri,H.KeySystemUnexpectedStateTransition,!0,To.InvalidState,void 0,void 0,`Unexpected state transition ${this.requestState}->` + e);
                    this.error(t)
                }
                this.ve.next(e);
                const t = new mn;
                return e === Go.NONE ? (t.complete(),
                this.pe = null) : this.pe = t,
                t
            }
            resolveState(e, t) {
                if (!this.pe)
                    return !1;
                if (e !== this.requestState) {
                    const t = new Bo(this.decryptdata.uri,H.KeySystemUnexpectedState,!0,To.InvalidState,void 0,void 0,`Unexpected state ${this.requestState} != ` + e);
                    return this.error(t),
                    !1
                }
                if (t instanceof Error)
                    return this.error(t),
                    !1;
                {
                    const e = this.pe;
                    return this.pe = null,
                    e.next(t),
                    e.complete(),
                    !0
                }
            }
            error(e) {
                var t;
                this.pe && (t = this.pe,
                this.pe = null,
                t.error(e)),
                this.clearRenewal(),
                this.setKeyRequestState(Go.NONE)
            }
        }
        function pl(e) {
            return `uri=${f(e.uri)} keyId=` + ut(e.keyId)
        }
        class ml {
            constructor(e, t, i, r, n, a, s, o, l) {
                this.mediaKeys = e,
                this.systemString = t,
                this.config = i,
                this.useSingleKeySession = n,
                this.sessionHandler = a,
                this.customUrlLoader = s,
                this.ksQuery = o,
                this.logger = l,
                this.destroy$ = new z,
                this.ge = !1,
                this.be = new pn(null),
                this.Se = new mn,
                this._keyStatusChange$ = new z,
                this.isDestroying = !1,
                this.shouldDestroyMediaKeys = !i.maintainMediaKeysBetweenSessions,
                this.sessions = [],
                this.keyIdToKeyInfo = {},
                this.keyUriToKeyInfo = {},
                this.sessionIdToKeyUri = {},
                this.eventEmitter = r,
                this.Se.next(!1),
                this.Se.complete(),
                this.we = this.handleKeyStatusesChange.bind(this),
                this.Te = this.handleKeyMessage.bind(this),
                this._signalRenewal = this._signalRenewal.bind(this)
            }
            get keyStatusChange$() {
                return this._keyStatusChange$
            }
            destroy() {
                this.isDestroying = !0,
                this.destroy$.next();
                for (const e of Object.values(this.keyIdToKeyInfo))
                    this._abortKeyRequest(e);
                const e = this.sessions.map(e => e.destroy())
                  , t = ha( () => 0 === e.length, ue, aa(e)).pipe(rn(void 0), ee( () => {
                    this.keyIdToKeyInfo = {},
                    this.keyUriToKeyInfo = {},
                    this.sessionIdToKeyUri = {}
                }
                ));
                return rl.clearKeyUriToKeyIdMap(),
                this.eventEmitter = void 0,
                t
            }
            setServerCertificate(e=new ArrayBuffer(0)) {
                return this.needsCert ? (0 < e.byteLength && this.be.next(e),
                ce(this.be, e => null != e).pipe(Nn(1e4)).pipe(te(e => {
                    if (this.ge)
                        return Y(!0);
                    if (this.Se.isStopped) {
                        if (this.Se = new mn,
                        null === e)
                            return this.Se;
                        const t = performance.now();
                        return Lr(this.mediaKeys.setServerCertificate(e)).pipe(ie(e => {
                            var e = void 0 === e || e;
                            this.ge = e,
                            this.Se.next(e),
                            this.Se.complete(),
                            null != (e = this.sessionHandler) && e.keySystemEvents({
                                eventId: $o.SetServerCertificate,
                                range: {
                                    tbegin: t,
                                    tend: performance.now()
                                }
                            })
                        }
                        ), $(e => (this.ge = !1,
                        this.Se.error(e),
                        ue)), te( () => this.Se))
                    }
                    return this.Se
                }
                ), $(e => {
                    throw new Uo("",H.KeySystemSetServerCertificateError,this.systemString,!1)
                }
                ))) : Y(!0)
            }
            ensureKeyContext(e) {
                var t, i, r, n = e.uri, e = (this.keyUriToKeyInfo[n] || (this.keyUriToKeyInfo[n] = new hl(e)),
                this.keyUriToKeyInfo[n]);
                return e.session || (this.useSingleKeySession && 0 < this.sessions.length ? e.session = this.sessions[0].session : (i = performance.now(),
                (r = this.mediaKeys.createSession()) ? (this.sessions.push(new cl(r,this.we,this.Te,this.logger)),
                null != (t = this.sessionHandler) && t.keySystemEvents({
                    eventId: $o.CreateSession,
                    range: {
                        tbegin: i,
                        tend: performance.now()
                    },
                    keyuri: n,
                    keyRequestState: e.requestState
                })) : (this.logger.error(this.systemString + ` FAIL: could not create MediaKeysSession`),
                null != (t = this.sessionHandler) && t.handleNonFatalError(new Uo("",H.KeySystemCouldNotCreateMediaKeySession,this.systemString,!1), !1)),
                e.session = r)),
                e
            }
            createDummySession() {
                var e = this.mediaKeys.createSession();
                e ? this.sessions.push(new cl(e,this.we,this.Te,this.logger)) : this.logger.error(this.systemString + ` FAIL: could not create MediaKeysSession`)
            }
            startKeyRequest(i) {
                const r = i.uri
                  , n = this.ensureKeyContext(i);
                if (null == n || !n.session)
                    return R( () => new Uo(i.uri,H.KeySystemFailedToCreateSession,this.systemString,!0));
                let e = "";
                return null !== i.keyId && (e = Ee.utf8arrayToStr(i.keyId)),
                this.keyIdToKeyInfo[e] = n,
                aa([this.getKeyRequestInfo(n), this.setServerCertificate()]).pipe(W(e => e[0]), te(e => {
                    var t;
                    return null != (t = this.sessionHandler) && t.licenseChallengeSubmitted({
                        keyuri: r,
                        keyFormat: this.systemString
                    }),
                    this.generateLicenseChallenge(n, e).pipe($(e => {
                        var t;
                        throw this.logger.error(`${this.systemString} generateLicenseChallenge Failed ${e.message} ` + pl(i)),
                        null != (t = this.sessionHandler) && t.licenseChallengeError({
                            keyuri: r
                        }),
                        e
                    }
                    ))
                }
                ), te(e => {
                    var t;
                    if (0 === e.length)
                        throw new Bo(r,H.KeySystemFailedToGenerateLicenseRequest,!0,To.InternalError);
                    return null != (t = this.sessionHandler) && t.licenseChallengeCreated({
                        keyuri: r,
                        cdmVersion: this.cdmVersion
                    }),
                    this.getKeyRequestResponse(n, e)
                }
                ), te(e => {
                    var t;
                    return null != (t = this.sessionHandler) && t.licenseResponseSubmitted({
                        keyuri: r
                    }),
                    n.clearChallenge(),
                    this.handleParsedKeyResponse(n, e).pipe($(e => {
                        var t;
                        throw this.logger.error(`${this.systemString} ParseKeyResponse Failed ${pl(i)} error=` + e.message),
                        null != (t = this.sessionHandler) && t.licenseResponseError({
                            keyuri: r
                        }),
                        e
                    }
                    ))
                }
                ), W( () => {
                    var e;
                    return null != (e = this.sessionHandler) && e.licenseResponseProcessed({
                        keyuri: r
                    }),
                    n.setKeyRequestState(Go.NONE),
                    this.removeSessions(n.decryptdata, !1).subscribe(),
                    i
                }
                ), $(e => {
                    throw this.handleKeyExchangeError(n, e),
                    e
                }
                ), ee( () => {
                    this._abortKeyRequest(n)
                }
                ))
            }
            _abortKeyRequest(e) {
                var t, i;
                e && (i = e.decryptdata.uri,
                e.decryptdata.keyId && Ee.utf8arrayToStr(e.decryptdata.keyId),
                e.requestState !== Go.NONE && null != (t = this.sessionHandler) && t.keyAborted({
                    keyuri: i
                }),
                e.abort())
            }
            handleKeyExchangeError(e, t) {
                e.error(t),
                e.decryptdata.keyId && Ee.utf8arrayToStr(e.decryptdata.keyId)
            }
            removeKey(e) {
                return this.removeKeyInternal(e)
            }
            removeKeyInternal(t) {
                var i = this.keyUriToKeyInfo[t.uri];
                if (i && i.session) {
                    var r = i.session;
                    i.abort(),
                    i.destroy();
                    let e = "";
                    return i.decryptdata.keyId && (e = Ee.utf8arrayToStr(i.decryptdata.keyId)),
                    delete this.keyIdToKeyInfo[e],
                    delete this.keyUriToKeyInfo[t.uri],
                    this.removeSession(r)
                }
                return ue
            }
            removeSessions(e, t) {
                var i = this.keyUriToKeyInfo[e.uri];
                if (i) {
                    const r = i.oldSessions.map(e => this.removeSession(e));
                    return i.oldSessions = [],
                    ha( () => 0 === r.length, ue, aa(r)).pipe(te( () => t ? this.removeKeyInternal(e) : ue))
                }
                return ue
            }
            removeSession(t) {
                var e = this.sessions.findIndex(e => e.session === t)
                  , i = this.sessions[e];
                return -1 < e && this.sessions.splice(e, 1),
                delete this.sessionIdToKeyUri[t.sessionId],
                i ? i.destroy() : ue
            }
            getKeyRequestInfo(e) {
                var t, i = e.decryptdata, r = i.uri, e = e.setKeyRequestState(Go.GET_REQUEST_INFO);
                return null != (t = this.eventEmitter) && t.trigger(L.KEY_REQUEST_STARTED, {
                    keyuri: r,
                    appItemIds: this.ksQuery.getAppItemIds(r),
                    decryptdata: i,
                    timestamp: Date.now()
                }),
                e
            }
            setKeyRequestInfo(e, t) {
                e = this.keyUriToKeyInfo[e];
                return !!e && e.resolveState(Go.GET_REQUEST_INFO, t)
            }
            sanitizeRequest(e) {
                return e
            }
            generateLicenseChallengeInternal(t, e, i) {
                const r = t.decryptdata
                  , n = t.session
                  , a = r.uri
                  , s = r.keyId;
                let o;
                if (null === n)
                    return this.logger.error("key session is null, this should not happen"),
                    R( () => new Uo(a,H.KeySystemInternalError,r.format,!0));
                const l = t.setKeyRequestState(Go.GET_CHALLENGE);
                if (n.generateRequestPromise)
                    o = kr(n.generateRequestPromise, Zn).pipe(te( () => this.generateRequestInitialized(t, "usable" === i)));
                else {
                    const i = this.generateInitData(null !== s ? s : new Uint8Array, r, e)
                      , l = performance.now();
                    n.generateRequestPromise = n.generateRequest(i.initDataType, null !== i.initData ? i.initData : new Uint8Array),
                    o = kr(n.generateRequestPromise, Zn).pipe(ie( () => {
                        var e;
                        this.sessionIdToKeyUri[n.sessionId] = a,
                        null != (e = this.sessionHandler) && e.keySystemEvents({
                            eventId: $o.GenerateRequest,
                            range: {
                                tbegin: l,
                                tend: performance.now()
                            },
                            keyuri: r.uri,
                            keyRequestState: t.requestState
                        })
                    }
                    ), $(e => {
                        throw new Uo(t.decryptdata.uri,H.KeySystemFailedToGenerateLicenseRequest,this.systemString,!0,e.message)
                    }
                    ))
                }
                return aa([l, o]).pipe(W(e => new Uint8Array(e[0])))
            }
            generateLicenseChallenge(e, t) {
                const i = e.decryptdata
                  , r = e.session
                  , n = i.uri
                  , a = i.keyId;
                if (null === r)
                    return this.logger.error("key session is null, this should not happen"),
                    R( () => new Uo(n,H.KeySystemInternalError,i.format,!0));
                let s, o;
                if (Ee.utf8arrayToStr(a),
                e.licenseChallenge && e.resolveState(Go.GET_CHALLENGE, e.licenseChallenge),
                t = this.sanitizeRequest(t),
                e.requestInfo = t,
                this.systemString === Qo.systemStringPrefix) {
                    const e = new Uint8Array(a);
                    Zo(e),
                    s = r.keyStatuses.get(e)
                } else
                    s = r.keyStatuses.get(null !== a ? a : new Uint8Array);
                switch (s) {
                case "status-pending":
                case "usable":
                case "expired":
                case void 0:
                    o = this.generateLicenseChallengeInternal(e, t, s);
                    break;
                default:
                    o = R( () => new Uo(n,H.KeySystemUnexpectedState,this.systemString,!0,`state=` + s))
                }
                return o
            }
            setParsedResponse(e, t) {
                e = this.keyUriToKeyInfo[e];
                e && e.resolveState(Go.GET_KEY_RESPONSE, t)
            }
            handleKeyStatusesChange(e) {
                e.target.keyStatuses.forEach( (e, t, i) => {
                    t = new Uint8Array(t),
                    this.systemString === Qo.systemStringPrefix && Zo(t),
                    t = Ee.utf8arrayToStr(t),
                    t = this.keyIdToKeyInfo[t];
                    t && this.handleKeyStatusForKey(e, t)
                }
                )
            }
            handleKeyStatusForKey(e, t) {
                if (t) {
                    var i = t.decryptdata
                      , r = i.uri;
                    switch (e) {
                    case "internal-error":
                        this.logger.error(this.systemString + ` internal-error for key ` + pl(i)),
                        this._signalError(t, new Bo(r,H.KeySystemInternalError,!1,To.InternalError));
                        break;
                    case "usable":
                        t.requestState === Go.PROCESS_LICENSE && t.resolveState(Go.PROCESS_LICENSE, void 0);
                        break;
                    case "output-restricted":
                        t.session && this.removeSession(t.session).pipe(Pn(this.destroy$)).subscribe(),
                        this._signalError(t, new Bo(r,H.KeySystemOutputRestricted,!1,To.OutputRestricted));
                        break;
                    case "expired":
                        this._signalRenewal(t)
                    }
                }
            }
            _scheduleRenewal(e, t) {
                if (!isFinite(t) || t <= 0)
                    return this._signalRenewal(e);
                var i, r;
                e.clearRenewal(),
                e.renewal = Y(e).pipe((r = yr(t, i = void 0 === i ? sr : i),
                nn(function() {
                    return r
                })), ie(this._signalRenewal), Pn(this.destroy$)).subscribe()
            }
            _signalRenewal(e) {
                e.clearRenewal(),
                this._keyStatusChange$.next({
                    decryptdata: e.decryptdata,
                    status: "needs-renewal"
                })
            }
            _signalError(e, t) {
                this._keyStatusChange$.next({
                    decryptdata: e.decryptdata,
                    status: "error",
                    error: t
                }),
                e.error(t)
            }
        }
        const fl = "org.w3.clearkey"
          , gl = {
            id: "clearkey",
            systemStringPrefix: fl,
            keyFormatString: fl,
            securityLevels: {
                NONE: 0
            }
        }
          , yl = {
            initDataTypes: ["keyids", "cenc"]
        }
          , vl = {
            initDataTypes: ["cenc"]
        }
          , Sl = new Uint8Array([148, 206, 134, 251, 7, 255, 79, 67, 173, 184, 147, 210, 250, 150, 140, 162]);
        (i = Wo = Wo || {})[i.CENC = 1667591779] = "CENC",
        i[i.CBCS = 1667392371] = "CBCS",
        zo = zo || {},
        zo[zo.ISOFFLINE = 2] = "ISOFFLINE";
        class Il extends ml {
            constructor(e, t, i, r, n, a, s, o, l) {
                super(e, t, i, r, n, a, s, o, l),
                this._hasSetRenewal = !1
            }
            static get systemId() {
                return Sl
            }
            static get requestAccessConfig() {
                return vl
            }
            get needsCert() {
                return !0
            }
            sanitizeRequest(e) {
                return {
                    assetId: e && e.assetId ? new Uint8Array(e.assetId) : void 0,
                    ssc: e && e.ssc ? new Uint8Array(e.ssc) : void 0,
                    sessionId: e && e.sessionId ? e.sessionId : void 0,
                    isOffline: !(!e || !e.isOffline)
                }
            }
            _scheduleRenewal(e, t) {
                this.useSingleKeySession ? this._hasSetRenewal || (this._hasSetRenewal = !0,
                yr(t).pipe(ie( () => {
                    var e = Object.values(this.keyUriToKeyInfo)[0];
                    e && this._signalRenewal(e)
                }
                ), ee( () => {
                    this._hasSetRenewal = !1
                }
                ), Pn(this.destroy$)).subscribe()) : super._scheduleRenewal(e, t)
            }
            handleParsedKeyResponse(t, e) {
                const i = t.decryptdata.uri
                  , r = e.statusCode
                  , n = e.ckc && 0 !== e.ckc.byteLength ? e.ckc : e.license && 0 !== e.license.byteLength ? e.license : void 0;
                if (0 === r && !n)
                    return R(new Bo(i,r,!0,To.HttpError));
                if (0 !== r)
                    return R(new Bo(i,void 0 === r ? 0 : r,!1,To.LicenseServerError));
                if (!n)
                    return R(new Bo(i,r,!1,To.LicenseServerError));
                var e = e.renewalDate
                  , a = new Date
                  , e = void 0 !== e && a < e ? e.getTime() - a.getTime() : 0;
                0 < e && e < Math.pow(2, 31) && this._scheduleRenewal(t, e);
                const s = this.makeProcessLicenseRequestMessage(t, n, e)
                  , o = t.session;
                if (null === o)
                    return this.logger.error("Key session is null"),
                    R( () => new Uo(i,H.InternalError,this.systemString,!0));
                const l = performance.now()
                  , d = Lr(o.update(s)).pipe(ie( () => {
                    var e = t.decryptdata.keyId
                      , e = o.keyStatuses.get(e);
                    this.handleKeyStatusForKey(e, t),
                    null != (e = this.sessionHandler) && e.keySystemEvents({
                        eventId: $o.Update,
                        range: {
                            tbegin: l,
                            tend: performance.now()
                        },
                        keyuri: t.decryptdata.uri,
                        keyRequestState: t.requestState
                    })
                }
                ), $(e => {
                    throw new Uo(t.decryptdata.uri,H.KeySystemFailedToUpdateSession,this.systemString,!0,e.message)
                }
                ));
                return aa([t.setKeyRequestState(Go.PROCESS_LICENSE), d]).pipe(rn(void 0))
            }
            makeKeyRequests(e) {
                var t = [];
                for (const i of e) {
                    const e = i.decryptdata
                      , r = i.requestInfo
                      , n = e.keyId;
                    t.push({
                        keyId: n || new Uint8Array,
                        assetId: r && r.assetId ? r.assetId : new Uint8Array,
                        ssc: r && r.ssc ? r.ssc : new Uint8Array,
                        versionList: e.formatversions || []
                    })
                }
                return t
            }
            getSchemeAndFlags(e, t) {
                e = "ISO-23001-7" === e.method ? Wo.CENC : Wo.CBCS;
                let i = 0;
                return t && (i |= zo.ISOFFLINE),
                {
                    scheme: e,
                    flags: i
                }
            }
            generateInitData(e, t, i) {
                var {scheme: r, flags: n} = this.getSchemeAndFlags(t, i.isOffline)
                  , t = this.makeKeyRequests([{
                    decryptdata: t,
                    requestInfo: i
                }]);
                return {
                    initData: this.makeFpsKeySystemInitData(r, n, t),
                    initDataType: "cenc"
                }
            }
            generateRequestInitialized(t, e) {
                var e = this.makeKeyRequestMessage(t, e)
                  , i = t.session;
                if (null === i)
                    return this.logger.error("Key is session is null"),
                    X;
                const r = performance.now();
                return Lr(i.update(e)).pipe(ie( () => {
                    var e;
                    t.requestInfo = void 0,
                    null != (e = this.sessionHandler) && e.keySystemEvents({
                        eventId: $o.Update,
                        range: {
                            tbegin: r,
                            tend: performance.now()
                        },
                        keyuri: t.decryptdata.uri,
                        keyRequestState: t.requestState
                    })
                }
                ), $(e => {
                    throw new Uo(t.decryptdata.uri,H.KeySystemFailedToGenerateLicenseRenewal,this.systemString,!0,e.message)
                }
                ))
            }
            getKeyRequestResponse(e, t) {
                var i, r = e.decryptdata.uri, e = e.setKeyRequestState(Go.GET_KEY_RESPONSE);
                return null != (i = this.eventEmitter) && i.trigger(L.LICENSE_CHALLENGE_CREATED, {
                    keyuri: r,
                    licenseChallenge: t,
                    keysystem: this.systemString,
                    appItemIds: this.ksQuery.getAppItemIds(r)
                }),
                e
            }
            resolveSPCPromise(e, t) {
                e.resolveState(Go.GET_CHALLENGE, t)
            }
        }
        const bl = 1919710053;
        function Tl(e, t, i) {
            if (!(i + 4 > e.byteLength)) {
                t = t.getUint32(i);
                if (!((i += 4) + t > e.byteLength))
                    return e = e.slice(i, i + t),
                    {
                        pos: i += t,
                        data: e
                    }
            }
        }
        function El(t) {
            var i = {}
              , r = new DataView(t.buffer);
            let n = 4;
            const a = r.getUint32(n);
            n += 4;
            for (let e = 0; e < a && n < t.byteLength && !(n + 16 > t.byteLength); ++e) {
                const a = t.slice(n, n + 16);
                if ((n += 16) + 4 > t.byteLength)
                    break;
                var s = Tl(t, r, n);
                if (!s)
                    break;
                n = s.pos,
                i[Ee.utf8arrayToStr(a)] = s.data
            }
            return i
        }
        function Al(e, t, i, r) {
            var n = r ? r.byteLength : 0;
            return t.setUint32(i, n),
            n && e.set(r, i + 4),
            i + (4 + n)
        }
        function Ol(e) {
            let t = 4;
            for (const i of e)
                t += 28 + (i.assetId ? i.assetId.byteLength : 0) + (i.ssc ? i.ssc.byteLength : 0) + (i.versionList ? 4 * i.versionList.length : 0);
            return t
        }
        function Rl(e, t, i, r) {
            t.setUint32(i, r.length),
            i += 4;
            for (const n of r)
                if (e.set(n.keyId, i),
                i = Al(e, t, i += 16, n.assetId),
                i = Al(e, t, i, n.ssc),
                t.setUint32(i, n.versionList ? n.versionList.length : 0),
                i += 4,
                n.versionList)
                    for (const e of n.versionList)
                        t.setUint32(i, e),
                        i += 4;
            return i
        }
        class wl extends Il {
            constructor(e, t, i, r, n, a, s, o) {
                super(e, t, i, r, void 0 === i.useMultipleKeySessions || !i.useMultipleKeySessions, n, a, s, o),
                this.Ie = !1,
                i.createDummySessionOnStart && this.createDummySession()
            }
            makeProcessLicenseRequestMessage(i, r, n) {
                r = new Uint8Array(r);
                {
                    i = [{
                        keyId: i.decryptdata.keyId || new Uint8Array,
                        expirySec: n / 1e3,
                        ckc: r
                    }];
                    var a = this.Ie;
                    let e = 0;
                    for (const a of i)
                        e += 24 + a.ckc.byteLength;
                    let t = 0;
                    var s = new Uint8Array(8 + e)
                      , o = new DataView(s.buffer);
                    a ? o.setUint32(0, 1868786531) : o.setUint32(0, 1667982195),
                    o.setUint32(4, i.length),
                    t += 8;
                    for (const a of i)
                        s.set(a.keyId, t),
                        t += 16,
                        o.setUint32(t, a.expirySec),
                        t += 4,
                        t = Al(s, o, t, a.ckc);
                    return s
                }
            }
            makeFpsKeySystemInitData(e, t, i) {
                this.Oe(t) && (this.Ie = !0);
                e = e,
                t = t,
                r = Ol(i = i),
                n = 0,
                r = new Uint8Array(8 + r),
                (a = new DataView(r.buffer)).setUint32(n, e),
                a.setUint32(n + 4, 1 << 24 | 16777215 & t),
                Rl(r, a, n += 8, i);
                var r, n, a, e = r;
                return y.pssh(wl.systemId, [], e)
            }
            Oe(e) {
                return (e & zo.ISOFFLINE) === zo.ISOFFLINE
            }
            makeKeyRequestMessage(e) {
                var t, i, r, n;
                return null != (t = e.requestInfo) && t.isOffline && (this.Ie = !0),
                t = [{
                    keyId: null != (t = null == (t = null == e ? void 0 : e.decryptdata) ? void 0 : t.keyId) ? t : new Uint8Array,
                    assetId: null != (t = null == (t = null == e ? void 0 : e.requestInfo) ? void 0 : t.assetId) ? t : new Uint8Array,
                    ssc: null != (t = null == (t = null == e ? void 0 : e.requestInfo) ? void 0 : t.ssc) ? t : new Uint8Array,
                    versionList: null != (e = null == (t = null == e ? void 0 : e.decryptdata) ? void 0 : t.formatversions) ? e : []
                }],
                e = this.Ie,
                i = Ol(t),
                r = 0,
                i = new Uint8Array(4 + i),
                n = new DataView(i.buffer),
                e ? n.setUint32(0, 1868788331) : n.setUint32(0, 1668442994),
                Rl(i, n, r += 4, t),
                i
            }
            handleKeyMessage(e) {
                var t;
                if (!(e.message.byteLength < 4)) {
                    const i = new Uint8Array(e.message)
                      , r = new DataView(e.message)
                      , n = r.getUint32(0);
                    if (!this.isDestroying || n === bl)
                        switch (n) {
                        case 1667592820:
                            break;
                        case 1919837559:
                            {
                                const e = El(i);
                                for (const t in e)
                                    if (Object.prototype.hasOwnProperty.call(e, t)) {
                                        const e = this.keyIdToKeyInfo[t];
                                        e && this._signalRenewal(e)
                                    }
                                break
                            }
                        case 1936745331:
                            {
                                const e = El(i);
                                for (const t in e)
                                    if (Object.prototype.hasOwnProperty.call(e, t)) {
                                        const i = this.keyIdToKeyInfo[t]
                                          , r = e[t];
                                        i && r && this.resolveSPCPromise(i, r)
                                    }
                                break
                            }
                        case bl:
                            this._handleLicenseRelease(i);
                            break;
                        case 1667525993:
                            {
                                const e = Tl(i, r, 4);
                                e && (this.cdmVersion = Ee.utf8arrayToStr(e.data));
                                break
                            }
                        case 1869767536:
                            {
                                const e = Tl(i, r, 4);
                                if (e) {
                                    const i = e.data;
                                    null != (t = this.eventEmitter) && t.trigger(L.OFFLINE_FAIRPLAY_DEVICE_CAPS, {
                                        capability: i
                                    })
                                }
                                break
                            }
                        }
                }
            }
            _handleLicenseRelease(e) {
                new DataView(e.buffer).getUint32(4),
                null != (e = this.eventEmitter) && e.trigger(L.LICENSE_RELEASED, {
                    keysystem: this.systemString,
                    itemId: "",
                    releaseRecord: {}
                })
            }
        }
        r = wl;
        const Pl = {
            fpsd: Ee.strToUtf8array("fpsd"),
            fpsi: Ee.strToUtf8array("fpsi"),
            fpsk: Ee.strToUtf8array("fpsk"),
            fkri: Ee.strToUtf8array("fkri"),
            fkai: Ee.strToUtf8array("fkai"),
            fkcx: Ee.strToUtf8array("fkcx"),
            fkvl: Ee.strToUtf8array("fkvl")
        };
        const Ml = {
            initDataTypes: ["cenc"]
        }
          , Cl = new Uint8Array([154, 4, 240, 121, 152, 64, 66, 134, 171, 146, 230, 91, 224, 136, 95, 149]);
        class kl extends ml {
            constructor(e, t, i, r, n, a, s, o) {
                super(e, t, i, r, !1, n, a, s, o),
                this.shouldDestroyMediaKeys = !0
            }
            static get systemId() {
                return Cl
            }
            static get requestAccessConfig() {
                return Ml
            }
            get needsCert() {
                return !1
            }
            generateInitData(e, t) {
                t = t.pssh;
                return {
                    initData: y.pssh(kl.systemId, [], t),
                    initDataType: "cenc"
                }
            }
            removeKey(e) {
                return super.removeSessions(e, !0)
            }
            ensureKeyContext(e) {
                var t = e.uri
                  , t = this.keyUriToKeyInfo[t];
                return null != t && t.session && (t.oldSessions.push(t.session),
                t.session = null),
                super.ensureKeyContext(e)
            }
            getKeyRequestResponse(e, t) {
                var i, r = e.decryptdata.uri, n = e.setKeyRequestState(Go.GET_KEY_RESPONSE);
                return null != (i = this.eventEmitter) && i.trigger(L.LICENSE_CHALLENGE_CREATED, {
                    keyuri: r,
                    licenseChallenge: t,
                    keysystem: this.systemString,
                    keyId: null !== e.decryptdata.keyId ? e.decryptdata.keyId : new Uint8Array,
                    appItemIds: this.ksQuery.getAppItemIds(r)
                }),
                n
            }
            generateRequestInitialized(e) {
                var t = e.licenseChallenge;
                return e.requestInfo = void 0,
                e.resolveState(Go.GET_CHALLENGE, void 0 !== t ? t : new j(!1,H.KeySystemUndefinedChallenge)),
                ue
            }
            handleParsedKeyResponse(t, e) {
                const i = t.decryptdata.uri
                  , r = e.statusCode;
                if (0 !== r)
                    return re(r) ? R(new Bo(i,r,!1,To.LicenseServerError)) : R(new Bo(i,H.KeySystemInternalError,!1,To.LicenseServerError));
                if (!e.license || !e.license.byteLength)
                    return R(new Bo(i,r,!1,To.LicenseServerError));
                if (e.renewalDate) {
                    const i = e.renewalDate
                      , r = new Date
                      , n = i > r ? i.getTime() - r.getTime() : 0;
                    0 < n && n < Math.pow(2, 31) && this._scheduleRenewal(t, n)
                }
                const n = t.setKeyRequestState(Go.PROCESS_LICENSE)
                  , a = t.session;
                if (null === a)
                    return this.logger.error("key session is null, this should not happen"),
                    ue;
                const s = performance.now()
                  , o = Lr(a.update(e.license)).pipe(ie( () => {
                    var e;
                    t.resolveState(Go.PROCESS_LICENSE, void 0),
                    null != (e = this.sessionHandler) && e.keySystemEvents({
                        eventId: $o.Update,
                        range: {
                            tbegin: s,
                            tend: performance.now()
                        },
                        keyuri: t.decryptdata.uri,
                        keyRequestState: t.requestState
                    })
                }
                ), $(e => {
                    throw this.logger.error(this.systemString + ` FAIL: Failed to update with key response message=` + e.message),
                    new Uo(t.decryptdata.uri,H.KeySystemFailedToUpdateSession,this.systemString,!0,e.message)
                }
                ));
                return aa([n, o]).pipe(rn(void 0))
            }
            handleKeyMessage(e) {
                var t, i, r;
                this.isDestroying || (r = new DOMParser,
                e = new ("utf16" === this.config.playReadyMessageFormat ? Uint16Array : Uint8Array)(e.message.buffer || e.message),
                e = String.fromCharCode.apply(null, Array.from(e)),
                (i = r.parseFromString(e, "application/xml").getElementsByTagName("PlayReadyKeyMessage")[0]) && "LicenseAcquisition" === i.getAttribute("type") && (i = r.parseFromString(e, "application/xml").getElementsByTagName("Challenge")[0]) && "base64encoded" === i.getAttribute("encoding") && 0 !== i.childNodes.length && (e = Xo.base64Decode(null !== i.childNodes[0].nodeValue ? i.childNodes[0].nodeValue : ""),
                i = Ee.utf8arrayToStr(e),
                t = null,
                t = (r = r.parseFromString(i, "application/xml").getElementsByTagName("KID")[0]).childNodes[0] ? r.childNodes[0].nodeValue : r.getAttribute("VALUE"),
                i = Xo.base64Decode(null !== t ? t : "").subarray(0, 16),
                Zo(i),
                r = this.keyIdToKeyInfo[Ee.utf8arrayToStr(i)]) && (r.cacheChallenge(e, !1),
                r.resolveState(Go.GET_CHALLENGE, e)))
            }
        }
        e = kl;
        const Ll = {
            initDataTypes: ["cenc", "keyids"]
        }
          , Nl = new Uint8Array([237, 239, 139, 169, 121, 214, 74, 206, 163, 200, 39, 220, 213, 29, 33, 237])
          , Dl = {
            clearkey: gl,
            fairplaystreaming: Vo,
            playready: Qo,
            widevine: Ko
        }
          , xl = {
            clearkey: [["org.w3.clearkey", class extends ml {
                constructor(e, t, i, r, n, a, s, o) {
                    super(e, t, i, r, !1, n, a, s, o)
                }
                static get requestAccessConfig() {
                    return yl
                }
                get needsCert() {
                    return !1
                }
                getKeyRequestResponse(e, t) {
                    return fo({
                        url: e.decryptdata.uri,
                        xhrSetup: this.config.xhrSetup
                    }, {
                        maxLoadTimeMs: 0,
                        maxTimeToFirstByteMs: 0,
                        autoRetry: !1,
                        timeoutRetry: void 0,
                        errorRetry: void 0
                    }, this.customUrlLoader).pipe(W( ([e]) => {
                        e = new Uint8Array(e);
                        return {
                            response: this.parseResponse(t, e)
                        }
                    }
                    ))
                }
                parseResponse(e, t) {
                    e = {
                        kty: "oct",
                        kid: Xo.base64UrlEncode(e),
                        k: Xo.base64UrlEncode(t)
                    };
                    return Ee.strToUtf8array(JSON.stringify({
                        keys: [e]
                    }))
                }
                handleParsedKeyResponse(t, e) {
                    let i = e.response;
                    void 0 === i && (i = new ArrayBuffer(0));
                    const r = t.setKeyRequestState(Go.PROCESS_LICENSE)
                      , n = t.session;
                    if (null === n)
                        return this.logger.error("Key is session is null"),
                        X;
                    const a = performance.now()
                      , s = Lr(n.update(i)).pipe(ie( () => {
                        var e = t.decryptdata.keyId
                          , e = n.keyStatuses.get(e);
                        this.handleKeyStatusForKey(e, t),
                        null != (e = this.sessionHandler) && e.keySystemEvents({
                            eventId: $o.Update,
                            range: {
                                tbegin: a,
                                tend: performance.now()
                            },
                            keyuri: t.decryptdata.uri,
                            keyRequestState: t.requestState
                        })
                    }
                    ), $(e => {
                        throw new Uo(t.decryptdata.uri,H.KeySystemFailedToUpdateSession,this.systemString,!0,e.message)
                    }
                    ));
                    return aa([r, s]).pipe(rn(void 0))
                }
                generateInitData(e) {
                    return {
                        initData: function(e) {
                            e = {
                                kids: e.map(Xo.base64UrlEncode)
                            };
                            return Ee.strToUtf8array(JSON.stringify(e))
                        }([e]),
                        initDataType: "keyids"
                    }
                }
                generateRequestInitialized() {
                    return ue
                }
                sanitizeRequest(e) {
                    return e
                }
                handleKeyMessage(e) {
                    var t;
                    this.isDestroying || "license-request" === e.messageType && (e = new Uint8Array(e.message),
                    1 === (e = JSON.parse(Ee.utf8arrayToStr(e).trim())).kids.length) && (e = Xo.base64Decode(e.kids[0]),
                    t = Ee.utf8arrayToStr(e),
                    t = this.keyIdToKeyInfo[t]) && t.resolveState(Go.GET_CHALLENGE, e)
                }
            }
            ]],
            fairplaystreaming: [["com.apple.fps.3_0", class extends Il {
                constructor(e, t, i, r, n, a, s, o) {
                    super(e, t, i, r, !1, n, a, s, o),
                    this.sessions = [],
                    this.keyIdToKeyInfo = {},
                    this.keyUriToKeyInfo = {},
                    this.sessionIdToKeyUri = {}
                }
                static get needsCert() {
                    return !0
                }
                handleKeyExchangeError(e, t) {
                    this.removeKey(e.decryptdata).subscribe(),
                    super.handleKeyExchangeError(e, t)
                }
                _abortKeyRequest(e) {
                    return !this.isDestroying && e && e.requestState !== Go.NONE && this.removeKey(e.decryptdata).subscribe(),
                    super._abortKeyRequest(e)
                }
                makeFpsKeySystemInitData(e, t, i) {
                    var r = e
                      , e = t
                      , t = i
                      , n = [Pl.fpsd, (r = r,
                    e = e,
                    i = new Uint8Array(4),
                    y.set32(r, i, 0),
                    y.box(Pl.fpsi, new Uint8Array([0, e >> 16 & 255, e >> 8 & 255, 255 & e]), i))];
                    for (const r of t)
                        n.push(function(t, e, i, r) {
                            var n = [Pl.fpsk]
                              , t = y.box(Pl.fkri, new Uint8Array([0, 0, 0, 0]), t);
                            if (n.push(t),
                            e && e.byteLength && n.push(y.box(Pl.fkai, e)),
                            i && i.byteLength && n.push(y.box(Pl.fkcx, i)),
                            r && r.length) {
                                const t = new Uint8Array(4 * r.length);
                                let e = 0;
                                for (const i of r)
                                    y.set32(i, t, e),
                                    e += 4;
                                n.push(y.box(Pl.fkvl, t))
                            }
                            return y.box.apply(null, n)
                        }(r.keyId, r.assetId, r.ssc, r.versionList));
                    return r = y.box.apply(null, n),
                    y.pssh(Il.systemId, null, r)
                }
                makeKeyRequestMessage(e, t) {
                    return t ? Ee.strToUtf8array("renew") : new Uint8Array
                }
                makeProcessLicenseRequestMessage(e, t, i) {
                    e = JSON.stringify([{
                        keyID: Xo.base64Encode(e.decryptdata.keyId || new Uint8Array),
                        payload: Xo.base64Encode(new Uint8Array(t))
                    }]);
                    return Ee.strToUtf8array(e)
                }
                handleKeyMessage(e) {
                    const t = e.target
                      , i = t.sessionId
                      , r = e.messageType
                      , n = this.sessionIdToKeyUri[i];
                    let a = null;
                    if (n)
                        a = this.keyUriToKeyInfo[n];
                    else
                        for (const e of Object.values(this.keyUriToKeyInfo))
                            e && e.session === t && (a = e);
                    if (a)
                        switch (r) {
                        case "license-request":
                            {
                                const t = new Uint8Array(e.message)
                                  , i = Ee.utf8arrayToStr(t);
                                try {
                                    JSON.parse(i).forEach(e => {
                                        var t = Xo.base64DecodeToStr(e.keyID)
                                          , e = Xo.base64Decode(e.payload)
                                          , t = this.keyIdToKeyInfo[t];
                                        t && this.resolveSPCPromise(t, e)
                                    }
                                    )
                                } catch (e) {
                                    this.resolveSPCPromise(a, t)
                                }
                                break
                            }
                        case "license-renewal":
                            {
                                const t = new Uint8Array(e.message);
                                this.resolveSPCPromise(a, t);
                                break
                            }
                        case "license-release":
                            this._handleLicenseRelease(t, a)
                        }
                }
                _handleLicenseRelease(e, i) {
                    const t = performance.now();
                    e.update(Ee.strToUtf8array("acknowledged")).then( () => {
                        var e;
                        null != (e = this.sessionHandler) && e.keySystemEvents({
                            eventId: $o.Update,
                            range: {
                                tbegin: t,
                                tend: performance.now()
                            },
                            keyuri: i.decryptdata.uri,
                            keyRequestState: i.requestState
                        })
                    }
                    ).catch(e => {
                        var t;
                        this.logger.error(`Promise error: ` + e.message),
                        null != (t = this.sessionHandler) && t.handleNonFatalError(new Uo(i.decryptdata.uri,H.KeySystemFailedToReleaseLicense,this.systemString,!1,e.message), !1)
                    }
                    )
                }
            }
            ], ["com.apple.fps", r]],
            playready: [["com.microsoft.playready.recommendation", e]],
            widevine: [["com.widevine.alpha", class extends ml {
                constructor(e, t, i, r, n, a, s, o) {
                    super(e, t, i, r, !1, n, a, s, o),
                    this.shouldDestroyMediaKeys = !0
                }
                static get systemId() {
                    return Nl
                }
                static get requestAccessConfig() {
                    return Ll
                }
                get needsCert() {
                    return !0
                }
                removeKey(e) {
                    return super.removeSessions(e, !0)
                }
                ensureKeyContext(e) {
                    var t = e.uri
                      , t = this.keyUriToKeyInfo[t];
                    return !t || t.shouldReuseSession && t.licenseChallenge || null != t && t.session && (t.oldSessions.push(t.session),
                    t.session = null),
                    super.ensureKeyContext(e)
                }
                getKeyRequestResponse(e, t) {
                    var i, r = e.decryptdata.uri, n = e.setKeyRequestState(Go.GET_KEY_RESPONSE);
                    return null != (i = this.eventEmitter) && i.trigger(L.LICENSE_CHALLENGE_CREATED, {
                        keyuri: r,
                        licenseChallenge: t,
                        keysystem: this.systemString,
                        keyId: null !== e.decryptdata.keyId ? e.decryptdata.keyId : void 0,
                        appItemIds: this.ksQuery.getAppItemIds(r)
                    }),
                    n
                }
                handleParsedKeyResponse(t, e) {
                    const i = t.decryptdata.uri
                      , r = e.statusCode;
                    if (0 !== r)
                        return R(void 0 === r ? new Bo(i,0,!1,To.LicenseServerError,void 0,void 0,"License server responded with error code: undefined") : new Bo(i,r,!1,To.LicenseServerError));
                    if (!e.license || !e.license.byteLength)
                        return R(new Bo(i,r,!1,To.LicenseServerError,void 0,void 0,"License server responded with invalid license"));
                    if (this.config.widevineProactiveRenewal && e.renewalDate) {
                        const i = e.renewalDate
                          , r = new Date
                          , n = i > r ? i.getTime() - r.getTime() : 0;
                        0 < n && n < Math.pow(2, 31) && this._scheduleRenewal(t, n)
                    }
                    const n = t.setKeyRequestState(Go.PROCESS_LICENSE)
                      , a = t.session;
                    if (null === a)
                        return this.logger.error("key session is null, this should not happen"),
                        ue;
                    const s = performance.now()
                      , o = Lr(a.update(e.license)).pipe(ie( () => {
                        var e = t.decryptdata.keyId
                          , e = a.keyStatuses.get(null !== e ? e : new Uint8Array);
                        this.handleKeyStatusForKey(e, t),
                        null != (e = this.sessionHandler) && e.keySystemEvents({
                            eventId: $o.Update,
                            range: {
                                tbegin: s,
                                tend: performance.now()
                            },
                            keyuri: t.decryptdata.uri,
                            keyRequestState: t.requestState
                        })
                    }
                    ), $(e => {
                        throw this.logger.error(`${this.systemString} FAIL: Failed to update with key response code=${e.code} message=` + e.message),
                        new Uo(t.decryptdata.uri,H.KeySystemFailedToUpdateSession,this.systemString,!0,e.message)
                    }
                    ));
                    return aa([n, o]).pipe(rn(void 0))
                }
                generateInitData(e, t) {
                    return {
                        initData: t.pssh,
                        initDataType: "cenc"
                    }
                }
                generateRequestInitialized(e) {
                    var t = e.licenseChallenge;
                    return e.requestInfo = void 0,
                    e.resolveState(Go.GET_CHALLENGE, void 0 !== t ? t : new j(!1,H.KeySystemUndefinedChallenge)),
                    ue
                }
                handleKeyMessage(i) {
                    if (!this.isDestroying) {
                        const r = i.target;
                        let e = null
                          , t = null;
                        if (r.sessionId in this.sessionIdToKeyUri)
                            e = this.sessionIdToKeyUri[r.sessionId],
                            t = this.keyUriToKeyInfo[e];
                        else
                            for (const [i,n] of Object.entries(this.keyUriToKeyInfo))
                                if (n.session === r) {
                                    e = i,
                                    t = n;
                                    break
                                }
                        if (t)
                            switch (i.messageType) {
                            case "license-request":
                                {
                                    const r = Ae(i.message);
                                    t.resolveState(Go.GET_CHALLENGE, r);
                                    break
                                }
                            case "license-renewal":
                                if (!this.config.widevineProactiveRenewal) {
                                    const r = Ae(i.message);
                                    t.cacheChallenge(r, !0),
                                    this._signalRenewal(t)
                                }
                            }
                    }
                }
            }
            ]]
        }
          , Fl = gl.id;
        class Bl {
            constructor(e) {
                this.Gt = e,
                this.ke = {},
                this.Me = new z
            }
            createMediaKeys(i, e, t, r, n, a) {
                let s = (this.Gt.maintainMediaKeysBetweenSessions ? Bl.idToMediaKeysInfoMap : this.ke)[i];
                return s || (e = tl(e, t),
                t = new mn,
                Bl.requestKeySystemAccess(i, e, n, r, a).pipe(te(e => {
                    this.Gt.maintainMediaKeysBetweenSessions ? Bl.idToMediaKeysInfoMap[i].keySystemAccess = e : this.ke[i].keySystemAccess = e;
                    const t = performance.now();
                    return Lr(e.createMediaKeys()).pipe(ie( () => {
                        null != a && a.keySystemEvents({
                            eventId: $o.CreateMediaKeys,
                            range: {
                                tbegin: t,
                                tend: performance.now()
                            }
                        })
                    }
                    ))
                }
                ), $(e => {
                    throw new Uo("",H.KeySystemFailedToInitialize,i,!0,e.message)
                }
                ), Pn(Bl.destroy$)).subscribe(t),
                s = this.Gt.maintainMediaKeysBetweenSessions ? Bl.idToMediaKeysInfoMap[i] = {
                    mediaKeys$: t,
                    keySystemAccess: null
                } : this.ke[i] = {
                    mediaKeys$: t,
                    keySystemAccess: null
                }),
                s.mediaKeys$
            }
            destroyMediaKeys() {
                this.Gt.maintainMediaKeysBetweenSessions ? (Bl.destroy$.next(),
                Bl.idToMediaKeysInfoMap = {}) : (this.Me.next(),
                this.ke = {})
            }
            static getKeySystemIdForDecryptData(e) {
                let t;
                if (e) {
                    t = Fl;
                    var i = e.format;
                    for (const e of al) {
                        var r = Dl[e];
                        if ((null == r ? void 0 : r.keyFormatString) === i) {
                            t = e;
                            break
                        }
                    }
                }
                if (t)
                    return t;
                throw Error("No matching key system")
            }
            static requestKeySystemAccess(e, t, i, r, n) {
                if ("undefined" == typeof navigator || void 0 === navigator.requestMediaKeySystemAccess)
                    return R( () => new Uo("",H.KeySystemUndefinedNavigator,e,!0));
                const a = xl[e];
                let s = R( () => new Uo("",H.KeySystemNoKeySystemsToTry,e,!0));
                for (const e of a) {
                    const a = e[0]
                      , l = e[1]
                      , H = (o = i) && "object" == typeof o ? i : l.requestAccessConfig
                      , d = [Object.assign({}, H, t)];
                    s = s.pipe($( () => Bl.requestKeySystemInternal(a, d, r, n)))
                }
                var o;
                return s
            }
            static requestKeySystemInternal(t, e, i, r) {
                const n = performance.now();
                return na( () => Lr(navigator.requestMediaKeySystemAccess(t, e)).pipe(ie( () => {
                    null != r && r.keySystemEvents({
                        eventId: $o.RequestMediaKeySystemAccess,
                        range: {
                            tbegin: n,
                            tend: performance.now()
                        }
                    })
                }
                ), $(e => {
                    throw new Uo("",H.KeySystemRequestMediaKeySystemAccessError,t,!1,e.message)
                }
                )))
            }
            make(e, t, i, r, n, a, s, o) {
                var l = this.Gt.maintainMediaKeysBetweenSessions ? null == (u = Bl.idToMediaKeysInfoMap[e]) ? void 0 : u.keySystemAccess : null == (u = this.ke[e]) ? void 0 : u.keySystemAccess;
                if (!l)
                    throw new Uo("",H.KeySystemNoKeySystemAccess,e,!0);
                let d;
                var u = Dl[e].systemStringPrefix;
                for (const t of xl[e])
                    if (t[0] === l.keySystem) {
                        d = t[1];
                        break
                    }
                if (d)
                    return new d(t,u,i,r,n,a,s,o);
                throw new Uo("",H.KeySystemNoConstructor,u,!0)
            }
            static get availableKeySystems() {
                return Object.keys(Dl)
            }
            static getKeySystemFormat(e) {
                e = Dl[e];
                return e ? e.keyFormatString : ""
            }
            static getKeySystemSecurityLevel(e) {
                e = Dl[e];
                return e ? e.securityLevels : void 0
            }
        }
        Bl.idToMediaKeysInfoMap = {},
        Bl.destroy$ = new z;
        const Ul = ["avc1.42E01E"]
          , _l = ["mp4a.40.2"];
        function Vl(e, t, i) {
            i = xo(i);
            if (t)
                if (t instanceof Ln)
                    t = new Fo(e,H.KeySystemRequestTimedOut);
                else if (t instanceof Uo) {
                    const i = (null == t ? void 0 : t.response) || H.InternalError;
                    t = new Bo(e,i,!1,To.InternalError,!0,void 0,t.message)
                } else
                    t instanceof Gs && (t = new Bo(e,t.statusCode,!1,To.HttpError,void 0,void 0,t.message));
            else
                t = new Bo(e,H.KeySystemCDMUnknownError,!1,To.InternalError);
            return (t instanceof Bo || t instanceof Fo) && (t.mediaOptionIds = [...i]),
            t
        }
        class Ql {
            constructor(e, t, i, n, r, a, s, o, l=void 0, d=new Bl(i)) {
                this.Ee = e,
                this.Gt = i,
                this.Ae = n,
                this.Ne = a,
                this.Re = s,
                this.Pe = l,
                this.Ce = d,
                this.De = new z,
                this.xe = new z,
                this.Le = new z,
                this._e = new pn(null),
                this.Fe = new z,
                this.je = new mn,
                this.Ue = {},
                this.Be = null,
                this.$e = {},
                this.Ve = r,
                this.ksQuery = e.query,
                this.R = o.child({
                    name: "eme"
                }),
                this.Gt.warmupCdms && this.Ke(this.He(this.Gt.keySystemPreference).keyTagInfo).subscribe();
                a = t.pipe(te(t => {
                    var e = this.ze
                      , i = [];
                    let r;
                    return this.ze = t,
                    e && i.push(e.clearMediaKeys()),
                    (r = t && (this.keySystem ? i.push(this.Qe(t)) : i.push(ce(n.platformInfo$, e => !0 === (null == e ? void 0 : e.requiresCDMAttachOnStart)).pipe(te( () => this.Qe(t)))),
                    this.Ge()) ? this.ksQuery.selectCount().pipe(W(e => 4 <= e), J(), te(e => e ? ue.pipe(on( () => {
                        const t = performance.now()
                          , e = this.ksQuery.getAll();
                        let i = 1 / 0;
                        return e.forEach(e => {
                            e.minHoldTime > t && (i = Math.min(e.minHoldTime, i))
                        }
                        ),
                        re(i) ? yr(i) : X
                    }
                    , 1), te( () => ma([t.mediaQuery.bufferedSegmentsTuple$, t.mediaQuery.updating$]).pipe(Z( ([,e]) => !1 === e), W( ([e]) => {
                        const t = new Set;
                        return e.forEach(e => e.forEach(e => {
                            e = null == (e = e.frag.keyTagInfo) ? void 0 : e.uri;
                            e && t.add(e)
                        }
                        )),
                        t
                    }
                    ), J(v)))) : X), _r(this.We.bind(this))) : r) ? ne(en(...i), r) : en(...i)
                }
                ));
                ne(a, this.xe.pipe(_r(e => e.pipe($( () => X)))), this._e.pipe(te(e => e ? e.keyStatusChange$.pipe(ie(e => {
                    var t = e.decryptdata.uri
                      , i = this.ksQuery.getKeyInfo(t);
                    "needs-renewal" === e.status ? this.Ee.updateKeyRequestState(t, bo.MustRequestResponse, e => e === bo.GotKeyResponse) : (i = Vl(t, e.error, i),
                    this.Ee.setError(t, i, !0)),
                    this.Fe.next(e)
                }
                )) : X))).pipe(ee( () => {
                    this.ze = void 0,
                    this.Ve = void 0
                }
                ), Pn(this.De)).subscribe()
            }
            get keyStatusChange$() {
                return this.Fe
            }
            get keySystem() {
                return this._e.value
            }
            destroy() {
                const e = this.ze;
                this.De.next();
                let t = ue;
                this.Be = null;
                var i = this.keySystem;
                let r = ue;
                if (i) {
                    const e = this.ksQuery.getAll()
                      , n = new Set;
                    e.forEach(e => e.mediaOptionKeys.forEach(e => {
                        n.add(e.itemId)
                    }
                    )),
                    t = this.removeItemsAndKeys(Array.from(n), !0),
                    this._e.next(null),
                    i.shouldDestroyMediaKeys && this.Ce.destroyMediaKeys(),
                    r = i.destroy()
                }
                this.Ee.removeAll();
                const n = [en(t, r)];
                return e && n.push(e.clearMediaKeys()),
                aa(n).pipe(W( () => {}
                ))
            }
            Qe(e) {
                return this.keySystem ? e.setMediaKeys(this.keySystem.mediaKeys, this.Ne) : this.Xe(this.He(this.Gt.keySystemPreference)).pipe(ie( () => {
                    this.je.next(!0),
                    this.je.complete()
                }
                ), W( () => {}
                ))
            }
            He(e) {
                e = e ? Bl.getKeySystemFormat(e) : Vo.keyFormatString;
                return new rl("NONE",void 0,null,e,[1])
            }
            Ge() {
                return !0 === this.Gt.useMultipleKeySessions || "widevine" === this.Gt.keySystemPreference || "playready" === this.Gt.keySystemPreference
            }
            static _eligibleForCleanup(e, t, i) {
                return "AES-128" !== i.decryptdata.method && i.requestState !== bo.WaitingForKeyResponse && !t.has(i.keyUri) && (e >= i.minHoldTime || 0 === i.mediaOptionKeys.length && re(i.minHoldTime))
            }
            We(e) {
                var t = performance.now();
                this.ksQuery.getCount();
                const i = this.ksQuery.getAll({
                    filterBy: Ql._eligibleForCleanup.bind(null, t, e)
                })
                  , r = new Array;
                return ae( () => {
                    for (const t of i) {
                        var e = Do(t.decryptdata);
                        r.push(this.Ye(t.keyUri, e))
                    }
                }
                ),
                this.ksQuery.getCount(),
                r.length ? aa(r) : ue
            }
            Ye(e, t) {
                this.Le.next(e),
                this.Ee.removeKey(e);
                e = this.keySystem;
                return null === e ? ue : e.removeKey(t)
            }
            removeItems(t) {
                ae( () => {
                    for (const e of t)
                        this.Ee.removeItemFromKeys(e)
                }
                )
            }
            removeItemsAndKeys(e, t) {
                let i = ue;
                return ae( () => {
                    this.removeItems(e),
                    i = this.Je(t)
                }
                ),
                i
            }
            Je(t) {
                var e = []
                  , i = this.ksQuery.getAll({
                    filterBy: e => 0 === e.mediaOptionKeys.length && (t || re(e.minHoldTime))
                });
                for (const t of i)
                    e.push(this.Ye(t.keyUri, Do(t.decryptdata)));
                return e.length ? aa(e).pipe(te( () => ue)) : ue
            }
            get availableKeySystems() {
                return Bl.availableKeySystems
            }
            initialize(e, t) {
                var i = this.Ue
                  , r = (this.Ue = {},
                this.Gt.keySystemPreference);
                for (const s of Bl.availableKeySystems) {
                    var n = e[s];
                    if (n && r === s) {
                        var a = n.certificate
                          , n = n.serverCertUrl ? us.buildAbsoluteURL(window.location.href, n.serverCertUrl) : void 0;
                        let e;
                        this.Ue[s] = {
                            serverCertUrl: n,
                            certificate: a
                        },
                        a ? e = Y({
                            keysystem: s,
                            certificate: a
                        }) : n && (null == (a = null == i ? void 0 : i[s]) ? void 0 : a.serverCertUrl) !== n && (a = cs(n) ? t.customURL : t.default,
                        e = fo({
                            url: n,
                            xhrSetup: this.Gt.xhrSetup
                        }, a, this.Re).pipe(W( ([e]) => ({
                            keysystem: s,
                            certificate: new Uint8Array(e)
                        })))),
                        e && e.pipe(te(e => this.Ze(e)), $(e => {
                            var t;
                            throw this.R.error(`Error loading cert: ` + e.message),
                            null != (t = this.Ve) && t.trigger(L.INTERNAL_ERROR, new d(H.KeySystemCertificateLoadError,e.message)),
                            e
                        }
                        ), Pn(this.De)).subscribe()
                    }
                }
            }
            generateRequest(e, t) {
                return t.pin && this.Ee.setPinnedKey(e, performance.now() + this.Gt.keyMinHoldTimeBeforeCleanup),
                !!this.keySystem && this.keySystem.setKeyRequestInfo(e, t)
            }
            setLicenseResponse(e, t) {
                this.keySystem && this.keySystem.setParsedResponse(e, t)
            }
            getKeyFromDecryptData(e, t, i) {
                var r;
                if (!e || !e.isEncrypted)
                    return null != (r = this.Ae.platformInfo) && r.requiresCDMAttachOnStart ? ce(this.je, e => e).pipe(W( () => e)) : Y(e);
                let n;
                return ae( () => {
                    n = this.ti(e, t, i)
                }
                ),
                n
            }
            ti(i, r, n) {
                var e;
                let a = null
                  , s = performance.now() + this.Gt.keyMinHoldTimeBeforeCleanup;
                r && (a = r.mediaOptionId);
                const o = i.uri
                  , l = (this.ksQuery.hasEntity(o) && (null != r && this.Ee.addMediaOption(o, r),
                (null == (e = this.ksQuery.getEntity(o)) ? void 0 : e.minHoldTime) === 1 / 0 && (s = 1 / 0),
                this.Ee.updateMinHoldTime(o, s)),
                this.ksQuery.getKeyInfo(o));
                if ((null == l ? void 0 : l.error)instanceof Bo && !1 === l.error.isOkToRetry)
                    return R( () => l.error);
                if (l && l.requestState !== bo.MustRequestResponse)
                    return l.requestState === bo.GotKeyResponse ? Y(Do(l.decryptdata)) : this.$e[o];
                {
                    if (this.Le.next(o),
                    !(r || l && 0 !== l.mediaOptionKeys.length))
                        return R( () => new Bo(o,H.KeySystemAbort,!1,To.Abort,void 0,void 0,"Key not associated with any items"));
                    let e;
                    this.Ee.upsertKey({
                        keyUri: o,
                        decryptdata: function(e) {
                            var {method: t, isEncrypted: i, uri: r, format: n, formatversions: a} = e;
                            return {
                                method: t,
                                isEncrypted: i,
                                uri: r,
                                format: n,
                                formatversions: a,
                                ivBuf: null == (t = e.iv) ? void 0 : t.buffer,
                                keyIdBuf: null == (i = e.keyId) ? void 0 : i.buffer,
                                keyBuf: null == (r = e.key) ? void 0 : r.buffer,
                                psshBuf: null == (n = e.key) ? void 0 : n.buffer
                            }
                        }(i),
                        minHoldTime: s,
                        mediaOptionKeys: r ? [r] : [],
                        requestState: bo.WaitingForKeyResponse
                    });
                    var d = i.method;
                    switch (d) {
                    case "SAMPLE-AES":
                    case "ISO-23001-7":
                    case "SAMPLE-AES-CTR":
                        {
                            const r = n.customURL;
                            e = this.fetchKeyEME(i).pipe(Nn(void 0 !== r.maxLoadTimeMs ? r.maxLoadTimeMs : 0));
                            break
                        }
                    case "AES-128":
                        e = this.fetchKeyHTTP(i.uri, i, n);
                        break;
                    default:
                        return R(new j(!1,H.KeySystemUnexpectedMETHOD,`Unexpected METHOD attribute ` + d))
                    }
                    let t = e.pipe(W(e => {
                        var t = e.decryptdata;
                        return this.Ee.updateKeyValue(o, t.key),
                        e.mediaOptionId = a,
                        null != (t = this.Ve) && t.trigger(L.KEY_LOADED, e),
                        e.decryptdata
                    }
                    ), $(e => {
                        var t = this.ksQuery.getKeyInfo(o);
                        throw e = Vl(o, e, t),
                        this.Ee.setError(o, e, !1),
                        null != (t = this.Ne) && t.keyErrorThrown({
                            keyuri: o,
                            mediaOptionId: a,
                            mediaOptionIds: e.mediaOptionIds
                        }),
                        e
                    }
                    ));
                    return t = (t = this.Pe ? t.pipe(this.Pe) : t).pipe(ee( () => {
                        var e;
                        null != (e = this.ksQuery.getKeyInfo(o)) && e.requestState,
                        this.Ee.updateKeyRequestState(o, bo.MustRequestResponse, e => e === bo.WaitingForKeyResponse),
                        this.$e[o] = X
                    }
                    ), Tn(), Pn(Sn(this.Le.pipe(Z(e => e === o)), this.De).pipe())),
                    this.$e[o] = t,
                    this.xe.next(t),
                    t
                }
            }
            fetchKeyEME(e) {
                return this.ei(e).pipe(W(e => {
                    var t = performance.now()
                      , i = e.uri;
                    return {
                        timestamp: t,
                        keyuri: i,
                        decryptdata: e,
                        appItemIds: this.ksQuery.getAppItemIds(i)
                    }
                }
                ))
            }
            fetchKeyHTTP(e, t, i) {
                return Ql.fetchKeyHTTP(e, this.Gt, t, i, this.Re, this.ksQuery, this.R)
            }
            static fetchKeyHTTP(t, e, i, r, n, a, s) {
                e = {
                    url: t,
                    xhrSetup: e.xhrSetup
                };
                return fo(e, eo(e, r), n).pipe(W( ([e]) => (i.key = new Uint8Array(e),
                {
                    decryptdata: i,
                    keyuri: t,
                    timestamp: performance.now(),
                    appItemIds: a.getAppItemIds(t)
                })))
            }
            ei(t) {
                return this.Xe(t).pipe(te(e => null === e ? X : e.startKeyRequest(t)))
            }
            ii(t) {
                return na( () => {
                    if (null == this.Ve)
                        throw new Bo("",H.KeySystemFailedToInitialize,!1,To.InternalError);
                    if (null === this.keySystem && this.Be) {
                        this._e.next(this.Ce.make(this.Be, t, this.Gt, this.Ve, this.Ne, this.Re, this.ksQuery, this.R));
                        var e = this.Ue && this.Ue[this.Be];
                        if (e) {
                            const t = this._e.value;
                            return null === t ? (this.R.error("Key system is null after calling keySystemFactory.make. This should not happen"),
                            R(new Bo("",H.KeySystemFailedToInitialize,!1,To.InternalError))) : t.setServerCertificate(e.certificate).pipe(rn(this.keySystem))
                        }
                    }
                    return Y(this.keySystem)
                }
                )
            }
            Xe(e) {
                return this.Ke(e).pipe(te(e => {
                    var t;
                    return aa([this.ii(e), null != (t = null == (t = this.ze) ? void 0 : t.setMediaKeys(e, this.Ne)) ? t : ue])
                }
                ), W(e => e[0]))
            }
            Ke(e) {
                var t = Bl.getKeySystemIdForDecryptData(e);
                if (null == this.Be)
                    this.Be = t;
                else if (this.Be !== t)
                    return R(new Bo(e.uri,H.KeySystemUnmatchedString,!1,To.InternalError,void 0,void 0,`New key system string does not match existing ${t} !== ` + this.Be));
                return this.Ce.createMediaKeys(this.Be, Ul, _l, this.R, null == (e = this.Ae.platformInfo) ? void 0 : e.keySystemConfig, this.Ne)
            }
            Ze(e) {
                const t = e.keysystem
                  , i = e.certificate
                  , r = this.Ue[t];
                return void 0 === r ? (this.R.error(`KeySystemAdapter: ProtectionData for keysystemId:${t} is undefined`),
                R( () => new Uo("",H.InternalError,t,!0))) : (r.certificate = i,
                this.keySystem && this.Be === t ? this.keySystem.setServerCertificate(i).pipe(rn(void 0)) : ue)
            }
        }
        function Kl() {
            return e => e.pipe(Z(e => null != e), W(e => e))
        }
        class Hl extends ja {
            constructor(e) {
                super(e)
            }
            getKeyInfo(e) {
                e = this.getEntity(e);
                return null != e && e.error ? Object.assign(Object.assign({}, e), {
                    error: _o(e.error, xo(e))
                }) : e
            }
            getKeyRequestState$(e) {
                return this.selectEntity(e, e => null == e ? void 0 : e.requestState)
            }
            getKeyStatus$(e) {
                return this.selectEntity(e, e => null == e ? void 0 : e.status)
            }
            getKeyError$(e) {
                return this.selectEntity(e, e => _o(null == e ? void 0 : e.error, xo(e))).pipe(Kl())
            }
            getAppItemIds(e) {
                var t = new Set
                  , i = null == (e = this.getEntity(e)) ? void 0 : e.mediaOptionKeys;
                if (i)
                    for (const e of i)
                        e.appItemId && t.add(e.appItemId);
                return Array.from(t)
            }
        }
        class jl extends Ua {
            constructor() {
                super({}, {
                    name: "key-system-store",
                    idKey: "keyUri"
                })
            }
        }
        class ql {
            constructor(e, t) {
                this.ce = e,
                this.ni = t,
                this.ri = new Hl(this.ce)
            }
            get query() {
                return this.ri
            }
            upsertKey(i) {
                const r = {};
                function n(e, t) {
                    for (const i of e) {
                        const {itemId: e, mediaOptionId: r, appItemId: n} = i;
                        t[e + r] = {
                            itemId: e,
                            mediaOptionId: r,
                            appItemId: n
                        }
                    }
                }
                n(i.mediaOptionKeys, r),
                this.ce.upsert(i.keyUri, e => {
                    var t = Object.assign(Object.assign({}, e), i);
                    return "mediaOptionKeys"in e && n(e.mediaOptionKeys, r),
                    t.mediaOptionKeys = Object.values(r),
                    t
                }
                , () => Object.assign(Object.assign({}, i), {
                    mediaOptionKeys: Object.values(r)
                }))
            }
            removeKey(e) {
                this.ce.remove(e)
            }
            removeItemFromKeys(i) {
                const e = this.ri.getAll();
                ae( () => {
                    e.forEach(e => {
                        var t;
                        e.mediaOptionKeys.some(e => e.itemId === i) && (t = e.mediaOptionKeys.filter(e => e.itemId !== i),
                        this.ce.update(e.keyUri, {
                            mediaOptionKeys: t
                        }))
                    }
                    )
                }
                )
            }
            removeAll() {
                this.ce.remove()
            }
            updateKeyValue(e, t) {
                var i = this.ri.getEntity(e);
                i && (t = {
                    requestState: bo.GotKeyResponse,
                    decryptdata: null == i.decryptdata.keyBuf && null != t ? Object.assign(Object.assign({}, i.decryptdata), {
                        keyBuf: t.buffer
                    }) : i.decryptdata
                },
                this.ce.update(e, t))
            }
            updateKeyStatus(e, t) {
                var i = this.ri.getEntity(e);
                null != i && i.status !== t && this.ce.update(e, {
                    status: t
                })
            }
            updateKeyRequestState(e, t, i) {
                var r = this.ri.getEntity(e);
                null == r || i && !1 === i(r.requestState) || this.ce.update(e, {
                    requestState: t
                })
            }
            updateMinHoldTime(e, t) {
                var i = null == (i = this.ri.getEntity(e)) ? void 0 : i.minHoldTime;
                null != i && i !== t && this.ce.update(e, {
                    minHoldTime: t
                })
            }
            setPinnedKey(e, t) {
                var i = null == (i = this.ri.getEntity(e)) ? void 0 : i.minHoldTime;
                if (null != i && i !== 1 / 0) {
                    const r = this.query.getAll({
                        filterBy: e => e.minHoldTime === 1 / 0
                    }).map(e => e.keyUri);
                    ae( () => {
                        0 < r.length && this.ce.update(r, {
                            minHoldTime: t
                        }),
                        this.ce.update(e, {
                            minHoldTime: 1 / 0
                        })
                    }
                    )
                }
            }
            addMediaOption(e, t) {
                var {itemId: i, mediaOptionId: r, appItemId: n} = t
                  , a = null == (a = this.ri.getEntity(e)) ? void 0 : a.mediaOptionKeys;
                a && !a.some(e => Fs(e, t)) && this.ce.update(e, {
                    mediaOptionKeys: [...a, {
                        itemId: i,
                        mediaOptionId: r,
                        appItemId: n
                    }]
                })
            }
            setError(e, t, i) {
                t = {
                    error: _o(t)
                };
                i && (t.requestState = bo.MustRequestResponse),
                this.ce.update(e, t)
            }
        }
        var Gl = {}
          , i = {}
          , r = {}
          , e = {}
          , $l = (Object.defineProperty(e, "__esModule", {
            value: !0
        }),
        e.isValidScrollSetting = e.isValidPositionAlignSetting = e.isValidLineAlignSetting = e.isValidLineAndPositionSetting = e.isValidDirectionSetting = e.isValidAlignSetting = e.isValidPercentValue = void 0,
        e.isValidPercentValue = function(e) {
            return "number" == typeof e && 0 <= e && e <= 100
        }
        ,
        e.isValidAlignSetting = function(e) {
            return "string" == typeof e && ["start", "center", "end", "left", "right", "middle"].includes(e)
        }
        ,
        e.isValidDirectionSetting = function(e) {
            return "string" == typeof e && ["", "rl", "lr"].includes(e)
        }
        ,
        e.isValidLineAndPositionSetting = function(e) {
            return "number" == typeof e || "auto" === e
        }
        ,
        e.isValidLineAlignSetting = function(e) {
            return "string" == typeof e && ["start", "center", "end"].includes(e)
        }
        ,
        e.isValidPositionAlignSetting = function(e) {
            return "string" == typeof e && ["line-left", "center", "line-right", "auto", "left", "start", "middle", "end", "right"].includes(e)
        }
        ,
        e.isValidScrollSetting = function(e) {
            return ["", "up"].includes(e)
        }
        ,
        {})
          , Wl = (Object.defineProperty($l, "__esModule", {
            value: !0
        }),
        {
            "&amp;": "&",
            "&lt;": "<",
            "&gt;": ">",
            "&lrm;": "‎",
            "&rlm;": "‏",
            "&nbsp;": " "
        })
          , zl = {
            c: "span",
            i: "i",
            b: "b",
            u: "u",
            ruby: "ruby",
            rt: "rt",
            v: "span",
            lang: "span"
        }
          , Xl = {
            v: "title",
            lang: "lang"
        }
          , Yl = {
            rt: "ruby"
        }
          , Jl = {
            "text-combine-upright": "-webkit-text-combine:horizontal; text-orientation: mixed;"
        };
        class Zl {
            static parseTimeStamp(e) {
                function t(e) {
                    var [e,t,i,r] = e.map(e => e ? parseInt("" + e) : 0);
                    return 3600 * e + 60 * t + i + r / 1e3
                }
                e = /^(\d+):(\d{2})(:\d{2})?\.(\d{3})/.exec(e);
                return e ? e[3] ? t([e[1], e[2], e[3].substring(1), e[4]]) : 59 < parseInt(e[1]) ? t([e[1], e[2], null, e[4]]) : t([null, e[1], e[2], e[4]]) : null
            }
            static parseContent(e, t, i) {
                var r = t.text;
                function n(e) {
                    return Wl[e]
                }
                for (var a, s, o, l, d, t = e.document.createElement("div"), u = [], c = t; null !== (d = void 0,
                d = r ? (d = (d = /^([^<]*)(<[^>]+>?)?/.exec(r))[1] || d[2],
                r = r.substr(d.length),
                d) : null); )
                    if ("<" !== d[0])
                        c.appendChild(e.document.createTextNode(d.replace(/&(amp|lt|gt|lrm|rlm|nbsp);/g, n)));
                    else {
                        if ("/" === d[1]) {
                            u.length && u[u.length - 1] === d.substr(2).replace(">", "") && (u.pop(),
                            c = c.parentNode);
                            continue
                        }
                        var h = Zl.parseTimeStamp(d.substr(1, d.length - 2))
                          , p = void 0;
                        if (h) {
                            p = e.document.createProcessingInstruction("timestamp", h.toString()),
                            c.appendChild(p);
                            continue
                        }
                        if (!(h = /^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/.exec(d)))
                            continue;
                        if (d = h[1],
                        a = h[2],
                        s = h[3],
                        l = o = void 0,
                        !(p = (l = zl[d]) ? ((o = e.document.createElement(l)).dataset.localName = l,
                        (l = Xl[d]) && s && (o[l] = s.trim()),
                        a && (i[a] ? (d = function(e) {
                            var t, i = "";
                            for (t in e)
                                i += Jl[t] || t + ":" + e[t] + ";";
                            return i
                        }(i[a]),
                        o.setAttribute("style", d)) : console.info("WebVTT: parseContent: Style referenced, but no style defined for '".concat(a, "'!"))),
                        o) : null))
                            continue;
                        if (l = c,
                        Yl[(s = p).dataset.localName] && Yl[s.dataset.localName] !== l.dataset.localName)
                            continue;
                        u.push(h[1]),
                        c.appendChild(p),
                        c = p
                    }
                return t
            }
        }
        $l.default = Zl;
        var ed = t && t.__decorate || function(e, t, i, r) {
            var n, a = arguments.length, s = a < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, i) : r;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
                s = Reflect.decorate(e, t, i, r);
            else
                for (var o = e.length - 1; 0 <= o; o--)
                    (n = e[o]) && (s = (a < 3 ? n(s) : 3 < a ? n(t, i, s) : n(t, i)) || s);
            return 3 < a && s && Object.defineProperty(t, i, s),
            s
        }
          , td = (Object.defineProperty(r, "__esModule", {
            value: !0
        }),
        r.VTTCue = void 0,
        e)
          , id = $l
          , ed = ed([function(e) {
            var t = e;
            return "undefined" != typeof window && null != window.VTTCue && ((t = window.VTTCue).create = e.create,
            t.fromJSON = e.fromJSON,
            t.prototype.toJSON = e.prototype.toJSON),
            t
        }
        ], class {
            constructor(e, t, i) {
                this._id = "",
                this._pauseOnExit = !1,
                this._region = null,
                this._vertical = "",
                this._snapToLines = !0,
                this._line = "auto",
                this._lineAlign = "start",
                this._position = "auto",
                this._positionAlign = "auto",
                this._size = 100,
                this._align = "center",
                this.hasBeenReset = !1,
                this._startTime = e,
                this._endTime = t,
                this._text = i
            }
            get id() {
                return this._id
            }
            set id(e) {
                this._id = "" + e
            }
            get pauseOnExit() {
                return this._pauseOnExit
            }
            set pauseOnExit(e) {
                this._pauseOnExit = !!e
            }
            get startTime() {
                return this._startTime
            }
            set startTime(e) {
                if ("number" != typeof e)
                    throw new TypeError("Start time must be set to a number: ".concat(e));
                this._startTime = e,
                this.hasBeenReset = !0
            }
            get endTime() {
                return this._endTime
            }
            set endTime(e) {
                if ("number" != typeof e)
                    throw new TypeError("End time must be set to a number: ".concat(e));
                this._endTime = e,
                this.hasBeenReset = !0
            }
            get text() {
                return this._text
            }
            set text(e) {
                this._text = "" + e,
                this.hasBeenReset = !0
            }
            get region() {
                return this._region
            }
            set region(e) {
                this._region = e,
                this.hasBeenReset = !0
            }
            get vertical() {
                return this._vertical
            }
            set vertical(e) {
                if (!td.isValidDirectionSetting(e))
                    throw new SyntaxError("An invalid or illegal string was specified for vertical: ".concat(e));
                this._vertical = e,
                this.hasBeenReset = !0
            }
            get snapToLines() {
                return this._snapToLines
            }
            set snapToLines(e) {
                this._snapToLines = !!e,
                this.hasBeenReset = !0
            }
            get line() {
                return this._line
            }
            set line(e) {
                if (!td.isValidLineAndPositionSetting(e))
                    throw new SyntaxError("An invalid number or illegal string was specified for line: ".concat(e));
                this._line = e,
                this.hasBeenReset = !0
            }
            get lineAlign() {
                return this._lineAlign
            }
            set lineAlign(e) {
                if (!td.isValidLineAlignSetting(e))
                    throw new SyntaxError("An invalid or illegal string was specified for lineAlign: ".concat(e));
                this._lineAlign = e,
                this.hasBeenReset = !0
            }
            get position() {
                return this._position
            }
            set position(e) {
                if (!td.isValidLineAndPositionSetting(e))
                    throw new Error("Position must be between 0 and 100 or auto: ".concat(e));
                this._position = e,
                this.hasBeenReset = !0
            }
            get positionAlign() {
                return this._positionAlign
            }
            set positionAlign(e) {
                if (!td.isValidPositionAlignSetting(e))
                    throw new SyntaxError("An invalid or illegal string was specified for positionAlign: ".concat(e));
                this._positionAlign = e,
                this.hasBeenReset = !0
            }
            get size() {
                return this._size
            }
            set size(e) {
                if (e < 0 || 100 < e)
                    throw new Error("Size must be between 0 and 100: ".concat(e));
                this._size = e,
                this.hasBeenReset = !0
            }
            get align() {
                return this._align
            }
            set align(e) {
                if (!td.isValidAlignSetting(e))
                    throw new SyntaxError("An invalid or illegal string was specified for align: ".concat(e));
                this._align = e,
                this.hasBeenReset = !0
            }
            getCueAsHTML() {
                return id.default.parseContent(window, this, {})
            }
            static create(t) {
                var i;
                if (t.hasOwnProperty("startTime") && t.hasOwnProperty("endTime") && t.hasOwnProperty("text"))
                    return i = new this(t.startTime,t.endTime,t.text),
                    Object.keys(t).forEach(e => {
                        i.hasOwnProperty(e) && (i[e] = t[e])
                    }
                    ),
                    i;
                throw new Error("You must at least have start time, end time, and text.")
            }
            static fromJSON(e) {
                return this.create(JSON.parse(e))
            }
            toJSON() {
                var t = {};
                return Object.keys(this).forEach(e => {
                    this.hasOwnProperty(e) && "getCueAsHTML" !== e && "hasBeenReset" !== e && "displayState" !== e && (t[e] = this[e])
                }
                ),
                t
            }
        }
        )
          , ed = (r.VTTCue = ed,
        {})
          , rd = t && t.__decorate || function(e, t, i, r) {
            var n, a = arguments.length, s = a < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, i) : r;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
                s = Reflect.decorate(e, t, i, r);
            else
                for (var o = e.length - 1; 0 <= o; o--)
                    (n = e[o]) && (s = (a < 3 ? n(s) : 3 < a ? n(t, i, s) : n(t, i)) || s);
            return 3 < a && s && Object.defineProperty(t, i, s),
            s
        }
          , nd = (Object.defineProperty(ed, "__esModule", {
            value: !0
        }),
        ed.VTTRegion = void 0,
        e)
          , e = rd([function(e) {
            var t = e;
            return "undefined" != typeof window && null != window.VTTRegion && ((t = window.VTTRegion).create = e.create,
            t.fromJSON = e.fromJSON,
            t.prototype.toJSON = e.prototype.toJSON),
            t
        }
        ], class {
            constructor() {
                this._id = "",
                this._lines = 3,
                this._regionAnchorX = 0,
                this._regionAnchorY = 100,
                this._scroll = "",
                this._viewportAnchorX = 0,
                this._viewportAnchorY = 100,
                this._width = 100
            }
            get id() {
                return this._id
            }
            set id(e) {
                if ("string" != typeof e)
                    throw new Error("ID must be a string.");
                this._id = e
            }
            get lines() {
                return this._lines
            }
            set lines(e) {
                if ("number" != typeof e)
                    throw new TypeError("Lines must be set to a number.");
                this._lines = e
            }
            get regionAnchorX() {
                return this._regionAnchorX
            }
            set regionAnchorX(e) {
                if (!nd.isValidPercentValue(e))
                    throw new TypeError("RegionAnchorX must be between 0 and 100.");
                this._regionAnchorX = e
            }
            get regionAnchorY() {
                return this._regionAnchorY
            }
            set regionAnchorY(e) {
                if (!nd.isValidPercentValue(e))
                    throw new TypeError("RegionAnchorY must be between 0 and 100.");
                this._regionAnchorY = e
            }
            get scroll() {
                return this._scroll
            }
            set scroll(e) {
                if ("string" == typeof e) {
                    e = e.toLowerCase();
                    if (nd.isValidScrollSetting(e))
                        return void (this._scroll = e)
                }
                throw new SyntaxError("An invalid or illegal string was specified.")
            }
            get viewportAnchorX() {
                return this._viewportAnchorX
            }
            set viewportAnchorX(e) {
                if (!nd.isValidPercentValue(e))
                    throw new TypeError("ViewportAnchorX must be between 0 and 100.");
                this._viewportAnchorX = e
            }
            get viewportAnchorY() {
                return this._viewportAnchorY
            }
            set viewportAnchorY(e) {
                if (!nd.isValidPercentValue(e))
                    throw new TypeError("ViewportAnchorY must be between 0 and 100.");
                this._viewportAnchorY = e
            }
            get width() {
                return this._width
            }
            set width(e) {
                if (!nd.isValidPercentValue(e))
                    throw new TypeError("Width must be between 0 and 100.");
                this._lines = e
            }
            toJSON() {
                var t = {};
                return Object.keys(this).forEach(e => {
                    this.hasOwnProperty(e) && (t[e] = this[e])
                }
                ),
                t
            }
            static create(t) {
                var i = new this;
                return Object.keys(t).forEach(e => {
                    i.hasOwnProperty(e) && (i[e] = t[e])
                }
                ),
                i
            }
            static fromJSON(e) {
                return this.create(JSON.parse(e))
            }
        }
        )
          , rd = (ed.VTTRegion = e,
        {});
        Object.defineProperty(rd, "__esModule", {
            value: !0
        });
        {
            e = i;
            var ad = t && t.__createBinding || (Object.create ? function(e, t, i, r) {
                void 0 === r && (r = i),
                Object.defineProperty(e, r, {
                    enumerable: !0,
                    get: function() {
                        return t[i]
                    }
                })
            }
            : function(e, t, i, r) {
                e[r = void 0 === r ? i : r] = t[i]
            }
            )
              , sd = t && t.__exportStar || function(e, t) {
                for (var i in e)
                    "default" === i || t.hasOwnProperty(i) || ad(t, e, i)
            }
              , od = (Object.defineProperty(e, "__esModule", {
                value: !0
            }),
            e.VTTRegion = e.VTTCue = e.WebVTTParser = e.ParsingError = void 0,
            r)
              , ld = (Object.defineProperty(e, "VTTCue", {
                enumerable: !0,
                get: function() {
                    return od.VTTCue
                }
            }),
            ed)
              , dd = (Object.defineProperty(e, "VTTRegion", {
                enumerable: !0,
                get: function() {
                    return ld.VTTRegion
                }
            }),
            $l);
            class ny extends Error {
                constructor(e, t) {
                    super(),
                    this.name = "ParsingError",
                    this.code = "number" == typeof e ? e : e.code,
                    t ? this.message = t : e instanceof ny && (this.message = e.message)
                }
            }
            (e.ParsingError = ny).Errors = {
                BadSignature: new ny(0,"Malformed WebVTT signature."),
                BadTimeStamp: new ny(1,"Malformed time stamp.")
            };
            class ay {
                constructor() {
                    this.values = {}
                }
                set(e, t) {
                    this.get(e) || "" === t || (this.values[e] = t)
                }
                get(e, t, i) {
                    return "object" == typeof t && "string" == typeof i ? this.has(e) ? this.values[e] : t[i] : this.has(e) ? this.values[e] : t
                }
                has(e) {
                    return e in this.values
                }
                alt(e, t, i) {
                    for (var r = 0; r < i.length; ++r)
                        if (t === i[r]) {
                            this.set(e, t);
                            break
                        }
                }
                integer(e, t) {
                    /^-?\d+$/.test(t) && this.set(e, parseInt(t, 10))
                }
                percent(e, t) {
                    if (t.match(/^([\d]{1,3})(\.[\d]*)?%$/))
                        try {
                            var i = parseFloat(t);
                            if (0 <= i && i <= 100)
                                return this.set(e, i),
                                !0
                        } catch (e) {}
                    return !1
                }
            }
            class sy {
                constructor(e, t, i) {
                    this.window = e,
                    this.state = "INITIAL",
                    this.styleCollector = "",
                    this.buffer = "",
                    this.decoder = t || new TextDecoder("utf8"),
                    this.regionList = [],
                    this.alreadyCollectedLine = "",
                    this.onStylesParsedCallback = i,
                    this._styles = {},
                    this.middleOrCenter = "center";
                    t = new od.VTTCue(0,0,"middleOrCenter");
                    try {
                        t.align = "center",
                        "center" !== t.align && (this.middleOrCenter = "middle")
                    } catch (e) {
                        this.middleOrCenter = "middle"
                    }
                }
                static StringDecoder() {
                    return {
                        decode: e => {
                            if (!e)
                                return "";
                            if ("string" != typeof e)
                                throw new Error("Error - expected string data.");
                            return decodeURIComponent(encodeURIComponent(e))
                        }
                    }
                }
                reportOrThrowError(e) {
                    if (!(e instanceof ny && "function" == typeof this.onparsingerror))
                        throw e;
                    this.onparsingerror(e)
                }
                parseOptions(e, t, i, r) {
                    var n, a;
                    for (n of r ? e.split(r) : [e])
                        "string" == typeof n && 2 === (a = n.split(i)).length && t(a[0], a[1])
                }
                parseCue(t, e, a) {
                    var s, i = t, r = () => {
                        var e = dd.default.parseTimeStamp(t);
                        if (null === e)
                            throw new ny(ny.Errors.BadTimeStamp,"Malformed timestamp: " + i);
                        return t = t.replace(/^[^\sa-zA-Z-]+/, ""),
                        e
                    }
                    , n = () => {
                        t = t.replace(/^\s+/, "")
                    }
                    ;
                    if (n(),
                    e.startTime = r(),
                    n(),
                    "--\x3e" !== t.substr(0, 3))
                        throw new ny(ny.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): ".concat(i));
                    t = t.substr(3),
                    n(),
                    e.endTime = r(),
                    n(),
                    r = t,
                    n = e,
                    s = new ay,
                    this.parseOptions(r, (e, t) => {
                        var i, r;
                        switch (e) {
                        case "region":
                            for (var n = a.length - 1; 0 <= n; n--)
                                if (a[n].id === t) {
                                    s.set(e, a[n].region);
                                    break
                                }
                            break;
                        case "vertical":
                            s.alt(e, t, ["rl", "lr"]);
                            break;
                        case "line":
                            r = (i = t.split(","))[0],
                            s.integer(e, r),
                            s.percent(e, r) && s.set("snapToLines", !1),
                            s.alt(e, r, ["auto"]),
                            2 === i.length && s.alt("lineAlign", i[1], ["start", "middle", "center", "end"]);
                            break;
                        case "position":
                            i = t.split(","),
                            s.percent(e, i[0]),
                            2 === i.length && s.alt("positionAlign", i[1], ["line-left", "line-right", "center", "auto", "left", "start", "middle", "end", "right"]);
                            break;
                        case "size":
                            s.percent(e, t);
                            break;
                        case "align":
                            s.alt(e, t, ["start", "center", "end", "left", "right", "middle"])
                        }
                    }
                    , /:/, /\s/),
                    n.region = s.get("region", null),
                    n.vertical = s.get("vertical", ""),
                    n.line = s.get("line", void 0 === n.line ? "auto" : n.line),
                    r = s.get("lineAlign", "start"),
                    n.lineAlign = "center" === r || "middle" === r ? this.middleOrCenter : r,
                    n.snapToLines = s.get("snapToLines", !0),
                    n.size = s.get("size", 100),
                    r = s.get("align", "center"),
                    n.align = "center" === r || "middle" === r ? this.middleOrCenter : r,
                    n.position = s.get("position", "auto"),
                    r = s.get("positionAlign", {
                        start: "start",
                        left: "start",
                        center: "center",
                        middle: "middle",
                        right: "end",
                        end: "end"
                    }, n.align),
                    n.positionAlign = "center" === r || "middle" === r ? this.middleOrCenter : {
                        start: "start",
                        "line-left": "start",
                        left: "start",
                        center: "center",
                        middle: "middle",
                        "line-right": "end",
                        right: "end",
                        end: "end"
                    }[r]
                }
                parseRegion(e) {
                    var n = new ay;
                    this.parseOptions(e, (e, t) => {
                        switch (e) {
                        case "id":
                            n.set(e, t);
                            break;
                        case "width":
                            n.percent(e, t);
                            break;
                        case "lines":
                            n.integer(e, t);
                            break;
                        case "regionanchor":
                        case "viewportanchor":
                            var i, r = t.split(",");
                            2 === r.length && ((i = new ay).percent("x", r[0]),
                            i.percent("y", r[1]),
                            i.has("x") && i.has("y")) && (n.set(e + "X", i.get("x")),
                            n.set(e + "Y", i.get("y")));
                            break;
                        case "scroll":
                            n.alt(e, t, ["up"])
                        }
                    }
                    , /=/, /\s/),
                    n.has("id") && ((e = new ld.VTTRegion).width = n.get("width", 100),
                    e.lines = n.get("lines", 3),
                    e.regionAnchorX = n.get("regionanchorX", 0),
                    e.regionAnchorY = n.get("regionanchorY", 100),
                    e.viewportAnchorX = n.get("viewportanchorX", 0),
                    e.viewportAnchorY = n.get("viewportanchorY", 100),
                    e.scroll = n.get("scroll", ""),
                    this.onregion && this.onregion(e),
                    this.regionList.push({
                        id: n.get("id"),
                        region: e
                    }))
                }
                parseStyle(e) {
                    var t, e = e.split("}");
                    for (t of (e.pop(),
                    e)) {
                        var i = null
                          , r = null
                          , n = t.split("{");
                        n[0] && (i = n[0].trim()),
                        n[1] && (r = (e => {
                            for (var t, i, r = {}, n = e.split(";"), a = 0; a < n.length; a++)
                                n[a].includes(":") && (t = (i = n[a].split(":", 2))[0].trim(),
                                i = i[1].trim(),
                                "" !== t) && "" !== i && (r[t] = i);
                            return r
                        }
                        )(n[1])),
                        i && r && (this._styles[i] = r)
                    }
                    this.onStylesParsedCallback && this.onStylesParsedCallback(this._styles)
                }
                parseHeader(e) {
                    this.parseOptions(e, function(e, t) {
                        "Region" === e && this.parseRegion(t)
                    }, /:/)
                }
                parse(e) {
                    e && (this.buffer += this.decoder.decode(e, {
                        stream: !0
                    }));
                    var t = () => {
                        for (var e = this.buffer, t = 0, i = {
                            start: e.length,
                            length: 0
                        }; t < e.length; ) {
                            var r = ( (e, t) => {
                                var i = {
                                    start: -1,
                                    length: -1
                                };
                                if ("\r" === e[t])
                                    i.start = t,
                                    i.length = 1;
                                else if ("\n" === e[t])
                                    i.start = t,
                                    i.length = 1;
                                else if ("<" === e[t] && t + 1 < e.length && "b" === e[t + 1] && t + 2 < e.length && "r" === e[t + 2]) {
                                    for (var r = t + 2; r < e.length && ">" !== e[r++]; )
                                        ;
                                    i.start = t,
                                    i.length = r - t
                                }
                                return i
                            }
                            )(e, t);
                            if (0 < r.length) {
                                i = r;
                                break
                            }
                            ++t
                        }
                        var n = e.substr(0, i.start);
                        return this.buffer = e.substr(i.start + i.length),
                        n
                    }
                    ;
                    try {
                        if ("INITIAL" === this.state) {
                            if (!/\r\n|\n/.test(this.buffer))
                                return this;
                            this.alreadyCollectedLine = "";
                            var i = t()
                              , r = /^(ï»¿)?WEBVTT([ \t].*)?$/.exec(i);
                            if (!r || !r[0])
                                throw new ny(ny.Errors.BadSignature);
                            this.state = "HEADER"
                        }
                        for (; this.buffer; ) {
                            if (!/\r\n|\n/.test(this.buffer))
                                return this;
                            switch (this.alreadyCollectedLine ? (i = this.alreadyCollectedLine,
                            this.alreadyCollectedLine = "") : i = t(),
                            this.state) {
                            case "HEADER":
                                i.includes(":") ? this.parseHeader(i) : i || (this.state = "ID");
                                continue;
                            case "NOTE":
                                i || (this.state = "ID");
                                continue;
                            case "STYLE":
                                i ? this.styleCollector += i : (this.parseStyle(this.styleCollector),
                                this.state = "ID",
                                this.styleCollector = "");
                                continue;
                            case "ID":
                                if (/^NOTE($|[ \t])/.test(i)) {
                                    this.state = "NOTE";
                                    break
                                }
                                if (/^STYLE($|[ \t])/.test(i)) {
                                    this.state = "STYLE";
                                    break
                                }
                                if (!i)
                                    continue;
                                if (this.cue = new od.VTTCue(0,0,""),
                                this.state = "CUE",
                                !i.includes("--\x3e")) {
                                    this.cue.id = i;
                                    continue
                                }
                            case "CUE":
                                try {
                                    this.parseCue(i, this.cue, this.regionList)
                                } catch (e) {
                                    this.reportOrThrowError(e),
                                    this.cue = null,
                                    this.state = "BADCUE";
                                    continue
                                }
                                this.state = "CUETEXT";
                                continue;
                            case "CUETEXT":
                                var n = i.includes("--\x3e");
                                if (!i || n) {
                                    this.alreadyCollectedLine = i,
                                    this.oncue && this.oncue(this.cue),
                                    this.cue = null,
                                    this.state = "ID";
                                    continue
                                }
                                this.cue.text && (this.cue.text += "\n"),
                                this.cue.text += i;
                                continue;
                            case "BADCUE":
                                i || (this.state = "ID");
                                continue
                            }
                        }
                    } catch (e) {
                        this.reportOrThrowError(e),
                        "CUETEXT" === this.state && this.cue && this.oncue && this.oncue(this.cue),
                        this.cue = null,
                        this.state = "INITIAL" === this.state ? "BADWEBVTT" : "BADCUE"
                    }
                    return this
                }
                flush() {
                    try {
                        if (this.buffer += this.decoder.decode(),
                        !this.cue && "HEADER" !== this.state || (this.buffer += "\n\n",
                        this.parse()),
                        "INITIAL" === this.state)
                            throw new ny(ny.Errors.BadSignature)
                    } catch (e) {
                        this.reportOrThrowError(e)
                    }
                    return this.onflush && this.onflush(),
                    this
                }
                styles() {
                    return this._styles
                }
            }
            e.default = sy,
            e.WebVTTParser = sy,
            sd(rd, e)
        }
        var ud, ed = {};
        {
            sd = ed;
            var cd = t && t.__createBinding || (Object.create ? function(e, t, i, r) {
                void 0 === r && (r = i),
                Object.defineProperty(e, r, {
                    enumerable: !0,
                    get: function() {
                        return t[i]
                    }
                })
            }
            : function(e, t, i, r) {
                e[r = void 0 === r ? i : r] = t[i]
            }
            )
              , e = t && t.__exportStar || function(e, t) {
                for (var i in e)
                    "default" === i || t.hasOwnProperty(i) || cd(t, e, i)
            }
              , hd = (Object.defineProperty(sd, "__esModule", {
                value: !0
            }),
            sd.VTTCue = sd.WebVTTRenderer = sd.BoxPosition = sd.CueStyleBox = sd.StyleBox = void 0,
            r)
              , pd = (Object.defineProperty(sd, "VTTCue", {
                enumerable: !0,
                get: function() {
                    return hd.VTTCue
                }
            }),
            $l)
              , md = [/^(::cue\()(\..*)(\))/, /^(::cue\()(#.*)(\))/, /^(::cue\()(c|i|b|u|ruby|rt|v|lang)(\))/]
              , fd = [[1470, 1470], [1472, 1472], [1475, 1475], [1478, 1478], [1488, 1514], [1520, 1524], [1544, 1544], [1547, 1547], [1549, 1549], [1563, 1563], [1566, 1610], [1645, 1647], [1649, 1749], [1765, 1766], [1774, 1775], [1786, 1805], [1807, 1808], [1810, 1839], [1869, 1957], [1969, 1969], [1984, 2026], [2036, 2037], [2042, 2042], [2048, 2069], [2074, 2074], [2084, 2084], [2088, 2088], [2096, 2110], [2112, 2136], [2142, 2142], [2208, 2208], [2210, 2220], [8207, 8207], [64285, 64285], [64287, 64296], [64298, 64310], [64312, 64316], [64318, 64318], [64320, 64321], [64323, 64324], [64326, 64449], [64467, 64829], [64848, 64911], [64914, 64967], [65008, 65020], [65136, 65140], [65142, 65276], [67584, 67589], [67592, 67592], [67594, 67637], [67639, 67640], [67644, 67644], [67647, 67669], [67671, 67679], [67840, 67867], [67872, 67897], [67903, 67903], [67968, 68023], [68030, 68031], [68096, 68096], [68112, 68115], [68117, 68119], [68121, 68147], [68160, 68167], [68176, 68184], [68192, 68223], [68352, 68405], [68416, 68437], [68440, 68466], [68472, 68479], [68608, 68680], [126464, 126467], [126469, 126495], [126497, 126498], [126500, 126500], [126503, 126503], [126505, 126514], [126516, 126519], [126521, 126521], [126523, 126523], [126530, 126530], [126535, 126535], [126537, 126537], [126539, 126539], [126541, 126543], [126545, 126546], [126548, 126548], [126551, 126551], [126553, 126553], [126555, 126555], [126557, 126557], [126559, 126559], [126561, 126562], [126564, 126564], [126567, 126570], [126572, 126578], [126580, 126583], [126585, 126588], [126590, 126590], [126592, 126601], [126603, 126619], [126625, 126627], [126629, 126633], [126635, 126651], [1114109, 1114109]];
            class oy {
                applyStyles(e, t) {
                    for (var i in t = t || this.div,
                    e)
                        e.hasOwnProperty(i) && (t.style[i] = e[i])
                }
                formatStyle(e, t) {
                    return 0 === e ? "0" : e + t
                }
            }
            class ly extends (sd.StyleBox = oy) {
                constructor(e, t, i, r, n) {
                    super();
                    var a = {
                        start: "left",
                        "line-left": "left",
                        left: "left",
                        center: "center",
                        middle: "center",
                        "line-right": "right",
                        right: "right",
                        end: "right"
                    }[(this.cue = t).positionAlign] || t.align
                      , a = {
                        textAlign: a = "middle" === a ? "center" : a,
                        whiteSpace: "pre-line",
                        position: "absolute"
                    }
                      , s = (a.direction = this.determineBidi(this.cueDiv),
                    a.writingMode = this.directionSettingToWritingMode(t.vertical),
                    a.unicodeBidi = "plaintext",
                    this.div = e.document.createElement("div"),
                    this.applyStyles(a),
                    a = {
                        backgroundColor: r.backgroundColor,
                        display: "inline-block"
                    },
                    this.parseOpacity(a.backgroundColor) && (a.padding = "5px",
                    a.borderRadius = "5px"),
                    this.backgroundDiv = e.document.createElement("div"),
                    this.applyStyles(a, this.backgroundDiv),
                    (a = {
                        color: i.color,
                        backgroundColor: i.backgroundColor,
                        textShadow: i.textShadow,
                        fontSize: i.fontSize,
                        fontFamily: i.fontFamily,
                        position: "relative",
                        left: "0",
                        right: "0",
                        top: "0",
                        bottom: "0",
                        display: "inline-block",
                        textOrientation: "upright"
                    }).writingMode = this.directionSettingToWritingMode(t.vertical),
                    a.unicodeBidi = "plaintext",
                    this.cueDiv = pd.default.parseContent(e, t, n),
                    this.applyStyles(a, this.cueDiv),
                    this.backgroundDiv.appendChild(this.cueDiv),
                    this.div.appendChild(this.backgroundDiv),
                    0);
                    if ("number" == typeof t.position) {
                        r = t.positionAlign || t.align;
                        if (r)
                            switch (r) {
                            case "start":
                            case "left":
                                s = t.position;
                                break;
                            case "center":
                            case "middle":
                                s = t.position - t.size / 2;
                                break;
                            case "end":
                            case "right":
                                s = t.position - t.size
                            }
                    }
                    "" === t.vertical ? this.applyStyles({
                        left: this.formatStyle(s, "%"),
                        width: this.formatStyle(t.size, "%")
                    }) : this.applyStyles({
                        top: this.formatStyle(s, "%"),
                        height: this.formatStyle(t.size, "%")
                    })
                }
                determineBidi(e) {
                    var t = []
                      , i = "";
                    if (e && e.childNodes)
                        for (a(t, e); i = function e(t) {
                            var i, r, n;
                            return t && t.length ? (r = (i = t.pop()).textContent || i.innerText) ? (n = /^.*(\n|\r)/.exec(r)) ? (t.length = 0,
                            n[0]) : r : "ruby" === i.tagName ? e(t) : i.childNodes ? (a(t, i),
                            e(t)) : void 0 : null
                        }(t); )
                            for (var r = 0; r < i.length; r++)
                                if (function(e, t) {
                                    for (var i of t)
                                        if (e >= i[0] && e <= i[1])
                                            return !0;
                                    return !1
                                }(i.charCodeAt(r), fd))
                                    return "rtl";
                    return "ltr";
                    function a(e, t) {
                        for (var i = t.childNodes.length - 1; 0 <= i; i--)
                            e.push(t.childNodes[i])
                    }
                }
                parseOpacity(e) {
                    return e && "string" == typeof e && (e = (e = e.replace(/ /g, "").replace("rgba(", "").replace(")", "")).split(",")) && 4 <= e.length ? e[3] : null
                }
                directionSettingToWritingMode(e) {
                    return "" === e ? "horizontal-tb" : "lr" === e ? "vertical-lr" : "vertical-rl"
                }
                move(e) {
                    this.applyStyles({
                        top: this.formatStyle(e.top, "px"),
                        bottom: this.formatStyle(e.bottom, "px"),
                        left: this.formatStyle(e.left, "px"),
                        right: this.formatStyle(e.right, "px"),
                        height: this.formatStyle(e.height, "px"),
                        width: this.formatStyle(e.width, "px")
                    })
                }
            }
            sd.CueStyleBox = ly;
            class dy {
                constructor(e) {
                    var t, i, r, n, a, s, o;
                    e instanceof ly && e.cue ? (s = e.cue) && "" !== s.vertical ? this.property = "width" : this.property = "height" : e instanceof dy && (this.property = e.property || "height"),
                    e instanceof ly && e.div ? (r = e.div.offsetHeight,
                    n = e.div.offsetWidth,
                    a = e.div.offsetTop,
                    o = (i = ((s = e.div.firstChild) || e.div).getBoundingClientRect()) && i[this.property] || null,
                    s && s.firstChild && (s = s.firstChild) && "string" == typeof s.textContent && (t = o / this.calculateNewLines(s.textContent))) : e instanceof dy && (i = e),
                    this.left = i.left,
                    this.right = i.right,
                    this.top = i.top || a,
                    this.height = i.height || r,
                    this.bottom = i.bottom || a + (i.height || r),
                    this.width = i.width || n,
                    this.lineHeight = null !== o ? o : i.lineHeight,
                    this.singleLineHeight = null !== t ? t : i.singleLineHeight,
                    this.singleLineHeight || (this.singleLineHeight = 41)
                }
                calculateNewLines(e) {
                    for (var t = 1, i = 0; i < e.length; i++)
                        "\n" === e[i] && t++;
                    return t
                }
                move(e, t) {
                    switch (t = void 0 !== t ? t : this.singleLineHeight,
                    e) {
                    case "+x":
                        this.left += t,
                        this.right += t;
                        break;
                    case "-x":
                        this.left -= t,
                        this.right -= t;
                        break;
                    case "+y":
                        this.top += t,
                        this.bottom += t;
                        break;
                    case "-y":
                        this.top -= t,
                        this.bottom -= t
                    }
                }
                overlaps(e) {
                    return this.left < e.right && this.right > e.left && this.top < e.bottom && this.bottom > e.top
                }
                overlapsAny(e) {
                    for (var t of e)
                        if (this.overlaps(t))
                            return !0;
                    return !1
                }
                within(e) {
                    return this.top >= e.top && this.bottom <= e.bottom && this.left >= e.left && this.right <= e.right
                }
                moveIfOutOfBounds(e, t) {
                    switch (t) {
                    case "+x":
                        this.left < e.left && (this.left = e.left,
                        this.right = this.left + this.width);
                        break;
                    case "-x":
                        this.right > e.right && (this.right = e.right,
                        this.left = this.right - this.width);
                        break;
                    case "+y":
                        this.top < e.top && (this.top = e.top,
                        this.bottom = this.top + this.height);
                        break;
                    case "-y":
                        this.bottom > e.bottom && (this.bottom = e.bottom,
                        this.top = this.bottom - this.height)
                    }
                }
                toCSSCompatValues(e) {
                    return {
                        top: this.top - e.top,
                        bottom: e.bottom - this.bottom,
                        left: this.left - e.left,
                        right: e.right - this.right,
                        height: this.height,
                        width: this.width
                    }
                }
                static getSimpleBoxPosition(e) {
                    var t = null
                      , e = (e instanceof oy && e.div ? t = e.div : e instanceof HTMLElement && (t = e),
                    t.offsetHeight || 0)
                      , i = t.offsetWidth || 0
                      , r = t.offsetTop || 0
                      , n = r + e
                      , t = t.getBoundingClientRect()
                      , {left: a, right: s} = t;
                    return t.top && (r = t.top),
                    t.height && (e = t.height),
                    t.width && (i = t.width),
                    {
                        left: a,
                        right: s,
                        top: r,
                        height: e,
                        bottom: n = t.bottom ? t.bottom : n,
                        width: i
                    }
                }
                static getBoxPosition(e, t) {
                    if (e && 0 < e.length) {
                        for (var i = 0, r = e[0][t], n = 0; n < e.length; n++)
                            t in ["top", "right"] ? e[n][t] > r && (r = e[i = n][t]) : t in ["bottom", "left"] && e[n][t] < r && (r = e[i = n][t]);
                        return e[i]
                    }
                    return null
                }
                static moveToMinimumDistancePlacement(e, t, i) {
                    "height" === e.property ? "+y" === t ? (e.top = i.topMostBoxPosition.bottom + 0,
                    e.bottom = e.top + e.height) : "-y" === t && (e.bottom = i.bottomMostBoxPosition.top - 0,
                    e.top = e.bottom - e.height) : "width" === e.property && ("+x" === t ? (e.left = i.rightMostBoxPosition.right + 0,
                    e.right = e.left + e.width) : "-x" === t && (e.right = i.leftMostBoxPosition.left - 0,
                    e.left = e.right - e.width))
                }
                static moveBoxToLinePosition(e, s, o) {
                    var t, n = e.cue, i = new dy(e), r = function() {
                        if ("number" == typeof n.line && (n.snapToLines || 0 <= n.line && n.line <= 100))
                            return n.line;
                        if (!n.track || !n.track.textTrackList || !n.track.textTrackList.mediaElement)
                            return -1;
                        for (var e = 0, t = n.track, i = t.textTrackList, r = 0; r < i.length && i[r] !== t; r++)
                            "showing" === i[r].mode && e++;
                        return -1 * ++e
                    }(), a = [];
                    if (n.snapToLines) {
                        var l = 0;
                        switch (n.vertical) {
                        case "":
                            a = ["+y", "-y"],
                            t = "height";
                            break;
                        case "rl":
                            a = ["+x", "-x"],
                            t = "width";
                            break;
                        case "lr":
                            a = ["-x", "+x"],
                            t = "width"
                        }
                        var d = i.lineHeight
                          , u = s[t] + d
                          , c = a[0];
                        if (r < 0) {
                            var h = 0;
                            switch (n.vertical) {
                            case "":
                                h = s.height - d - .05 * s.height;
                                break;
                            case "rl":
                            case "lr":
                                h = -s.width + d + .05 * s.width
                            }
                            l = h,
                            a = a.reverse()
                        } else {
                            switch (n.vertical) {
                            case "":
                            case "lr":
                                l = d * Math.round(r);
                                break;
                            case "rl":
                                l = s.width - d * Math.round(r)
                            }
                            Math.abs(l) > u && (l = l < 0 ? -1 : 1,
                            l *= Math.ceil(u / d) * d)
                        }
                        i.move(c, l)
                    } else {
                        var u = "" === n.vertical ? s.height : s.width
                          , p = i.lineHeight / u * 100;
                        switch (n.lineAlign) {
                        case "center":
                        case "middle":
                            r -= p / 2;
                            break;
                        case "end":
                            r -= p
                        }
                        switch (n.vertical) {
                        case "":
                            e.applyStyles({
                                top: e.formatStyle(r, "%")
                            });
                            break;
                        case "rl":
                            e.applyStyles({
                                right: e.formatStyle(r, "%")
                            });
                            break;
                        case "lr":
                            e.applyStyles({
                                left: e.formatStyle(r, "%")
                            })
                        }
                        a = ["+y", "-y", "+x", "-x"],
                        "+y" === n.axis ? a = ["+y", "-y", "+x", "-x"] : "-y" === n.axis && (a = ["-y", "+y", "+x", "-x"]),
                        i = new dy(e)
                    }
                    c = function(e, t) {
                        for (var i, r = 0; r < t.length; r++) {
                            e.moveIfOutOfBounds(s, t[r]);
                            for (var n = 0, a = !1; e.overlapsAny(o) && !(9 < n); )
                                a ? e.move(t[r]) : (o && 0 < o.length && (i = i || {
                                    topMostBoxPosition: dy.getBoxPosition(o, "top"),
                                    bottomMostBoxPosition: dy.getBoxPosition(o, "bottom"),
                                    leftMostBoxPosition: dy.getBoxPosition(o, "left"),
                                    rightMostBoxPosition: dy.getBoxPosition(o, "right")
                                },
                                dy.moveToMinimumDistancePlacement(e, t[r], i)),
                                a = !0),
                                n++
                        }
                        return e
                    }(i, a);
                    e.move(c.toCSSCompatValues(s))
                }
            }
            sd.BoxPosition = dy;
            class uy {
                constructor(e, t) {
                    var i = !(2 < arguments.length && void 0 !== arguments[2]) || arguments[2];
                    if (!e)
                        return null;
                    this.window = e,
                    this.overlay = t,
                    this.loggingEnabled = i,
                    this.foregroundStyleOptions = {
                        fontFamily: "Helvetica",
                        fontSize: "36px",
                        color: "rgba(255, 255, 255, 1)",
                        textShadow: "",
                        backgroundColor: "rgba(0, 0, 0, 0)"
                    },
                    this.backgroundStyleOptions = {
                        backgroundColor: "rgba(0, 0, 0, 0.5)"
                    },
                    this.globalStyleCollection = {};
                    i = e.document.createElement("div");
                    i.style.position = "absolute",
                    i.style.left = "0",
                    i.style.right = "0",
                    i.style.top = "0",
                    i.style.bottom = "0",
                    i.style.margin = "1.5%",
                    this.paddedOverlay = i,
                    t.appendChild(this.paddedOverlay),
                    this.initSubtitleCSS()
                }
                initSubtitleCSS() {
                    var e = [new hd.VTTCue(0,0,"String to init CSS - Won't be visible to user")];
                    this.paddedOverlay.style.opacity = "0",
                    this.processCues(e),
                    this.processCues([]),
                    this.paddedOverlay.style.opacity = "1"
                }
                convertCueToDOMTree(e) {
                    return e ? pd.default.parseContent(this.window, e, this.globalStyleCollection) : null
                }
                setStyles(e) {
                    function t(e, t, i) {
                        for (var r in t)
                            t.hasOwnProperty(r) && (!0 === i && void 0 !== e[r] || !1 === i) && (e[r] = t[r])
                    }
                    for (var i in e) {
                        var r = !1
                          , n = null
                          , a = ("::cue" === i ? (n = this.foregroundStyleOptions,
                        r = !0) : "::-webkit-media-text-track-display" === i && (n = this.backgroundStyleOptions,
                        r = !0),
                        e[i]);
                        if (!0 === r)
                            t(n, a, r);
                        else
                            for (var s = 0; s < md.length; s++) {
                                var o, l = md[s].exec(i);
                                l && 4 === l.length && (l = l[2],
                                t(o = {}, a, r),
                                this.globalStyleCollection[l] = o)
                            }
                    }
                    this.initSubtitleCSS(),
                    this.loggingEnabled && (console.log("WebVTTRenderer setStyles foregroundStyleOptions: " + JSON.stringify(this.foregroundStyleOptions)),
                    console.log("WebVTTRenderer setStyles backgroundStyleOptions: " + JSON.stringify(this.backgroundStyleOptions)),
                    console.log("WebVTTRenderer setStyles globalStyleCollection: " + JSON.stringify(this.globalStyleCollection)))
                }
                processCues(e) {
                    if (e) {
                        for (; this.paddedOverlay.firstChild; )
                            this.paddedOverlay.removeChild(this.paddedOverlay.firstChild);
                        if (function(e) {
                            for (var t = 0; t < e.length; t++)
                                if (e[t].hasBeenReset || !e[t].displayState)
                                    return !0;
                            return !1
                        }(e)) {
                            var t = []
                              , i = dy.getSimpleBoxPosition(this.paddedOverlay);
                            1 < e.length && (e = function(e) {
                                for (var t = [], i = 0, r = 0; r < e.length; r++) {
                                    var n = e[r];
                                    if ("number" != typeof n.line)
                                        return e;
                                    i += n.line,
                                    t.push(n)
                                }
                                return 50 < (i /= e.length) ? (t.forEach(function(e) {
                                    e.axis = "-y"
                                }),
                                t.sort( (e, t) => t.line - e.line)) : (t.forEach(function(e) {
                                    e.axis = "+y"
                                }),
                                t.sort( (e, t) => e.line - t.line)),
                                t
                            }(e));
                            for (var r = 0; r < e.length; r++) {
                                var n = e[r]
                                  , a = new ly(this.window,n,this.foregroundStyleOptions,this.backgroundStyleOptions,this.globalStyleCollection);
                                this.paddedOverlay.appendChild(a.div),
                                dy.moveBoxToLinePosition(a, i, t),
                                n.displayState = a.div,
                                t.push(dy.getSimpleBoxPosition(a))
                            }
                        } else
                            for (var s = 0; s < e.length; s++)
                                this.paddedOverlay.appendChild(e[s].displayState)
                    }
                }
                setSize(e, t) {
                    e && (this.overlay.style.width = e + "px"),
                    t && (this.overlay.style.height = t + "px")
                }
                getOverlay() {
                    return this.overlay
                }
            }
            sd.default = uy,
            sd.WebVTTRenderer = uy,
            e(rd, sd)
        }
        r = Gl,
        ud = t && t.__createBinding || (Object.create ? function(e, t, i, r) {
            void 0 === r && (r = i),
            Object.defineProperty(e, r, {
                enumerable: !0,
                get: function() {
                    return t[i]
                }
            })
        }
        : function(e, t, i, r) {
            e[r = void 0 === r ? i : r] = t[i]
        }
        ),
        $l = t && t.__exportStar || function(e, t) {
            for (var i in e)
                "default" === i || t.hasOwnProperty(i) || ud(t, e, i)
        }
        ,
        Object.defineProperty(r, "__esModule", {
            value: !0
        }),
        $l(i, r),
        $l(ed, r);
        const gd = 9e4;
        function yd(e, t, i) {
            return e.substr(i || 0, t.length) === t
        }
        function vd(e) {
            var t = Math.floor(e)
              , i = t + .5
              , r = t + 1;
            return i <= e ? r - e <= e - i ? r : i : i - e <= e - t ? i : t
        }
        function Sd(e, t=0, i=8589934592) {
            return Number.isFinite(t) ? t + (t < e ? -1 : 1) * (i / 2 < (t = Math.abs(e - t) % i) ? i - t : -t) : e
        }
        function Id(e) {
            let t = e;
            return Td.hasOwnProperty(e) && (t = Td[e]),
            String.fromCharCode(t)
        }
        function bd(t) {
            var i = [];
            for (let e = 0; e < t.length; e++)
                i.push(t[e].toString(16));
            return i
        }
        const Td = {
            42: 225,
            92: 233,
            94: 237,
            95: 243,
            96: 250,
            123: 231,
            124: 247,
            125: 209,
            126: 241,
            127: 9608,
            128: 174,
            129: 176,
            130: 189,
            131: 191,
            132: 8482,
            133: 162,
            134: 163,
            135: 9834,
            136: 224,
            137: 32,
            138: 232,
            139: 226,
            140: 234,
            141: 238,
            142: 244,
            143: 251,
            144: 193,
            145: 201,
            146: 211,
            147: 218,
            148: 220,
            149: 252,
            150: 8216,
            151: 161,
            152: 42,
            153: 8217,
            154: 9473,
            155: 169,
            156: 8480,
            157: 8226,
            158: 8220,
            159: 8221,
            160: 192,
            161: 194,
            162: 199,
            163: 200,
            164: 202,
            165: 203,
            166: 235,
            167: 206,
            168: 207,
            169: 239,
            170: 212,
            171: 217,
            172: 249,
            173: 219,
            174: 171,
            175: 187,
            176: 195,
            177: 227,
            178: 205,
            179: 204,
            180: 236,
            181: 210,
            182: 242,
            183: 213,
            184: 245,
            185: 123,
            186: 125,
            187: 92,
            188: 94,
            189: 95,
            190: 124,
            191: 8764,
            192: 196,
            193: 228,
            194: 214,
            195: 246,
            196: 223,
            197: 165,
            198: 164,
            199: 9475,
            200: 197,
            201: 229,
            202: 216,
            203: 248,
            204: 9487,
            205: 9491,
            206: 9495,
            207: 9499
        }
          , Ed = 15
          , Ad = 100
          , Od = {
            17: 1,
            18: 3,
            21: 5,
            22: 7,
            23: 9,
            16: 11,
            19: 12,
            20: 14
        }
          , Rd = {
            17: 2,
            18: 4,
            21: 6,
            22: 8,
            23: 10,
            19: 13,
            20: 15
        }
          , wd = {
            25: 1,
            26: 3,
            29: 5,
            30: 7,
            31: 9,
            24: 11,
            27: 12,
            28: 14
        }
          , Pd = {
            25: 2,
            26: 4,
            29: 6,
            30: 8,
            31: 10,
            27: 13,
            28: 15
        }
          , Md = ["white", "green", "blue", "cyan", "red", "yellow", "magenta", "black", "transparent"]
          , Cd = {
            verboseFilter: {
                DATA: 3,
                DEBUG: 3,
                INFO: 2,
                WARNING: 2,
                TEXT: 1,
                ERROR: 0
            },
            time: null,
            verboseLevel: 0,
            setTime: function(e) {
                this.time = e
            },
            log: function(e, t) {
                var i = this.verboseFilter[e];
                this.verboseLevel >= i && console.log(this.time + " [" + e + "] " + t)
            }
        };
        class kd {
            constructor(e, t, i, r, n) {
                this.foreground = e || "white",
                this.underline = t || !1,
                this.italics = i || !1,
                this.background = r || "black",
                this.flash = n || !1
            }
            reset() {
                this.foreground = "white",
                this.underline = !1,
                this.italics = !1,
                this.background = "black",
                this.flash = !1
            }
            setStyles(e) {
                Object.assign(this, e)
            }
            isDefault() {
                return "white" === this.foreground && !this.underline && !this.italics && "black" === this.background && !this.flash
            }
            equals(e) {
                return this.foreground === e.foreground && this.underline === e.underline && this.italics === e.italics && this.background === e.background && this.flash === e.flash
            }
            copy(e) {
                this.foreground = e.foreground,
                this.underline = e.underline,
                this.italics = e.italics,
                this.background = e.background,
                this.flash = e.flash
            }
            toString() {
                return "color=" + this.foreground + ", underline=" + this.underline + ", italics=" + this.italics + ", background=" + this.background + ", flash=" + this.flash
            }
        }
        class Ld {
            constructor(e, t, i, r, n, a) {
                this.uchar = e || " ",
                this.penState = new kd(t,i,r,n,a)
            }
            reset() {
                this.uchar = " ",
                this.penState.reset()
            }
            setChar(e, t) {
                this.uchar = e,
                this.penState.copy(t)
            }
            setPenState(e) {
                this.penState.copy(e)
            }
            equals(e) {
                return this.uchar === e.uchar && this.penState.equals(e.penState)
            }
            copy(e) {
                this.uchar = e.uchar,
                this.penState.copy(e.penState)
            }
            isEmpty() {
                return " " === this.uchar && this.penState.isDefault()
            }
        }
        class Nd {
            constructor() {
                this.cueStartTime = null,
                this.chars = [];
                for (let e = 0; e < Ad; e++)
                    this.chars.push(new Ld);
                this.si = 0,
                this.oi = new kd
            }
            equals(t) {
                let i = !0;
                for (let e = 0; e < Ad; e++)
                    if (!this.chars[e].equals(t.chars[e])) {
                        i = !1;
                        break
                    }
                return i
            }
            copy(t) {
                for (let e = 0; e < Ad; e++)
                    this.chars[e].copy(t.chars[e])
            }
            isEmpty() {
                let t = !0;
                for (let e = 0; e < Ad; e++)
                    if (!this.chars[e].isEmpty()) {
                        t = !1;
                        break
                    }
                return t
            }
            setCursor(e) {
                this.si !== e && (this.si = e),
                this.si < 0 ? (Cd.log("ERROR", "Negative cursor position " + this.si),
                this.si = 0) : this.si > Ad && (Cd.log("ERROR", "Too large cursor position " + this.si),
                this.si = Ad)
            }
            moveCursor(e) {
                var t = this.si + e;
                if (1 < e)
                    for (let e = this.si + 1; e < t + 1; e++)
                        this.chars[e].setPenState(this.oi);
                this.setCursor(t)
            }
            backSpace() {
                this.moveCursor(-1),
                this.chars[this.si].setChar(" ", this.oi)
            }
            insertChar(e) {
                144 <= e && this.backSpace();
                var t = Id(e);
                this.si >= Ad ? Cd.log("ERROR", "Cannot insert " + e.toString(16) + " (" + t + ") at position " + this.si + ". Skipping it!") : (this.chars[this.si].setChar(t, this.oi),
                this.moveCursor(1))
            }
            clearFromPos(e) {
                let t;
                for (t = e; t < Ad; t++)
                    this.chars[t].reset()
            }
            clear() {
                this.clearFromPos(0),
                this.si = 0,
                this.oi.reset()
            }
            clearToEndOfRow() {
                this.clearFromPos(this.si)
            }
            getTextString() {
                var t = [];
                let i = !0;
                for (let e = 0; e < Ad; e++) {
                    var r = this.chars[e].uchar;
                    " " !== r && (i = !1),
                    t.push(r)
                }
                return i ? "" : t.join("")
            }
            setPenStyles(e) {
                this.oi.setStyles(e),
                this.chars[this.si].setPenState(this.oi)
            }
        }
        class Dd {
            constructor() {
                this.nrRollUpRows = null,
                this.lastOutputScreen = null,
                this.rows = [];
                for (let e = 0; e < Ed; e++)
                    this.rows.push(new Nd);
                this.ai = 14,
                this.reset()
            }
            reset() {
                for (let e = 0; e < Ed; e++)
                    this.rows[e].clear();
                this.ai = 14
            }
            equals(t) {
                let i = !0;
                for (let e = 0; e < Ed; e++)
                    if (!this.rows[e].equals(t.rows[e])) {
                        i = !1;
                        break
                    }
                return i
            }
            copy(t) {
                for (let e = 0; e < Ed; e++)
                    this.rows[e].copy(t.rows[e])
            }
            isEmpty() {
                let t = !0;
                for (let e = 0; e < Ed; e++)
                    if (!this.rows[e].isEmpty()) {
                        t = !1;
                        break
                    }
                return t
            }
            backSpace() {
                this.rows[this.ai].backSpace()
            }
            clearToEndOfRow() {
                this.rows[this.ai].clearToEndOfRow()
            }
            insertChar(e) {
                this.rows[this.ai].insertChar(e)
            }
            setPen(e) {
                this.rows[this.ai].setPenStyles(e)
            }
            moveCursor(e) {
                this.rows[this.ai].moveCursor(e)
            }
            setCursor(e) {
                Cd.log("INFO", "setCursor: " + e),
                this.rows[this.ai].setCursor(e)
            }
            setPAC(t) {
                var i;
                Cd.log("INFO", "pacData = " + JSON.stringify(t));
                let r = t.row - 1;
                if (this.nrRollUpRows && r < this.nrRollUpRows - 1 && (r = this.nrRollUpRows - 1),
                this.nrRollUpRows && this.ai !== r) {
                    for (let e = 0; e < Ed; e++)
                        this.rows[e].clear();
                    const t = this.ai + 1 - this.nrRollUpRows
                      , i = this.lastOutputScreen;
                    if (i) {
                        const e = i.rows[t].cueStartTime;
                        if (re(e) && re(Cd.time) && e < Cd.time)
                            for (let e = 0; e < this.nrRollUpRows; e++)
                                this.rows[r - this.nrRollUpRows + e + 1].copy(i.rows[t + e])
                    }
                }
                this.ai = r;
                const e = this.rows[this.ai];
                if (null !== t.indent) {
                    const r = t.indent
                      , n = Math.max(r - 1, 0);
                    e.setCursor(t.indent),
                    t.color = null != (i = e.chars[n].penState.foreground) ? i : ""
                }
                const n = {
                    foreground: t.color,
                    underline: t.underline,
                    italics: t.italics,
                    background: "black",
                    flash: !1
                };
                this.setPen(n)
            }
            setBkgData(e) {
                Cd.log("INFO", "bkgData = " + JSON.stringify(e)),
                this.backSpace(),
                this.setPen(e),
                this.insertChar(32)
            }
            setRollUpRows(e) {
                this.nrRollUpRows = e
            }
            rollUp() {
                var e;
                null === this.nrRollUpRows ? Cd.log("DEBUG", "roll_up but nrRollUpRows not set yet") : (Cd.log("INFO", "TEXT " + this.getDisplayText()),
                e = this.ai + 1 - this.nrRollUpRows,
                (e = this.rows.splice(e, 1)[0]).clear(),
                this.rows.splice(this.ai, 0, e),
                Cd.log("INFO", "Rolling up"))
            }
            getDisplayText(t) {
                t = t || !1;
                var i = [];
                let e = "", r;
                for (let e = 0; e < Ed; e++) {
                    var n = this.rows[e].getTextString();
                    n && (r = e + 1,
                    i.push(t ? "Row " + r + ": '" + n + "'" : n.trim()))
                }
                return e = 0 < i.length ? t ? "[" + i.join(" | ") + "]" : i.join("\n") : e
            }
            getTextAndFormat() {
                return this.rows
            }
        }
        class xd {
            constructor(e, t) {
                this.li = null,
                this.cueStartTime = null,
                this.lastCueEndTime = null,
                this.ci = e,
                this.hi = t,
                this.di = 0,
                this.fi = new Dd,
                this.vi = new Dd,
                this.pi = new Dd,
                this.yi = this.fi.rows[14],
                this.gi = this.fi
            }
            reset() {
                this.li = null,
                this.fi.reset(),
                this.vi.reset(),
                this.pi.reset(),
                this.yi = this.fi.rows[14],
                this.gi = this.fi,
                this.li = null,
                this.cueStartTime = null,
                this.lastCueEndTime = null
            }
            getHandler() {
                return this.hi
            }
            setHandler(e) {
                this.hi = e
            }
            setPAC(e) {
                this.gi.setPAC(e)
            }
            setBkgData(e) {
                this.gi.setBkgData(e)
            }
            setMode(e) {
                e !== this.li && (this.li = e,
                Cd.log("INFO", "MODE=" + e),
                "MODE_POP-ON" === this.li ? this.gi = this.vi : (this.gi = this.fi,
                this.gi.reset()),
                "MODE_ROLL-UP" !== this.li && (this.fi.nrRollUpRows = null,
                this.vi.nrRollUpRows = null),
                this.li = e)
            }
            insertChars(t) {
                for (let e = 0; e < t.length; e++)
                    this.gi.insertChar(t[e]);
                var e = this.gi === this.fi ? "DISP" : "NON_DISP";
                Cd.log("INFO", e + ": " + this.gi.getDisplayText(!0)),
                "MODE_PAINT-ON" !== this.li && "MODE_ROLL-UP" !== this.li || (Cd.log("TEXT", "DISPLAYED: " + this.fi.getDisplayText(!0)),
                this.outputDataUpdate())
            }
            ccRCL() {
                Cd.log("INFO", "RCL - Resume Caption Loading"),
                this.setMode("MODE_POP-ON")
            }
            ccBS() {
                Cd.log("INFO", "BS - BackSpace"),
                "MODE_TEXT" !== this.li && (this.gi.backSpace(),
                this.gi === this.fi) && this.outputDataUpdate()
            }
            ccAOF() {}
            ccAON() {}
            ccDER() {
                Cd.log("INFO", "DER- Delete to End of Row"),
                this.gi.clearToEndOfRow(),
                this.outputDataUpdate()
            }
            ccRU(e) {
                Cd.log("INFO", "RU(" + e + ") - Roll Up"),
                this.gi = this.fi,
                this.setMode("MODE_ROLL-UP"),
                this.gi.setRollUpRows(e)
            }
            ccFON() {
                Cd.log("INFO", "FON - Flash On"),
                this.gi.setPen({
                    flash: !0
                })
            }
            ccRDC() {
                Cd.log("INFO", "RDC - Resume Direct Captioning"),
                this.setMode("MODE_PAINT-ON")
            }
            ccTR() {
                Cd.log("INFO", "TR"),
                this.setMode("MODE_TEXT")
            }
            ccRTD() {
                Cd.log("INFO", "RTD"),
                this.setMode("MODE_TEXT")
            }
            ccEDM() {
                Cd.log("INFO", "EDM - Erase Displayed Memory"),
                this.fi.reset(),
                this.outputDataUpdate(!0)
            }
            ccCR() {
                Cd.log("INFO", "CR - Carriage Return"),
                this.gi.rollUp(),
                this.outputDataUpdate(!0)
            }
            ccENM() {
                Cd.log("INFO", "ENM - Erase Non-displayed Memory"),
                this.vi.reset()
            }
            ccEOC() {
                var e;
                Cd.log("INFO", "EOC - End Of Caption"),
                "MODE_POP-ON" === this.li && (e = this.fi,
                this.fi = this.vi,
                this.vi = e,
                this.gi = this.vi,
                Cd.log("TEXT", "DISP: " + this.fi.getDisplayText())),
                this.outputDataUpdate(!0)
            }
            ccTO(e) {
                Cd.log("INFO", "TO(" + e + ") - Tab Offset"),
                this.gi.moveCursor(e)
            }
            ccMIDROW(e) {
                var t = {
                    flash: !1,
                    underline: !1,
                    italics: !1
                };
                t.underline = e % 2 == 1,
                t.italics = 46 <= e,
                t.italics ? t.foreground = "white" : (e = Math.floor(e / 2) - 16,
                t.foreground = ["white", "green", "blue", "cyan", "red", "yellow", "magenta"][e]),
                Cd.log("INFO", "MIDROW: " + JSON.stringify(t)),
                this.gi.setPen(t)
            }
            outputDataUpdate(e=!1) {
                var t = Cd.time;
                null !== t && this.hi && (this.hi.updateData && this.hi.updateData(t, this.fi),
                null !== this.cueStartTime || this.fi.isEmpty() ? this.fi.equals(this.pi) || (this.hi.newCue && re(this.cueStartTime) && (this.hi.newCue(this.cueStartTime, t, this.pi),
                !0 === e) && this.hi.dispatchCue && this.hi.dispatchCue(),
                this.cueStartTime = this.fi.isEmpty() ? null : t) : this.cueStartTime = t,
                this.pi.copy(this.fi))
            }
            cueSplitAtTime(e) {
                !this.hi || this.fi.isEmpty() || (this.hi.newCue && re(this.cueStartTime) && this.hi.newCue(this.cueStartTime, e, this.fi),
                this.cueStartTime = e)
            }
        }
        var Fd, Bd, Ud = {
            newCue: function(e, t, i, r, n, a) {
                let s, o, l, d, u;
                var c, h, p = {
                    foreground: void 0,
                    background: void 0,
                    italics: !1,
                    underline: !1,
                    flash: !1,
                    styleStack: []
                };
                for ([c,h] of r.rows.entries())
                    if (o = !0,
                    l = 0,
                    d = "",
                    !h.isEmpty()) {
                        for (let e = 0; e < h.chars.length; e++)
                            h.chars[e].uchar.match(/\s/) && o ? l++ : (d += this.getFormattedChar(h.chars[e], p),
                            o = !1);
                        (h.cueStartTime = t) === i && (i += 1e-4),
                        d = d.trim().replace(/<br(?: \/)?>/gi, "\n"),
                        d += this.closeStyles(p),
                        s = new Gl.VTTCue(t,i,d),
                        16 <= l ? l-- : l++,
                        u = !navigator.userAgent.match(/Firefox\//) && 7 < c ? c : c + 1,
                        s.snapToLines = !1,
                        s.line = 10 + 5.33 * u,
                        s.align = "left",
                        s.position = this.getPosition(l, n, a),
                        e.addCue(s)
                    }
            },
            getPosition: function(e, t, i) {
                let r = 1.3333333333333333
                  , n = 10 + e / 32 * 80
                  , a = 10
                  , s = 90;
                return 1.7777777777777777 === (r = t && i && 1.6 <= t / i ? 1.7777777777777777 : r) && (n = 12.5 + .75 * n,
                a = 20,
                s = 80),
                Math.max(a, Math.min(s, n + (navigator.userAgent.match(/Firefox\//) ? 50 : 0)))
            },
            getRootStyleTag: function(e) {
                var t = e[0];
                return "c" === t ? t : e
            },
            closeStyles: function(t) {
                let i = "";
                for (let e = t.styleStack.length - 1; 0 <= e; --e)
                    i += "</" + this.getRootStyleTag(t.styleStack[e]) + ">",
                    t.styleStack.pop();
                return i
            },
            beginStyleAndBalance: function(e, t) {
                let i = "";
                return "c" === t[0] && (i += this.closeStyleAndBalance(e, "c")),
                i += "<" + t + ">",
                e.styleStack.push(t),
                i
            },
            closeStyleAndBalance: function(t, i) {
                var r = t.styleStack.length;
                let n = 0
                  , a = "";
                for (let e = r - 1; 0 <= e; --e) {
                    var s = t.styleStack[e]
                      , o = this.getRootStyleTag(s);
                    if (i[0] === s[0]) {
                        a += "</" + o + ">",
                        t.styleStack.splice(r - 1 - n);
                        break
                    }
                    "c" === o[0] ? (t.background = "",
                    t.foreground = "",
                    t.flash = !1,
                    a += "</c>") : "u" === o[0] ? (t.underline = !1,
                    a += "</u>") : "i" === o[0] && (t.italics = !1,
                    a += "</i>"),
                    n++
                }
                return a
            },
            getFormattedChar: function(e, t) {
                let i = ""
                  , r = e.uchar
                  , n = "";
                var a = e.penState.foreground !== t.foreground
                  , s = e.penState.background !== t.background
                  , o = e.penState.flash !== t.flash;
                return (a || s || o) && (n = "." + e.penState.foreground,
                n += ".bg_" + e.penState.background,
                e.penState.flash && o && (n += ".blink"),
                e.penState.foreground || e.penState.background || e.penState.blink ? i += this.beginStyleAndBalance(t, "c" + n) : i += this.closeStyleAndBalance(t, "c"),
                a && (t.foreground = e.penState.foreground),
                s && (t.background = e.penState.background),
                o) && (t.flash = null != (a = e.penState.flash) && a),
                e.penState.underline !== t.underline && (i += e.penState.underline ? this.beginStyleAndBalance(t, "u") : this.closeStyleAndBalance(t, "u"),
                t.underline = null != (s = e.penState.underline) && s),
                e.penState.italics !== t.italics && (i += e.penState.italics ? this.beginStyleAndBalance(t, "i") : this.closeStyleAndBalance(t, "i"),
                t.italics = null != (o = e.penState.italics) && o),
                i + r
            }
        };
        class _d {
            constructor(e, t) {
                this.bi = e,
                this.Si = t,
                this.wi = null,
                this.Ti = null,
                this.Ii = null
            }
            dispatchCue() {
                null !== this.wi && null !== this.Ti && (this.bi.addCues("cc" + this.Si, this.wi, this.Ti, this.Ii),
                this.wi = null)
            }
            newCue(e, t, i) {
                (null === this.wi || this.wi > e) && (this.wi = e),
                this.Ti = t,
                this.Ii = i,
                this.bi.createHTMLCaptionsTrack(this.Si)
            }
        }
        const Vd = 9e4
          , Qd = /^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/
          , Kd = /^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/
          , Hd = {
            extractXML(e) {
                e = k.findBox(e, ["mdat"]);
                return e.length ? Ee.utf8arrayToStr(e[0]) : ""
            },
            generateCues(e, t, a, i) {
                const r = (new DOMParser).parseFromString(e, "text/xml")
                  , n = r.getElementsByTagName("tt")[0]
                  , s = "preserve" !== n.getAttribute("xml:space")
                  , o = [];
                if (n) {
                    const l = S(t, Vd)
                      , d = {
                        frameRate: 30,
                        subFrameRate: 1,
                        frameRateMultiplier: 0,
                        tickRate: 0
                    }
                      , u = Object.keys(d).reduce( (e, t) => {
                        var i = n.getAttribute(`ttp:` + t)
                          , i = i && re(parseInt(i)) ? parseInt(i) : null;
                        return e[t] = i || d[t],
                        e
                    }
                    , {
                        frameRate: 30,
                        subFrameRate: 1,
                        frameRateMultiplier: 0,
                        tickRate: 0
                    });
                    r.querySelectorAll("p").forEach(e => {
                        var t = function r(e, n) {
                            return [].slice.call(e.childNodes).reduce( (e, t, i) => {
                                return "br" === t.nodeName && i ? e + "\n" : null != (i = t.childNodes) && i.length ? e + r(t, n) : n ? e + (null != (i = null == (i = t.textContent) ? void 0 : i.trim().replace(/\s+/g, " ")) ? i : "") : e + t.textContent
                            }
                            , "")
                        }(e, s)
                          , i = jd(e.getAttribute("begin"), u)
                          , r = jd(e.getAttribute("dur"), u);
                        let n = jd(e.getAttribute("end"), u);
                        !n && re(i) && r && (n = i + r);
                        r = P({
                            baseTime: Sd(Sd(0) - l.baseTime, a * Vd),
                            timescale: Vd
                        });
                        if (t && re(i) && re(n)) {
                            i = Sd(i + r - 0, 0, 95443.7176888889),
                            n = Sd(n + r - 0, 0, 95443.7176888889);
                            const e = new VTTCue(i,n,t);
                            e.id = U(vd(e.startTime).toString()) + U(vd(e.endTime - e.startTime).toString()) + U(e.text),
                            o.push(e)
                        }
                    }
                    )
                } else
                    i.error("[subtitle] Invalid ttml");
                return o
            }
        };
        function jd(e, t) {
            if (!e)
                return null;
            let i = e ? ([n,a,s] = e.split(":"),
            [s,r] = s.split("."),
            3600 * parseInt(n) + 60 * parseInt(a) + parseInt(s) + parseInt(r) / 1e3) : null;
            var r, n, a, s;
            return null === i && (Qd.test(e) ? i = (n = e,
            a = t,
            n = Qd.exec(n),
            s = (0 | n[4]) + (0 | n[5]) / a.subFrameRate,
            3600 * (0 | n[1]) + 60 * (0 | n[2]) + (0 | n[3]) + s / a.frameRate) : Kd.test(e) && (i = function(e, t) {
                var e = Kd.exec(e)
                  , i = Number(e[1]);
                switch (e[2]) {
                case "h":
                    return 3600 * i;
                case "m":
                    return 60 * i;
                case "ms":
                    return 1e3 * i;
                case "f":
                    return i / t.frameRate;
                case "t":
                    return i / t.tickRate
                }
                return i
            }(e, t))),
            i
        }
        (e = Fd = Fd || {}).CloseEnough = "CloseEnough",
        e.TooFar = "TooFar",
        e.Unknown = "Unknown",
        (rd = Bd = Bd || {})[rd.TryAgain = 1] = "TryAgain",
        rd[rd.Complete = 2] = "Complete";
        const qd = e => "cc1" === e || "cc2" === e;
        function Gd(t) {
            var i = [];
            for (let e = 0; e < t.length; e++) {
                var r = t[e];
                ("captions" === r.kind || "subtitles" === r.kind || "metadata" === r.kind && r.customTextTrackCueRenderer) && i.push(r)
            }
            return i
        }
        function $d(e) {
            if (e && e.cues)
                for (; 0 < e.cues.length; )
                    e.removeCue(e.cues[0])
        }
        class Wd extends G {
            constructor(e, t, i, r) {
                super(e => {
                    if (this.Oi) {
                        const t = dl(this.Oi, this);
                        if (e.add(t.event(L.INLINE_STYLES_PARSED, this.onInlineStylesParsed).pipe(ee( () => this.destroy())).subscribe()),
                        e.add(yr(0, this.Gt.trottleCheckInterval).pipe(te( () => (this.ki(),
                        ue))).subscribe()),
                        this.Gt.enableInterstitialPlayback && (this.Gt.nativeTextTrackChangeHandling = !1),
                        this.Gt.nativeTextTrackChangeHandling)
                            if (this.ze.textTracks && "onchange"in this.ze.textTracks) {
                                const t = dl(this.ze.textTracks, this);
                                e.add(t.event("change", this.Mi).subscribe())
                            } else
                                e.add(yr(0, 500).pipe(te( () => (this.Mi(),
                                ue))).subscribe())
                    }
                }
                ),
                this.Gt = t,
                this.Ei = NaN,
                this.Ai = NaN,
                this.Ni = !1,
                this.Ri = !1,
                this.Pi = !1,
                this.Ci = 0,
                this.Di = 0,
                this.xi = 0,
                this.Li = 0,
                this._i = new z,
                this.Fi = {},
                this.Oi = i,
                this.R = r.child({
                    name: "legible"
                }),
                this.ze = e,
                this.Ui = e.id3TextTrack,
                this.Bi = !0,
                this.$i = Ud,
                this.Vi = [],
                this.qi = [],
                this.Ki = {},
                this.Hi = {},
                this.zi = 0,
                this.gotTracks = !1,
                this.tryAgain$ = new pn(Bd.TryAgain),
                this.needNextSubtitle$ = new pn(!0)
            }
            reset() {
                this.resetTracks(),
                this.Qi = this.Gi = void 0,
                this.Wi = void 0,
                this.Xi = this.Yi = void 0
            }
            destroy() {
                this._i.next(),
                this.reset(),
                this.nativeSubtitleTrackChange$ = void 0,
                this.Fi = {},
                this.Oi = void 0
            }
            handlePlayingItemChanged(e) {
                var {playingInterstitialId: e, subtitleMediaOption: t} = e;
                this.Ri = !!e,
                this.Ji(t)
            }
            convertCuesIntoSubtitleFragInfo(t, i) {
                var r = {};
                if (null != t && 0 < t.length)
                    for (let e = 0; e < t.length; e++) {
                        var n, a = t[e];
                        re(a.fragSN) && a.itemId === i && ((n = r[a.fragSN]) ? (n.count++,
                        n.startTime = Math.min(a.startTime, n.startTime),
                        n.endTime = Math.max(a.endTime, n.endTime)) : r[a.fragSN] = {
                            count: 1,
                            startTime: a.startTime,
                            endTime: a.endTime
                        })
                    }
                return r
            }
            ki() {
                let e = !1;
                this.ze.mediaQuery.currentTime >= this.zi - this.Gt.subtitleLeadTime && (e = !0),
                this.needNextSubtitle$.next(e)
            }
            checkReadyToLoadNextSubtitleFragment$(e, t) {
                return e.mediaSeqNum === (null == (e = t[0]) ? void 0 : e.mediaSeqNum) ? Y(!0) : (this.ki(),
                this.needNextSubtitle$)
            }
            getNextFragment(e, t) {
                t = t.mediaSeqNum + 1;
                return t < e.fragments.length ? e.fragments[t - e.startSN] : null
            }
            Zi(e, t, i, r) {
                var n = this.convertCuesIntoSubtitleFragInfo(t, r.itemId);
                let a = {
                    len: 0,
                    start: e,
                    end: e
                }
                  , s = e
                  , o = e
                  , l = NaN
                  , d = NaN;
                for (const t in n)
                    if (Object.prototype.hasOwnProperty.call(n, t)) {
                        var u = Number(t);
                        if (re(u)) {
                            var c = n[u];
                            if (c && (!i || this.tn(u, c.count, i))) {
                                if (u === r.startSN && e < c.startTime && (s = o = a.start = a.end = e = c.startTime),
                                e >= c.startTime && (s === e || re(l) && 1 < u - l) && (s = o = c.startTime),
                                !(e >= c.startTime || re(l) && u - l == 1)) {
                                    d = u;
                                    break
                                }
                                o = c.endTime,
                                l = u
                            }
                        }
                    }
                return {
                    fragInfoMap: n,
                    bufferInfo: a = {
                        len: o - s,
                        start: s,
                        end: o
                    },
                    prevFragSN: l,
                    nextFragSN: d
                }
            }
            findFrags$(i, r, n) {
                return this.tryAgain$.next(Bd.TryAgain),
                this.tryAgain$.pipe(Pr(sr), te( () => {
                    var e = this.findFragmentsForPosition(n, r, i)
                      , t = e.foundFrags;
                    return t && 0 !== t.length ? (this.zi = 0,
                    this.needNextSubtitle$.next(!0),
                    Y(e)) : (this.tryAgain$.next(Bd.Complete),
                    X)
                }
                ), Pn(this.tryAgain$.pipe(Z(e => e === Bd.Complete))), ee( () => {}
                ))
            }
            reviewParsedFrag(i, r, n, a, e) {
                var s = r.frag
                  , o = r.cueRange
                  , t = n.subtitleBufferInfo
                  , l = n.subtitleParsedInfo
                  , r = n.foundFrags;
                let d = !0;
                if (s.gap)
                    return Fd.CloseEnough;
                if (r && r.length && s.mediaSeqNum === r[0].mediaSeqNum) {
                    if (this.selectedMediaOption == this.en && this.Ri)
                        return Fd.CloseEnough;
                    if (!n.timelineEstablished)
                        return e ? Fd.TooFar : Fd.CloseEnough;
                    if (!o)
                        return Fd.Unknown;
                    if (o.startTime < i) {
                        const r = a.fragments
                          , n = s.mediaSeqNum - a.startSN;
                        let e = n
                          , t = o.startTime;
                        for (; e < r.length && !((t += r[e].duration) >= i); ++e)
                            ;
                        d = e - n <= this.Gt.earlyFragTolerance
                    } else if (o.startTime > i && s.mediaSeqNum !== a.startSN) {
                        if (!t || !l)
                            return Fd.TooFar;
                        const r = o.startTime - i
                          , n = t.prevFragSN;
                        if (!re(n))
                            return Fd.TooFar;
                        d = s.mediaSeqNum === n + 1 && (null == (e = t.fragInfoMap[n]) ? void 0 : e.count) === (null == (a = l[n]) ? void 0 : a.count) || r <= this.Gt.lateTolerance
                    }
                }
                return d ? Fd.CloseEnough : Fd.TooFar
            }
            nn(e) {
                return e && !re(e.startTime) && 0 === e.count
            }
            tn(e, t, i) {
                i = i ? i[e] : null;
                return (null == i ? void 0 : i.count) === t || this.nn(i)
            }
            rn(e, t, i) {
                var r = t.mediaSeqNum - e.startSN - 1;
                return r < 0 || r > e.fragments.length - 1 ? (this.R.error(`[subtitle] getEarlierFragmentInSameDisco index ${r} out of range`),
                t) : (e = e.fragments[r]) && e.discoSeqNum === t.discoSeqNum && !i[t.mediaSeqNum] ? e : t
            }
            inferSubtitleFragmentForPosition(r, n, a, s, o) {
                var l, d, i, u;
                let c = null
                  , h = NaN
                  , e = null
                  , p = NaN
                  , m = null;
                if (s && a && re(s.prevFragSN) && (h = s.prevFragSN - o.startSN,
                e = a[s.prevFragSN]),
                s && a && re(s.nextFragSN) && (p = s.nextFragSN - o.startSN,
                m = a[s.nextFragSN]),
                s && a && re(h) && 0 <= h && h < o.fragments.length && e) {
                    let t = e.startTime
                      , i = null;
                    const u = re(p) ? p : o.fragments.length;
                    for (let e = h; e < u; ++e) {
                        const p = o.fragments[e];
                        if (!re(n) || p.discoSeqNum === n) {
                            if (!(i || re(n) && p.discoSeqNum !== n)) {
                                const r = null == (l = s.fragInfoMap[p.mediaSeqNum]) ? void 0 : l.count;
                                this.tn(p.mediaSeqNum, null != r ? r : 0, a) || (i = p)
                            }
                            if (e === u - 1) {
                                c = {
                                    foundFrag: p,
                                    timelineEstablished: !0
                                };
                                break
                            }
                            if (t + p.duration > r && e > h) {
                                c = {
                                    foundFrag: p,
                                    timelineEstablished: !0
                                };
                                break
                            }
                            t += p.duration
                        }
                    }
                    !c && i && (c = {
                        foundFrag: i,
                        timelineEstablished: !1
                    })
                } else if (s && a && re(p) && 0 <= p && p < o.fragments.length && m) {
                    let t = m.startTime
                      , i = null;
                    for (let e = p - 1; 0 <= e; --e) {
                        const h = o.fragments[e];
                        if (!re(n) || h.discoSeqNum === n) {
                            if (!re(n) || h.discoSeqNum === n) {
                                const r = null == (d = s.fragInfoMap[h.mediaSeqNum]) ? void 0 : d.count;
                                this.tn(h.mediaSeqNum, null != r ? r : 0, a) || (i = h)
                            }
                            if (t <= r) {
                                c = {
                                    foundFrag: h,
                                    timelineEstablished: !0
                                };
                                break
                            }
                            t -= h.duration
                        }
                    }
                    !c && i && (c = {
                        foundFrag: i,
                        timelineEstablished: !1
                    })
                } else {
                    let t = !0;
                    for (let e = 0; e < o.fragments.length; ++e) {
                        const h = o.fragments[e];
                        if (s && a && re(n) && h.discoSeqNum === n) {
                            const n = null != (u = null == (i = s.fragInfoMap[h.mediaSeqNum]) ? void 0 : i.count) ? u : 0;
                            if (!this.tn(h.mediaSeqNum, n, a) && (t = !1,
                            r >= h.start && r < h.start + h.duration)) {
                                c = {
                                    foundFrag: h,
                                    timelineEstablished: !1
                                };
                                break
                            }
                        }
                    }
                    t || (c = c || {
                        foundFrag: o.fragments[0],
                        timelineEstablished: !1
                    })
                }
                return c
            }
            sn(t, i, e, r, n, a) {
                var s, o, l = [], d = null == e ? void 0 : e.foundFrag;
                if (!d)
                    return {
                        foundFrags: void 0,
                        subtitleParsedInfo: void 0,
                        subtitleBufferInfo: void 0,
                        timelineEstablished: null != (s = null == e ? void 0 : e.timelineEstablished) && s
                    };
                for (let e = d ? d.mediaSeqNum - a.startSN : a.fragments.length; e < a.fragments.length && l.length < t; ++e) {
                    const t = a.fragments[e];
                    if (t.discoSeqNum === i && r && n) {
                        const i = null == (o = n.fragInfoMap[t.mediaSeqNum]) ? void 0 : o.count;
                        this.tn(t.mediaSeqNum, null != i ? i : 0, r) || l.push(t)
                    }
                }
                return {
                    foundFrags: l,
                    subtitleParsedInfo: null != r ? r : void 0,
                    subtitleBufferInfo: null != n ? n : void 0,
                    timelineEstablished: null == e ? void 0 : e.timelineEstablished
                }
            }
            findFragmentsForPosition(e, t, i) {
                let r = i.itemId + i.mediaOptionId;
                var n = this.availableMediaOptions.find(e => e.mediaOptionId === i.mediaOptionId);
                n && n.isInterstitial && (r = "interstitial");
                let a = this.ze.mediaQuery.getParsedSubtitleRecordsForMediaOption(r);
                this.Gt.condenseSubtitleTrack && n && re(n.persistentID) && !n.isInterstitial && (a && 0 < Object.keys(a).length ? this.Fi[n.persistentID] = a : this.Fi[n.persistentID] && (a = this.Fi[n.persistentID]));
                var n = this.getCuesOfEnabledTrack(null == (n = this.selectedMediaOption) ? void 0 : n.mediaOptionId, !1)
                  , n = this.Zi(e, n, a, i)
                  , s = n.bufferInfo
                  , e = Math.max(e, s.end)
                  , s = this.inferSubtitleFragmentForPosition(e, t, a, n, i);
                return this.sn(1 / 0, t, s, a, n, i)
            }
            get selectedMediaOption() {
                let e = this.an;
                return this.Ri && (e = this.en),
                this.selectedTrack || e
            }
            set selectedMediaOption(e) {
                this.selectedTrack = "groupId"in e ? e : void 0
            }
            get selectedTrack() {
                return this.Ri ? this.ln : this.un
            }
            set selectedTrack(e) {
                !this.Ni && e === this.un || this.Ni && e === this.ln || (null != e && e.isInterstitial ? this.ln = e : this.un = e,
                this.cn(e))
            }
            hn(t) {
                return this.availableMediaOptions.find(e => e.mediaOptionId === t)
            }
            cn(e) {
                var t;
                !this.ze.textTracks || e && e.isInterstitial && !this.Ri || e && !e.isInterstitial && this.Ri || (e = this.selectedTrack ? this.getExistingHTMLTextTrack(this.selectedTrack) : void 0,
                t = Gd(this.ze.textTracks),
                this.dn(t, e))
            }
            Ji(e) {
                var t;
                this.ze.textTracks && (t = Gd(this.ze.textTracks),
                e = e ? this.getExistingHTMLTextTrack(e) : void 0,
                this.dn(t, e))
            }
            dn(t, i) {
                for (let e = 0; e < t.length; e++) {
                    var r = t[e];
                    r === i && "showing" !== t[e].mode ? t[e].mode = "showing" : r !== i && "hidden" !== t[e].mode && (t[e].mode = "hidden")
                }
            }
            get availableMediaOptions() {
                var e;
                return this.Ri ? null != (e = this.fn) ? e : [] : null != (e = this.vn) ? e : []
            }
            Mi() {
                var r, n;
                if (this.ze && this.nativeSubtitleTrackChange$) {
                    let t = !1
                      , i = NaN;
                    var a = Gd(this.ze.textTracks);
                    for (let e = 0; e < a.length; e++)
                        a[e].seen ? "showing" === a[e].mode && (i = null != (n = this.selectedTrack) && n.isInterstitial ? null != (r = this.selectedTrack.persistentID) ? r : NaN : null != (n = a[e].persistentId) ? n : NaN) : (a[e].seen = !0,
                        t = !0);
                    if (!t) {
                        const n = this.selectedTrack;
                        if ((null == n ? void 0 : n.persistentID) !== i) {
                            const n = this.availableMediaOptions.find(function(e) {
                                return e.persistentID === i
                            })
                              , r = null != n ? n : this.an;
                            r && this.nativeSubtitleTrackChange$.next(r)
                        }
                    }
                }
            }
            addCues(e, t, i, r) {
                var n, a, s, o = this.qi;
                let l = !1;
                for (let e = o.length; e--; ) {
                    const r = o[e]
                      , d = (n = r[0],
                    a = r[1],
                    s = t,
                    Math.min(a, i) - Math.max(n, s));
                    if (0 <= d && (r[0] = Math.min(r[0], t),
                    r[1] = Math.max(r[1], i),
                    l = !0,
                    .5 < d / (i - t)))
                        return
                }
                let d;
                l || o.push([t, i]),
                d = (d = this.Pi ? this.Ki["i" + e] : d) || this.Ki[e],
                this.$i.newCue(d, t, i, r, this.ze.offsetWidth, this.ze.offsetHeight)
            }
            getExistingHTMLTextTrackWithChannelNumber(t) {
                var i = this.ze;
                if (i)
                    for (let e = 0; e < i.textTracks.length; e++) {
                        var r = i.textTracks[e]
                          , n = "cc" + t;
                        if (qd(n) && !0 === r[n])
                            return r
                    }
                return null
            }
            sendAddTrackEvent(e, t) {
                let i = null;
                try {
                    i = new window.Event("addtrack")
                } catch (e) {
                    (i = document.createEvent("Event")).initEvent("addtrack", !1, !1)
                }
                i.track = e,
                t.dispatchEvent(i)
            }
            createHTMLCaptionsTrackGuts(e, t, i, r) {
                var n = "cc" + e;
                if (!this.Ki[n]) {
                    e = this.getExistingHTMLTextTrackWithChannelNumber(e);
                    if (e)
                        this.Ki[n] = e,
                        $d(this.Ki[n]),
                        this.sendAddTrackEvent(this.Ki[n], this.ze);
                    else {
                        const e = this.createHTMLTextTrackGuts("captions", t, i, r);
                        e && qd(n) && (e[n] = !0,
                        this.Ki[n] = e)
                    }
                }
                return this.Ki[n]
            }
            createHTMLCaptionsTrack(e) {
                return this.createHTMLCaptionsTrackGuts(e, this.Gt[1 === e ? "captionsTextTrack1Label" : "captionsTextTrack2Label"], this.Gt.captionsTextTrack1LanguageCode, !1)
            }
            htmlTextTrackBelongToThisItem(e) {
                return Object.values(this.Hi).includes(e)
            }
            getExistingHTMLTextTrack(e) {
                var t;
                if (e.isInterstitial)
                    return e.mediaType === O.CLOSEDCAPTION ? 1 === this.pn(e) ? this.Xi : this.Yi : this.Wi;
                let i = this.Gt.condenseSubtitleTrack ? this.Hi[null != (t = e.persistentID) ? t : NaN] : this.Hi[e.id];
                return i || this.getExistingHTMLTextTrackFromPreviousItem(e) || (i = this.Gt.dynamicTextTrackCreation ? this.createHTMLTextTrack(e) : i)
            }
            getExistingHTMLTextTrackFromPreviousItem(t) {
                var i, r = t.mediaType === O.SUBTITLE ? "subtitles" : "captions", n = this.ze.textTracks;
                let a = -1;
                for (let e = 0; e < n.length; ++e) {
                    var s = n[e];
                    if ((null != (i = s.originalKind) ? i : s.kind) === r && s.forced === t.forced && s.language === t.lang && !this.htmlTextTrackBelongToThisItem(s)) {
                        a = e;
                        break
                    }
                }
                return n[a]
            }
            getExistingHTMLTextTrackWithSubtitleTrackId(t) {
                var e = this.availableMediaOptions.find(e => e.id === t);
                return e ? this.getExistingHTMLTextTrack(e) : void 0
            }
            getExistingHTMLTextTrackIndex(e) {
                var t = this.getExistingHTMLTextTrack(e)
                  , i = this.ze.textTracks;
                let r = -1;
                for (let e = 0; e < i.length; ++e)
                    if (i[e] === t) {
                        r = e;
                        break
                    }
                return r
            }
            setExistingHTMLTextTrack(e, t) {
                if (re(e.persistentID))
                    return t.persistentId = e.persistentID,
                    this.Gt.condenseSubtitleTrack ? this.Hi[e.persistentID] = t : this.Hi[e.id] = t
            }
            createHTMLTextTrack(t, i=void 0) {
                var e;
                if (i)
                    this.xi += 1;
                else {
                    if ("sbtl" === t.mediaType)
                        this.Ci += 1,
                        i = this.createHTMLTextTrackGuts("subtitles", t.name, t.lang, null != (e = t.forced) && e);
                    else {
                        let e = 1;
                        t.inStreamID && (e = Number(t.inStreamID.substring(2))),
                        this.Di += 1,
                        i = this.createHTMLCaptionsTrackGuts(e, t.name, t.lang, !1)
                    }
                    i ? this.setExistingHTMLTextTrack(t, i) : (this.R.error(`failed to create HTML text track for track ${t.id}: persistent id ${t.persistentID} name ${t.name} lang ${t.lang} inStreamID ` + t.inStreamID),
                    this.Li += 1)
                }
                return i
            }
            createHTMLTextTrackGuts(t, i, r, n) {
                var a = this.ze;
                if (a) {
                    let e = !1;
                    "metadata" !== t && this.Gt.customTextTrackCueRenderer && (e = !0,
                    t = "metadata");
                    a = a.addTextTrack(t, i, r);
                    return e && (a.customTextTrackCueRenderer = !0,
                    a.originalKind = t),
                    a.forced = n,
                    a
                }
            }
            pn(e) {
                let t = 1;
                return t = e.inStreamID ? Number(e.inStreamID.substring(2)) : t
            }
            removeEarlierId3Cues(e) {
                var t = this.ze.id3TextTrack;
                if (t && t.cues && 0 < t.cues.length)
                    for (; 0 < t.cues.length; ) {
                        var i = t.cues[0];
                        if (!(i.startTime < e))
                            break;
                        t.removeCue(i)
                    }
            }
            removeEarlierCues(e, t=50) {
                return this.removeCues(e, !0, t)
            }
            removeLaterCues(e, t=-1) {
                return this.removeCues(e, !1, t)
            }
            removeCues(t, i=!0, r=50) {
                if (this.ze) {
                    var n = this.ze.textTracks;
                    for (let e = 0; n && e < n.length; e++) {
                        var a = n[e];
                        if (a && a.cues && 0 < a.cues.length) {
                            let e = 0;
                            for (; 0 < a.cues.length && (e < r || r < 0); ) {
                                const r = i ? a.cues[0] : a.cues[a.cues.length - 1];
                                if (!(i ? r.endTime < t : r.startTime >= t))
                                    break;
                                a.removeCue(r),
                                e++
                            }
                        }
                    }
                    i ? (this.mn(t),
                    this.ze.removeEarlierParsedSubtitleFragmentRecord(t)) : (this.yn(t),
                    this.ze.removeLaterParsedSubtitleFragmentRecord(t))
                }
            }
            mn(t) {
                var i = this.qi;
                let r = 0;
                for (let e = 0; e < i.length && !(i[e][0] > t); e++)
                    i[e][1] < t ? r++ : i[e][0] < t && i[e][1] >= t && (i[e][0] = t);
                0 < r && i.splice(0, r)
            }
            yn(t) {
                var i = this.qi;
                let r = 0;
                for (let e = i.length - 1; 0 <= e && !(i[e][1] <= t); e--)
                    i[e][0] >= t ? r++ : i[e][0] < t && i[e][1] >= t && (i[e][0] = t);
                0 < r && i.splice(-r, r)
            }
            _removeHtmlTextTrackMappings() {
                Object.entries(this.Hi).forEach( ([e,t]) => {
                    re(e) && t && (this.Hi[e] = void 0)
                }
                )
            }
            resetTracks() {
                var e;
                this._clearAllTracks(),
                this.qi = [],
                null != (e = this.ze) && e.clearAllParsedSubtitleFragmentRecord(),
                this._removeHtmlTextTrackMappings(),
                this.Fi = {}
            }
            _clearAllTracks() {
                var e = this.ze;
                if (e) {
                    var t = e.textTracks;
                    for (let e = 0; t && e < t.length; e++)
                        $d(t[e])
                }
            }
            _isInterstitialTextTrack(e) {
                return e === this.Wi || e === this.Xi || e === this.Xi
            }
            endLoadingInterstitials() {
                this.fn = [],
                this.en = void 0,
                this.ln = void 0,
                this.Ni = !1
            }
            getCuesOfEnabledTrack(e, t=!1) {
                if (!e)
                    return [];
                let i = [];
                if (t) {
                    const t = this._getCuesOfEnabledTrack(e);
                    for (let e = 0; e < t.length; e++) {
                        var r = t[e];
                        Boolean(r.webVTTCue) && i.push(r)
                    }
                } else
                    i = this._getCuesOfEnabledTrack(e);
                return i
            }
            _getCuesOfEnabledTrack(e) {
                var t = this.hn(e);
                let i;
                if (null != t && t.isInterstitial)
                    i = t.mediaType === O.SUBTITLE ? "interstitial" : 1 === this.pn(t) ? "interstitialCC1" : "interstitialCC2";
                else {
                    const e = this.Gt.condenseSubtitleTrack ? null == t ? void 0 : t.persistentID : null == t ? void 0 : t.id;
                    i = null != e ? e : NaN
                }
                e = this.Hi[i];
                return null != t && t.isInterstitial && this.Ri && e && this.gn(t, e),
                e && e.cues ? Array.from(e.cues) : []
            }
            gn(e, t) {
                e.persistentID !== t.persistentId && (t.persistentId = e.persistentID,
                $d(t),
                this.ze.clearParsedSubtitleRecordsForMediaOption("interstitial"))
            }
            bn() {
                $d(this.Wi),
                $d(this.Xi),
                $d(this.Yi),
                this.ze.clearParsedSubtitleRecordsForMediaOption("interstitial")
            }
            Sn() {
                for (let e = 0; e < this.ze.textTracks.length; ++e)
                    this.ze.textTracks[e].persistentId = void 0
            }
            attachSubtitleTracks() {
                this.gotTracks && (this.Ci = 0,
                this.Di = 0,
                this.xi = 0,
                this.Li = 0,
                this.Sn(),
                this.Vi.forEach(e => {
                    var t;
                    "sbtl" === e.mediaType && this.Gt.dynamicTextTrackCreation || (t = this.getExistingHTMLTextTrack(e),
                    this.createHTMLTextTrack(e, t))
                }
                ))
            }
            setTracks(e, t, i) {
                this.Hi = {},
                this.qi = [],
                this.Gt.enableWebVTT && (this.Vi = e || []),
                this.gotTracks = !0,
                this.vn = e,
                this.an = i,
                this.attachSubtitleTracks(),
                this.selectedTrack = t,
                this.nativeSubtitleTrackChange$ = new z,
                this.ze.textTracksCreated = !0
            }
            setInterstitialTracks(e, t, i) {
                this.Hi || (this.Hi = {}),
                this.Ni = !0;
                let r = !1
                  , n = !1
                  , a = !1;
                e.forEach(e => {
                    e.mediaType === O.SUBTITLE ? r = !0 : 1 === this.pn(e) ? n = !0 : a = !0
                }
                ),
                !this.Wi && r && (this.Wi = this.createHTMLTextTrackGuts("subtitles", "interstitialTextTrack", "interstitialMulti", !1),
                this.Hi.interstitial = this.Wi),
                !this.Xi && n && (this.Xi = this.createHTMLTextTrackGuts("captions", "interstitialCCTrack1", "interstitialMulti", !1),
                this.Xi) && (this.Hi.interstitialCC1 = this.Xi,
                this.Ki.icc1 = this.Xi),
                !this.Yi && a && (this.Yi = this.createHTMLTextTrackGuts("captions", "interstitialCCTrack2", "interstitialMulti", !1),
                this.Yi) && (this.Hi.interstitialCC2 = this.Yi,
                this.Ki.icc2 = this.Yi),
                this.fn = e,
                this.en = i,
                (this.selectedTrack = t) && (t.mediaType === O.SUBTITLE ? this.Wi && (this.Wi.persistentId = t.persistentID) : 1 === this.pn(t) ? this.Xi && (this.Xi.persistentId = t.persistentID) : this.Yi && (this.Yi.persistentId = t.persistentID)),
                this.nativeSubtitleTrackChange$ = new z
            }
            onInlineStylesParsed(e) {}
            processSubtitleFrag(e, t, i, r, n=!0) {
                e = this.getExistingHTMLTextTrackIndex(e);
                return t && r.byteLength ? n ? this._parseVTTs(e, t, i, r).pipe(W(e => (e && re(e.startTime) && (this.zi = Math.max(this.zi, e.endTime)),
                e))) : this._parseTTML(e, t, i, r, this.R).pipe(W(e => (e && re(e.startTime) && (this.zi = Math.max(this.zi, e.endTime)),
                e))) : Y(void 0)
            }
            wn(e, n, t, a) {
                const s = this.ze.textTracks[e]
                  , i = {
                    count: 0,
                    startTime: Number.POSITIVE_INFINITY,
                    endTime: 0
                }
                  , o = new pn(0);
                o.pipe(Pr(sr), Qr( (e, t) => {
                    var i = performance.now();
                    let r = t;
                    for (; r < a.length && (r - t < 100 || performance.now() - i < 200); ++r) {
                        const t = a[r];
                        !s || s.cues && s.cues.getCueById(t.id) || (t.fragSN = n.mediaSeqNum,
                        t.webVTTCue = !0,
                        t.itemId = n.itemId,
                        s.addCue(t),
                        e.count++),
                        e.startTime = Math.min(t.startTime, e.startTime),
                        e.endTime = Math.max(t.endTime, e.endTime)
                    }
                    return r < a.length ? o.next(r) : o.complete(),
                    e
                }
                , i), ie( () => {
                    let e = "interstitial";
                    this.selectedTrack && !this.selectedTrack.isInterstitial && (e = this.selectedTrack.itemId + this.selectedTrack.mediaOptionId),
                    this.ze.archiveParsedSubtitleFragmentRecord(e, n.mediaSeqNum, i)
                }
                ), ee( () => {
                    t.complete()
                }
                )).subscribe(t)
            }
            _parseVTTs(f, g, y, v) {
                return new G(t => {
                    {
                        var i = v
                          , r = y
                          , n = g.start
                          , a = (g.discoSeqNum,
                        e => {
                            this.wn(f, g, t, e)
                        }
                        )
                          , s = e => {}
                          , u = e => {
                            var t;
                            null != (t = this.Oi) && t.trigger(L.INLINE_STYLES_PARSED, {
                                styles: e
                            })
                        }
                        ;
                        this.R;
                        const c = Ee.utf8arrayToStr(new Uint8Array(i)).trim().replace(/\r\n|\n\r|\n|\r/g, "\n").split("\n")
                          , h = S(r, gd);
                        let o = 0
                          , l = 0;
                        const p = [];
                        let d = null
                          , e = !0;
                        const m = new Gl.WebVTTParser(window,Gl.WebVTTParser.StringDecoder(),u);
                        m.oncue = function(e) {
                            var t = P({
                                baseTime: Sd(Sd(o) - h.baseTime, n * gd),
                                timescale: gd
                            });
                            e.startTime = Sd(e.startTime + t - l, 0, 95443.7176888889),
                            e.endTime = Sd(e.endTime + t - l, 0, 95443.7176888889),
                            e.id = U(vd(e.startTime).toString()) + U(vd(e.endTime - e.startTime).toString()) + U(e.text),
                            e.text = decodeURIComponent(encodeURIComponent(e.text)),
                            0 < e.endTime && p.push(e)
                        }
                        ,
                        m.onparsingerror = function(e) {
                            d = e
                        }
                        ,
                        m.onflush = function() {
                            d && s ? d : a(p)
                        }
                        ,
                        c.forEach(s => {
                            e && yd(s, "X-TIMESTAMP-MAP=") ? (e = !1,
                            s.substr(16).split(",").forEach(e => {
                                if (yd(e, "LOCAL:")) {
                                    let t;
                                    try {
                                        t = (i = e.substr(6),
                                        r = parseInt(i.substr(-3)),
                                        n = parseInt(i.substr(-6, 2)),
                                        a = parseInt(i.substr(-9, 2)),
                                        i = 9 < i.length ? parseInt(i.substr(0, i.indexOf(":"))) : 0,
                                        re(r) && re(n) && re(a) && re(i) ? (r += 1e3 * n) + 6e4 * a + 36e5 * i : -1)
                                    } catch (e) {
                                        t = -1
                                    }
                                    -1 !== t ? l = t / 1e3 : d = new j(!1,H.WebVTTMalformedXTIMESTAMPMAP,`Malformed X-TIMESTAMP-MAP: ` + s)
                                } else
                                    yd(e, "MPEGTS:") && (o = parseInt(e.substr(7)));
                                var i, r, n, a
                            }
                            )) : "<br/>" !== s && "<br>" !== s && (s = (s = s.replace(/<br\/>/g, "")).replace(/<br>/g, ""),
                            m.parse(s + "\n"))
                        }
                        ),
                        m.flush()
                    }
                }
                )
            }
            _parseTTML(t, i, e, r, n) {
                const a = Hd.extractXML(r)
                  , s = Hd.generateCues(a, e, i.start, n);
                return new G(e => {
                    this.wn(t, i, e, s)
                }
                )
            }
            _ensureParser() {
                var e, t;
                this.Tn || (e = new _d(this,1),
                t = new _d(this,2),
                this.Tn = new class {
                    constructor(e=1, t, i) {
                        this.On = e,
                        this.kn = -1,
                        this.Mn = null,
                        this.En = null,
                        this.An = [new xd(1,t), new xd(2,i)],
                        this.Nn = {
                            padding: 0,
                            char: 0,
                            cmd: 0,
                            other: 0
                        }
                    }
                    getHandler(e) {
                        return this.An[e].getHandler()
                    }
                    setHandler(e, t) {
                        this.An[e].setHandler(t)
                    }
                    addData(e, t) {
                        let i, r, n, a = null;
                        Cd.setTime(e);
                        for (let e = 0; e < t.length; e += 2)
                            r = 127 & t[e],
                            n = 127 & t[e + 1],
                            16 <= r && r <= 31 && r === this.Mn && n === this.En ? (this.Mn = null,
                            this.En = null,
                            Cd.log("DEBUG", "Repeated command (" + bd([r, n]) + ") is dropped")) : 0 != r || 0 != n ? (Cd.log("DATA", "[" + bd([t[e], t[e + 1]]) + "] -> (" + bd([r, n]) + ")"),
                            !(i = (i = (i = (i = this.parseCmd(r, n)) || this.parseMidrow(r, n)) || this.parsePAC(r, n)) || this.parseBackgroundAttributes(r, n)) && (a = this.parseChars(r, n)) && (this.kn && 0 <= this.kn ? this.An[this.kn - 1].insertChars(a) : Cd.log("WARNING", "No channel found yet. TEXT-MODE?")),
                            i ? this.Nn.cmd += 2 : a ? this.Nn.char += 2 : (this.Nn.other += 2,
                            Cd.log("WARNING", "Couldn't parse cleaned data " + bd([r, n]) + " orig: " + bd([t[e], t[e + 1]])))) : this.Nn.padding += 2
                    }
                    parseCmd(e, t) {
                        var i, r;
                        return ((20 === e || 21 === e || 28 === e || 29 === e) && 32 <= t && t <= 47 || (23 === e || 31 === e) && 33 <= t && t <= 35) && (r = this.An[(i = 20 === e || 23 === e ? 1 : 2) - 1],
                        20 === e || 21 === e || 28 === e || 29 === e ? 32 === t ? r.ccRCL() : 33 === t ? r.ccBS() : 34 === t ? r.ccAOF() : 35 === t ? r.ccAON() : 36 === t ? r.ccDER() : 37 === t ? r.ccRU(2) : 38 === t ? r.ccRU(3) : 39 === t ? r.ccRU(4) : 40 === t ? r.ccFON() : 41 === t ? r.ccRDC() : 42 === t ? r.ccTR() : 43 === t ? r.ccRTD() : 44 === t ? r.ccEDM() : 45 === t ? r.ccCR() : 46 === t ? r.ccENM() : 47 === t && r.ccEOC() : r.ccTO(t - 32),
                        this.Mn = e,
                        this.En = t,
                        this.kn = i,
                        !0)
                    }
                    parseMidrow(e, t) {
                        var i;
                        return (17 === e || 25 === e) && 32 <= t && t <= 47 && ((i = 17 === e ? 1 : 2) !== this.kn ? (Cd.log("ERROR", "Mismatch channel in midrow parsing"),
                        !1) : ((i = this.An[i - 1]).insertChars([32]),
                        i.ccMIDROW(t),
                        Cd.log("DEBUG", "MIDROW (" + bd([e, t]) + ")"),
                        this.Mn = e,
                        this.En = t,
                        !0))
                    }
                    parsePAC(e, t) {
                        var i = null
                          , r = null;
                        return ((17 <= e && e <= 23 || 25 <= e && e <= 31) && 64 <= t && t <= 127 || (16 === e || 24 === e) && 64 <= t && t <= 95) && (i = e <= 23 ? 1 : 2,
                        r = (64 <= t && t <= 95 ? 1 == i ? Od : wd : 1 == i ? Rd : Pd)[e],
                        r = this.interpretPAC(r, t),
                        this.An[i - 1].setPAC(r),
                        this.Mn = e,
                        this.En = t,
                        this.kn = i,
                        !0)
                    }
                    interpretPAC(e, t) {
                        e = {
                            color: void 0,
                            italics: !1,
                            indent: null,
                            underline: !1,
                            row: e
                        };
                        return e.underline = 1 == (1 & (t = 95 < t ? t - 96 : t - 64)),
                        t <= 13 ? e.color = ["white", "green", "blue", "cyan", "red", "yellow", "magenta", "white"][Math.floor(t / 2)] : t <= 15 ? (e.italics = !0,
                        e.color = "white") : e.indent = 4 * Math.floor((t - 16) / 2),
                        e
                    }
                    parseChars(e, t) {
                        let i = null
                          , r = null
                          , n = null;
                        var a;
                        if (17 <= (n = 25 <= e ? (i = 2,
                        e - 8) : (i = 1,
                        e)) && n <= 19 ? (a = t,
                        a = 17 === n ? t + 80 : 18 === n ? t + 112 : t + 144,
                        Cd.log("INFO", "Special char '" + Id(a) + "' in channel " + i),
                        r = [a],
                        this.Mn = e,
                        this.En = t) : 32 <= e && e <= 127 && (r = 0 === t ? [e] : [e, t],
                        this.Mn = null,
                        this.En = null),
                        r) {
                            const e = bd(r);
                            Cd.log("DEBUG", `Char codes =  ` + e.join(","))
                        }
                        return r
                    }
                    parseBackgroundAttributes(e, t) {
                        var i, r;
                        return ((16 === e || 24 === e) && 32 <= t && t <= 47 || (23 === e || 31 === e) && 45 <= t && t <= 47) && (i = {
                            underline: !1
                        },
                        16 === e || 24 === e ? (r = Math.floor((t - 32) / 2),
                        i.background = Md[r],
                        t % 2 == 1 && (i.background = i.background + "_semi")) : 45 === t ? i.background = "transparent" : (i.foreground = "black",
                        47 === t && (i.underline = !0)),
                        this.An[(e < 24 ? 1 : 2) - 1].setBkgData(i),
                        this.Mn = null,
                        this.En = null,
                        !0)
                    }
                    reset() {
                        for (let e = 0; e < this.An.length; e++)
                            this.An[e] && this.An[e].reset();
                        this.Mn = null,
                        this.En = null
                    }
                    cueSplitAtTime(t) {
                        for (let e = 0; e < this.An.length; e++)
                            this.An[e] && this.An[e].cueSplitAtTime(t)
                    }
                }
                (0,e,t))
            }
            setupForFrag(e) {
                var t;
                e && e.mediaOptionType === se.Variant && !e.iframe && (t = e.mediaSeqNum,
                e = e.discoSeqNum,
                t === this.Ei + 1 && e === this.Ai || this.resetClosedCaptionParser(),
                this.Ei = t,
                this.Ai = e)
            }
            resetClosedCaptionParser() {
                var e;
                null != (e = this.Tn) && e.reset()
            }
            addLegibleSamples(e, t, i, r, n, a) {
                this.Pi = !!a,
                t && this.addClosedCaptionSamples(e, t),
                i && 0 < i.length && this.addId3Samples(e, i, r, P(n))
            }
            addClosedCaptionSamples(e, t) {
                t.mp4 ? this.addMP4CaptionSamples(e, t.mp4) : t.ts && this.addTSCaptionSamples(e, t.ts)
            }
            addMP4CaptionSamples(e, i) {
                var r;
                if (this.Bi && this.Gt.enableCEA708Captions) {
                    var n = P(e);
                    this._ensureParser();
                    for (let e = 0; e < i.length; e++) {
                        let t = i[e].pts - n;
                        var a = i[e].bytes;
                        for (let e = 0; e < a.length; e += 2) {
                            const i = [];
                            i.push(a[e]),
                            e + 1 < a.length ? i.push(a[e + 1]) : i.push(80),
                            null != (r = this.Tn) && r.addData(t, i),
                            t += .03336666666666667
                        }
                    }
                }
            }
            addTSCaptionSamples(e, t) {
                var i;
                if (this.Bi && this.Gt.enableCEA708Captions) {
                    var r = P(e);
                    this._ensureParser();
                    for (let e = 0; e < t.length; e++) {
                        var n = t[e].pts - r
                          , a = function(t) {
                            var i = 31 & t[0];
                            let r, n, a, s = 2;
                            var o = [];
                            for (let e = 0; e < i; e++)
                                r = t[s++],
                                n = 127 & t[s++],
                                a = 127 & t[s++],
                                0 == n && 0 == a || 0 != (4 & r) && 0 == (3 & r) && (o.push(n),
                                o.push(a));
                            return o
                        }(t[e].bytes);
                        null != (i = this.Tn) && i.addData(n, a)
                    }
                }
            }
            addId3Samples(e, t, r, n) {
                var a;
                if (this.Gt.enableID3Cues) {
                    const s = window.WebKitDataCue || window.VTTCue || window.TextTrackCue
                      , o = P(e);
                    for (let e = 0; e < t.length; e++) {
                        const l = this._adjustID3PtsForRollover(t[e].pts, r) - o;
                        let i = this._adjustID3PtsForRollover(e < t.length - 1 ? t[e + 1].pts : n, r) - o;
                        l === i && (i += 1e-4),
                        !t[e].frames || null != (a = t[e].frames) && a.forEach(e => {
                            var t;
                            e && !this.id3shouldIgnore(e) && ((t = new s(l,i,"")).value = e,
                            this.Ui.addCue(t))
                        }
                        )
                    }
                }
            }
            _adjustID3PtsForRollover(e, t) {
                return Sd(e * t.timescale, t.baseTime, Math.pow(2, 33)) / t.timescale
            }
            id3shouldIgnore(e) {
                return "PRIV" === e.key && ("com.apple.streaming.transportStreamTimestamp" === e.info || "com.apple.streaming.audioDescription" === e.info)
            }
        }
        class zd {
            constructor(e) {
                this.R = e,
                this.Rn = {},
                this.gotRequest$ = new z
            }
            load(d, u) {
                return new G(e => {
                    const {url: t, extendMaxTTFB: i} = d
                      , r = u["maxTimeToFirstByteMs"]
                      , n = {
                        trequest: performance.now(),
                        tfirst: NaN,
                        tload: NaN,
                        loaded: 0,
                        total: NaN,
                        complete: !1
                    }
                      , a = this.Rn[t] = new mn
                      , s = re(i) && 0 < i ? i : r
                      , o = a.pipe(Nn(s), te(e => (n.tfirst = performance.now(),
                    this.Pn(e, d, u, n))), $(e => {
                        if (e instanceof Ln)
                            throw new Js(e.message,n);
                        throw e
                    }
                    ), ee( () => {
                        delete this.Rn[t]
                    }
                    ))
                      , l = (d.onProgress && d.onProgress.cb(t, 0, n, null),
                    o.subscribe(e));
                    return this.gotRequest$.next({
                        uri: t,
                        responseType: d.responseType,
                        userAgent: navigator.userAgent,
                        forInterstitialAssetList: !!d.forInterstitialAssetList,
                        interstitialIdentifier: d.interstitialIdentifier
                    }),
                    () => {
                        l.unsubscribe(),
                        delete this.Rn[t]
                    }
                }
                )
            }
            setCustomUrlResponse(e, t) {
                var i = this.Rn[e];
                i && (i.next(t),
                i.complete(),
                delete this.Rn[e])
            }
            Pn(e, t, i, r) {
                r.tload = performance.now();
                var n = e.response.status;
                return 200 <= n && n < 300 || 0 === n && e.response.data ? ("arraybuffer" === t.responseType && e.response.data instanceof ArrayBuffer ? r.loaded = e.response.data.byteLength : r.loaded = e.response.data.toString().length,
                r.total = r.loaded,
                r.complete = !0,
                kr(Y({
                    status: n,
                    data: e,
                    stats: r
                }), Zn)) : 300 === n || 302 === n || 303 === n || 305 === n ? this.Cn(e.response.uri, t, i, r) : R(new Gs("Unable to load custom url",n))
            }
            Cn(e, t, i, n) {
                var r = t["extendMaxTTFB"]
                  , {maxLoadTimeMs: a, maxTimeToFirstByteMs: s} = i
                  , a = re(a) ? a - (performance.now() - n.trequest) : void 0
                  , r = re(r) && 0 < r ? r : s - (performance.now() - n.trequest)
                  , s = Object.assign(Object.assign({}, i), {
                    maxLoadTimeMs: a,
                    maxTimeToFirstByteMs: r
                })
                  , i = Object.assign(Object.assign({}, t), {
                    url: e
                });
                if (re(a) && a <= 0 || r <= 0)
                    throw new Js("",n);
                return cs(e) ? this.load(i, s) : po(i, s).pipe(W( ([e,t]) => {
                    var {responseURL: i, status: r} = e
                      , i = i || ""
                      , r = {
                        uri: i,
                        response: {
                            status: r,
                            uri: i,
                            data: e.response
                        }
                    };
                    return n.loaded = n.total = t.loaded,
                    n.tload = performance.now(),
                    n.complete = !0,
                    {
                        status: e.status,
                        data: r,
                        stats: n
                    }
                }
                ))
            }
        }
        class Xd {
            constructor(e, t, i) {
                this.Dn = e,
                this.Re = t,
                this.xn = (e, t) => {
                    const i = t["sessionDataAutoLoad"]
                      , r = Object.assign({}, e);
                    return e.complete || e.itemList && (r.complete = e.itemList.every(e => !(i[e["DATA-ID"]] && !e.VALUE && !e._STATUS && e.URI))),
                    r
                }
                ,
                this.R = i.child({
                    name: "SessionDataLoader"
                })
            }
            loadSessionData(n, a) {
                const s = a["sessionDataAutoLoad"]
                  , t = n.itemList || [];
                let o = Y(n);
                return t.forEach(e => {
                    const i = e["DATA-ID"]
                      , r = e.URI;
                    if (r && s[i])
                        if ("_hls.localized-rendition-names" === i && function(e) {
                            var t = e.split(":");
                            if ("data" === t[0] && 2 === t.length) {
                                const e = t[1].split(";")
                                  , i = e[e.length - 1].split(",");
                                return 2 === i.length ? "base64" === i[0] : void 0
                            }
                        }(r)) {
                            const n = el(r);
                            let t = "";
                            null != n && (t = Ee.utf8arrayToStr(n)),
                            void (o = o.pipe(te(e => Y(this.Ln(e, i, "VALUE", t)))))
                        } else {
                            const s = us.buildAbsoluteURL(n.baseUrl, r, {
                                alwaysNormalize: !0
                            })
                              , e = "";
                            o = o.pipe(te(t => this._n(s, i, e, a, t, this.Dn, this.Re).pipe($(e => (this.R.error(`Error loading SessionData > url=${f(s)}, id=${i}, err=` + e),
                            Y(t))))))
                        }
                }
                ),
                o.pipe(W(e => {
                    if (t.length < 1)
                        return e;
                    e = this.xn(e, a);
                    if (e.complete)
                        return e;
                    throw new j(!1,H.IncompleteSessionData)
                }
                ), ee( () => {}
                ))
            }
            _n(r, n, e, t, a, i, s) {
                const o = {
                    url: r,
                    method: "GET",
                    responseType: e,
                    xhrSetup: t.xhrSetup,
                    mimeType: "application/xml"
                }
                  , l = eo({
                    url: r
                }, t.fragLoadPolicy);
                let d;
                if (cs(r))
                    d = s(o, l).pipe(W(e => this.Fn(a, n, e.data.response.data.toString(), e.data.response.data)));
                else {
                    const r = performance.now();
                    d = i(o, l).pipe(W( ([e]) => this.Fn(a, n, e.response, e.responseXML)), $(e => {
                        if (e instanceof Gs && e.isAuthOrCorsError)
                            return t = o,
                            i = l,
                            s(t, oo(t, i, r)).pipe(W(e => this.Fn(a, n, e.data.response.data.toString(), e.data.response.data)));
                        var t, i;
                        throw e
                    }
                    ))
                }
                return d.pipe($(e => (e instanceof Ln ? e = new Xs(!1,H.SessionDataLoadTimeout) : e instanceof Gs && (e = new Xs(!1,e.statusCode,e.message)),
                this.R.error(`Unable to load SessionData > err=` + e),
                Y(this.jn(a, n, e)))))
            }
            Fn(e, t, i, r) {
                let n = null
                  , a = e;
                if (s = i,
                (o = /[\s]*<\?xml/i).lastIndex = 0,
                ((o = o.exec(s)) || /[\s]*<plist/i.exec(s)) && (n = r)) {
                    const i = function n(e) {
                        if (!e)
                            return null;
                        let a = null;
                        var s = e.childNodes;
                        if (s)
                            if (e.tagName) {
                                const t = null == (e = e.tagName) ? void 0 : e.toLowerCase();
                                if ("plist" === t) {
                                    a = [];
                                    for (let e = 0; e < s.length; ++e) {
                                        const t = s[e];
                                        t.tagName && a.push(n(t))
                                    }
                                    1 === a.length && (a = a[0])
                                }
                                if ("array" === t) {
                                    a = [];
                                    for (let e = 0; e < s.length; ++e) {
                                        const t = s[e];
                                        t.tagName && a.push(n(t))
                                    }
                                }
                                if ("dict" === t) {
                                    let t, i, r = 0;
                                    a = {};
                                    for (let e = 0; e < s.length; e++) {
                                        var o = s[e]
                                          , l = null == (l = o.tagName) ? void 0 : l.toLowerCase();
                                        l && (r % 2 == 0 ? "key" === l && (t = n(o),
                                        r++) : (i = n(o),
                                        a[t] = i,
                                        t = null,
                                        i = null,
                                        r++))
                                    }
                                    t && (a[t] = i,
                                    t = null,
                                    i = null)
                                } else if ("key" === t) {
                                    const e = s[0];
                                    a = e ? e.nodeValue : null
                                } else if ("string" === t) {
                                    const e = s[0];
                                    a = e ? e.nodeValue : null
                                } else if ("integer" === t) {
                                    const e = s[0];
                                    a = e && e.nodeValue ? parseInt(e.nodeValue) : 0
                                } else if ("float" === t) {
                                    const e = s[0];
                                    a = e && e.nodeValue ? parseFloat(e.nodeValue) : 0
                                } else if ("date" === t) {
                                    const e = s[0];
                                    a = e && e.nodeValue ? new Date(e.nodeValue) : null
                                } else if ("data" === t) {
                                    const e = s[0];
                                    a = e && e.nodeValue ? atob(e.nodeValue) : null
                                } else
                                    "true" === t ? a = !0 : "false" === t && (a = !1)
                            } else if (!(s.length < 1)) {
                                a = [];
                                for (let e = 0; e < s.length; ++e) {
                                    const t = s[e];
                                    t.tagName && a.push(n(t))
                                }
                                1 === a.length && (a = a[0])
                            }
                        return a
                    }(n);
                    a = this.Ln(e, t, "VALUE", i)
                } else if (o = i,
                (s = /[\s]*[\{\[]/).lastIndex = 0,
                s.exec(o))
                    try {
                        const r = JSON.parse(i);
                        a = this.Ln(e, t, "VALUE", r)
                    } catch (r) {
                        this.R.error(`JSON parser error: ` + r),
                        a = this.Ln(e, t, "VALUE", i),
                        a = this.Ln(a, t, "_STATUS", -1)
                    }
                else
                    a = this.Ln(e, t, "VALUE", i);
                var s, o;
                return a
            }
            Ln(t, i, r, n) {
                let a = t;
                if (t.itemList) {
                    let e;
                    var s = [...t.itemList];
                    for (e = 0; e < t.itemList.length; ++e) {
                        const t = Object.assign({}, s[e]);
                        if (t["DATA-ID"] === i) {
                            t[r] = n,
                            s[e] = t;
                            break
                        }
                    }
                    e === t.itemList.length && this.R.error(`Can't set ${r} of session data ` + i),
                    a = Object.assign(Object.assign({}, t), {
                        itemList: s
                    })
                } else
                    this.R.error(`Can't set ${r} on uninitialized session data`);
                return a
            }
            jn(e, t, i) {
                return this.Ln(e, t, "_STATUS", i.response)
            }
        }
        const Yd = new Set(["buildType", "customTextTrackCueRenderer", "debug", "debugLevel", "disableVideoCodecList", "disableAudioCodecList", "enablePerformanceLogging", "enableQueryParamsForITunes", "enableRtcReporting", "nativeControlsEnabled", "offlinePlayback", "playReadyMessageFormat", "rtcIntervalTimeout", "sessionDataAutoLoad", "storage", "storageKeyPrefix", "supportedStorebagVersion", "useCustomMediaFunctions", "useHighestVideoCodecPrivate", "xhrSetup"]);
        function Jd(e, t) {
            var i = e.split(".").map(e => Number.parseInt(e))
              , r = t.split(".").map(e => Number.parseInt(e));
            for (let e = 0; e < Math.min(i.length, r.length); e++) {
                if (i[e] < r[e])
                    return !1;
                if (i[e] > r[e])
                    return !0
            }
            return !0
        }
        function Zd(t) {
            var i = Math.random();
            let r = 0;
            for (let e = 0; e < t.length; e++)
                if (i < (r += t[e]))
                    return e;
            return t.length - 1
        }
        function eu(e) {
            try {
                return JSON.stringify(e)
            } catch (e) {
                return '"[Circular]"'
            }
        }
        var tu, iu, ru, nu, au = function(e, t, i) {
            var r = i && i.stringify || eu;
            if ("object" == typeof e && null !== e) {
                var n = t.length + 1;
                if (1 === n)
                    return e;
                var a = new Array(n);
                a[0] = r(e);
                for (var s = 1; s < n; s++)
                    a[s] = r(t[s]);
                return a.join(" ")
            }
            if ("string" != typeof e)
                return e;
            var o = t.length;
            if (0 === o)
                return e;
            for (var l, d = "", u = 0, c = -1, h = e && e.length || 0, p = 0; p < h; ) {
                if (37 === e.charCodeAt(p) && p + 1 < h) {
                    switch (c = -1 < c ? c : 0,
                    e.charCodeAt(p + 1)) {
                    case 100:
                        o <= u || (c < p && (d += e.slice(c, p)),
                        null != t[u] && (d += Number(t[u]),
                        c = p += 2));
                        break;
                    case 79:
                    case 111:
                    case 106:
                        o <= u || (c < p && (d += e.slice(c, p)),
                        void 0 !== t[u] && (d += "string" == (l = typeof t[u]) ? "'" + t[u] + "'" : "function" == l ? t[u].name || "<anonymous>" : r(t[u]),
                        c = p + 2,
                        p++));
                        break;
                    case 115:
                        o <= u || (c < p && (d += e.slice(c, p)),
                        d += String(t[u]),
                        c = p + 2,
                        p++);
                        break;
                    case 37:
                        c < p && (d += e.slice(c, p)),
                        d += "%",
                        c = p + 2,
                        p++
                    }
                    ++u
                }
                ++p
            }
            return -1 === c ? e : (c < h && (d += e.slice(c)),
            d)
        }, su = lu, ou = function() {
            function t(e) {
                return void 0 !== e && e
            }
            try {
                return "undefined" == typeof globalThis && Object.defineProperty(Object.prototype, "globalThis", {
                    get: function() {
                        return delete Object.prototype.globalThis,
                        this.globalThis = this
                    },
                    configurable: !0
                }),
                globalThis
            } catch (e) {
                return t(my) || t(window) || t(this) || {}
            }
        }().console || {}, sd = {
            mapHttpRequest: pu,
            mapHttpResponse: pu,
            wrapRequestSerializer: mu,
            wrapResponseSerializer: mu,
            wrapErrorSerializer: mu,
            req: pu,
            res: pu,
            err: function(e) {
                var t, i = {
                    type: e.constructor.name,
                    msg: e.message,
                    stack: e.stack
                };
                for (t in e)
                    void 0 === i[t] && (i[t] = e[t]);
                return i
            }
        };
        function lu(a) {
            (a = a || {}).browser = a.browser || {};
            var s = a.browser.transmit;
            if (s && "function" != typeof s.send)
                throw Error("pino: transmit option must have a send function");
            var e = a.browser.write || ou
              , o = (a.browser.write && (a.browser.asObject = !0),
            a.serializers || {})
              , l = (t = a.browser.serialize,
            i = o,
            Array.isArray(t) ? t.filter(function(e) {
                return "!stdSerializers.err" !== e
            }) : !0 === t && Object.keys(i))
              , t = a.browser.serialize
              , i = (Array.isArray(a.browser.serialize) && -1 < a.browser.serialize.indexOf("!stdSerializers.err") && (t = !1),
            "function" == typeof e && (e.error = e.fatal = e.warn = e.info = e.debug = e.trace = e),
            !1 === a.enabled && (a.level = "silent"),
            a.level || "info")
              , r = Object.create(e)
              , n = (r.log || (r.log = fu),
            Object.defineProperty(r, "levelVal", {
                get: function() {
                    return "silent" === this.level ? 1 / 0 : this.levels.values[this.level]
                }
            }),
            Object.defineProperty(r, "level", {
                get: function() {
                    return this._level
                },
                set: function(e) {
                    if ("silent" !== e && !this.levels.values[e])
                        throw Error("unknown level " + e);
                    this._level = e,
                    du(n, r, "error", "log"),
                    du(n, r, "fatal", "error"),
                    du(n, r, "warn", "error"),
                    du(n, r, "info", "log"),
                    du(n, r, "debug", "log"),
                    du(n, r, "trace", "log")
                }
            }),
            {
                transmit: s,
                serialize: l,
                asObject: a.browser.asObject,
                levels: ["error", "fatal", "warn", "info", "debug", "trace"],
                timestamp: "function" == typeof (e = a).timestamp ? e.timestamp : !1 === e.timestamp ? gu : yu
            });
            return r.levels = lu.levels,
            r.level = i,
            r.setMaxListeners = r.getMaxListeners = r.emit = r.addListener = r.on = r.prependListener = r.once = r.prependOnceListener = r.removeListener = r.removeAllListeners = r.listeners = r.listenerCount = r.eventNames = r.write = r.flush = fu,
            r.serializers = o,
            r._serialize = l,
            r._stdErrSerialize = t,
            r.child = function(t) {
                var e, i, r;
                if (t)
                    return e = t.serializers,
                    l && e && (i = Object.assign({}, o, e),
                    r = !0 === a.browser.serialize ? Object.keys(i) : l,
                    delete t.serializers,
                    uu([t], r, i, this._stdErrSerialize)),
                    n.prototype = this,
                    new n(this);
                throw new Error("missing bindings for child Pino");
                function n(e) {
                    this._childLevel = 1 + (0 | e._childLevel),
                    this.error = cu(e, t, "error"),
                    this.fatal = cu(e, t, "fatal"),
                    this.warn = cu(e, t, "warn"),
                    this.info = cu(e, t, "info"),
                    this.debug = cu(e, t, "debug"),
                    this.trace = cu(e, t, "trace"),
                    i && (this.serializers = i,
                    this._serialize = r),
                    s && (this._logEvent = hu([].concat(e._logEvent.bindings, t)))
                }
            }
            ,
            s && (r._logEvent = hu()),
            r
        }
        function du(e, t, i, r) {
            var u, c, h, p, n = Object.getPrototypeOf(t);
            t[i] = !(t.levelVal > t.levels.values[i]) && (n[i] || ou[i] || ou[r]) || fu,
            c = t,
            h = i,
            !(u = e).transmit && c[h] === fu || (c[h] = (p = c[h],
            function() {
                for (var e, t, i, r, n, a, s = u.timestamp(), o = new Array(arguments.length), l = Object.getPrototypeOf && Object.getPrototypeOf(this) === ou ? ou : this, d = 0; d < o.length; d++)
                    o[d] = arguments[d];
                u.serialize && !u.asObject && uu(o, this._serialize, this.serializers, this._stdErrSerialize),
                u.asObject ? p.call(l, function(e, t, i, r) {
                    e._serialize && uu(i, e._serialize, e.serializers, e._stdErrSerialize);
                    var n = i.slice()
                      , i = n[0]
                      , a = {}
                      , s = (r && (a.time = r),
                    a.level = lu.levels.values[t],
                    1 + (0 | e._childLevel));
                    if (s < 1 && (s = 1),
                    null !== i && "object" == typeof i) {
                        for (; s-- && "object" == typeof n[0]; )
                            Object.assign(a, n.shift());
                        i = n.length ? au(n.shift(), n) : void 0
                    } else
                        "string" == typeof i && (i = au(n.shift(), n));
                    return void 0 !== i && (a.msg = i),
                    a
                }(this, h, o, s)) : p.apply(l, o),
                u.transmit && (l = u.transmit.level || c.level,
                e = lu.levels.values[l],
                (t = lu.levels.values[h]) < e || (e = this,
                s = {
                    ts: s,
                    methodLevel: h,
                    methodValue: t,
                    transmitLevel: l,
                    transmitValue: lu.levels.values[u.transmit.level || c.level],
                    send: u.transmit.send,
                    val: c.levelVal
                },
                t = o,
                l = s.send,
                i = s.ts,
                r = s.methodLevel,
                n = s.methodValue,
                s = s.val,
                a = e._logEvent.bindings,
                uu(t, e._serialize || Object.keys(e.serializers), e.serializers, void 0 === e._stdErrSerialize || e._stdErrSerialize),
                e._logEvent.ts = i,
                e._logEvent.messages = t.filter(function(e) {
                    return -1 === a.indexOf(e)
                }),
                e._logEvent.level.label = r,
                e._logEvent.level.value = n,
                l(r, e._logEvent, s),
                e._logEvent = hu(a)))
            }
            ))
        }
        function uu(e, t, i, r) {
            for (var n in e)
                if (r && e[n]instanceof Error)
                    e[n] = lu.stdSerializers.err(e[n]);
                else if ("object" == typeof e[n] && !Array.isArray(e[n]))
                    for (var a in e[n])
                        t && -1 < t.indexOf(a) && a in i && (e[n][a] = i[a](e[n][a]))
        }
        function cu(i, r, n) {
            return function() {
                var e = new Array(1 + arguments.length);
                e[0] = r;
                for (var t = 1; t < e.length; t++)
                    e[t] = arguments[t - 1];
                return i[n].apply(this, e)
            }
        }
        function hu(e) {
            return {
                ts: 0,
                messages: [],
                bindings: e || [],
                level: {
                    label: "",
                    value: 0
                }
            }
        }
        function pu() {
            return {}
        }
        function mu(e) {
            return e
        }
        function fu() {}
        function gu() {
            return !1
        }
        function yu() {
            return Date.now()
        }
        lu.levels = {
            values: {
                fatal: 60,
                error: 50,
                warn: 40,
                info: 30,
                debug: 20,
                trace: 10
            },
            labels: {
                10: "trace",
                20: "debug",
                30: "info",
                40: "warn",
                50: "error",
                60: "fatal"
            }
        },
        lu.stdSerializers = sd,
        lu.stdTimeFunctions = Object.assign({}, {
            nullTime: gu,
            epochTime: yu,
            unixTime: function() {
                return Math.round(Date.now() / 1e3)
            },
            isoTime: function() {
                return new Date(Date.now()).toISOString()
            }
        });
        const vu = () => {}
        ;
        function Su(e, t) {
            t = (e = t in e ? e : console)[t] || e.log;
            return t ? t.bind(e) : vu
        }
        function Iu(r, n, t, i, a) {
            var {time: s, sessionId: o, critical: l, name: d, isEnabled: u, msg: c} = a;
            if (!(t.size && !t.has(d) || i.has(d))) {
                let e = "";
                if ("data"in a)
                    try {
                        const r = []
                          , n = [];
                        e = JSON.stringify(a.data, (e, t) => {
                            if ("object" == typeof t && null !== t) {
                                var i = n.indexOf(t);
                                if (-1 !== i)
                                    return `[Circular object reference: '${r[i]}']`;
                                r.push(e),
                                n.push(t)
                            }
                            return t
                        }
                        )
                    } catch (r) {
                        e = `Log serialization error: "${r}"`
                    }
                u && !u.value || r((t = new Date(s),
                i = t.getTimezoneOffset(),
                a = bu(Math.floor(Math.abs(i) / 60)),
                u = bu(Math.abs(i) % 60),
                i = i <= 0 ? "UTC+" + a : "UTC-" + a,
                i = u ? i + ":" + u : i,
                t.getFullYear() + "-" + bu(t.getMonth() + 1) + "-" + bu(t.getDate()) + " " + bu(t.getHours()) + ":" + bu(t.getMinutes()) + ":" + bu(t.getSeconds()) + "." + (t.getMilliseconds() / 1e3).toFixed(3).slice(2, 5) + " " + i + `| [SessionID: ${o}] | [${n}] >${l ? " [QE Critical]" : ""} [${d}] ${c || ""} ` + e))
            }
        }
        function bu(e) {
            return e < 10 ? "0" + e : e.toString()
        }
        function Tu(e, t, i) {
            return e.has(t) ? e.get(t) : (i = i(),
            e.set(t, i),
            i)
        }
        class Eu extends Map {
            constructor(e, t) {
                super(Array.isArray(e) ? e : Array.isArray(t) ? t : null),
                this.max = Eu.DEFAULT_MAX,
                "number" == typeof e ? this.max = e : "number" == typeof t && (this.max = t)
            }
            get(e) {
                let t;
                return super.has(e) ? (this.stats && (this.stats.hits = this.stats.hits ? 1 : this.stats.hits + 1),
                t = super.get(e),
                super.delete(e),
                t && super.set(e, t)) : this.stats && (this.stats.misses = this.stats.misses ? 1 : this.stats.misses + 1),
                t
            }
            set(e, t) {
                return this.size >= this.max && super.delete(super.keys().next().value),
                super.set(e, t),
                this
            }
        }
        Eu.DEFAULT_MAX = 5;
        function Au(e, t) {
            var i = {
                mediaOptions: new Array,
                audioGroups: new Set,
                subtitleGroups: new Set,
                closedCaptionGroups: new Set
            };
            for (const n of e) {
                if (( (e, t) => {
                    let i = !0
                      , r = (e.videoCodec && t.videoCodec && (i = q.isCompatibleVideoCodec(e.videoCodec, t.videoCodec)),
                    !1)
                      , n = (e.videoRange && t.videoRange ? r = e.videoRange == t.videoRange : e.videoRange || t.videoRange || (r = !0),
                    !0);
                    return e.audioCodec && t.audioCodec && (n = q.isCompatibleAudioCodec(e.audioCodec, t.audioCodec)),
                    i && r && n
                }
                )(t, n)) {
                    const e = n.audioAlternates && 0 < n.audioAlternates.length ? n.audioAlternates[0].groupId : void 0;
                    e && i.audioGroups.add(e),
                    i.mediaOptions.push(n)
                }
                const e = n.subtitleAlternates && 0 < n.subtitleAlternates.length ? n.subtitleAlternates[0].groupId : void 0;
                e && i.subtitleGroups.add(e);
                var r = n.closedcaption;
                r && i.closedCaptionGroups.add(r)
            }
            return i
        }
        const Ou = [le.ContentSteeringPathwayCloner, le.PathwayPenaltyBoxFilter, le.PermanentRemovalFilter, le.PenaltyBoxFilter, le.CompatibleIdsFilter, le.HDRFilter, le.ViewportFilter, le.HDCPFilter, le.MatchingPathwayFilter]
          , Ru = {
            [os.ABR]: [...Ou, le.HostRankFilter, le.NonIframeOnlyFilter, le.BitrateFilter],
            [os.ABRLowestLevel]: [...Ou, le.HostRankFilter, le.NonIframeOnlyFilter, le.ValidAlternatesFilter, le.LowerQualitySelector],
            [os.ABRIframe]: [...Ou, le.IframeOnlyFilter, le.BitrateFilter],
            [os.ABRIframeLowestLevel]: [...Ou, le.IframeOnlyFilter, le.LowerQualitySelector],
            [os.ErrorHandling]: [...Ou, le.PathwayRankSelector, le.LowerPivotQualitySelector, le.PivotAudioGroupSelector, le.ValidFallbackFilter, le.ErrorHandlingValidAlternatesFilter, le.FallbackSelector],
            [os.ErrorHandlingSdrOnly]: [le.ContentSteeringPathwayCloner, le.PathwayPenaltyBoxFilter, le.PermanentRemovalFilter, le.PenaltyBoxFilter, le.SdrOnlyFilter, le.ViewportFilter, le.HDCPFilter, le.MatchingPathwayFilter, le.PathwayRankSelector, le.LowerPivotQualitySelector, le.PivotAudioGroupSelector, le.ValidFallbackFilter, le.ErrorHandlingValidAlternatesFilter, le.FallbackSelector],
            [os.FirstSelection]: [le.ContentSteeringPathwayCloner, le.PathwayPenaltyBoxFilter, le.PermanentRemovalFilter, le.PenaltyBoxFilter, le.CompatibleIdsFilter, le.HDRFilter, le.ViewportFilter, le.HDCPFilter, le.PathwayFilter, le.NonIframeOnlyFilter],
            [os.ImageVariant]: [le.ContentSteeringPathwayCloner, le.MediaFilteringBasedOnImageIframes, le.MatchingPathwayFilter],
            [os.CompatibleOptions]: [le.ContentSteeringPathwayCloner, le.PathwayPenaltyBoxFilter, le.PermanentRemovalFilter, le.PenaltyBoxFilter, le.HDRFilter, le.ViewportFilter, le.HDCPFilter, le.PathwayFilter]
        };
        class wu {
            constructor(e, t, i, r, n) {
                this.store = e,
                this.transformersCache = t,
                this.selection$Cache = i,
                this.itemId = r,
                this.logger = n,
                this._selectTransformers = e => t => e.map(e => t[e]).filter(e => e)
            }
            variantFor(e) {
                var {transformersCache: t, _inputVariants: i} = this;
                return this._applyTransformers(i, this._transformers(e), t)[0]
            }
            variantsFor(e) {
                var {transformersCache: t, _inputVariants: i} = this;
                return this._applyTransformers(i, this._transformers(e), t)
            }
            variantFor$(e) {
                const {selection$Cache: t, transformersCache: i} = this;
                var r;
                return t.has(e) ? t.get(e) : (r = ma([this._inputVariants$, this._transformers$(e)]).pipe(W( ([e,t]) => this._applyTransformers(e, t, i)[0]), J(), Tn()),
                t.set(e, r),
                r)
            }
            getCompatibleOptionBasedOnFirstMediaOptions(e) {
                return Au(this.variantsFor(os.CompatibleOptions), e)
            }
            get _inputVariants() {
                return this.store.getEntity(this.itemId).inputVariants
            }
            get _inputVariants$() {
                return this.store.inputVariantsChanged$
            }
            _transformers(e) {
                return this._selectTransformers(Ru[e])(this.store.getEntity(this.itemId).transformers)
            }
            _transformers$(e) {
                return this.store.tranformersChanged$.pipe(this._selectTransformers$(Ru[e]))
            }
            _selectTransformers$(t) {
                return e => e.pipe(W(this._selectTransformers(t)), _n())
            }
            _produceVariants(e, t, i) {
                return Tu(e, t.generation, () => {
                    var e = i(t.variants);
                    return e === t.variants ? t : new js(e)
                }
                )
            }
            _applyTransformers(e, t, i) {
                for (const r of t) {
                    const t = e.variants
                      , n = Tu(i, r, wu.newTransformerCache);
                    if (e = this._produceVariants(n, e, r.apply.bind(r)),
                    this.Un(`Boss transformerID: ` + le[r.id], t, e.variants, this.logger),
                    0 === e.variants.length)
                        break
                }
                return e.variants
            }
            static newTransformerCache() {
                var e = new Eu;
                return e.stats = wu.TransformerCacheStats,
                e
            }
            Un(e, t, i, r) {
                t.filter(e => !i.includes(e)).map(e => e.mediaOptionId)
            }
        }
        wu.TransformerCacheStats = {
            hits: 0,
            misses: 0
        };
        class Pu {
            constructor() {
                this.inputVariantsChanged$ = new z,
                this.tranformersChanged$ = new z,
                this.Bn = {}
            }
            getEntity(e) {
                if (e)
                    return this.Bn[e]
            }
            addEntity(e) {
                this.Bn[e.itemId] = e
            }
            updateInputVariants(e, t) {
                e = this.Bn[e];
                e && (e.inputVariants = new js(t),
                this.inputVariantsChanged$.next(e.inputVariants))
            }
            updateTransformers(e, t, i) {
                e = this.Bn[e];
                e && (e.transformers[t] = i,
                this.tranformersChanged$.next(e.transformers))
            }
            deleteTransformers(e, t) {
                e = this.Bn[e];
                e && (delete e.transformers[t],
                this.tranformersChanged$.next(e.transformers))
            }
            removeEntityByID(e) {
                delete this.Bn[e]
            }
            resetStore() {
                this.Bn = {}
            }
        }
        const Mu = {
            NONE: 0,
            "TYPE-0": 1,
            "TYPE-1": 2,
            "TYPE-2": 3
        };
        function Cu(e) {
            return e in Mu
        }
        function ku(e) {
            return null == e ? 4 : Mu[e]
        }
        class Lu {
            constructor(e) {
                this.$n = e
            }
            get name() {
                return this.$n.name
            }
            get priority() {
                return this.$n.priority
            }
            get expiry() {
                return this.$n.expiry
            }
            filter(n, e) {
                const a = this.$n.initFn && this.$n.initFn(n, e) || (e ? Object.assign({}, e) : {});
                let t = n;
                return this.$n.firstPassFn && n.forEach( (e, t) => {
                    var i, r;
                    return null == (r = (i = this.$n).firstPassFn) ? void 0 : r.call(i, e, t, a, n)
                }
                ),
                this.$n.filterFn && (t = n.filter( (e, t) => {
                    var i, r;
                    return null == (r = (i = this.$n).filterFn) ? void 0 : r.call(i, e, t, a, n)
                }
                )),
                this.$n.finalFn && this.$n.finalFn(t, a, n),
                t
            }
        }
        function Nu(e, t, i) {
            return (t || []).reduce( (e, t) => t.filter(e, i), Array.from(e))
        }
        function Du(e, t) {
            return e - t
        }
        function xu(e) {
            return () => e
        }
        function Fu(i) {
            return (e, t) => -1 * i(e, t)
        }
        function Bu(...r) {
            return (e, t) => {
                for (const i of r) {
                    const r = i(e, t);
                    if (r)
                        return r
                }
                return 0
            }
        }
        function Uu(n, a, {AgtB: s, AltB: o, ABgtPvt: l, ABltPvt: d, ABeqPvt: u, AeqPvt: c, BeqPvt: h}={}) {
            return (e, t) => {
                var i = n(e, a)
                  , r = n(t, a);
                return u && 0 === i && 0 === r ? u(e, t) : c && 0 === i ? c(e, t) : h && 0 === r ? h(e, t) : 0 <= i && r < 0 || 0 < i && r <= 0 ? s ? s(e, t) : 1 : i <= 0 && 0 < r || i < 0 && 0 <= r ? o ? o(e, t) : -1 : 0 <= i && 0 <= r ? l ? l(e, t) : 0 : i <= 0 && r <= 0 && d ? d(e, t) : 0
            }
        }
        const _u = {
            clearkey: gl,
            fairplaystreaming: Vo,
            playready: Qo,
            widevine: Ko
        }
          , Vu = {
            getKeySystemFormat(e) {
                e = _u[e];
                return e ? e.keyFormatString : ""
            },
            getKeySystemSecurityLevel(e) {
                e = _u[e];
                return e ? e.securityLevels : null
            }
        };
        function Qu(e=!0) {
            return (e || !l.MediaSource ? l.ManagedMediaSource : void 0) || l.MediaSource || l.WebKitMediaSource
        }
        function Ku(e, t, i, r, n, a) {
            var {targetDuration: i, targetStartupMs: s} = i
              , r = r["avgPlaylistLoadTimeMs"]
              , n = n["avgParseTimeMs"]
              , {avgBufferCreateMs: a, avgInitFragAppendMs: o, avgDataFragAppendMs: l} = a
              , {avgBandwidth: t, avgLatencyMs: d} = t;
            return e.bandwidth <= t && (e.avgBandwidth || e.bandwidth) * i / t * 1e3 + r + a + 1 * (d + n + (o + l)) <= s
        }
        function Hu() {
            const r = new Set
              , n = new Set
              , i = (e, t) => {
                return i = e,
                t = t ? "audio" : "video",
                r.has(i) || n.has(i) || (( (e, t) => {
                    var i = Qu();
                    let r = i.isTypeSupported(e + `/mp4;codecs=` + t);
                    return r = "mp4a.40.34" === t ? r || i.isTypeSupported(e + `/mpeg`) : r
                }
                )(t, i) ? r : n).add(i),
                n.has(e);
                var i
            }
            ;
            return e => {
                let t = !1;
                return !(e.audioCodecList && (t = e.audioCodecList.some(e => i(e, !0))) || (t = e.videoCodecList ? e.videoCodecList.some(e => i(e, !1)) : t))
            }
        }
        function ju(e, t) {
            for (const i in e)
                if (e[i].type === t)
                    return e[i];
            return {}
        }
        function qu(e, t) {
            t = Vu.getKeySystemSecurityLevel(t);
            return null != e && null != t && void 0 !== t[e]
        }
        function Gu(e, t) {
            return !re(e) || !re(t) || e <= t
        }
        function $u(e, t) {
            if (!e || "number" == typeof e)
                return re(e) ? e : void 0;
            const i = re(t)
              , r = {
                framerate: NaN,
                bitrate: NaN
            }
              , n = Object.entries(e);
            for (const [e,a] of n) {
                const n = r.framerate
                  , s = parseFloat(e);
                re(s) && re(a) && (re(n) ? i ? s > n && s <= t && (r.framerate = s,
                r.bitrate = a) : s < n && (r.framerate = s,
                r.bitrate = a) : (r.framerate = s,
                r.bitrate = a))
            }
            return re(r.bitrate) ? r.bitrate : void 0
        }
        function Wu(e) {
            return e.every(e => e.iframes)
        }
        function zu(e) {
            return "PQ" === e.videoRange || "HLG" === e.videoRange
        }
        function Xu(e, t) {
            var i, r, n = 1.35;
            return !(!re(t.width) || !re(t.height)) && (i = e.width < t.width * n,
            r = e.height < t.height * n,
            e = e.width * e.height < t.width * t.height * n,
            i) && r && e
        }
        const Yu = (e=[]) => {
            const t = e.reduce( (e, t, i, r) => (e[t] = r.length - i,
            e), {});
            let i = -1;
            const r = {};
            return e => Object.prototype.hasOwnProperty.call(t, e) ? t[e] : Object.prototype.hasOwnProperty.call(r, e) ? r[e] : r[e] = i--
        }
          , Ju = (e, i=Yu(e)) => (e, t) => i(e.pathwayID) - i(t.pathwayID);
        function Zu(e, {hasScore: i, pivotVariant: r, pathwayPriority: t, enableSteering: n, preferHostOverQuality: a, preferCloseToPivotQuality: s}={
            hasScore: !1,
            pivotVariant: null,
            pathwayPriority: null,
            enableSteering: !1,
            preferHostOverQuality: !0,
            preferCloseToPivotQuality: !1
        }) {
            const o = (e, t) => e.bitrate - t.bitrate
              , l = i ? Bu( (e, t) => i && re(e.score) && re(t.score) ? e.score - t.score : 0, Fu(o)) : o
              , d = ( () => {
                const t = {};
                let i = 0;
                if (null != r) {
                    const i = ms(r.url);
                    i && (t[i] = e)
                }
                return e => {
                    e = ms(e.url);
                    return null == e ? -1 : (Object.prototype.hasOwnProperty.call(t, e) || (t[e] = i++),
                    t[e])
                }
            }
            )()
              , u = (e, t) => Fu(Du)(d(t), d(e))
              , c = [];
            return null != t && n && c.push(Ju(t)),
            a && c.push(u),
            s && null != r ? c.push(Uu(Fu(l), r, {
                AeqPvt: xu(1),
                BeqPvt: xu(-1),
                ABgtPvt: l,
                ABltPvt: Fu(l)
            })) : (null != r && c.push(Uu(l, r)),
            c.push(l)),
            a || c.push(u),
            null != r && c.push(Uu( (e, t) => null == e.audioAlternates || null == t.audioAlternates || (e.audioAlternates && 0 < e.audioAlternates.length ? e.audioAlternates[0].groupId : void 0) === (t.audioAlternates && 0 < t.audioAlternates.length ? t.audioAlternates[0].groupId : void 0) ? 1 : -1, r)),
            Bu(...c)
        }
        function ec(e, t) {
            e = [...e],
            r = t[0];
            var r, i, n, a, e = e.filter(t => {
                const i = performance.now();
                return !r || r.every(e => e.expiry <= i || t.mediaOptionId !== e.id)
            }
            );
            return a = t[1],
            e = e.filter(t => !a || a.every(e => t.mediaOptionId !== e)),
            i = e,
            n = t[2],
            e = i.filter(t => !n || n.some(e => e === t.mediaOptionId))
        }
        function tc(e, t, i, r) {
            return e && null != (e = e.find(e => !(0 < (null == r ? void 0 : r.length) && r.includes(e.mediaOptionId) || re(t) && e.persistentID !== t))) ? e : null
        }
        function ic(e, t) {
            var i = e.bitrate;
            return e.iframes ? (e = e.frameRate || 1,
            i * (t.minIframeDuration / e)) : i
        }
        function rc(e) {
            let t = 0;
            var {avgPlaylistLoadTimeMs: e, avgLatencyMs: i} = e;
            return re(e) ? t = e : re(i) && (t = i),
            t
        }
        function nc(e, t, i, r, n, a, s, o) {
            var l = n.avgBandwidth
              , t = t.bitrate
              , d = pc(i, e, r)
              , r = t * d
              , t = rc(n)
              , r = r / l + F(n.avgLatencyMs, 0) / 1e3
              , l = null == i || i.liveOrEvent
              , u = fc(n, !1, !1)
              , n = fc(n, o, l);
            let c = 0;
            if (a) {
                const t = (null == (l = null == (o = a.sbTuple[se.Variant]) ? void 0 : o.buffered) ? void 0 : l.len) || 0
                  , r = i ? ac(e, i, a) : sc(d, e.maxStarvationDelay);
                c = Math.max(0, Math.ceil((r - t) / d))
            }
            o = r + u;
            return {
                totalTime: r + n + (c = null == i || !i.liveOrEvent || i.ptsKnown && !oc(i.totalduration, t, s) ? c : 1) * o,
                avgTime: o
            }
        }
        function ac(e, t, i) {
            var r;
            let n = 1 / 0;
            var a = i.playingFrags[t.mediaOptionType];
            if (a) {
                const {mediaSeqNum: e, part: i, partIndex: r} = a;
                var a = i ? hc(t.parts, e, r) : hc(t.fragments, e);
                n = null != (a = null == a ? void 0 : a.duration) ? a : 1 / 0
            }
            var {minRequiredStartDuration: i, maxRequiredStartDuration: a, startTargetDurationFactor: e, liveAllowLowLatencyPlayback: s, minRequiredStartDurationLLHLS: o} = e
              , {targetduration: l, averagetargetduration: d, partTargetDuration: u} = t
              , e = e * Math.min(n, d, l, a, s && re(u) ? u : 1 / 0);
            let c = i;
            return s && null != (r = t.parts) && r.length && (c = o),
            Math.max(c, e)
        }
        function sc(e, t) {
            return re(e) ? Math.min(e, t) : t
        }
        function oc(e, t, i) {
            return t = re(t) ? t : 0,
            !re(i) || performance.now() - i + t > 1e3 * e
        }
        function lc(e, t) {
            t = re(t.avgParseTimeMs) ? t.avgParseTimeMs : 0;
            return performance.now() < e ? t / 1e3 : Math.max(0, t - (performance.now() - e)) / 1e3
        }
        function dc(e, t) {
            t = re(t.avgDataFragAppendMs) ? t.avgDataFragAppendMs : 0;
            return performance.now() < e ? t / 1e3 : Math.max(0, t - (performance.now() - e)) / 1e3
        }
        function uc(e, t) {
            const i = e.query.slice(1).split("&")
              , r = new Map;
            i.forEach(e => {
                var e = e.split("=")
                  , t = e[0]
                  , e = null != (e = e[1]) ? e : "";
                r.set(decodeURIComponent(t), decodeURIComponent(e))
            }
            );
            for (const [e,i] of Object.entries(t))
                i && r.set(e, i);
            let n = "";
            for (const [e,t] of Array.from(r.keys()).sort().map(e => {
                return [e, null != (e = r.get(e)) ? e : ""]
            }
            )) {
                const i = encodeURIComponent(e)
                  , r = encodeURIComponent(t);
                n.length ? n += `&${i}=` + r : n += `?${i}=` + r
            }
            e.query = n
        }
        function cc(t, i, r) {
            for (let e = 0; e < t.length; e++) {
                t[e] = Object.assign({}, t[e]);
                var n = t[e];
                if (!n.url && n.relativeUrl && (n.url = ps(n.relativeUrl, r)),
                i["URI-REPLACEMENT"]["PER-RENDITION-URIS"] && n.stableRenditionID && i["URI-REPLACEMENT"]["PER-RENDITION-URIS"][n.stableRenditionID])
                    n.url = i["URI-REPLACEMENT"]["PER-RENDITION-URIS"][n.stableRenditionID];
                else if (n.url) {
                    const t = i["URI-REPLACEMENT"].HOST
                      , r = i["URI-REPLACEMENT"].PARAMS
                      , a = us.parseURL(n.url);
                    a && (t && (a.netLoc = `//` + t),
                    r && uc(a, r),
                    n.url = us.buildURLFromParts(a))
                }
                n.groupId = `${n.groupId}_"${i.ID}"`,
                n.mediaOptionId = n.mediaOptionId + `_` + i.ID
            }
        }
        function hc(e, t, i=NaN) {
            if (null != e && e.length)
                return re(i) ? e.find(e => e.mediaSeqNum === t && e.partIndex === i) : e[t - (null == (e = e[0]) ? void 0 : e.mediaSeqNum)]
        }
        function pc(e, t, i) {
            return i ? null != (i = null == e ? void 0 : e.partTargetDuration) ? i : t.defaultPartTargetDuration : null != (i = null == e ? void 0 : e.targetduration) ? i : t.defaultTargetDuration
        }
        function mc(e, t, i) {
            return e && t && 0 < i
        }
        function fc(t, i, e) {
            let r = lc(1 / 0, t) + dc(1 / 0, t);
            if (i) {
                const i = t["avgInitFragAppendMs"];
                re(i) && (r += i / 1e3)
            }
            if (e) {
                const i = t["avgPlaylistParseTimeMs"];
                let e = rc(t);
                re(i) && (e += i),
                r += e / 1e3
            }
            return r
        }
        function gc(e) {
            return e ? q.isDolby(e) ? ts.DOVI : q.isHEVC(e) ? ts.HEVC : q.isVP09(e) ? ts.VP09 : q.isAVC(e) ? ts.AVC : ts.UNKNOWN : ts.UNKNOWN
        }
        function yc(e) {
            return null == e ? void 0 : e.substring(0, 4)
        }
        function vc(e) {
            return e ? q.isALAC(e) ? rs.ALAC : q.isFLAC(e) ? rs.FLAC : q.isEC3(e) ? rs.EC3 : q.isAC3(e) ? rs.AC3 : q.isXHEAAC(e) ? rs.XHEAAC : q.isAAC(e) ? rs.AAC : q.isMP3(e) ? rs.MP3 : rs.UNKNOWN : rs.UNKNOWN
        }
        class Sc {
            constructor(...e) {
                this.Vn = e
            }
            ensureSameIdentifierLength(e) {
                if (this.Vn.length !== e.Vn.length)
                    throw new j(!1,H.RankIdentifierComparisonError,`Identifiers have non-matching lengths! (${this.Vn.length} vs ${e.Vn.length})`)
            }
            isGreaterThan(t) {
                this.ensureSameIdentifierLength(t);
                for (let e = 0; e < this.Vn.length; ++e) {
                    if (this.Vn[e] < t.Vn[e])
                        return !1;
                    if (this.Vn[e] > t.Vn[e])
                        return !0
                }
                return !1
            }
            isEqualTo(i) {
                return this.ensureSameIdentifierLength(i),
                this.Vn.every( (e, t) => e === i.Vn[t])
            }
        }
        class Ic {
            apply(i) {
                let r, e = i;
                return this.initFn && (r = this.initFn(i)),
                this.firstPassFn && i.forEach( (e, t) => this.firstPassFn(e, t, i, r)),
                this.filterFn && (e = i.filter( (e, t) => this.filterFn(e, t, i, r))),
                this.finalFn && this.finalFn(e, i, r),
                e.length === i.length ? i : e
            }
        }
        (t = tu = tu || {})[t.SelectMinimum = 0] = "SelectMinimum",
        t[t.SelectMaximum = 1] = "SelectMaximum";
        class bc extends Ic {
            constructor(e) {
                super(),
                this.removed = e,
                this.filterFn = (t, e, i) => !this.removed || this.removed.every(e => t.mediaOptionId !== e)
            }
            get id() {
                return le.PermanentRemovalFilter
            }
        }
        class Tc extends Ic {
            constructor(e) {
                super(),
                this.compatibleIds = e,
                this.filterFn = (t, e, i) => !this.compatibleIds || this.compatibleIds.some(e => e === t.mediaOptionId)
            }
            get id() {
                return le.CompatibleIdsFilter
            }
        }
        class Ec extends Ic {
            constructor(e) {
                super(),
                this.penaltyBoxInfo = e,
                this.filterFn = (t, e, i) => {
                    const r = performance.now();
                    return !this.penaltyBoxInfo || this.penaltyBoxInfo.every(e => e.expiry <= r || t.mediaOptionId !== e.id)
                }
            }
            get id() {
                return le.PenaltyBoxFilter
            }
        }
        class Ac extends Ic {
            constructor(e) {
                super(),
                this.pathwayPenaltyBox = e,
                this.filterFn = (t, e, i) => {
                    const r = performance.now();
                    return !this.pathwayPenaltyBox || this.pathwayPenaltyBox.every(e => e.expiry <= r || t.pathwayID !== e.id)
                }
            }
            get id() {
                return le.PathwayPenaltyBoxFilter
            }
        }
        class Oc extends Ic {
            constructor(e, t) {
                super(),
                this.hasHdrLevels = e,
                this.preferHDR = t,
                this.filterFn = (e, t, i) => (this.hasHdrLevels && this.preferHDR) === zu(e)
            }
            get id() {
                return le.HDRFilter
            }
        }
        class Rc extends Ic {
            constructor(e) {
                super(),
                this.viewportInfo = e,
                this.initFn = e => {
                    let t = NaN;
                    for (const i of e)
                        i && !i.iframes && i.videoCodec && (t = !t || i.bitrate < t ? i.bitrate : t);
                    return {
                        lowestBitrate: t
                    }
                }
                ,
                this.filterFn = (e, t, i, r) => !(e && r && this.viewportInfo && e.videoCodec && r.lowestBitrate) || Xu({
                    width: e.width,
                    height: e.height
                }, this.viewportInfo) || e.bitrate === r.lowestBitrate
            }
            get id() {
                return le.ViewportFilter
            }
        }
        class wc extends Ic {
            constructor(e) {
                super(),
                this.maxHdcpLevel = e,
                this.filterFn = (e, t, i) => !Cu(this.maxHdcpLevel) || ku(e.hdcpLevel) < ku(this.maxHdcpLevel)
            }
            get id() {
                return le.HDCPFilter
            }
        }
        class Pc extends Ic {
            constructor(e, t) {
                super(),
                this.enabledUrl = e,
                this.baseUrl = t,
                this.initFn = e => this.qn(this.enabledUrl),
                this.qn = e => hs(e) ? ms(e) : ms(this.baseUrl),
                this.filterFn = (e, t, i, r) => {
                    var n;
                    return this.qn(null != (n = e.url) ? n : e.relativeUrl) === r
                }
            }
            get id() {
                return le.HostRankFilter
            }
        }
        class Mc extends Ic {
            constructor(e, t, i=!1, r=null) {
                super(),
                this.fromVariant = e,
                this.shouldSwitchHosts = t,
                this.shouldDownswitch = i,
                this.excludingOptions = r,
                this.filterFn = (e, t, i) => this.Kn(e)
            }
            get id() {
                return le.ValidFallbackFilter
            }
            Kn(t) {
                var e = !(t.iframes !== this.fromVariant.iframes || this.shouldSwitchHosts && vs(this.fromVariant, t))
                  , i = this.shouldDownswitch ? t.bitrate < this.fromVariant.bitrate : t.bitrate <= this.fromVariant.bitrate;
                return e && i && !(null != (e = this.excludingOptions) && e.some(e => e === t.mediaOptionId))
            }
        }
        class Cc extends Ic {
            constructor() {
                super(),
                this.filterFn = (e, t, i) => e.iframes && !!e.imageCodec
            }
            get id() {
                return le.MediaFilteringBasedOnImageIframes
            }
        }
        class kc {
            constructor(e=tu.SelectMinimum) {
                this.rule = e
            }
            apply(e) {
                const t = this.makeComparator(e)
                  , i = [...e]
                  , r = i.splice(0, 1);
                for (const e of i) {
                    const i = t(e, r[0]);
                    0 === i && r.push(e),
                    (this.rule === tu.SelectMinimum && i < 0 || this.rule === tu.SelectMaximum && 0 < i) && r.splice(0, r.length, e)
                }
                return r.length === e.length ? e : r
            }
        }
        (i = iu = iu || {})[i.SelectLowerQuality = 0] = "SelectLowerQuality",
        i[i.SelectHigherQuality = 1] = "SelectHigherQuality";
        class Lc extends kc {
            constructor(e=iu.SelectHigherQuality) {
                super(e === iu.SelectHigherQuality ? tu.SelectMaximum : tu.SelectMinimum),
                this.qualityRule = e,
                this.name = "QualitySelector"
            }
            get id() {
                return le.QualitySelector
            }
            makeComparator(e) {
                const i = e.every(e => null != e.score)
                  , t = (e, t) => e.bitrate - t.bitrate;
                return i ? Bu( (e, t) => i && re(e.score) && re(t.score) ? e.score - t.score : 0, Fu(t)) : t
            }
        }
        class Nc extends Ic {
            constructor(e, t) {
                super(),
                this.minBitrate = e,
                this.maxBitrate = t,
                this.name = "BitrateFilter",
                this.filterFn = (e, t, i) => e.bitrate >= this.minBitrate && e.bitrate <= this.maxBitrate
            }
            get id() {
                return le.BitrateFilter
            }
        }
        class Dc extends Ic {
            constructor() {
                super(),
                this.filterFn = (e, t, i) => !1 === zu(e)
            }
            get id() {
                return le.SdrOnlyFilter
            }
        }
        class xc extends kc {
            constructor(e, t=iu.SelectHigherQuality) {
                super(t === iu.SelectHigherQuality ? tu.SelectMaximum : tu.SelectMinimum),
                this.criteria = e,
                this.qualityRule = t,
                this.name = "SortSelector"
            }
            get id() {
                return le.FallbackSelector
            }
            makeComparator(e) {
                return Zu(e.length, this.criteria)
            }
        }
        class Fc extends Ic {
            constructor(e, t, i, r, n, a, s, o) {
                super(),
                this.currentAudioIsAtmos = e,
                this.altAudioFilterParams = t,
                this.subtitleFilterParams = i,
                this.audioPersistentId = r,
                this.subtitlePersistentId = n,
                this.mediaOptionMask = a,
                this.excludingOptions = s,
                this.switchingAudioLanguage = o,
                this.filterFn = (t, e, i) => {
                    var r, n = ec(null != (n = t.subtitleAlternates) ? n : [], this.subtitleFilterParams);
                    let a = ec(null != (s = t.audioAlternates) ? s : [], this.altAudioFilterParams);
                    this.switchingAudioLanguage || null == this.currentAudioIsAtmos || (a = (s = a,
                    r = this.currentAudioIsAtmos,
                    0 === (o = s.filter(e => !!e.channels && r === q.isJOCChannels(e.channels))).length && r ? s : o));
                    {
                        var [s,o,t,l,d,u=[]] = [t, this.audioPersistentId, this.subtitlePersistentId, a, this.mediaOptionMask, this.excludingOptions];
                        let e = !1;
                        var c, h, l = function(e, t, i, r, n) {
                            e = re(i) ? tc(e, i, 0, n) : void 0,
                            i = re(r) ? tc(t, r, 0, n) : void 0;
                            return [e || de, i || de]
                        }(l, n, o, t, u);
                        return c = [s, ...l],
                        h = d,
                        e = [se.Variant, se.AltAudio, se.Subtitle].reduce( (e, t) => e && h[t] === Ds(c[t]), !0) ? !0 : e
                    }
                }
            }
            get id() {
                return le.ValidAlternatesFilter
            }
        }
        class Bc extends Ic {
            constructor(e) {
                super(),
                this.iframeMode = e,
                this.filterFn = (e, t, i) => e.iframes === this.iframeMode
            }
            get id() {
                return le.MediaFilterBasedOnMode
            }
        }
        class Uc extends Ic {
            constructor(e) {
                super(),
                this.currentPathwayID = e,
                this.filterFn = (e, t, i) => ys(e.pathwayID, this.currentPathwayID)
            }
            get id() {
                return le.MatchingPathwayFilter
            }
        }
        class _c extends class {
            apply(e) {
                var t = this.getNewVariants(e);
                return 0 === t.length ? e : t.concat(e)
            }
        }
        {
            constructor(e, t, i) {
                super(),
                this.pathwayClones = e,
                this.mvpUrl = t,
                this.clonedPathwayMapping = i
            }
            get id() {
                return le.ContentSteeringPathwayCloner
            }
            Hn(t) {
                const i = new Map;
                let r, e, n = !1;
                if (this.pathwayClones.forEach(e => {
                    i.has(e["BASE-ID"]) || t.has(e["BASE-ID"]) || (n = !0),
                    i.set(e.ID, e),
                    r ? r.push([e["BASE-ID"], e.ID]) : r = [[e["BASE-ID"], e.ID]]
                }
                ),
                n) {
                    try {
                        e = g(r)
                    } catch (t) {
                        return
                    }
                    this.pathwayClones = [],
                    e.forEach(e => {
                        i.has(e) && this.pathwayClones.push(i.get(e))
                    }
                    )
                }
            }
            getNewVariants(t) {
                var i;
                const r = new Map;
                t.forEach(e => {
                    r.has(e.pathwayID) ? r.get(e.pathwayID).push(e) : r.set(e.pathwayID, [e])
                }
                ),
                this.Hn(r);
                for (let e = 0; e < this.pathwayClones.length; e++) {
                    const n = this.pathwayClones[e]
                      , a = []
                      , s = n["BASE-ID"];
                    if (!r.has(n.ID) && !this.clonedPathwayMapping.has(n.ID) && (r.has(s) || this.clonedPathwayMapping.has(s))) {
                        const t = null != (i = r.get(s)) ? i : this.clonedPathwayMapping.get(s)
                          , o = new Map
                          , l = new Map;
                        t.forEach(e => {
                            var t = Object.assign({}, e);
                            if (t.mediaOptionId = t.mediaOptionId + `_` + n.ID,
                            a.push(t),
                            t.pathwayID = n.ID,
                            !t.url && t.relativeUrl && (t.url = ps(t.relativeUrl, this.mvpUrl)),
                            t.url) {
                                var i = us.parseURL(t.url);
                                if (n["URI-REPLACEMENT"].HOST && (i.netLoc = `//` + n["URI-REPLACEMENT"].HOST),
                                n["URI-REPLACEMENT"].PARAMS && uc(i, n["URI-REPLACEMENT"].PARAMS),
                                n["URI-REPLACEMENT"]["PER-VARIANT-URIS"] && e.stableVariantID && n["URI-REPLACEMENT"]["PER-VARIANT-URIS"][e.stableVariantID] ? t.url = n["URI-REPLACEMENT"]["PER-VARIANT-URIS"][e.stableVariantID] : t.url = us.buildURLFromParts(i),
                                t.audioAlternates && 0 < t.audioAlternates.length) {
                                    const e = `${t.audioAlternates.find(e => !!e).groupId}_"${n.ID}"`;
                                    if (o.has(e))
                                        t.audioAlternates = o.get(e);
                                    else {
                                        const e = [...t.audioAlternates];
                                        cc(e, n, this.mvpUrl),
                                        t.audioAlternates = e;
                                        i = t.audioAlternates.find(e => !!e).groupId;
                                        o.set(i, t.audioAlternates)
                                    }
                                }
                                if (t.subtitleAlternates && 0 < t.subtitleAlternates.length) {
                                    const e = `${t.subtitleAlternates.find(e => !!e).groupId}_"${n.ID}"`;
                                    if (l.has(e))
                                        t.subtitleAlternates = l.get(e);
                                    else {
                                        const e = [...t.subtitleAlternates];
                                        cc(e, n, this.mvpUrl),
                                        t.subtitleAlternates = e;
                                        i = t.subtitleAlternates.find(e => !!e).groupId;
                                        l.set(i, t.subtitleAlternates)
                                    }
                                }
                                t.closedcaption && (t.closedcaption = `${t.closedcaption}_"${n.ID}"`)
                            }
                        }
                        ),
                        this.clonedPathwayMapping.set(n.ID, a)
                    }
                }
                let n = [];
                for (const [t,i] of this.clonedPathwayMapping)
                    n = n.concat(i);
                return n
            }
        }
        class Vc {
            constructor(e) {
                this.ce = e,
                this.zn = {
                    [le.LowerQualitySelector]: new Lc(iu.SelectLowerQuality),
                    [le.HigherQualitySelector]: new Lc(iu.SelectHigherQuality),
                    [le.SdrOnlyFilter]: new Dc,
                    [le.NonIframeOnlyFilter]: new Bc(!1),
                    [le.IframeOnlyFilter]: new Bc(!0),
                    [le.MediaFilteringBasedOnImageIframes]: new Cc
                },
                this.transformersCache = new Map,
                this.selection$Cache = new Map
            }
            getQuery(e, t) {
                return this.transformersCache.has(e) || this.transformersCache.set(e, new WeakMap),
                this.selection$Cache.has(e) || this.selection$Cache.set(e, new Eu),
                new wu(this.ce,this.transformersCache.get(e),this.selection$Cache.get(e),e,t)
            }
            setVariants(e, t) {
                this._addEmptyEntity(e),
                this.ce.updateInputVariants(e, t)
            }
            setTransformer(e, t, i) {
                this._addEmptyEntity(e),
                this.ce.updateTransformers(e, t, i)
            }
            setMultipleTransformers(e, t) {
                for (var [i,r] of t)
                    this.setTransformer(e, i, r)
            }
            removeTransformer(e, t) {
                this._addEmptyEntity(e),
                this.ce.deleteTransformers(e, t)
            }
            destroyItems(e) {
                e.forEach(this.destroyItem.bind(this))
            }
            destroyItem(e) {
                this.transformersCache.delete(e),
                this.selection$Cache.delete(e),
                this.ce.removeEntityByID(e)
            }
            endItem() {
                this.transformersCache.clear(),
                this.selection$Cache.clear(),
                this.ce.resetStore()
            }
            destroy() {
                this.transformersCache.clear(),
                this.selection$Cache.clear(),
                this.ce.resetStore()
            }
            _addEmptyEntity(e) {
                this.ce.getEntity(e) || this.ce.addEntity({
                    itemId: e,
                    inputVariants: new js([]),
                    transformers: Object.assign({}, this.zn)
                })
            }
        }
        const Qc = {
            timeRangesToBufferedRange(t) {
                var i = [];
                for (let e = 0; t && e < t.length; e++)
                    i.push({
                        start: t.start(e),
                        end: t.end(e)
                    });
                return i
            },
            getBufferedInfo(e, t, i) {
                let r, n, a, s, o;
                var l = this.getBufferedTimeRanges(e, i)
                  , d = Math.max(i, .001);
                for (o = 0,
                r = 0,
                n = a = t; o < l.length; o++) {
                    const e = l[o]["start"]
                      , i = l[o]["end"];
                    if (t + d >= e && t < i)
                        n = e,
                        a = i,
                        r = a - t;
                    else if (t + d < e) {
                        s = e;
                        break
                    }
                }
                return {
                    len: r,
                    start: n,
                    end: a,
                    nextStart: s
                }
            },
            getBufferedTimeRanges(e, t) {
                var i = []
                  , r = e.map( ({start: e, end: t}) => ({
                    start: e,
                    end: t
                }));
                r.sort( (e, t) => e.start - t.start || t.end - e.end);
                for (let e = 0; e < r.length; e++) {
                    var n, a = i.length;
                    a && (n = i[a - 1].end,
                    r[e].start - n < t) ? r[e].end > n && (i[a - 1].end = r[e].end) : i.push(r[e])
                }
                return i
            },
            isTimeRangeContainedInRanges(t, i, r=.25) {
                for (let e = 0; e < t.length; e++)
                    if (i.start >= t[e].start - r && i.end <= t[e].end + r)
                        return !0;
                return !1
            }
        };
        function Kc(e, i) {
            return null == e && null == i || null != e && null != i && e.combined === i.combined && e.sbTuple.every( (e, t) => e === i.sbTuple[t])
        }
        function Hc(e) {
            return null != e && "iframeMediaDuration"in e && "iframeMediaStart"in e
        }
        function jc(e, t) {
            return e === t || e && t && e.itemId === t.itemId && e.mediaOptionId === t.mediaOptionId && e.mediaSeqNum === t.mediaSeqNum && e.discoSeqNum === t.discoSeqNum && (!e.part && !t.part || e.part === t.part && e.partIndex === t.partIndex)
        }
        function qc(e, t) {
            return e === t || e && t && e.itemId === t.itemId && e.mediaOptionId === t.mediaOptionId && e.mediaSeqNum === t.mediaSeqNum && e.discoSeqNum === t.discoSeqNum
        }
        function Gc(e, t) {
            return t && e && t.part && !e.part && t.itemId === e.itemId && t.mediaOptionId === e.mediaOptionId && t.mediaSeqNum === e.mediaSeqNum
        }
        function $c(e) {
            var {itemId: e, mediaOptionId: t, discoSeqNum: i, keyTagInfo: r} = e;
            return {
                itemId: e,
                mediaOptionId: t,
                discoSeqNum: i,
                keyId: ut(null == r ? void 0 : r.keyId)
            }
        }
        function Wc(e, i) {
            return null == e || e.length !== i.length || e.some( (e, t) => e.start !== i[t].start || e.end !== i[t].end)
        }
        ($l = ru = ru || {}).Seek = "Seek",
        $l.HighBuffer = "HighBuffer",
        $l.LowBuffer = "LowBuffer",
        $l.BufferHole = "BufferHole",
        (ed = nu = nu || {})[ed.AlmostDry = 0] = "AlmostDry",
        ed[ed.LowWater = 1] = "LowWater",
        ed[ed.HighWater = 2] = "HighWater",
        ed[ed.AboveHighWater = 3] = "AboveHighWater";
        class zc extends Ua {
            constructor() {
                super({}, {
                    name: "media-element-store"
                }),
                this.Qn = new ja(this),
                this.Gn = ""
            }
            get activeId() {
                return this.Gn
            }
            startMediaSession(i, r, n, a) {
                return this.Gn = `media session: ` + (new Date).toISOString(),
                ae( () => {
                    var e = a
                      , t = Math.max(e, r - e)
                      , e = {
                        id: this.activeId,
                        desiredRate: !i.autoplay && i.paused ? 0 : 1,
                        paused: i.paused,
                        gotPlaying: !1,
                        seeking: i.seeking,
                        seekTo: null,
                        flushing: !1,
                        readyState: i.readyState,
                        ended: i.ended,
                        bufferedRanges: [],
                        contentGapRanges: [],
                        haveEnough: !1,
                        stopStreaming: !1,
                        mediaSourceEntity: null,
                        expectSeekingEvent: !1,
                        expectedSbCount: NaN,
                        bufferMonitorInfo: {
                            waterLevelType: null,
                            almostDryWaterLevelSeconds: n,
                            lowWaterLevelSeconds: e,
                            highWaterLevelSeconds: t,
                            maxBufferSeconds: r
                        },
                        mediaOptionParsedSubtitleRecord: {},
                        textTracksCreated: !1,
                        waitingForDisco: !1
                    };
                    this.add(e),
                    this.setActive(this.activeId)
                }
                ),
                this.activeId
            }
            Wn(e, t, i) {
                var r = this.Qn.getActive()
                  , n = null == r ? void 0 : r.mediaSourceEntity;
                if (r && n)
                    return (r = {}).mediaSourceEntity = Object.assign(Object.assign({}, n), {
                        sourceBufferEntities: n.sourceBufferEntities ? [...n.sourceBufferEntities] : [null, null]
                    }),
                    (n = null != (n = r.mediaSourceEntity.sourceBufferEntities[e]) ? n : i) ? (r.mediaSourceEntity.sourceBufferEntities[e] = Object.assign(Object.assign({}, n), t),
                    r) : void 0
            }
            Xn(e, t, i) {
                e = this.Wn(e, t, i);
                e && this.updateActive(e)
            }
            setMediaSourceEntity(e, t) {
                var i = this.Qn.getActive();
                i && this.updateActive({
                    mediaSourceEntity: null != e && null != t ? {
                        objectUrl: e,
                        readyState: t,
                        duration: NaN,
                        sourceBufferEntities: [null, null]
                    } : null,
                    bufferedRanges: [],
                    haveEnough: !1,
                    stopStreaming: !1,
                    expectSeekingEvent: !1,
                    readyState: 0,
                    bufferMonitorInfo: Object.assign(Object.assign({}, i.bufferMonitorInfo), {
                        waterLevelType: null
                    }),
                    seeking: !1
                })
            }
            set mediaElementDuration(e) {
                var t = this.Qn.getActive()
                  , i = null == t ? void 0 : t.mediaElementDuration;
                t && i !== e && this.updateActive({
                    mediaElementDuration: e
                })
            }
            set primaryContentMediaElementDuration(e) {
                var t = this.Qn.getActive()
                  , i = null == t ? void 0 : t.primaryContentMediaElementDuration;
                t && i !== e && (!re(i) || 0 < e && i < e) && this.updateActive({
                    primaryContentMediaElementDuration: e
                })
            }
            set msReadyState(e) {
                var t = this.Qn.getActive()
                  , i = null == (i = null == t ? void 0 : t.mediaSourceEntity) ? void 0 : i.readyState;
                t && i !== e && this.updateActive({
                    mediaSourceEntity: Object.assign(Object.assign({}, t.mediaSourceEntity), {
                        readyState: e
                    })
                })
            }
            set readyState(e) {
                var t, i = this.Qn.getActive();
                i && (null == i ? void 0 : i.readyState) !== e && (t = {
                    readyState: e
                },
                e >= HTMLMediaElement.HAVE_METADATA && (t.expectSeekingEvent = null != i.seekTo),
                this.updateActive(t))
            }
            set ended(e) {
                var t = this.Qn.getActive()
                  , i = null == t ? void 0 : t.ended;
                t && i !== e && this.updateActive({
                    ended: e
                })
            }
            set msDuration(e) {
                var t = this.Qn.getActive()
                  , i = null == (i = null == t ? void 0 : t.mediaSourceEntity) ? void 0 : i.duration;
                t && i !== e && this.updateActive({
                    mediaSourceEntity: Object.assign(Object.assign({}, t.mediaSourceEntity), {
                        duration: e
                    })
                })
            }
            set textTracksCreated(e) {
                var t = this.Qn.getActive()
                  , i = null == t ? void 0 : t.textTracksCreated;
                t && i !== e && this.updateActive({
                    textTracksCreated: e
                })
            }
            set expectedSbCount(e) {
                var t = this.Qn.getActive()
                  , i = null == t ? void 0 : t.expectedSbCount;
                t && i !== e && this.updateActive({
                    expectedSbCount: e
                })
            }
            setSeekToPos(e, t=!1, i, r, n) {
                var a, s = this.Qn.getActive();
                s && (a = {},
                re(e) ? (a.seekTo = {
                    pos: e,
                    fromEvent: t,
                    discoSeqNum: i,
                    inContentGap: r,
                    startPos: n
                },
                a.gotPlaying = !1,
                a.haveEnough = !1,
                a.stopStreaming = !1,
                a.expectSeekingEvent = s.readyState >= HTMLMediaElement.HAVE_METADATA) : a.seekTo = null,
                t && (a.seeking = re(e),
                a.stopStreaming = !1,
                a.expectSeekingEvent = !1),
                this.updateActive(a))
            }
            setLiveSeekableRange(e) {
                this.updateActive({
                    liveSeekableRange: e
                })
            }
            set seeking(e) {
                this.updateActive({
                    seeking: e,
                    expectSeekingEvent: !1
                })
            }
            set paused(e) {
                var t = {
                    paused: e
                };
                (t.paused = e) && (t.gotPlaying = !1),
                this.updateActive(t)
            }
            gotPlayingEvent() {
                var e = this.Qn.getActive();
                !e || e.gotPlaying || e.paused || this.updateActive({
                    gotPlaying: !0
                })
            }
            set desiredRate(e) {
                this.updateActive({
                    desiredRate: e
                })
            }
            set haveEnough(e) {
                var t;
                (null == (t = this.Qn.getActive()) ? void 0 : t.haveEnough) !== e && this.updateActive({
                    haveEnough: e
                })
            }
            set stopStreaming(e) {
                var t;
                (null == (t = new ja(this).getActive()) ? void 0 : t.stopStreaming) !== e && this.updateActive({
                    stopStreaming: e
                })
            }
            set flushing(e) {
                var t;
                !(null == (t = this.Qn.getActive()) || !t.flushing) != !!e && this.updateActive({
                    flushing: e
                })
            }
            set waitingForDisco(e) {
                var t;
                !(null == (t = this.Qn.getActive()) || !t.waitingForDisco) != !!e && this.updateActive({
                    waitingForDisco: e
                })
            }
            setSourceBufferUpdating(e) {
                this.Xn(e, {
                    updating: !0,
                    error: void 0
                })
            }
            setTimestampOffset(e, t) {
                var i = this.Qn.getActive()
                  , i = null == (i = null == (i = null == i ? void 0 : i.mediaSourceEntity) ? void 0 : i.sourceBufferEntities) ? void 0 : i[e];
                i && i.timestampOffset !== t && this.Xn(e, {
                    timestampOffset: t
                })
            }
            setBufferedRangesUpdated(e, t, a, s, o, i) {
                var r = this.Qn.getActive();
                if (r) {
                    var n = null == (n = null == (n = r.mediaSourceEntity) ? void 0 : n.sourceBufferEntities) ? void 0 : n[e]
                      , l = null == n ? void 0 : n.bufferedRanges
                      , d = r.bufferedRanges
                      , l = s || Wc(l, t)
                      , d = s || Wc(d, a)
                      , u = i && null != (null == n ? void 0 : n.inFlight);
                    if (null != n && n.updating || l || d || u) {
                        var n = {}
                          , u = null == (u = null == (u = r.mediaSourceEntity) ? void 0 : u.sourceBufferEntities) ? void 0 : u[e];
                        if (u) {
                            n.mediaSourceEntity = Object.assign(Object.assign({}, r.mediaSourceEntity), {
                                sourceBufferEntities: [...r.mediaSourceEntity.sourceBufferEntities]
                            });
                            const a = Object.assign({}, u);
                            if (a.updating = !1,
                            (l || i) && (a.bufferedRanges = [...t],
                            a.bufferedSegments = [...u.bufferedSegments]),
                            i && (s ? a.inFlight = null : (r = a,
                            t = o,
                            u = r.inFlight,
                            i = r.bufferedSegments,
                            u && re(u.startPTS) && re(u.endPTS) && function(i, r, n) {
                                if (0 === i.length || i[0].startPTS >= r.endPTS)
                                    return i.splice(0, 0, r);
                                let a = !1;
                                for (let t = i.length - 1; -1 < t; t--) {
                                    let e = i[t];
                                    var s = e.endPTS - e.startPTS
                                      , o = Math.max(r.startPTS, e.startPTS)
                                      , l = Math.min(r.endPTS, e.endPTS)
                                      , d = l - o;
                                    l < o || d < n || ((d = (1 - d / s) * e.bytes) <= 0 ? (!e.evicting && jc(e.frag, r.frag) && (r.rebuffered = !0),
                                    i.splice(t, 1)) : ((e = Object.isFrozen(e) ? i[t] = Object.assign({}, e) : e).bytes = d,
                                    e.startPTS < r.startPTS ? e.endPTS = o : (e.startPTS = l,
                                    a || (i.splice(t, 0, r),
                                    a = !0))))
                                }
                                if (!a) {
                                    let e = i.length - 1;
                                    for (; 0 < e && i[e].startPTS > r.startPTS; )
                                        e--;
                                    i.splice(e + 1, 0, r)
                                }
                            }(i, u, t),
                            r.inFlight = null)),
                            l) {
                                var c = a;
                                o = s;
                                const m = c.bufferedSegments
                                  , f = c.bufferedRanges;
                                let i, r = 0, n = !1;
                                if (f.length)
                                    for (let e = m.length - 1; -1 < e; e--) {
                                        let t = m[e];
                                        (t = Object.isFrozen(t) ? m[e] = Object.assign({}, t) : t).partialFrag && !t.evicting && (t.evicting = !0);
                                        const g = !t.frag.iframe;
                                        g && t.frag.isLastFragment && e === m.length - 1 && (i = t.frag);
                                        var h = t.endPTS - t.startPTS
                                          , p = function(e, t) {
                                            var i = t.endPTS - t.startPTS
                                              , r = function(e, t) {
                                                let i, r = 0;
                                                for (const s of e)
                                                    if (s.start <= t.endPTS && s.end > t.startPTS) {
                                                        n = t,
                                                        a = s;
                                                        const e = Math.min(n.endPTS, a.end) - Math.max(n.startPTS, a.start);
                                                        e > r && (i = s,
                                                        r = e)
                                                    } else if (0 < r)
                                                        break;
                                                var n, a;
                                                return i
                                            }(e, t);
                                            if (r) {
                                                const e = Math.max(r.start, t.startPTS)
                                                  , n = Math.min(r.end, t.endPTS)
                                                  , a = n - e;
                                                return {
                                                    overlapStart: e,
                                                    overlapEnd: n,
                                                    appendedDuration: a,
                                                    appendedBytes: t.bytes * a / i
                                                }
                                            }
                                        }(f, t);
                                        if (p) {
                                            const {overlapStart: c, overlapEnd: m, appendedDuration: f, appendedBytes: e} = p;
                                            r += e,
                                            g && (f < h && re(t.appendStart) && re(t.appendEnd) && (t.appendStart < c || t.appendEnd > m) && (t.evicting = !0),
                                            t.appendStart = c,
                                            t.appendEnd = m)
                                        } else
                                            m.splice(e, 1),
                                            n = t.frag === i
                                    }
                                else
                                    m.length && m.splice(0, m.length);
                                c.totalDuration = i && !n && 0 < f.length ? f[f.length - 1].end : 1 / 0,
                                c.gotQuotaExceeded = c.gotQuotaExceeded || o,
                                c.totalBytes = r,
                                c.maxTotalBytes = Math.max(c.totalBytes, c.maxTotalBytes)
                            }
                            n.mediaSourceEntity.sourceBufferEntities[e] = a
                        }
                        d && (n.bufferedRanges = [...a]),
                        this.updateActive(n)
                    }
                }
            }
            updateContentGapRanges(e) {
                this.updateActive({
                    contentGapRanges: e
                })
            }
            updateSourceBufferEntity(e, t) {
                var {mimeType: t, audioCodec: i, videoCodec: r} = t;
                this.Xn(e, {
                    mimeType: t,
                    audioCodec: i,
                    videoCodec: r,
                    initSegmentInfo: null
                })
            }
            setSourceBufferEntity(e, t) {
                var {mimeType: t, audioCodec: i, videoCodec: r} = t;
                this.Xn(e, {}, {
                    mimeType: t,
                    audioCodec: i,
                    videoCodec: r,
                    updating: !1,
                    bufferedRanges: [],
                    timestampOffset: 0,
                    inFlight: null,
                    bufferedSegments: [],
                    totalBytes: 0,
                    maxTotalBytes: 0,
                    gotQuotaExceeded: !1,
                    totalDuration: 1 / 0
                })
            }
            setInflightSegment(e, t) {
                this.Xn(e, {
                    inFlight: t
                })
            }
            updateInFlightRange(e, t) {
                var i = this.Qn.getActive()
                  , r = null == (r = null == i ? void 0 : i.inFlightRanges) ? void 0 : r[e];
                !i || null == r && null == t || null != r && null != t && r.start === t.start && r.end === t.end || ((r = i.inFlightRanges ? [...i.inFlightRanges] : [null, null])[e] = t,
                this.updateActive({
                    inFlightRanges: r
                }))
            }
            setInitSegmentEntity(e, t) {
                this.Xn(e, {
                    initSegmentInfo: t
                })
            }
            setSourceBufferError(e, t) {
                this.Xn(e, {
                    inFlight: null,
                    updating: !1,
                    error: t
                })
            }
            setStallInfo(e) {
                var t = this.Qn.getActive()
                  , i = null == t ? void 0 : t.stallInfo;
                t && (null == i ? void 0 : i.currentTime) !== (null == e ? void 0 : e.currentTime) && (t = {
                    stallInfo: e
                },
                e && (t.gotPlaying = !1),
                this.updateActive(t))
            }
            setNudgeInfo(e) {
                this.updateActive({
                    nudgeInfo: e
                })
            }
            updateWaterLevels(e, t) {
                var i = this.Qn.getActive()
                  , r = null == (r = null == i ? void 0 : i.bufferMonitorInfo) ? void 0 : r.waterLevelType;
                i && !Kc(r, {
                    combined: e,
                    sbTuple: t
                }) && this.updateActive({
                    bufferMonitorInfo: Object.assign(Object.assign({}, i.bufferMonitorInfo), {
                        waterLevelType: {
                            combined: e,
                            sbTuple: [...t]
                        }
                    })
                })
            }
            set bufferMonitorTargetDuration(e) {
                var t, i, r, n, a = this.Qn.getActive();
                !a || !re(e) || e <= 0 || ({maxBufferSeconds: n, lowWaterLevelSeconds: t, highWaterLevelSeconds: i} = a.bufferMonitorInfo,
                r = Math.min(e, n),
                n = Math.max(r, n - e),
                r === t && n === i) || this.updateActive({
                    bufferMonitorInfo: Object.assign(Object.assign({}, a.bufferMonitorInfo), {
                        lowWaterLevelSeconds: r,
                        highWaterLevelSeconds: n
                    })
                })
            }
            archiveParsedSubtitleFragmentRecord(e, t, i) {
                var r, n = this.Qn.getActive();
                n && ((r = (r = (n = {
                    mediaOptionParsedSubtitleRecord: Object.assign({}, n.mediaOptionParsedSubtitleRecord)
                }).mediaOptionParsedSubtitleRecord[e]) ? Object.assign({}, r) : {})[t] = i,
                n.mediaOptionParsedSubtitleRecord[e] = r,
                this.updateActive(n))
            }
            clearAllParsedSubtitleFragmentRecord() {
                var e = null == (e = this.Qn.getActive()) ? void 0 : e.mediaOptionParsedSubtitleRecord;
                e && 0 === Object.keys(e).length || this.updateActive({
                    mediaOptionParsedSubtitleRecord: {}
                })
            }
            clearParsedSubtitleFragmentRecord(e) {
                var t, i = this.Qn.getActive();
                i && null != (t = i.mediaOptionParsedSubtitleRecord) && t[e] && (delete (t = Object.assign({}, i.mediaOptionParsedSubtitleRecord))[e],
                this.updateActive({
                    mediaOptionParsedSubtitleRecord: t
                }))
            }
            removeOldSubtitleFragmentRecord(t) {
                const i = this.Qn.getActive();
                if (i) {
                    const n = {
                        mediaOptionParsedSubtitleRecord: {}
                    };
                    for (const a of Object.keys(i.mediaOptionParsedSubtitleRecord)) {
                        let e;
                        var r = i.mediaOptionParsedSubtitleRecord[a];
                        for (const i of Object.keys(r)) {
                            const n = Number(i)
                              , s = r[n];
                            s.endTime > t && ((e = e || {})[n] = s)
                        }
                        null != e && (n.mediaOptionParsedSubtitleRecord[a] = e)
                    }
                    this.updateActive(n)
                }
            }
            removeLaterSubtitleFragmentRecord(t) {
                const i = this.Qn.getActive();
                if (i) {
                    const n = {
                        mediaOptionParsedSubtitleRecord: {}
                    };
                    for (const a of Object.keys(i.mediaOptionParsedSubtitleRecord)) {
                        let e;
                        var r = i.mediaOptionParsedSubtitleRecord[a];
                        for (const i of Object.keys(r)) {
                            const n = Number(i)
                              , s = r[n];
                            s.startTime < t && ((e = e || {})[n] = s)
                        }
                        e && (n.mediaOptionParsedSubtitleRecord[a] = e)
                    }
                    this.updateActive(n)
                }
            }
        }
        function Xc(e) {
            return null != (e = null == e ? void 0 : e.itemStartOffsets[se.Variant]) ? e : 0
        }
        function Yc(e) {
            return re(e) && 0 !== e && 1 !== e
        }
        function Jc(e) {
            return re(e) && (0 === e || 1 === e)
        }
        class Zc extends Error {
        }
        class eh {
            constructor(e) {
                this.value = e,
                this.Yn = [],
                this.Jn = 0,
                this.Zn = 0
            }
            lock(e, t=!1) {
                return this.tr(!0, e, t)
            }
            unlock() {
                this.er(!0)
            }
            readLock(e, t=!1) {
                return this.tr(!1, e, t)
            }
            readUnlock() {
                this.er(!1)
            }
            ir() {
                const t = [];
                this.Yn = this.Yn.filter(e => !this.nr(e.rw) || (e.rw ? ++this.Jn : ++this.Zn,
                t.push(e),
                !1));
                for (const e of t)
                    e.observer.next(this.value),
                    e.observer.complete()
            }
            nr(e) {
                return e && 0 === this.Jn && 0 === this.Zn || !e && 0 === this.Jn
            }
            tr(s, o, i=!1) {
                "boolean" == typeof o && ([i,o] = [o, void 0]);
                var e = new G(e => {
                    var t = this.nr(s);
                    if (i && !t)
                        throw new Zc;
                    t ? (s ? ++this.Jn : ++this.Zn,
                    e.next(),
                    e.complete()) : this.Yn.push({
                        rw: s,
                        observer: e
                    })
                }
                );
                return o ? e.pipe(_r( () => {
                    {
                        var i = this.value
                          , r = e => {
                            this.value = e
                        }
                          , n = () => this.er(s)
                          , a = o;
                        if (!a)
                            return Y(i);
                        let e, t;
                        try {
                            e = a(i, r)
                        } catch (i) {
                            t = R( () => i)
                        }
                        return (t = t || (void 0 === e ? Y(i) : Lr(e))).pipe(ee(n))
                    }
                }
                )) : e
            }
            er(e) {
                e ? this.Jn = Math.max(this.Jn - 1, 0) : this.Zn = Math.max(this.Zn - 1, 0),
                this.ir()
            }
        }
        class th extends G {
            constructor() {
                super(e => this.rr.pipe(Z(e => 0 === e), tn(1), rn(void 0)).subscribe(e)),
                this.rr = new pn(0)
            }
            wrap(e) {
                return na( () => (this.add(),
                Lr(e))).pipe(ie({
                    error: e => this.rr.error(e)
                }), ee( () => this.done()))
            }
            add(e=1) {
                this.rr.next(this.rr.value + e)
            }
            done(e=1) {
                this.rr.next(this.rr.value - e)
            }
        }
        function ih(t, e) {
            return [{
                threshold: e.highWaterLevelSeconds,
                level: nu.HighWater
            }, {
                threshold: e.lowWaterLevelSeconds,
                level: nu.LowWater
            }, {
                threshold: e.almostDryWaterLevelSeconds,
                level: nu.AlmostDry
            }].find( ({threshold: e}) => e < t)
        }
        function rh(t, e) {
            return [{
                threshold: e.almostDryWaterLevelSeconds,
                level: nu.AlmostDry
            }, {
                threshold: e.lowWaterLevelSeconds,
                level: nu.LowWater
            }, {
                threshold: e.highWaterLevelSeconds,
                level: nu.HighWater
            }, {
                threshold: 1 / 0,
                level: nu.AboveHighWater
            }].find( ({threshold: e}) => t <= e)
        }
        function nh(t, i) {
            const r = [null, null];
            return [oe.Variant, oe.AltAudio].forEach(e => {
                null != t.sourceBufferEntityByType(e) && (r[e] = rh(t.getCurrentWaterLevelByType(e, i), t.bufferMonitorInfo).level)
            }
            ),
            {
                combined: rh(t.getCurrentWaterLevel(i), t.bufferMonitorInfo).level,
                sbTuple: r
            }
        }
        function ah(i, r) {
            return Fr([i.combinedBuffer$, i.seeking$]).pipe(te( () => ce(i.updating$, e => !e)), Pr(sr), W( () => i.getCurrentWaterLevel(r)), J(), te(e => {
                var t = Y(nh(i, r));
                return 0 === e ? t : t.pipe(on( () => Fr([i.paused$, i.stallInfo$]).pipe(W( ([e,t]) => !e && null == t), J(), te(e => e ? function t(i, r, e) {
                    const n = i.getCurrentWaterLevel(r)
                      , a = ih(n, i.bufferMonitorInfo);
                    if (a) {
                        const e = a["threshold"];
                        return yr(Math.ceil(1e3 * (n - e))).pipe(te( () => {
                            const e = ih(i.getCurrentWaterLevel(r), i.bufferMonitorInfo);
                            return (null == e ? void 0 : e.level) === a.level ? t(i, r) : ue
                        }
                        ), W( () => nh(i, r)))
                    }
                    return X
                }(i, r) : X), tn(1))))
            }
            ))
        }
        class sh extends ja {
            constructor(e, t, i) {
                super(t),
                this.sr = e,
                this.R = i
            }
            get mediaElementDuration$() {
                return this.selectActive( ({mediaElementDuration: e}) => e)
            }
            get primaryContentMediaElementDuration() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.primaryContentMediaElementDuration) ? e : 1 / 0
            }
            get mediaElementDuration() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.mediaElementDuration) ? e : 1 / 0
            }
            get msDuration() {
                var e;
                return null != (e = null == (e = this.mediaSourceEntity) ? void 0 : e.duration) ? e : 1 / 0
            }
            get minSBDuration() {
                var e;
                let i = Number.POSITIVE_INFINITY;
                return null != (e = null == (e = this.mediaSourceEntity) ? void 0 : e.sourceBufferEntities) && e.forEach( (e, t) => {
                    e && (i = re(e.totalDuration) ? Math.min(i, e.totalDuration) : Number.NEGATIVE_INFINITY)
                }
                ),
                re(i) ? i : 1 / 0
            }
            get currentTime() {
                return this.sr.currentTime
            }
            get clientWidth() {
                return this.sr.clientWidth
            }
            get clientHeight() {
                return this.sr.clientHeight
            }
            getBufferedDuration(e=.5) {
                var t = Qc.timeRangesToBufferedRange(this.sr.buffered)
                  , t = Qc.getBufferedInfo(t, this.currentTime, e);
                return t.end - t.start
            }
            get mediaSourceEntity() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.mediaSourceEntity
            }
            get msReadyState() {
                var e;
                return null == (e = this.mediaSourceEntity) ? void 0 : e.readyState
            }
            get sourceBufferEntities() {
                var e;
                return null == (e = this.mediaSourceEntity) ? void 0 : e.sourceBufferEntities
            }
            sourceBufferEntityByType(e) {
                var t;
                return null == (t = this.sourceBufferEntities) ? void 0 : t[e]
            }
            initSegmentEntityByType(e) {
                return null == (e = this.sourceBufferEntityByType(e)) ? void 0 : e.initSegmentInfo
            }
            get maxBufferSize() {
                var e = null == (e = this.sourceBufferEntities) ? void 0 : e[oe.Variant];
                let t = 1 / 0;
                return t = null != e && e.gotQuotaExceeded ? null != (e = e.maxTotalBytes) ? e : 1 / 0 : t
            }
            get seekable() {
                return this.sr.seekable
            }
            get liveSeekableRange() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.liveSeekableRange
            }
            get liveSeekableRange$() {
                return this.selectActive( ({liveSeekableRange: e}) => e)
            }
            get seekableTimeRanges() {
                return oh(this.liveSeekableRange, this.seekable)
            }
            get seekableTimeRanges$() {
                return Fr([this.liveSeekableRange$, this.mediaElementDuration$]).pipe(W( ([e]) => oh(e, this.seekable)))
            }
            get isPlayingAtLive() {
                var {liveSeekableRange: e, isIframeRate: t} = this;
                return null != e && !t && this.currentTime >= e.boundary + (performance.now() - e.tupdate) / 1e3
            }
            get expectSeekingEvent() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.expectSeekingEvent) && e
            }
            get desiredRate() {
                var e;
                return (null == (e = this.getActive()) ? void 0 : e.desiredRate) || 0
            }
            get desiredRate$() {
                return this.selectActive( ({desiredRate: e}) => null != e ? e : 0)
            }
            get effectiveRate() {
                return this.isIframeRate ? this.desiredRate : this.paused ? 0 : 1
            }
            get playbackRate() {
                return this.sr.playbackRate
            }
            get isIframeRate() {
                return Yc(this.desiredRate)
            }
            get isIframeRate$() {
                return this.desiredRate$.pipe(W(Yc))
            }
            get msObjectUrl$() {
                return this.selectActive( ({mediaSourceEntity: e}) => null == e ? void 0 : e.objectUrl).pipe(J())
            }
            get msReadyState$() {
                return this.selectActive( ({mediaSourceEntity: e}) => {
                    return null != (e = null == e ? void 0 : e.readyState) ? e : null
                }
                )
            }
            get readyState() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.readyState) ? e : 0
            }
            get readyState$() {
                return this.selectActive( ({readyState: e}) => null != e ? e : 0)
            }
            get mediaSourceEntity$() {
                return this.selectActive( ({mediaSourceEntity: e}) => e)
            }
            get expectedSbCount$() {
                return this.selectActive( ({expectedSbCount: e}) => e)
            }
            get expectedSbCount() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.expectedSbCount
            }
            get paused$() {
                return this.selectActive( ({paused: e}) => e)
            }
            get paused() {
                var e;
                return null == (e = null == (e = this.getActive()) ? void 0 : e.paused) || e
            }
            get flushing$() {
                return this.selectActive( ({flushing: e}) => e)
            }
            get flushing() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.flushing) && e
            }
            get waitingForDisco$() {
                return this.selectActive( ({waitingForDisco: e}) => e)
            }
            get waitingForDisco() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.waitingForDisco) && e
            }
            get gotPlaying() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.gotPlaying) && e
            }
            get gotPlaying$() {
                return this.selectActive( ({gotPlaying: e}) => e)
            }
            get seekTo() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.seekTo
            }
            get seekTo$() {
                return this.selectActive( ({seekTo: e}) => e)
            }
            get seeking() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.seeking) && e
            }
            get seeking$() {
                return this.selectActive( ({seeking: e}) => e)
            }
            get seekToPos$() {
                return this.selectActive( ({seekTo: e}) => null == e ? void 0 : e.pos).pipe(J())
            }
            get seekInProgress() {
                var e;
                return re(null == (e = this.seekTo) ? void 0 : e.pos)
            }
            get seekInProgress$() {
                return this.selectActive( ({seekTo: e}) => re(null == e ? void 0 : e.pos)).pipe(J())
            }
            get nudgeTarget$() {
                return this.selectActive( ({nudgeInfo: e}) => null == e ? void 0 : e.nudgeTarget)
            }
            get nudgeCount() {
                var e;
                return null != (e = null == (e = null == (e = this.getActive()) ? void 0 : e.nudgeInfo) ? void 0 : e.nudgeCount) ? e : 0
            }
            get inFlightRange() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.inFlightRanges
            }
            get inFlightRanges$() {
                return this.selectActive( ({inFlightRanges: e}) => e)
            }
            get sourceBufferEntities$() {
                return this.selectActive( ({mediaSourceEntity: e}) => null == e ? void 0 : e.sourceBufferEntities)
            }
            sourceBufferEntityByType$(t) {
                return this.selectActive( ({mediaSourceEntity: e}) => {
                    return null == (e = null == e ? void 0 : e.sourceBufferEntities) ? void 0 : e[t]
                }
                )
            }
            bufferedSegmentsByType$(t) {
                return this.selectActive( ({mediaSourceEntity: e}) => {
                    return null != (e = null == (e = null == (e = null == e ? void 0 : e.sourceBufferEntities) ? void 0 : e[t]) ? void 0 : e.bufferedSegments) ? e : []
                }
                )
            }
            getBufferedSegmentsByType(e) {
                return null != (e = null == (e = this.sourceBufferEntityByType(e)) ? void 0 : e.bufferedSegments) ? e : []
            }
            get bufferedSegmentsTuple$() {
                return this.selectActive(e => {
                    var t;
                    return [null != (t = null == (t = null == (t = null == (t = null == e ? void 0 : e.mediaSourceEntity) ? void 0 : t.sourceBufferEntities) ? void 0 : t[oe.Variant]) ? void 0 : t.bufferedSegments) ? t : [], null != (e = null == (t = null == (e = null == (t = null == e ? void 0 : e.mediaSourceEntity) ? void 0 : t.sourceBufferEntities) ? void 0 : e[oe.AltAudio]) ? void 0 : t.bufferedSegments) ? e : []]
                }
                )
            }
            get timeupdate$() {
                var e = dl(this.sr);
                return this.ar || (this.ar = e.event("timeupdate").pipe(kn(125, void 0, {
                    leading: !0,
                    trailing: !0
                }), W( () => this.currentTime), Z(e => re(e)), Tn())),
                this.ar
            }
            get playingEvent$() {
                return dl(this.sr).event("playing").pipe(W( () => {}
                ))
            }
            get mediaElementEntity$() {
                return this.selectActive(e => Boolean(e))
            }
            get ended$() {
                return this.selectActive(e => {
                    return null != (e = null == e ? void 0 : e.ended) && e
                }
                )
            }
            sbUpdating$(t) {
                return this.selectActive(e => {
                    return null != (e = null == (e = null == (e = null == (e = null == e ? void 0 : e.mediaSourceEntity) ? void 0 : e.sourceBufferEntities) ? void 0 : e[t]) ? void 0 : e.updating) && e
                }
                )
            }
            sbUpdating(e) {
                var t;
                return null != (e = null == (t = null == (t = null == (t = null == (t = this.getActive()) ? void 0 : t.mediaSourceEntity) ? void 0 : t.sourceBufferEntities) ? void 0 : t[e]) ? void 0 : t.updating) && e
            }
            sbError(e) {
                var t;
                return null == (t = null == (t = null == (t = null == (t = this.getActive()) ? void 0 : t.mediaSourceEntity) ? void 0 : t.sourceBufferEntities) ? void 0 : t[e]) ? void 0 : t.error
            }
            get updating$() {
                return Fr([this.sbUpdating$(oe.Variant), this.sbUpdating$(oe.AltAudio)]).pipe(W(e => e.some(e => e)), J())
            }
            get bufferedRangeTuple$() {
                return this.selectActive(e => {
                    var t;
                    return [null == (t = null == (t = null == (t = null == e ? void 0 : e.mediaSourceEntity) ? void 0 : t.sourceBufferEntities) ? void 0 : t[oe.Variant]) ? void 0 : t.bufferedRanges, null == (t = null == (e = null == (t = null == e ? void 0 : e.mediaSourceEntity) ? void 0 : t.sourceBufferEntities) ? void 0 : e[oe.AltAudio]) ? void 0 : t.bufferedRanges]
                }
                )
            }
            get bufferedRangeTuple() {
                return [this.getBufferedRangeByType(oe.Variant), this.getBufferedRangeByType(oe.AltAudio)]
            }
            getBufferedRangeByType$(t) {
                return this.selectActive(e => {
                    return null != (e = null == (e = null == (e = null == (e = null == e ? void 0 : e.mediaSourceEntity) ? void 0 : e.sourceBufferEntities) ? void 0 : e[t]) ? void 0 : e.bufferedRanges) ? e : []
                }
                )
            }
            getBufferedRangeByType(e) {
                var t;
                return null != (e = null == (t = null == (t = this.sourceBufferEntities) ? void 0 : t[e]) ? void 0 : t.bufferedRanges) ? e : []
            }
            get combinedBuffer$() {
                return this.selectActive(e => {
                    return null != (e = null == e ? void 0 : e.bufferedRanges) ? e : []
                }
                )
            }
            get combinedBuffer() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.bufferedRanges) ? e : []
            }
            gotFirstAppend$(e) {
                var t = ce(Fr([this.combinedBuffer$, this.updating$]), ([e,t]) => 0 < (null == e ? void 0 : e.length) && !t);
                return e ? kr(t, e) : t
            }
            get desiredPos() {
                var e;
                return F(null == (e = this.seekTo) ? void 0 : e.pos, this.currentTime)
            }
            getMediaBufferInfo(i, e) {
                const t = this.getBufferInfo(i, e)
                  , r = [null, null];
                t.forEach( (e, t) => {
                    r[t] = null != (e = null == (t = e.bufferedSegments.find(e => e.startPTS <= i && e.endPTS > i)) ? void 0 : t.frag) ? e : null
                }
                );
                e = this.getCombinedBufferInfo(i, e);
                return {
                    pos: i,
                    playbackRate: this.playbackRate,
                    sbTuple: t,
                    combined: e,
                    playingFrags: r
                }
            }
            getBufferInfo(r, n, a) {
                var e;
                const t = null == (e = this.sourceBufferEntities) ? void 0 : e.map(e => null == e ? void 0 : e.bufferedRanges)
                  , i = {
                    buffered: {
                        start: r,
                        end: r,
                        len: 0
                    },
                    bufferedSegments: []
                }
                  , s = [i, i];
                return t && t.forEach( (t, e) => {
                    if (t) {
                        var i = Qc.getBufferedInfo(t, r, n)
                          , t = null != (t = this.sourceBufferEntities[e].bufferedSegments) ? t : [];
                        if (a) {
                            let e = !1;
                            for (const r of t)
                                r.frag.itemId === a && r.startPTS < i.end && r.endPTS >= i.start && (e = !0,
                                i.start = Math.max(i.start, r.startPTS),
                                i.end = Math.min(i.end, r.endPTS));
                            e || (i.start = i.end = r),
                            i.len = i.start - i.end
                        }
                        s[e] = {
                            buffered: i,
                            bufferedSegments: t
                        }
                    }
                }
                ),
                s
            }
            getCombinedBufferInfo(e, t) {
                var i = this.getActive();
                return i ? Qc.getBufferedInfo(i.bufferedRanges, e, t) : null
            }
            getContentGapRanges() {
                var e = this.getActive();
                return e ? e.contentGapRanges : []
            }
            hasGaps$() {
                return this.selectActive(e => 0 < (null == e ? void 0 : e.contentGapRanges.length))
            }
            avoidContentGap(t, i, e) {
                let r = t;
                var n = this.getActive();
                if (n)
                    for (let e = 0; e < n.contentGapRanges.length; e++) {
                        var a = n.contentGapRanges[e];
                        if (t > a.start - i && t < a.end) {
                            r = a.end;
                            break
                        }
                    }
                return r
            }
            get bufferMonitorInfo() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.bufferMonitorInfo) ? e : null
            }
            get bufferMonitorThresholds$() {
                return this.selectActive(e => {
                    var t, i, r, e = null == e ? void 0 : e.bufferMonitorInfo;
                    return e ? ({almostDryWaterLevelSeconds: e, lowWaterLevelSeconds: t, highWaterLevelSeconds: i, maxBufferSeconds: r} = e,
                    {
                        almostDryWaterLevelSeconds: e,
                        lowWaterLevelSeconds: t,
                        highWaterLevelSeconds: i,
                        maxBufferSeconds: r
                    }) : null
                }
                ).pipe(J( (e, t) => (null == e ? void 0 : e.lowWaterLevelSeconds) === (null == t ? void 0 : t.lowWaterLevelSeconds)))
            }
            get highWaterLevelSeconds() {
                var e;
                return null == (e = this.bufferMonitorInfo) ? void 0 : e.highWaterLevelSeconds
            }
            get lowWaterLevelSeconds() {
                var e;
                return null == (e = this.bufferMonitorInfo) ? void 0 : e.lowWaterLevelSeconds
            }
            get waterLevelType$() {
                return this.selectActive(e => {
                    return null != (e = null == e ? void 0 : e.bufferMonitorInfo.waterLevelType) ? e : null
                }
                )
            }
            waterLevelForType(e) {
                var t;
                return null != (t = null == (t = null == (t = this.bufferMonitorInfo) ? void 0 : t.waterLevelType) ? void 0 : t.sbTuple[e]) ? t : null
            }
            waterLevelChangedForType$(t) {
                return this.waterLevelType$.pipe(W(e => null == e ? null : null == t ? e.combined : e.sbTuple[t]))
            }
            isBufferedToEnd$(r, t=!0) {
                return ma([this.combinedBuffer$, this.selectActive(e => e.bufferMonitorInfo).pipe(Kl(), W(e => t ? e.almostDryWaterLevelSeconds : Math.max(e.almostDryWaterLevelSeconds, e.lowWaterLevelSeconds / 2))), this.seeking$]).pipe(W( ([e,t]) => {
                    var i = this.minSBDuration;
                    return !(!e || !re(i)) && (e = Qc.getBufferedInfo(e, this.currentTime, r).end,
                    Math.abs(i - e) <= t)
                }
                ), J())
            }
            get haveEnough() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.haveEnough) && e
            }
            get haveEnough$() {
                return this.selectActive( ({haveEnough: e}) => e)
            }
            get stopStreaming() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.stopStreaming) && e
            }
            withinFragDurationOfContentGap(t, i=10) {
                var r = this.getContentGapRanges();
                for (let e = 0; e < r.length; e++)
                    if (t > r[e].start - i && t < r[e].start)
                        return !0;
                return !1
            }
            static likelyToKeepUp(e, t, i) {
                return t && e && i >= e.HAVE_FUTURE_DATA
            }
            get playbackLikelyToKeepUp() {
                return sh.likelyToKeepUp(this.sr, this.haveEnough, this.readyState)
            }
            get playbackLikelyToKeepUp$() {
                return Fr([this.haveEnough$, this.readyState$]).pipe(W( ([e,t]) => sh.likelyToKeepUp(this.sr, e, t)), J())
            }
            getCurrentWaterLevel(e) {
                var t = this.currentTime
                  , i = null != (i = null == (i = this.getActive()) ? void 0 : i.bufferedRanges) ? i : [];
                return Qc.getBufferedInfo(i, t, e).len
            }
            getCombinedMediaSourceBufferInfo(e) {
                var t = this.currentTime
                  , [i,r] = null != (i = null == (i = null == (i = this.getActive()) ? void 0 : i.mediaSourceEntity) ? void 0 : i.sourceBufferEntities) ? i : [void 0, void 0];
                return [Qc.getBufferedInfo(null != (i = null == i ? void 0 : i.bufferedRanges) ? i : [], t, e), Qc.getBufferedInfo(null != (i = null == r ? void 0 : r.bufferedRanges) ? i : [], t, e)]
            }
            getCurrentWaterLevelByType(e, t) {
                var i = this.currentTime
                  , e = this.sourceBufferEntityByType(e)
                  , e = null != (e = null == e ? void 0 : e.bufferedRanges) ? e : [];
                return Qc.getBufferedInfo(e, i, t).len
            }
            canContinuePlaybackWithoutGap(e, t, i, r) {
                if ("LIVE" !== e.type)
                    return !0;
                if (!e.ptsKnown)
                    return !1;
                var n = this.currentTime
                  , i = performance.now() + i.avgPlaylistLoadTimeMs + 1e3 * e.targetduration
                  , a = e.fragments
                  , s = a[0].start
                  , a = a[a.length - 1].start + a[a.length - 1].duration
                  , i = s + (i - t) / 1e3;
                let o = this.getBufferInfo(n, r)[Qs(e.mediaOptionType)].buffered["end"];
                return i <= (o = o >= s - r && o <= a ? a : o) + r
            }
            get stallInfo$() {
                return this.selectActive(e => {
                    return null != (e = null == e ? void 0 : e.stallInfo) ? e : null
                }
                )
            }
            get stallInfo() {
                var e;
                return null != (e = null == (e = this.getActive()) ? void 0 : e.stallInfo) ? e : null
            }
            get textTracks() {
                return this.sr.textTracks
            }
            get textTracksCreated$() {
                return this.selectActive(e => null == e ? void 0 : e.textTracksCreated)
            }
            get mediaOptionParsedSubtitleRecord() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.mediaOptionParsedSubtitleRecord
            }
            getParsedSubtitleRecordsForMediaOption(e) {
                return this.mediaOptionParsedSubtitleRecord ? this.mediaOptionParsedSubtitleRecord[e] || {} : null
            }
            gotQuotaExceeded(e) {
                return null != (e = null == (e = this.sourceBufferEntityByType(e)) ? void 0 : e.gotQuotaExceeded) && e
            }
            maxTotalBytesByType(e) {
                return null != (e = null == (e = this.sourceBufferEntityByType(e)) ? void 0 : e.maxTotalBytes) ? e : 1 / 0
            }
            likelyToExceedBuffer(t, i, r, n, a) {
                var s, o, l = F(t, this.currentTime);
                let d = !1
                  , u = 0;
                const c = null != (t = this.highWaterLevelSeconds) ? t : 1 / 0
                  , h = this.sourceBufferEntityByType(i);
                if (h && h.gotQuotaExceeded && re(r) && re(h.maxTotalBytes)) {
                    if (!a) {
                        const t = this.getBufferedRangeByType(i);
                        a = Qc.getBufferedInfo(t, l, n)
                    }
                    const t = this.getBufferedSegmentsByType(i);
                    let e = 0;
                    for (const i of t) {
                        const {startPTS: t, endPTS: n, appendStart: d, appendEnd: c} = i
                          , h = Math.max(a.start, null != d ? d : t)
                          , p = Math.min(a.end, null != c ? c : n);
                        p <= l || h > a.end || h >= p || (s = p - h,
                        o = n - t,
                        (e += i.bytes * s / o) >= r && 0 === u && (u = a.end - p))
                    }
                    d = e + r > h.maxTotalBytes
                }
                return u = d ? Math.min(u, c) : c,
                {
                    likelyToExceed: d,
                    safeWaterLevel: u
                }
            }
        }
        function oh(e, t) {
            let i = Qc.timeRangesToBufferedRange(t);
            if (e) {
                const t = [];
                for (const r of i)
                    r.end < e.start || r.start > e.edge || t.push({
                        start: Math.max(e.start, r.start),
                        end: Math.min(e.edge, r.end)
                    });
                i = t
            }
            return i
        }
        class lh {
            constructor(e, t, i, r) {
                this.ze = e,
                this.lr = t,
                this.R = r,
                this.ur = i.useCustomMediaFunctions,
                this.cr = i.overridePlaybackRate
            }
            install() {
                const e = this.lr;
                e && (this.ur && e && e.play && e.pause && (e.originalPlay || (e.originalPlay = e.play.bind(e)),
                e.originalPause || (e.originalPause = e.pause.bind(e)),
                e.play = () => (this.ze.checkForReplay(),
                this.ze.desiredRate = 1,
                0 < e.currentTime && !e.paused && !e.ended && 2 < e.readyState ? Promise.resolve() : new Promise( (e, t) => {
                    this.hr || (this.hr = []),
                    this.hr.push({
                        resolve: e,
                        reject: t
                    })
                }
                )),
                e.pause = () => {
                    this.ze.desiredRate = 0
                }
                ),
                "function" == typeof HTMLMediaElement && this.cr && Object.defineProperty(e, "playbackRate", {
                    enumerable: !0,
                    configurable: !0,
                    get: function() {
                        return 1
                    },
                    set: function(e) {
                        Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, "playbackRate").set.call(this, e)
                    }
                }),
                this.dr = null,
                this.expectPauseEvent = this.expectPlayEvent = !1)
            }
            uninstall() {
                var e = this.lr;
                e && (e.originalPlay && (e.play = e.originalPlay,
                delete e.originalPlay),
                e.originalPause && (e.pause = e.originalPause,
                delete e.originalPause),
                this.cr) && (e.playbackRate = 1,
                delete e.playbackRate),
                this.dr = null,
                this.expectPauseEvent = this.expectPlayEvent = !1
            }
            play() {
                var e;
                this.lr && (e = this.ze.flushing,
                this.dr || e || (this.expectPlayEvent = this.expectPlayEvent || this.lr.paused,
                this.dr = this.vr(),
                this.dr && this.dr.then( () => {
                    this.dr = null,
                    this.pr(null)
                }
                ).catch(e => {
                    this.dr = null,
                    this.expectPlayEvent = !1,
                    this.pr(e || new j(!1,H.PlayRejected)),
                    "NotAllowedError" === (null == e ? void 0 : e.name) && (this.ze.desiredRate = 0)
                }
                )))
            }
            pause(e=!1) {
                this.lr && (e ? (this.pr(null),
                this.mr()) : this.dr ? this.dr.then( () => {
                    var e = this.ze.mediaQuery;
                    (0 === this.ze.desiredRate || e.seeking && !e.playbackLikelyToKeepUp) && this.mr()
                }
                ).catch(e => {}
                ) : this.mr())
            }
            pr(t) {
                var e, i = null == (e = this.hr) ? void 0 : e.length;
                if (t)
                    for (let e = 0; e < i; e++)
                        this.hr[e].reject(t);
                else
                    for (let e = 0; e < i; e++)
                        this.hr[e].resolve();
                this.hr = []
            }
            vr() {
                return (this.lr.originalPlay || this.lr.play.bind(this.lr))()
            }
            mr() {
                return this.expectPauseEvent = this.expectPauseEvent || !this.lr.paused,
                (this.lr.originalPause || this.lr.pause.bind(this.lr))()
            }
        }
        class dh extends Error {
        }
        class uh extends b {
            constructor(e, t, i, r, n) {
                super(he.MEDIA_ERROR, e, t, i, n),
                this.sbType = r,
                this.response = i
            }
        }
        class ch extends uh {
            constructor(e, t, i, r) {
                super(Q.BUFFER_ADD_CODEC_ERROR, !1, e, t, r),
                this.mediaOptionId = i,
                this.mediaOptionType = Ks(this.sbType)
            }
        }
        class hh extends uh {
            constructor(e, t, i, r, n, a) {
                super(e, t, i, r, a),
                this.isTimeout = n,
                this.mediaOptionType = Ks(this.sbType)
            }
        }
        class ph extends hh {
            constructor(e, t, i, r) {
                super(Q.BUFFER_FULL_ERROR, !1, e, t, !1, r),
                this.maxTotalBytes = i
            }
        }
        class mh extends hh {
            constructor(e, t, i) {
                super(Q.BUFFER_APPEND_ERROR, !1, e, t, !0, i)
            }
        }
        class fh extends hh {
            constructor(e, t, i, r) {
                super(Q.BUFFER_APPEND_ERROR, !1, e, t, !1, r),
                this.mediaOptionId = i,
                this.mediaOptionType = Ks(this.sbType)
            }
        }
        class gh extends b {
            constructor(e, t, i, r, n, a=NaN, s) {
                super(he.MEDIA_ERROR, e, t, i, s),
                this.stallType = r,
                this.bufferLen = n,
                this.nudgePosition = a,
                this.response = i
            }
        }
        class yh extends G {
            constructor(n, e, a, s, o, l, d, u, c) {
                super(e => {
                    var t = dl(l)
                      , i = (this.R = u.child({
                        sb: o
                    }),
                    n.setSourceBufferEntity(o, d),
                    d.mimeType.includes("audio/mpeg") && (this.updateMp3Timestamps = !0),
                    [t.event("updatestart").pipe(ie( () => {
                        n.setSourceBufferUpdating(o)
                    }
                    )), t.event("updateend").pipe(Pr(Zn), ie( () => {
                        var e = Qc.timeRangesToBufferedRange(l.buffered)
                          , t = Qc.timeRangesToBufferedRange(a.buffered);
                        this.yr && (this.yr(),
                        this.yr = null),
                        n.setBufferedRangesUpdated(o, e, t, !1, c.maxBufferHole, !0)
                    }
                    )), t.event("error").pipe(ie( () => {
                        this.yr = null,
                        n.setSourceBufferError(o, "Got source buffer error")
                    }
                    )), t.event("abort").pipe(ie( () => {
                        this.yr = null
                    }
                    ))]);
                    "onbufferedchange"in t.target && i.push(t.event("bufferedchange").pipe(Pr(Zn), ie(e => {
                        if (e.removedRanges) {
                            const e = Qc.timeRangesToBufferedRange(l.buffered)
                              , t = Qc.timeRangesToBufferedRange(a.buffered);
                            n.setBufferedRangesUpdated(o, e, t, !1, c.maxBufferHole, !1)
                        }
                    }
                    )));
                    const r = ne(...i).pipe(te( () => X)).subscribe(e);
                    return () => {
                        r.unsubscribe();
                        try {
                            "open" === s.readyState && l.abort(),
                            this.yr = null,
                            s.removeSourceBuffer(l)
                        } catch (e) {}
                    }
                }
                ),
                this.gr = n,
                this.br = e,
                this.sr = a,
                this.type = o,
                this.sourceBuffer = l,
                this.config = c,
                this.updateMp3Timestamps = !1
            }
            get buffered() {
                return this.sourceBuffer.buffered
            }
            appendBuffer(e, t, i) {
                return na( () => this.sourceBuffer.updating ? this.Sr().pipe(te( () => this.appendBuffer(e, t, i))) : this._appendBufferAsync(e, t, i))
            }
            clearInitSegmentInfo() {
                this.gr.setInitSegmentEntity(this.type, null)
            }
            wr(e) {
                e = $c(e);
                this.gr.setInitSegmentEntity(this.type, e)
            }
            Tr(e) {
                this.clearInitSegmentInfo(),
                this.abort()
            }
            _appendBufferAsync(e, t, i) {
                let r = NaN
                  , n = null;
                const a = ("startPTS"in t ? t.frag : t).mediaOptionId
                  , s = "startPTS"in t ? t.frag.mediaOptionType : void 0;
                try {
                    "startPTS"in t && (n = {
                        startPTS: t.startPTS,
                        endPTS: t.endPTS,
                        bytes: t.bytes,
                        frag: Object.assign({}, t.frag),
                        partialFrag: t.partialFrag
                    }),
                    this.gr.setInflightSegment(this.type, n),
                    "initParsedData"in t ? this.yr = this.wr.bind(this, t) : t.partialFrag && (this.yr = this.Tr.bind(this, t)),
                    r = performance.now(),
                    re(i) && this.sourceBuffer.timestampOffset !== i && (this.sourceBuffer.timestampOffset = i),
                    this.sourceBuffer.appendBuffer(e)
                } catch (e) {
                    return this.yr = null,
                    22 === e.code ? (this.gr.setBufferedRangesUpdated(this.type, Qc.timeRangesToBufferedRange(this.sourceBuffer.buffered), Qc.timeRangesToBufferedRange(this.sr.buffered), !0, this.config.maxBufferHole, !0),
                    R(new ph(H.AllocationFailed,this.type,this.maxTotalBytes,e.message))) : (this.gr.setInflightSegment(this.type, null),
                    this.sr.error ? R(new fh(H.VideoDecoderBadDataErr,this.type,a,e.message)) : R(e))
                }
                return this.Sr().pipe(W( () => ({
                    fragmentType: s,
                    startAppend: r,
                    endAppend: performance.now(),
                    bytesAppend: e.byteLength
                })), Nn(1e4), $(e => {
                    throw e instanceof Ln ? (this.sourceBuffer.abort(),
                    this.clearInitSegmentInfo(),
                    e = new mh(H.InternalError,this.type,"Append took longer than 10000ms")) : e instanceof uh && (e = new fh(e.response,this.type,a)),
                    e
                }
                ))
            }
            remove(e, t) {
                return this.Sr().pipe(te(this._removeAsync.bind(this, e, t)))
            }
            _removeAsync(e, t) {
                try {
                    this.sourceBuffer.remove(e, t)
                } catch (e) {
                    return R(new uh(Q.SOURCE_BUFFER_ERROR,!1,H.SourceBufferRemoveError,this.type,e.message))
                }
                return this.Sr()
            }
            abort() {
                try {
                    this.sourceBuffer.abort()
                } catch (e) {
                    return R(new uh(Q.SOURCE_BUFFER_ERROR,!1,H.SourceBufferAbortError,this.type,e.message))
                }
                return this.Sr()
            }
            get updating() {
                return this.sourceBuffer.updating
            }
            get timestampOffset() {
                return this.sourceBuffer.timestampOffset
            }
            set timestampOffset(e) {
                this.sourceBuffer.timestampOffset = e
            }
            get gotQuotaExceeded() {
                var e;
                return null != (e = null == (e = this.br.sourceBufferEntityByType(this.type)) ? void 0 : e.gotQuotaExceeded) && e
            }
            get bufferedSegments() {
                var e;
                return null != (e = null == (e = this.br.sourceBufferEntityByType(this.type)) ? void 0 : e.bufferedSegments) ? e : []
            }
            get totalBytes() {
                var e;
                return null != (e = null == (e = this.br.sourceBufferEntityByType(this.type)) ? void 0 : e.totalBytes) ? e : 0
            }
            get maxTotalBytes() {
                var e = null != (e = null == (e = this.br.sourceBufferEntityByType(this.type)) ? void 0 : e.maxTotalBytes) ? e : 1 / 0;
                return this.gotQuotaExceeded ? e : 1 / 0
            }
            Sr() {
                return this.sourceBuffer.updating && this.gr.setSourceBufferUpdating(this.type),
                ce(this.br.sbUpdating$(this.type), e => !1 === e).pipe(W( () => {
                    if (this.br.sbError(this.type))
                        throw new uh(Q.SOURCE_BUFFER_ERROR,!1,H.SourceBufferUpdatingError,this.type)
                }
                ))
            }
            changeType(e) {
                var t;
                let i = !1;
                if (this.config.changeType && "function" == typeof this.sourceBuffer.changeType)
                    try {
                        this.sourceBuffer.changeType(e),
                        i = !0
                    } catch (i) {
                        null != (t = this.R) && t.error(`changeType(${e}) failed: ` + i.msg)
                    }
                return i
            }
        }
        class vh extends G {
            constructor(a, s, e, o, t, i) {
                super(e => {
                    var t = dl(o)
                      , i = [t.event("sourceopen").pipe(ie(e => {
                        re(this.Ir) && (this.commitMediaSourceAndMediaElementStoreDuration(this.Ir),
                        this.Ir = null);
                        e = null != (e = null == e ? void 0 : e.target) ? e : o;
                        s.msReadyState = e.readyState
                    }
                    )), ne(t.event("sourceclose"), t.event("sourceended")).pipe(ie(e => {
                        e = (null != (e = null == e ? void 0 : e.target) ? e : o).readyState;
                        s.msReadyState = e
                    }
                    )), this.Or.pipe(te(e => e ? ne(...e.filter(e => null != e)) : X))];
                    if ("onstartstreaming"in t.target) {
                        const a = ne(t.event("startstreaming"), t.event("endstreaming")).pipe(ie(e => {
                            e = null == e ? void 0 : e.type;
                            s.stopStreaming = "endstreaming" === e
                        }
                        ));
                        i.push(a)
                    }
                    const r = ne(...i).pipe(te( () => X)).subscribe(e)
                      , n = URL.createObjectURL(o);
                    if (a.disableRemotePlayback = !0,
                    l.WebKitPlaybackTargetAvailabilityEvent)
                        try {
                            a.removeAttribute("src"),
                            Sh(a),
                            Ih(a, n),
                            a.load()
                        } catch (e) {
                            a.src = n
                        }
                    else
                        a.src = n;
                    return s.setMediaSourceEntity(n, o.readyState),
                    () => {
                        r.unsubscribe(),
                        this.Ir = null,
                        URL.revokeObjectURL(n),
                        this.kr === n && (Sh(a),
                        a.removeAttribute("src"),
                        a.load(),
                        s.setMediaSourceEntity(null)),
                        this.Or.next(null)
                    }
                }
                ),
                this.sr = a,
                this.gr = s,
                this.br = e,
                this.Mr = o,
                this.R = t,
                this.Ir = i,
                this.Or = new pn(null)
            }
            addAirPlaySource(e) {
                var t = this.sr;
                !t.src && 0 < t.childElementCount && !cs(e) && (t.disableRemotePlayback = !1,
                Sh(t, 1),
                Ih(t, e, "application/vnd.apple.mpegurl"))
            }
            get kr() {
                var e = this.sr
                  , e = (null == e ? void 0 : e.firstChild) || e;
                return null == e ? void 0 : e.src
            }
            get readyState() {
                return this.Mr.readyState
            }
            set duration(e) {
                this.Mr.duration = e
            }
            get duration() {
                return this.Mr.duration
            }
            commitMediaSourceAndMediaElementStoreDuration(e) {
                try {
                    this.duration !== e && (this.duration = e,
                    this.gr.msDuration = e)
                } catch (e) {}
            }
            endOfStream(e) {
                this.Mr.endOfStream(e)
            }
            createSourceBuffers(e, o) {
                ae( () => {
                    const a = this.Mr;
                    try {
                        const s = [null, null];
                        e.forEach( (t, i) => {
                            if (t) {
                                var {mimeType: r, mediaOptionId: n} = t;
                                let e;
                                try {
                                    e = a.addSourceBuffer(r)
                                } catch (t) {
                                    const o = this.sr;
                                    throw (!o.src && 1 < o.childElementCount || !o.disableRemotePlayback) && (o.disableRemotePlayback = !0,
                                    Sh(o, 1)),
                                    new ch(H.IncompatibleAsset,i,n,t.message)
                                }
                                s[i] = new yh(this.gr,this.br,this.sr,this.Mr,i,e,t,this.R,o)
                            }
                        }
                        ),
                        this.Or.next(s)
                    } catch (e) {
                        if (e instanceof b)
                            throw e;
                        throw new dh(`error initializing sourcebuffers ${e.message} readyState=` + a.readyState)
                    }
                }
                )
            }
            get needSourceBuffers() {
                return null == this.Or.value || null == this.Or.value[0]
            }
            get sourceBuffers() {
                return this.Or.value
            }
            getSourceBufferByType(e) {
                var t = this.Or.value;
                return t ? t[e] : null
            }
            updateLiveSeekableRange(e, t) {
                var i = this.Mr;
                null != i && i.setLiveSeekableRange && "open" === (null == i ? void 0 : i.readyState) && i.setLiveSeekableRange(e, t)
            }
            clearLiveSeekableRange() {
                var e = this.Mr;
                null != e && e.clearLiveSeekableRange && "open" === (null == e ? void 0 : e.readyState) && e.clearLiveSeekableRange()
            }
        }
        function Sh(e, t=0) {
            for (; e.childElementCount > t; )
                e.removeChild(e.children[e.childElementCount - 1])
        }
        function Ih(e, t, i="video/mp4") {
            var r = my.document.createElement("source");
            r.type = i,
            r.src = t,
            e.appendChild(r)
        }
        function bh(e, t, i, r, n, a) {
            var s = performance.now() - i;
            return {
                type: e,
                isLowBufferStall: r.len <= n || !a,
                tstalled: i,
                stallDurationMs: s,
                currentTime: t
            }
        }
        class Th extends G {
            constructor(I, b, e, t, i, r, n, a) {
                super(e => {
                    b.logger = this.R;
                    const l = this.Gt
                      , t = b.startMediaSession(I, l.maxBufferLength, l.almostDryBufferSec, l.defaultTargetDuration)
                      , i = Eh(I, b, this.Er, this, this.Ar, this.errorRecovery, l, this.R, this.Nr)
                      , r = this.Rr.pipe(te(e => e || X))
                      , n = this.Pr.pipe(Z(e => !!e), te( ({start: e, end: t, cb: i}) => this.flushAll(e, t).pipe(te( () => ce(this.Er.updating$, e => !1 === e)), ie( () => i()))))
                      , a = this.Er.seekTo$.pipe((o = I,
                    d = this.Er,
                    c = (u = this).gr,
                    h = this.Gt,
                    p = (p = this.R).child({
                        name: "seek"
                    }),
                    e => e.pipe(Z(e => e && re(e.pos)), te(function(e) {
                        return ce(Fr([d.readyState$, d.flushing$]), ([e,t]) => e >= o.HAVE_METADATA && !1 === t).pipe(W( () => e), te(function({pos: e, fromEvent: t, inContentGap: i}) {
                            u.checkForInconsistentStoreBufferRangesAndUpdate();
                            var r = !t && o.currentTime !== e;
                            return o.paused || i || !t && !r || u.pause(),
                            r && (o.currentTime = e),
                            ce(d.haveEnough$, e => e).pipe(W( () => ({
                                pos: e,
                                fromEvent: t
                            })))
                        }), te(function({pos: e, fromEvent: t}) {
                            var i = d.getCombinedBufferInfo(e, 0)
                              , r = i.nextStart;
                            if ((!t || h.nudgeFromEventSeek) && 0 === i.len && re(r) && e < r && r - e <= h.maxSeekHole) {
                                const o = u.isPosBetweenJaggedStart(e);
                                if (!h.jaggedSeekTolerance || !o)
                                    return u.seekTo = r,
                                    X
                            }
                            t = d.desiredRate;
                            return o.paused && 0 !== t && u.play(),
                            ce(d.seeking$, e => !e)
                        }), Pr(Wn), te(function() {
                            return c.setSeekToPos(null),
                            X
                        }), $(e => (p.error(`error during seek ` + e.message),
                        c.setSeekToPos(null),
                        X)))
                    }))))
                      , s = this.Er.desiredRate$.pipe((m = I,
                    f = this.Er,
                    g = this,
                    e => e.pipe(te(e => 0 === e ? (m.paused || g.pause(),
                    X) : f.seekInProgress ? X : f.paused$.pipe(te(e => e ? Sn(ce(f.seekInProgress$, e => e), ce(f.haveEnough$, e => e).pipe(ie( () => {
                        m.paused && !m.ended && g.play()
                    }
                    ))) : X))), te( () => X))));
                    var o, d, u, c, h, p, m, f, g;
                    this.Cr = this.Cr || new lh(this,I,l,this.R),
                    this.Cr.install();
                    const y = this.Dr.pipe(te(e => {
                        return e ? ne(function(p, m) {
                            const {lowBufferThreshold: f, lowBufferWatchdogPeriod: g, highBufferWatchdogPeriod: y, seekWatchdogPeriod: v} = m
                              , e = ma([p.desiredRate$, p.ended$, p.combinedBuffer$, p.seekToPos$, p.inFlightRanges$]).pipe(W(e => {
                                var t, i, [e,r,n,a,s] = e;
                                return t = p.currentTime,
                                e = e,
                                r = r,
                                n = n,
                                a = isFinite(a),
                                s = s,
                                i = n.some(e => e.start <= t && e.end > t),
                                s = s && s.some(e => e && e.start <= t && t <= e.end),
                                !(!i && s || 1 !== e || r || 0 === n.length || a && !i)
                            }
                            ), J())
                              , t = p.combinedBuffer$.pipe(W( () => p.getCurrentWaterLevel(0) <= m.lowBufferThreshold || !p.haveEnough ? ru.LowBuffer : ru.HighBuffer), J())
                              , i = ma([e, p.seekToPos$, p.gotPlaying$, t]).pipe(te(e => {
                                var t, a, s, o, l, d, i, r, n, u, [e,c,h] = e;
                                return e ? (e = p.nudgeCount,
                                t = v + 1 * e,
                                isFinite(c) || !h ? (i = p,
                                r = performance.now(),
                                c = t,
                                n = f,
                                u = e,
                                yr(1e3 * c).pipe(W( () => {
                                    var e = i.currentTime
                                      , t = i.getCombinedBufferInfo(e, 0);
                                    if (null === i.stallInfo || i.stallInfo.type === ru.Seek || 1 === u && i.stallInfo.type === ru.HighBuffer)
                                        return bh(ru.Seek, e, r, t, n, i.haveEnough)
                                }
                                ), Kl())) : (a = p,
                                s = g,
                                o = y + 1 * e,
                                l = f,
                                d = m.maxBufferHole,
                                ne(Y(a.currentTime), a.timeupdate$).pipe(te(e => {
                                    const t = performance.now()
                                      , i = a.getCombinedBufferInfo(e, 0);
                                    let r, n;
                                    return r = i.len <= l || !a.haveEnough ? i.nextStart && i.nextStart <= i.end + d ? (n = o,
                                    ru.BufferHole) : (n = s,
                                    ru.LowBuffer) : (n = o,
                                    ru.HighBuffer),
                                    yr(Math.max(100, 1e3 * n)).pipe(W( () => e < a.currentTime ? null : bh(r, e, t, i, l, a.haveEnough)))
                                }
                                )))) : Y(null)
                            }
                            ), Tn())
                              , r = i.pipe(Kl(), te(e => ma([p.seeking$, p.paused$])), te( ([e,t]) => e || t ? X : p.timeupdate$.pipe(dn(), Z( ([e,t]) => re(e) && re(t) && e < t), tn(1))), W( () => null));
                            return ne(i, r)
                        }((this.R,
                        this.Er), this.Gt).pipe(ie(e => {
                            b.setStallInfo(e)
                        }
                        )), this.mediaQuery.stallInfo$.pipe((r = b,
                        n = (i = this).Gt,
                        a = this.R,
                        e => e.pipe(sn(e => {
                            if (e) {
                                var h = i
                                  , t = r
                                  , p = n
                                  , m = a;
                                const f = h.mediaQuery;
                                return ne(ma([f.seekTo$, f.nudgeTarget$]).pipe(Z( ([e,t]) => e && re(e.pos) && re(t) && (e.pos < t || e.pos - t > p.maxSeekHole)), rn(null)), f.stallInfo$).pipe(xn(f.desiredRate$), Pr(sr), W( ([e,i], r) => {
                                    if (e) {
                                        var n = f.getCombinedBufferInfo(e.currentTime, 0)
                                          , i = Yc(i);
                                        {
                                            var a = h
                                              , s = p
                                              , o = m
                                              , l = e
                                              , e = i
                                              , i = r
                                              , {type: r, isLowBufferStall: l, currentTime: d} = l
                                              , u = n.len
                                              , c = s.maxSeekHole;
                                            let t = NaN;
                                            if (l) {
                                                const o = n.nextStart - d <= c ? n.nextStart : 1 / 0;
                                                if (re(o))
                                                    t = o;
                                                else if (a.mediaQuery.msDuration - d < s.nudgeOffset)
                                                    t = d + s.nudgeOffset;
                                                else if (0 < a.mediaQuery.getContentGapRanges().length) {
                                                    const s = a.mediaQuery.getContentGapRanges();
                                                    for (let e = 0; e < s.length; e++)
                                                        if (!(s[e].start < d) && s[e].start - d <= c) {
                                                            t = s[e].start;
                                                            break
                                                        }
                                                }
                                            } else if (i < s.nudgeMaxRetry)
                                                t = d + s.nudgeOffset;
                                            else if (e)
                                                o.error(`still stuck in high buffer @${d} after ${s.nudgeMaxRetry}, non fatal in iframeMode`);
                                            else {
                                                o.error(`still stuck in high buffer @${d} after ${s.nudgeMaxRetry}, raise fatal error`);
                                                const l = new gh(Q.BUFFER_STALLED_ERROR,!0,H.VideoDecoderBadDataErr,r,u);
                                                if (!a.errorRecovery || !a.errorRecovery.shouldAttemptErrorRecovery(l))
                                                    throw l;
                                                a.errorRecovery.recoverFromFatalError()
                                            }
                                            return re(t) && a.nudgeSeek(t, i + 1),
                                            t
                                        }
                                    }
                                    return NaN
                                }
                                ), Mn(e => re(e)), ee( () => {
                                    t.setNudgeInfo(null)
                                }
                                ))
                            }
                            return Y(NaN)
                        }
                        )))), (t = this.mediaQuery,
                        s = b,
                        o = l.maxBufferHole,
                        ce(t.readyState$, e => e >= HTMLMediaElement.HAVE_METADATA).pipe(te( () => t.bufferMonitorThresholds$), te(e => re(null == e ? void 0 : e.lowWaterLevelSeconds) && re(null == e ? void 0 : e.highWaterLevelSeconds) ? ah(t, o) : X), J(Kc), ie( ({combined: e, sbTuple: t}) => {
                            s.updateWaterLevels(e, t)
                        }
                        )))) : X;
                        var i, r, n, a, t, s, o
                    }
                    ))
                      , v = l["contentGapPlaythroughIntervalSeconds"]
                      , S = 1e3 * v;
                    ne(i, r, a, s, y, n, this.mediaQuery.hasGaps$().pipe(te(e => e ? Fr([this.mediaQuery.timeupdate$, this.mediaQuery.desiredRate$]).pipe(Pr(sr), te( ([e,t]) => {
                        return e === this.mediaQuery.avoidContentGap(e, this.Gt.timeAccuracyThresholdSeconds, this.R) ? X : 0 === t ? (this.Cr.pause(!0),
                        X) : (I.paused && this.play(),
                        yr(e = (e = void 0 === (e = S) ? 0 : e) < 0 ? 0 : e, e, i = void 0 === i ? sr : i).pipe(W( () => {
                            var e = this.mediaQuery.currentTime + v
                              , t = e > this.msDuration;
                            return this.seekWithOptions(e, void 0, !1, !1, !0),
                            t && this.pause(),
                            t
                        }
                        ), Mn(e => !e)));
                        var i
                    }
                    )) : X))).pipe(te( () => X), ee( () => {
                        this.toggleTrickPlaybackMode(!1),
                        b.remove(t),
                        this.Cr.uninstall(),
                        this.Cr = void 0,
                        this.Ar = void 0,
                        this.errorRecovery = void 0,
                        b.logger = void 0
                    }
                    )).subscribe(e)
                }
                ),
                this.sr = I,
                this.gr = b,
                this.Gt = e,
                this.R = r,
                this.Lr = n,
                this.Nr = a,
                this.Pr = new z,
                this.Rr = new pn(null),
                this.Dr = new pn(!0),
                this._r = new eh,
                this.Er = new sh(I,b,this.R),
                this.R = r.child({
                    name: "mse"
                }),
                this.Fr(I),
                this.Cr = new lh(this,I,e,this.R),
                this.Ar = t,
                this.errorRecovery = i
            }
            get jr() {
                return this.Rr.value
            }
            get Ur() {
                var e;
                return null != (e = null == (e = this.jr) ? void 0 : e.sourceBuffers) ? e : []
            }
            get needSourceBuffers() {
                return !this.Ur[0]
            }
            get mediaQuery() {
                return this.Er
            }
            Br(e) {
                var t = null == (t = null == (t = this.jr) ? void 0 : t.sourceBuffers) ? void 0 : t[e];
                return t ? Qc.timeRangesToBufferedRange(t.sourceBuffer.buffered) : null
            }
            Fr(e) {
                this.Ui = e.addTextTrack("metadata", "id3"),
                this.Ui.mode = "hidden"
            }
            checkForInconsistentStoreBufferRangesAndUpdate() {
                var e = Qc.timeRangesToBufferedRange(this.sr.buffered)
                  , t = this.Br(oe.Variant)
                  , i = this.Br(oe.AltAudio)
                  , r = null != (r = null == (r = this.mediaQuery.sourceBufferEntityByType(oe.Variant)) ? void 0 : r.bufferedRanges) ? r : null
                  , n = null != (n = null == (n = this.mediaQuery.sourceBufferEntityByType(oe.AltAudio)) ? void 0 : n.bufferedRanges) ? n : null;
                this.$r(t, r) && this.Vr(e, oe.Variant),
                this.$r(i, n) && this.Vr(e, oe.AltAudio)
            }
            updateInFlightRange(e, t) {
                this.gr.updateInFlightRange(Qs(e), t)
            }
            $r(e, i) {
                return !(null == e && null == i || (null == e ? void 0 : e.length) == (null == i ? void 0 : i.length) && !e.find(t => {
                    var e = yo.search(i, e => t.start >= e.start && t.end <= e.end ? 0 : t.end < e.start ? -1 : 1);
                    return null == e || e.start != t.start || e.end != t.end || void 0
                }
                ))
            }
            Vr(e, t) {
                var i = this.Br(t);
                i && !this.mediaQuery.sbUpdating(t) && this.gr.setBufferedRangesUpdated(t, i, e, !1, this.Gt.maxBufferHole, !1)
            }
            destroyMediaSource() {
                this.Rr.next(null)
            }
            reset() {
                this.stopMonitors(),
                this.textTracksCreated = !1,
                this.primaryContentDuration = 0,
                this.clearLiveSeekableRange()
            }
            makeMediaSource() {
                return new (Qu(this.Gt.preferManagedMediaSource))
            }
            openMediaSource(t) {
                const i = this.makeMediaSource();
                ae( () => {
                    var e;
                    i ? (e = new vh(this.sr,this.gr,this.mediaQuery,i,this.R,t),
                    this.Rr.next(e)) : this.Rr.next(null)
                }
                )
            }
            createSourceBuffers(e) {
                var t = this.jr;
                if (!t)
                    throw new j(!0,H.SBEmptyMediaSource);
                t.createSourceBuffers(e, this.Gt)
            }
            qr(i) {
                const r = this.mediaQuery.mediaSourceEntity.objectUrl;
                return Fr([this.mediaQuery.msReadyState$, this.mediaQuery.msObjectUrl$]).pipe(te( ([e,t]) => t !== r ? Y(null) : "open" === e || "ended" === e ? Y(i) : X))
            }
            get Kr() {
                return this.mediaQuery.isIframeRate ? [oe.Variant, oe.AltAudio] : [oe.AltAudio, oe.Variant]
            }
            Hr(e) {
                e.forEach(e => {
                    null != e && e.dataSeg && (e.dataSeg.flushBeforeAppend = {
                        start: 0,
                        end: 0
                    })
                }
                )
            }
            Qr(e) {
                return e.reduce( (e, t) => {
                    t = t ? t.dataSeg.switchPosition : void 0;
                    return re(t) ? re(e) ? Math.min(e, t) : t : e
                }
                , void 0)
            }
            checkForReplay() {
                var e = this.sr;
                e.paused && !e.seeking && e.duration && e.currentTime && e.currentTime >= e.duration - this.Gt.maxTotalDurationTolerance && (this.seekTo = 0)
            }
            isCompatibleWithSourceBuffers(e) {
                return Ah(e, this.gr, this.jr, this.mediaQuery.sourceBufferEntities, this.mediaQuery.expectedSbCount, this.Gt.changeType ? Object.assign(Object.assign({}, this.Gt), {
                    changeType: !1
                }) : this.Gt)
            }
            resetMediaSourceIfNeeded(i) {
                const {mediaQuery: r, gr: e} = this
                  , t = r["sourceBufferEntities"]
                  , n = r.getActive()["expectedSbCount"];
                if (!t || this.needSourceBuffers)
                    return this.qr(i);
                const a = Ah(i, e, this.jr, t, n, this.Gt);
                if (a.compatible)
                    return this.qr(i);
                let s = a.boundary;
                const o = a.allowance
                  , l = this.Qr(i);
                if (re(l) && (s = l),
                !re(s))
                    return Y(null);
                const d = r.getCombinedBufferInfo(r.currentTime, this.Gt.maxBufferHole);
                var u = Yc(this.mediaQuery.desiredRate) ? yr(1e3 * (d.end - r.currentTime)) : Sn(ce(ne(Y(r.currentTime), r.timeupdate$), e => 0 === d.len || s - e <= .001), ce(r.stallInfo$.pipe(W(e => {
                    return null != (e = null == e ? void 0 : e.currentTime) ? e : NaN
                }
                )), e => e >= s - o - this.Gt.discontinuitySeekTolerance));
                return this.gr.waitingForDisco = !0,
                u.pipe(W( () => s), te(e => {
                    performance.now();
                    var t = r.currentTime;
                    return this.resetMediaSource(Math.max(t, e), a.discoSeqNum, this.msDuration),
                    this.qr(i).pipe(ie( () => {
                        var e, t, i, r, n;
                        performance.now(),
                        this.liveSeekableRange && ({start: e, end: t, edge: i, boundary: r, tupdate: n} = this.liveSeekableRange,
                        this.updateLiveSeekableRange(e, t, i, r, n))
                    }
                    ))
                }
                ), ee( () => {
                    this.gr.waitingForDisco = !1
                }
                ))
            }
            resetMediaSource(e=NaN, t, i) {
                var r;
                re(e) || (e = null != (r = null == (r = this.mediaQuery.seekTo) ? void 0 : r.pos) ? r : this.mediaQuery.currentTime),
                re(t) || (t = null == (r = this.mediaQuery.seekTo) ? void 0 : r.discoSeqNum),
                0 < this.Ur.length && (this.openMediaSource(i),
                this.seekWithOptions(e, t, !1, !1))
            }
            setExpectedSbCount(e) {
                this.gr.expectedSbCount = e
            }
            get expectedSbCount() {
                return this.mediaQuery.expectedSbCount
            }
            Gr(e, t, i) {
                var r, n, a = this["mediaQuery"], s = null == (s = this.Ur) ? void 0 : s[e], a = null == (a = a.sourceBufferEntities) ? void 0 : a[e];
                if (null == t || !t.initSeg)
                    return nl;
                if (s && a)
                    return t = t["initSeg"],
                    n = a.initSegmentInfo,
                    (r = $c(t)) && n && r.itemId === n.itemId && r.mediaOptionId === n.mediaOptionId && r.discoSeqNum === n.discoSeqNum && r.keyId === n.keyId ? nl : (r = Ks(e),
                    s.appendBuffer(t.data, t).pipe(i(s, r, t.mediaOptionId, this.Gt, this.mediaQuery)));
                throw new j(!0,H.SBNotInitialized,`_appendInitSegment ${oe[e]} not initialized buffer=${s} entity=` + a)
            }
            Wr(e, t, i) {
                const r = this["mediaQuery"]
                  , n = null == (d = this.Ur) ? void 0 : d[e]
                  , a = null == (d = r.sourceBufferEntities) ? void 0 : d[e];
                if (null == t || !t.dataSeg)
                    return nl;
                if (!n || !a)
                    throw new j(!0,H.SBNotInitialized,`_sbAppendData ${oe[e]} not initialized buffer=${n} entity=` + a);
                const s = a.initSegmentInfo
                  , {dataSeg: o, offsetTimestamp: l} = t;
                if (!s)
                    throw new j(!0,H.SBNullCurrentInitSegmentInfo,`appendDataSegments: sb[${Vs[e]}] null currentInitSegmentInfo`);
                if (!a)
                    throw new j(!0,H.SBNullCurrentSBEntity,`appendDataSegments: sb[${Vs[e]}] null currentSbEntity`);
                if (!n)
                    throw new j(!0,H.SBNullSourceBuffer,`appendDataSegments: sb[${Vs[e]}] null source buffer`);
                var d = P(o.startPts);
                let u = -1 * P(l);
                n.updateMp3Timestamps && .1 < Math.abs(n.timestampOffset - d) && (u = d + u);
                const c = n.timestampOffset !== u
                  , h = d + u
                  , p = P(o.endPts) + u
                  , m = o.firstKeyframePts ? P(o.firstKeyframePts) + u : void 0
                  , {part: f=!1, partIndex: g=NaN} = o
                  , y = {
                    startPTS: h,
                    endPTS: p,
                    firstKeyframePts: m,
                    bytes: o.data2 ? o.data1.byteLength + o.data2.byteLength : o.data1.byteLength,
                    partialFrag: o.partialFrag,
                    frag: {
                        itemId: o.itemId,
                        mediaOptionId: o.mediaOptionId,
                        mediaOptionType: o.mediaOptionType,
                        mediaSeqNum: o.mediaSeqNum,
                        discoSeqNum: o.discoSeqNum,
                        keyTagInfo: o.keyTagInfo,
                        isLastFragment: o.isLastFragment,
                        iframe: o.iframe,
                        framesWithoutIDR: o.framesWithoutIDR,
                        dropped: o.dropped,
                        part: f,
                        partIndex: g
                    }
                }
                  , v = Ks(e);
                let S = ue;
                d = t.dataSeg.flushBeforeAppend,
                d && d.start !== d.end && (S = this.flushData(e, d.start, d.end)),
                t = {
                    fragmentType: se.Variant,
                    bytesAppend: 0,
                    startAppend: 1 / 0,
                    endAppend: -1 / 0
                };
                return S.pipe(te( () => Y(o.data1, o.data2).pipe(Kl()).pipe($r(e => n.appendBuffer(e, y, u).pipe(i(n, v, o.mediaOptionId, this.Gt, this.mediaQuery))))), Qr( (e, t) => (e.bytesAppend += t.bytesAppend,
                e.startAppend = Math.min(t.startAppend, e.startAppend),
                e.endAppend = Math.max(t.endAppend, e.endAppend),
                e), t), ie( () => {
                    r.getBufferedRangeByType(e),
                    c && this.gr.setTimestampOffset(e, n.timestampOffset)
                }
                ))
            }
            appendDataSegments(t, i) {
                var e = this.Kr.map(e => {
                    if (null == t[e])
                        return null;
                    const r = {
                        sbType: e,
                        initAppend: null,
                        dataAppend: null
                    };
                    return en(na( () => this.Gr(e, t[e], i)), na( () => this.Wr(e, t[e], i))).pipe(Qr( (e, t, i) => (0 === i ? r.initAppend = t : r.dataAppend = t,
                    e), r))
                }
                ).filter(e => Boolean(e));
                return 0 === e.length ? Y([]) : aa(e)
            }
            adjustJaggedStart(e) {
                var {mediaQuery: t, R: i} = this
                  , {sourceBufferEntities: n, currentTime: r, seekTo: a} = t;
                if (!n)
                    throw new j(!0,H.SBNullCurrentSBEntity);
                const s = (null == a ? void 0 : a.pos) || r;
                if (t.avoidContentGap(s, 0, i) === s) {
                    a = re(this.Gt.jaggedSeekTolerance) ? this.Gt.jaggedSeekTolerance : 0;
                    let r = NaN;
                    n.forEach( (e, t) => {
                        if (e) {
                            var i = Qc.getBufferedInfo(e.bufferedRanges, s, 0);
                            if (0 === i.len) {
                                const e = i["nextStart"];
                                re(e) && (!re(r) || e > r) && (r = e)
                            }
                        }
                    }
                    ),
                    re(r) && e.end > r && r - s > a && (re(e.start) && s + this.Gt.maxSeekHole < e.start || (this.seekTo = r))
                }
            }
            Xr(e, t) {
                const i = this.sr.textTracks[e];
                i && t.forEach(e => {
                    i.addCue(e)
                }
                )
            }
            Yr(e, t, i) {
                return na( () => 0 === e.buffered.length ? ue : e.remove(t, i)).pipe()
            }
            flushAll(i, r, n=!1) {
                return 0 === this.Ur.length ? ue : aa(this.Ur.map( (e, t) => e ? this.flushData(t, i, r, n) : ue)).pipe(rn(void 0))
            }
            flushAndCallback(e, t, i) {
                this.Pr.next({
                    start: e,
                    end: t,
                    cb: i
                })
            }
            flushData(t, o, l, d=!1) {
                var e = this["mediaQuery"];
                return ce(e.updating$, e => !1 === e).pipe(te( () => {
                    const r = this.Ur[t];
                    if (!r)
                        return ue;
                    let n, a, s = ue;
                    var e = -1 === navigator.userAgent.toLowerCase().indexOf("firefox");
                    if (this.flushing = !0,
                    e)
                        return this.Yr(r, o, l);
                    for (let i = 0; i < r.buffered.length; i++) {
                        let e, t;
                        n = r.buffered.start(i),
                        a = r.buffered.end(i),
                        t = l === 1 / 0 ? (e = o,
                        l) : (e = Math.max(n, o),
                        Math.min(a, l)),
                        Math.min(t, a) > e && (d || .5 < Math.min(t, a) - e) && (s = s.pipe(te( () => this.Yr(r, e, t))))
                    }
                    return s
                }
                ), ee( () => {
                    this.flushing = !1
                }
                ))
            }
            static convertInitSegToCompatInfo(e) {
                return {
                    mimeType: e.mimeType,
                    audioCodec: e.initParsedData.audioCodec,
                    videoCodec: e.initParsedData.videoCodec,
                    startPTSSec: void 0,
                    endPTSSec: void 0,
                    discoSeqNum: e.discoSeqNum,
                    mediaOptionId: e.mediaOptionId
                }
            }
            static combineAppendDataInfoWithCompatInfo(e, t, i, r, n=0) {
                const a = [...t];
                e.forEach( (e, t) => {
                    null != e && e.initSeg && (a[t] = Th.convertInitSegToCompatInfo(e.initSeg)),
                    1 === r && (a[1] = null)
                }
                );
                var t = null == (t = a[oe.Variant]) ? void 0 : t.videoCodec
                  , s = yc(t);
                if (i && i.has(s)) {
                    const e = i.get(s);
                    a[oe.Variant].mimeType = a[oe.Variant].mimeType.replace(t, e),
                    a[oe.Variant].videoCodec = e
                }
                return a
            }
            static maxDurationFromAppendDataTuple(e) {
                return e.reduce( (e, t) => t && re(t.duration) ? Math.max(t.duration, e) : e, 0)
            }
            Jr(e) {
                const t = e.sourceBufferEntities
                  , i = [null, null];
                return null != t && t.forEach( (e, t) => {
                    e && (i[t] = {
                        mimeType: e.mimeType,
                        audioCodec: e.audioCodec,
                        videoCodec: e.videoCodec,
                        startPTSSec: void 0,
                        endPTSSec: void 0,
                        discoSeqNum: void 0,
                        mediaOptionId: null == (t = e.initSegmentInfo) ? void 0 : t.mediaOptionId
                    })
                }
                ),
                i
            }
            avAppend(e, t, i, r) {
                const {mediaQuery: n, R: a} = this
                  , s = n.expectedSbCount
                  , d = this.Jr(n);
                if (t.every(e => null == e))
                    return Y([null, null]);
                let o = (null == e ? this.resetMediaSourceIfNeeded(t) : Y(t)).pipe(tn(1), nn( () => null == t ? ue : ce(n.updating$, e => !1 === e)), te(e => {
                    if (!e)
                        return Y([null, null]);
                    let o = NaN
                      , l = NaN;
                    if (this.needSourceBuffers) {
                        o = performance.now();
                        const i = Th.combineAppendDataInfoWithCompatInfo(e, d, r, s, a);
                        this.createSourceBuffers(i),
                        l = performance.now(),
                        this.Hr(e)
                    }
                    var t = Th.maxDurationFromAppendDataTuple(e);
                    return (!re(this.msDuration) || this.msDuration < t) && (this.msDuration = t),
                    e.forEach(e => {
                        e = null == e ? void 0 : e.dataSeg;
                        null != e && e.cues && re(null == e ? void 0 : e.texttrackIdx) && this.Xr(e.texttrackIdx, e.cues)
                    }
                    ),
                    this.appendDataSegments(e, i).pipe(W(e => {
                        var t, i = [null, null];
                        for (const r of e) {
                            const {sbType: e, initAppend: n, dataAppend: a} = r
                              , s = {
                                fragmentType: Ks(e),
                                bufferCreationStart: o,
                                bufferCreationEnd: l,
                                startInitAppend: null != (t = null == n ? void 0 : n.startAppend) ? t : NaN,
                                endInitAppend: null != (t = null == n ? void 0 : n.endAppend) ? t : NaN,
                                initBytesAppend: null != (t = null == n ? void 0 : n.bytesAppend) ? t : NaN,
                                startDataAppend: null != (t = null == a ? void 0 : a.startAppend) ? t : NaN,
                                endDataAppend: null != (t = null == a ? void 0 : a.endAppend) ? t : NaN,
                                dataBytesAppend: null != (t = null == a ? void 0 : a.bytesAppend) ? t : NaN
                            };
                            i[e] = s
                        }
                        return i
                    }
                    ))
                }
                ), tn(1));
                if (null == e && t.some(e => null != (null == e ? void 0 : e.dataSeg))) {
                    const e = t.reduce( (e, t) => {
                        var {start: e, end: i} = e;
                        return {
                            start: null != t && t.dataSeg.startPts ? Math.min(x(t.dataSeg.startPts, t.offsetTimestamp), e) : e,
                            end: null != t && t.dataSeg.endPts ? Math.min(x(t.dataSeg.endPts, t.offsetTimestamp), i) : i
                        }
                    }
                    , {
                        start: Number.POSITIVE_INFINITY,
                        end: Number.POSITIVE_INFINITY
                    });
                    o = o.pipe(ie(this.adjustJaggedStart.bind(this, e)))
                }
                return o
            }
            endStream() {
                try {
                    this.jr.endOfStream()
                } catch (e) {}
            }
            setMediaKeys(e, t) {
                const i = performance.now();
                return this.Lr.wrap(this._r.lock( () => Lr(this.sr.setMediaKeys(e))).pipe(ie( () => {
                    null != t && t.keySystemEvents({
                        eventId: $o.SetMediaKeys,
                        range: {
                            tbegin: i,
                            tend: performance.now()
                        }
                    })
                }
                ), bn(e => e.pipe(te( (e, t) => {
                    if (t < 3)
                        return yr(100 * t);
                    throw new j(!1,H.KeySystemCouldNotCreateMediaKeySession)
                }
                )))))
            }
            clearMediaKeys() {
                return na( () => {
                    var e, t;
                    return this.sr ? (null != (t = (e = this.mediaQuery).getCombinedBufferInfo(e.currentTime, 0)) && t.len ? ce(e.combinedBuffer$, e => !e).pipe(W( () => null)) : ue).pipe(te( () => {
                        const e = -1 < navigator.userAgent.toLowerCase().indexOf("chrome");
                        let t = this.setMediaKeys(null, null);
                        if (e) {
                            const e = this.sr.src;
                            this.sr.src = "",
                            t = t.pipe(ie( () => this.sr.src = e))
                        }
                        return t
                    }
                    )) : ue
                }
                )
            }
            set seekTo(e) {
                this.seekWithOptions(e, void 0, !1)
            }
            seekWithOptions(e, t, i, r=!1, n) {
                var a = this.liveSeekableRange
                  , s = this.sr.currentTime
                  , o = re(this.sr.duration) ? this.sr.duration : 1 / 0;
                let l = 0
                  , d = o;
                if (i && a) {
                    const {start: t, edge: i, end: n, tupdate: u} = a
                      , c = (performance.now() - u) / 1e3;
                    if (l = Math.min(o, n, t + c),
                    d = Math.min(o, n, i + c),
                    !r && e >= d && s >= d)
                        return !1
                }
                const u = Math.max(l, Math.min(d, e));
                return this.gr.setSeekToPos(u, !1, t, n, s),
                !0
            }
            updateContentGapRanges(e, r) {
                var n = .25
                  , a = null == (a = this.mediaQuery) ? void 0 : a.getContentGapRanges();
                if (a) {
                    let t = [...a]
                      , i = (t.sort( (e, t) => t.start - e.start),
                    !0);
                    for (let e = 0; e < t.length; e++) {
                        const a = t[e];
                        if (r.start > a.start - n && r.start < a.start + n && r.end > a.end - n && r.end < a.end + n)
                            return void (i = !1)
                    }
                    i && (t.push(r),
                    t.sort()),
                    1 < t.length && (t = Qc.getBufferedTimeRanges(t, n)),
                    this.gr.updateContentGapRanges(t)
                }
            }
            nudgeSeek(e, t) {
                ae( () => {
                    this.gr.setSeekToPos(e),
                    this.gr.setNudgeInfo({
                        nudgeTarget: e,
                        nudgeCount: t
                    })
                }
                )
            }
            set desiredRate(e) {
                this.gr.desiredRate = e
            }
            toggleTrickPlaybackMode(e) {
                if (this.Gt.overridePlaybackRate) {
                    const t = e ? 2 : 1;
                    try {
                        this.sr.playbackRate = t
                    } catch (e) {
                        this.R.error({
                            name: "iframes"
                        }, `Exception when setting playbackRate=${t}: ` + e.message)
                    }
                }
                const t = this.Zr;
                e && void 0 === t ? (this.Zr = this.sr.muted,
                this.sr.muted = e) : e || void 0 === t || (this.sr.muted = t,
                this.Zr = void 0)
            }
            play() {
                this.Cr.play()
            }
            pause() {
                this.Cr.pause()
            }
            get expectPlayEvent() {
                return this.Cr.expectPlayEvent
            }
            set expectPlayEvent(e) {
                this.Cr.expectPlayEvent = e
            }
            get expectPauseEvent() {
                return this.Cr.expectPauseEvent
            }
            set expectPauseEvent(e) {
                this.Cr.expectPauseEvent = e
            }
            get expectSeekingEvent() {
                return this.mediaQuery.expectSeekingEvent
            }
            set textTracksCreated(e) {
                var t = this["gr"];
                t.textTracksCreated = e
            }
            get msDuration() {
                return this.Er.msDuration
            }
            set msDuration(e) {
                this.jr.commitMediaSourceAndMediaElementStoreDuration(e)
            }
            set primaryContentDuration(e) {
                this.gr.primaryContentMediaElementDuration = e
            }
            set haveEnough(e) {
                this.gr.haveEnough = e
            }
            set flushing(e) {
                this.gr.flushing = e
            }
            stopMonitors() {
                this.Dr.value && this.Dr.next(!1)
            }
            startMonitors() {
                this.Dr.value || this.Dr.next(!0)
            }
            set bufferMonitorTargetDuration(e) {
                this.gr.bufferMonitorTargetDuration = e
            }
            get textTracks() {
                return this.sr.textTracks
            }
            get id3TextTrack() {
                return this.Ui
            }
            addTextTrack(e, t, i) {
                return this.sr.addTextTrack(e, t, i)
            }
            dispatchEvent(e) {
                return this.sr.dispatchEvent(e)
            }
            get offsetWidth() {
                return this.sr.offsetWidth
            }
            get offsetHeight() {
                return this.sr.offsetHeight
            }
            get liveSeekableRange() {
                return this.mediaQuery.liveSeekableRange
            }
            get seekable() {
                return this.mediaQuery.seekable
            }
            archiveParsedSubtitleFragmentRecord(e, t, i) {
                return this.gr.archiveParsedSubtitleFragmentRecord(e, t, i)
            }
            removeEarlierParsedSubtitleFragmentRecord(e) {
                this.gr.removeOldSubtitleFragmentRecord(e)
            }
            removeLaterParsedSubtitleFragmentRecord(e) {
                this.gr.removeLaterSubtitleFragmentRecord(e)
            }
            clearParsedSubtitleRecordsForMediaOption(e) {
                return this.gr.clearParsedSubtitleFragmentRecord(e)
            }
            clearAllParsedSubtitleFragmentRecord() {
                return this.gr.clearAllParsedSubtitleFragmentRecord()
            }
            updateLiveSeekableRange(e, t, i, r, n) {
                var a;
                const s = this.mediaQuery.liveSeekableRange
                  , o = Math.max(null != (a = null == s ? void 0 : s.start) ? a : 0, e)
                  , l = Math.max(null != (a = null == s ? void 0 : s.end) ? a : 0, t)
                  , d = Math.max(null != (e = null == s ? void 0 : s.edge) ? e : 0, i)
                  , u = Math.max(null != (a = null == s ? void 0 : s.boundary) ? a : 0, r);
                ae( () => {
                    this.gr.setLiveSeekableRange({
                        start: o,
                        end: l,
                        edge: d,
                        boundary: u,
                        tupdate: n
                    }),
                    this.jr.updateLiveSeekableRange(o, l)
                }
                )
            }
            clearLiveSeekableRange() {
                null != this.liveSeekableRange && ae( () => {
                    this.gr.setLiveSeekableRange(void 0),
                    this.jr.clearLiveSeekableRange()
                }
                )
            }
            isPosBetweenJaggedStart(e) {
                if (this.Gt.jaggedSeekTolerance && this.Ur[oe.Variant] && this.Ur[oe.AltAudio]) {
                    const i = this.mediaQuery.getBufferInfo(e, this.Gt.jaggedSeekTolerance)
                      , t = [oe.Variant, oe.AltAudio].reduce( (e, t) => {
                        return i[t].buffered.len && (t = i[t].buffered.start,
                        e) ? [Math.min(t, e[0]), Math.max(t, e[1])] : null
                    }
                    , [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]);
                    if (t && t[1] - e <= this.Gt.jaggedSeekTolerance)
                        return !0
                }
                return !1
            }
            addAirPlaySource(e) {
                this.jr.addAirPlaySource(e)
            }
        }
        const Eh = (t, l, d, u, c, e, h, r, n) => {
            if (!t)
                return X;
            const i = dl(t)
              , p = e => {
                var t = e.currentTarget
                  , i = t.readyState;
                l.readyState = i,
                l.ended = t.ended,
                "playing" != e.type && (e.type,
                t.currentTime.toFixed(3),
                t.duration.toFixed(3))
            }
            ;
            return ne(i.event("durationchange").pipe(W(e => ul(t, "durationchange", e)), Fa(e => {
                var t = e.currentTarget;
                l.mediaElementDuration = t.duration,
                p(e)
            }
            )), i.event("seeking").pipe(kn(h.seekEventThrottleMs, void 0, {
                leading: !0,
                trailing: !0
            }), W(e => ul(t, "seeking", e)), Fa(e => {
                var t = e.currentTarget
                  , i = t.currentTime;
                if (t.readyState >= t.HAVE_METADATA) {
                    const e = d.seekTo;
                    if (!e || 1e-5 < Math.abs(e.pos - i)) {
                        if (!e || !e.fromEvent) {
                            if (c.inGaplessMode && !h.enableInterstitialPlayback) {
                                var r = i;
                                var n = c;
                                var a = u;
                                var s = l;
                                let e = !1;
                                var o = Xc(n.playingItem)
                                  , o = (r < o && (r = o,
                                e = !0),
                                Xc(n.loadingItem));
                                n.isPreloading && (o < r && (r = o,
                                e = !0),
                                n.dequeueSource("SeekToUnbufferedTimeRanges")),
                                e ? a.resetMediaSource(r) : s.setSeekToPos(r, !0);
                                return
                            }
                            if (u && !u.expectSeekingEvent && (t.controls || h.nativeControlsEnabled) && u.liveSeekableRange && u.seekWithOptions(i, void 0, !0, !0))
                                return
                        }
                        l.setSeekToPos(i, !0)
                    } else
                        l.seeking = !0
                }
                p(e)
            }
            )), i.event("seeked").pipe(W(e => ul(t, "seeked", e)), Fa(e => {
                var t = e.target;
                l.seeking = t.seeking,
                p(e)
            }
            )), i.event("play").pipe(W(e => ul(t, "play", e)), Fa(e => {
                var t = e.currentTarget
                  , i = (l.paused = t.paused,
                u.expectPlayEvent)
                  , t = t.controls || h.nativeControlsEnabled;
                !i && t && (u.checkForReplay(),
                l.desiredRate = 1),
                u.expectPlayEvent = !1,
                p(e)
            }
            )), i.event("playing").pipe(W(e => ul(t, "playing", e)), Fa(e => {
                var t = e.currentTarget;
                l.paused = t.paused,
                l.gotPlayingEvent(),
                p(e)
            }
            )), i.event("pause").pipe(W(e => ul(t, "pause", e)), Fa(e => {
                var t = e.currentTarget
                  , i = (l.paused = t.paused,
                u.expectPauseEvent)
                  , t = t.controls || h.nativeControlsEnabled;
                !i && t && (l.desiredRate = 0),
                u.expectPauseEvent = !1,
                p(e)
            }
            )), ne(i.event("loadedmetadata").pipe(W(e => ul(t, "loadedmetadata", e))), i.event("loadeddata").pipe(W(e => ul(t, "loadeddata", e))), i.event("canplay").pipe(W(e => ul(t, "canplay", e))), i.event("canplaythrough").pipe(W(e => ul(t, "canplaythrough", e))), i.event("waiting").pipe(W(e => ul(t, "waiting", e))), i.event("emptied").pipe(W(e => ul(t, "emptied", e))), i.event("ended").pipe(W(e => ul(t, "ended", e)))).pipe(Fa(p)), i.event("error").pipe(te( () => {
                throw t.error
            }
            ))).pipe($(e => {
                var t, i;
                try {
                    e instanceof MediaError ? null != n && n.handleMediaElementError(e, null != (i = null == (t = null == c ? void 0 : c.loadingItem) ? void 0 : t.isInterstitial) && i) : r.error(`media event error: ` + (null == e ? void 0 : e.message))
                } catch (e) {
                    r.error(`MediaError may be undefined on the platform: ` + (null == e ? void 0 : e.message))
                }
                return X
            }
            ), te( () => X))
        }
        ;
        function Ah(e, s, o, l, t, d) {
            const i = l.filter(e => Boolean(e)).length
              , r = e.filter(e => Boolean(e)).length
              , u = [null, null];
            e.forEach( (e, t) => {
                var i, r, n, a, s, o;
                e && (s = e["offsetTimestamp"],
                s = P(s),
                i = e.initSeg.mimeType,
                {audioCodec: r, videoCodec: n} = e.initSeg.initParsedData,
                o = e["dataSeg"],
                a = P(o.startPts) - s,
                s = P(o.endPts) - s,
                o = o.discoSeqNum,
                u[t] = {
                    audioCodec: r,
                    videoCodec: n,
                    mimeType: i,
                    startPTSSec: a,
                    endPTSSec: s,
                    discoSeqNum: o,
                    mediaOptionId: e.initSeg.mediaOptionId
                })
            }
            );
            let c = i === t
              , n = r === t;
            if (1 === r && r < t && 0 !== i) {
                const s = e[se.Variant] ? se.Variant : se.AltAudio
                  , o = 1 - s
                  , t = u[s]
                  , d = u[o] = function(e, t, i) {
                    const r = null == e ? void 0 : e.bufferedSegments;
                    if (!r)
                        return null;
                    var n = r.find(e => e.frag.discoSeqNum === t);
                    if (null == n)
                        return null;
                    {
                        const {audioCodec: a, videoCodec: r, mimeType: s} = e;
                        return {
                            mimeType: s,
                            audioCodec: a,
                            videoCodec: r,
                            startPTSSec: n.startPTS,
                            endPTSSec: n.endPTS,
                            discoSeqNum: t,
                            mediaOptionId: i
                        }
                    }
                }(l[o], t.discoSeqNum, t.mediaOptionId);
                if (!d && s === se.Variant && u[s]) {
                    const e = l[s].videoCodec
                      , o = u[s].videoCodec;
                    if (c = c && (e === o || q.isCompatibleVideoCodec(e, o)))
                        return {
                            compatible: c,
                            boundary: NaN,
                            allowance: NaN,
                            discoSeqNum: u[s].discoSeqNum
                        }
                }
                n = null != d
            }
            let h = NaN
              , p = NaN
              , m = NaN;
            return n && u.forEach( (t, i) => {
                if (!t)
                    return null;
                re(m) ? m !== t.discoSeqNum && (m = NaN) : m = t.discoSeqNum;
                var r = l[i];
                if (r) {
                    const l = r.audioCodec
                      , n = r.videoCodec
                      , a = r.mimeType
                      , {audioCodec: h, videoCodec: p, mimeType: m} = t;
                    let e = d.changeType;
                    if (e) {
                        const t = null == (r = o.sourceBuffers) ? void 0 : r[i];
                        t && (!!l == !!h && !!n == !!p ? a !== m && "string" == typeof m && (e = t.changeType(m)) && s.updateSourceBufferEntity(i, u[i]) : e = !1)
                    }
                    e || (c = (c = c && (n === p || q.isCompatibleVideoCodec(n, p))) && (l === h || q.isCompatibleAudioCodec(l, h)))
                } else
                    c = !1;
                h = re(h) ? (p = Math.abs(t.startPTSSec - h),
                Math.max(t.startPTSSec, h)) : (p = 0,
                t.startPTSSec)
            }
            ),
            {
                compatible: c && n,
                boundary: h,
                allowance: p,
                discoSeqNum: m
            }
        }
        function Oh(e) {
            return e.matches
        }
        class Rh extends Ka {
            constructor(e) {
                super(e),
                this.store = e,
                this.displaySupportsHdr$ = this.select("supportsHdr"),
                this.platformInfo$ = this.select("platformInfo"),
                this.viewportInfo$ = this.select("viewportInfo")
            }
            get platformInfo() {
                return this.getValue().platformInfo
            }
            get displaySupportsHdr() {
                return this.getValue().supportsHdr
            }
            get viewportInfo() {
                return this.getValue().viewportInfo
            }
        }
        class wh extends Ba {
            constructor() {
                super({
                    supportsHdr: !0
                }, {
                    name: "platform"
                })
            }
        }
        class Ph {
            constructor(e) {
                this.ce = e,
                this.ri = new Rh(e)
            }
            get query() {
                return this.ri
            }
            updateSupportsHdr(e) {
                this.ce.update({
                    supportsHdr: e
                })
            }
            updatePlatformInfo(e) {
                this.ce.update({
                    platformInfo: e
                })
            }
            updateViewportInfo(e) {
                this.ce.update({
                    viewportInfo: e
                })
            }
        }
        function Mh(e) {
            let t = !1;
            var i = "" !== e.identifier
              , r = 0 < e.urls.length
              , n = re(null == (n = e.startTime) ? void 0 : n.baseTime) || re(e.startDate);
            return t = i && r && n ? !0 : t
        }
        const Ch = {
            ID: (e, t) => Object.assign(Object.assign({}, e), {
                identifier: t
            }),
            "START-DATE": (e, t, i, r, n) => {
                var t = new Date(Date.parse(t)).getTime()
                  , [r,n] = p(t, null != r ? r : [], null != n ? n : [])
                  , t = t && null != n ? t - r + 1e3 * n : NaN;
                return Object.assign(Object.assign({}, e), {
                    startTime: {
                        baseTime: t,
                        timescale: 1e3
                    }
                })
            }
            ,
            "X-ASSET-LIST": (e, t) => Object.assign(Object.assign({}, e), {
                urls: [t]
            }),
            "X-ASSET-URI": (e, t) => Object.assign(Object.assign({}, e), {
                urls: [t]
            }),
            "X-RESUME-OFFSET": (e, t) => Object.assign(Object.assign({}, e), {
                resumptionOffset: {
                    baseTime: 1e3 * parseFloat(t),
                    timescale: 1e3
                }
            }),
            "X-PLAYOUT-LIMIT": (e, t) => Object.assign(Object.assign({}, e), {
                playoutLimit: {
                    baseTime: 1e3 * parseFloat(t),
                    timescale: 1e3
                }
            }),
            "X-SNAP": (e, t) => {
                var i = -1 < t.indexOf("IN")
                  , t = -1 < t.indexOf("OUT");
                let r = So.None;
                return i && t ? r = So.InOut : i ? r = So.In : t && (r = So.Out),
                Object.assign(Object.assign({}, e), {
                    snapOptions: r
                })
            }
            ,
            "X-RESTRICT": (e, t) => {
                var i = -1 < t.indexOf("SKIP")
                  , t = -1 < t.indexOf("JUMP");
                let r = Io.None;
                return i && t ? r = Io.SkipJump : i ? r = Io.Skip : t && (r = Io.Jump),
                Object.assign(Object.assign({}, e), {
                    referenceRestrictions: r
                })
            }
            ,
            CUE: kh,
            "X-CUE": kh,
            default: (e, t, i) => {
                return 0 !== (null == i ? void 0 : i.indexOf("X-")) || ((e = Object.assign({}, e)).extraAttributes[i] = t),
                e
            }
        };
        function kh(e, t) {
            let i = vo.Midroll
              , r = (-1 < t.indexOf("PRE") ? i = vo.Preroll : -1 < t.indexOf("POST") && (i = vo.Postroll),
            !1);
            return -1 < t.indexOf("ONCE") && (r = !0),
            Object.assign(Object.assign({}, e), {
                cueType: i,
                playOnce: r
            })
        }
        function Lh(i, e, t) {
            var {daterangeTags: r, pdtToMSN: n} = i;
            let a = [];
            e = -1 < e.indexOf("interstitial");
            return a = r && !e && t.allowServerGeneratedInterstitials && 0 < n.length ? Object.entries(r).reduce( (e, [,t]) => {
                t = function(e, t, i) {
                    if (!e || "com.apple.hls.interstitial" !== e.CLASS)
                        return null;
                    let r = {
                        extraAttributes: {},
                        resumptionOffset: {
                            baseTime: NaN,
                            timescale: 1e3
                        },
                        identifier: "",
                        cueType: vo.Midroll,
                        snapOptions: So.None,
                        referenceRestrictions: Io.None,
                        startTime: {
                            baseTime: NaN,
                            timescale: 1e3
                        },
                        urls: [],
                        hasPlayed: !1,
                        playOnce: !1,
                        assets: []
                    };
                    for (const a in e) {
                        var n;
                        Object.prototype.hasOwnProperty.call(e, a) && (n = e[a],
                        r = (Ch[a] || Ch.default)(r, n, a, t, i))
                    }
                    return Mh(r) ? r : null
                }(t, i.pdtToMSN, i.fragments);
                return t && e.push(t),
                e
            }
            , []) : a
        }
        class Nh extends G {
            constructor(e, t) {
                super(e => {
                    null != t && t.add(),
                    e.add(this.es.pipe(_r( ([e,t,i]) => e(...t).pipe(ie({
                        next(e) {
                            i(e, null)
                        },
                        error(e) {
                            i(null, e)
                        }
                    })))).subscribe())
                }
                ),
                this.ns = e,
                this.teardownWG$ = t,
                this.es = new z
            }
            register(e, i) {
                return this.ns.register(e, (...t) => e => {
                    this.es.next([i, t, e])
                }
                )
            }
            invoke(e, t, r) {
                return new G(i => {
                    this.ns.invoke(e, t, r)( (e, t) => {
                        null != t ? i.error(t) : (i.next(e),
                        i.complete())
                    }
                    )
                }
                )
            }
        }
        class Dh extends Nh {
            constructor(e) {
                super(e)
            }
            decrypt(e, t, i, r, n) {
                return this.invoke("decrypt", [e, t, i, r, n], [e, t, r])
            }
        }
        class xh extends Nh {
            constructor(e) {
                super(e),
                this.rs = e,
                this.ss = {},
                this.os = (e, t, i) => () => {
                    null != this.ss[e] && this.ss[e].observer.trigger(t, i)
                }
                ,
                this.rs.register("demuxer.event", this.os)
            }
            init(e, t, i) {
                return {maxSeekHole: r, maxBufferHole: n, audioPrimingDelay: a, stretchShortVideoTrack: s, forceKeyFrameOnDiscontinuity: o} = [t][0],
                this.invoke("demuxer.init", [e, t = {
                    maxSeekHole: r,
                    maxBufferHole: n,
                    audioPrimingDelay: a,
                    stretchShortVideoTrack: s,
                    forceKeyFrameOnDiscontinuity: o
                }, i], []).pipe(W(e => {
                    var t = new Fh(this,e);
                    return this.ss[e] = t
                }
                ));
                var r, n, a, s, o
            }
        }
        class Fh {
            constructor(e, t) {
                this.N = e,
                this.ls = t,
                this.observer = new a
            }
            push(e, t, i, r, n, a, s, o, l, d, u, c, h, p) {
                return this.N.invoke("demuxer.push", [this.ls, e, t, i, r, n, a, s, o, l, d, u, c, h], null != p ? p : [e])
            }
            destroy() {
                this.observer.removeAllListeners(),
                this.N.invoke("demuxer.destroy", [this.ls], []).subscribe()
            }
        }
        class Bh {
            constructor() {
                this.handlers = {}
            }
            register(e, t) {
                return null == this.handlers[e] && (this.handlers[e] = t,
                !0)
            }
            unregister(e) {
                return null == this.handlers[e] && (delete this.handlers[e],
                !0)
            }
            invoke(e, i) {
                return (t=Bh._fallbackCallback) => {
                    try {
                        if (null == this.handlers[e])
                            throw new j(!0,H.RPCInlineInvokeCommandNotFound,`command ${e} not found`);
                        this.handlers[e](...i)(t)
                    } catch (e) {
                        t(void 0, e)
                    }
                }
            }
            teardown(e) {
                this.handlers = {},
                e()
            }
        }
        Bh._fallbackCallback = (e, t) => {
            if (null != t)
                throw t
        }
        ;
        const Uh = e => {
            e = e.child({
                name: "InlineRPCService"
            });
            var t = new Bh;
            return new n(t,e),
            new Rt(t,e),
            t
        }
        ;
        let _h;
        const Vh = t => {
            try {
                if (null == _h) {
                    const t = new Blob(["var exports = {};var module = { exports: exports };function define(f){f()};define.amd = true;(" + hy.toString() + ")(true);"],{
                        type: "text/javascript"
                    })
                      , r = URL.createObjectURL(t);
                    _h = new Worker(r)
                }
                var e = new wt(_h);
                return i = e,
                a = t.child({
                    name: "WorkerRPCService"
                }),
                i.register("logger.log", (i, r, ...n) => t => {
                    try {
                        let e = a;
                        for (const a of i)
                            e = e.child(a);
                        "function" == typeof e[r] && e[r](...n),
                        t()
                    } catch (e) {
                        t(void 0, e)
                    }
                }
                ),
                e
            } catch (e) {
                throw t.error("Failed to create WebWorker.", e),
                e
            }
            var i, a
        }
          , Qh = (...r) => t => {
            for (let e = 0; e < r.length; e++) {
                var i = r[e];
                try {
                    return i(t)
                } catch (t) {
                    if (e === r.length - 1)
                        throw t
                }
            }
            throw new j(!0,H.createRPCServiceMissingFallbacks)
        }
          , Kh = e => Qh(Vh, Uh)(e);
        class Hh {
            constructor(e, t, i) {
                this.us = t,
                this.R = i,
                this.cs = null,
                this.Oi = e,
                this.hs = this.ds(),
                this.fs = [],
                this.vs = []
            }
            reset() {
                this.Oi = void 0,
                this.cs = null,
                this.fs = [],
                this.vs = [],
                this.hs = this.ds()
            }
            destroy() {
                this.reset()
            }
            setRTCQuery(e) {
                this.cs = e
            }
            setupReporter(e) {
                this.ps = {
                    SessionID: this.us,
                    ClientName: null == e ? void 0 : e.clientName,
                    ServiceName: null == e ? void 0 : e.serviceName
                }
            }
            addPlayTime(e) {
                var t = null == (t = this.cs) ? void 0 : t.entity(e);
                t && (e = t.sessionControlRecord,
                t = performance.now() - e.eventStartTime,
                "RTC_STATE_PLAY" === e.state) && (this.hs.PlayTimeWC = (this.hs.PlayTimeWC || 0) + t)
            }
            updatePlaybackInfo(e, t) {
                var i;
                null !== e && (this.hs.ViFrDr = (null == (i = null == (i = this.cs) ? void 0 : i.entity(e)) ? void 0 : i.sessionControlRecord.droppedVideoFrames) || 0)
            }
            updateStallCount(e) {
                var t;
                "RTC_STATE_PLAY" === (null == (e = null == (t = null == (t = this.cs) ? void 0 : t.entity(e)) ? void 0 : t.sessionControlRecord) ? void 0 : e.state) && this.hs.StallCount++
            }
            updateMediaEngineStallCount(e) {
                var t;
                "RTC_STATE_PLAY" === (null == (e = null == (t = null == (t = this.cs) ? void 0 : t.entity(e)) ? void 0 : t.sessionControlRecord) ? void 0 : e.state) && this.hs.MediaEngineStallCount++
            }
            updateCanPlay(e) {
                var t;
                this.hs.StartupTime = null != (e = null == (t = null == (t = this.cs) ? void 0 : t.entity(e)) ? void 0 : t.sessionControlRecord.eventStartTime) ? e : 0
            }
            updateFragLoaded(e, t, i) {
                var r;
                this.Oi && (i.fragType === se.Variant ? (this.hs.NetBytes += i.bytes,
                this.hs.ADT += i.adt,
                r = this.ys(i, ++this.hs.fragmentCnt, this.hs.NetBytes, this.hs.ADT),
                this.hs.OBRLast = r.obrLast,
                this.hs.OBRMean = r.obrMean,
                this.gs(this.hs, r.obr),
                re(r = null != (r = this.Oi.realCurrentTime) ? r : NaN) && r > i.startPTS && !t && this.hs.overdue++,
                this.bs(i.startPTS, i.endPTS, this.hs.lastStartPTS, this.hs.lastEndPTS) && this.addToAccessLog(e),
                this.hs.startPTS || (this.hs.startPTS = i.startPTS),
                this.hs.lastStartPTS = i.startPTS,
                this.hs.lastEndPTS = i.endPTS,
                this.hs.videoBytes += i.bytes,
                this.hs.videoDuration += i.duration) : i.fragType === se.AltAudio && (this.hs.audioBytes += i.bytes,
                this.hs.audioDuration += i.duration))
            }
            addToAccessLog(e) {
                var t = this.Ss(e)
                  , i = null == (i = null == (i = this.cs) ? void 0 : i.entity(e)) ? void 0 : i.sessionControlRecord.curLevelUrl
                  , r = null == (r = null == (r = this.cs) ? void 0 : r.entity(e)) ? void 0 : r.playEndedRecord.PlayType;
                if (i && "" !== i && this.Oi) {
                    i = this.ws(e, i, t, r);
                    if (i) {
                        const e = this.fs.length - 20;
                        0 < e && this.fs.splice(0, e),
                        this.fs.push(i)
                    }
                    this.hs = this.ds();
                    i = null == (r = null == (t = this.cs) ? void 0 : t.entity(e)) ? void 0 : r.switchCompleteRecord.MediaDur;
                    this.hs.lastMediaDur = i || this.Oi.bufferedDuration
                }
            }
            addToErrorLog(e, t) {
                var i = null == (i = this.cs) ? void 0 : i.entity(e);
                if (i) {
                    var r = Number(("mediaError" === t ? i.playErrorRecord : i.nwErrorRecord).ErrCode)
                      , i = i.sessionControlRecord.curLevelUrl
                      , i = this.Ts(e, i, {
                        domain: t,
                        code: r
                    });
                    if (i) {
                        const e = this.vs.length - 20;
                        0 < e && this.vs.splice(0, e),
                        this.vs.push(i)
                    }
                }
            }
            getAccessLog(e) {
                var t, i;
                const r = this.fs.slice(0)
                  , n = null == (t = this.cs) ? void 0 : t.entity(e);
                if (r && n) {
                    const t = n.sessionControlRecord.curLevelUrl;
                    if (t && "" !== t) {
                        const n = this.Ss(e)
                          , a = this.ws(e, t, n, null == (i = null == (i = this.cs) ? void 0 : i.entity(e)) ? void 0 : i.playEndedRecord.PlayType);
                        a && (a["c-provisional-entry"] = !0,
                        r.push(a))
                    }
                }
                return r
            }
            get errorLog() {
                return this.vs
            }
            ds() {
                return {
                    fragmentCnt: 0,
                    overdue: 0,
                    startPTS: 0,
                    obrMax: 0,
                    obrMin: 0,
                    audioBytes: 0,
                    audioDuration: 0,
                    videoBytes: 0,
                    videoDuration: 0,
                    svrAddrChanged: 0,
                    svrAddr: "",
                    PlayTimeWC: 0,
                    ViFrDr: 0,
                    StallCount: 0,
                    MediaEngineStallCount: 0,
                    ADT: 0,
                    NetBytes: 0,
                    StartupTime: 0,
                    OBRMean: 0,
                    OBRLast: 0
                }
            }
            Is(e) {
                return e ? "object" == typeof e ? e.toString() : e : ""
            }
            Os(t) {
                var i = us.parseURL(t);
                if (i && i.netLoc) {
                    const t = i.netLoc.indexOf(":");
                    let e = 0 <= t ? i.netLoc.slice(0, t) : i.netLoc;
                    e.startsWith("//") && (e = e.slice(2)),
                    this.hs.svrAddr ? e !== this.hs.svrAddr && this.hs.svrAddrChanged++ : this.hs.svrAddrChanged = 0,
                    this.hs.svrAddr = e
                }
            }
            ws(e, t, i, r) {
                t = this.Is(t);
                this.Os(t);
                let n = null == (a = null == (a = this.cs) ? void 0 : a.entity(e)) ? void 0 : a.switchCompleteRecord.MediaDur;
                n = (n = n || this.Oi && this.Oi.bufferedDuration || 0) || 0;
                var a = {
                    uri: t,
                    "s-ip": this.hs.svrAddr,
                    "s-ip-changes": this.hs.svrAddrChanged,
                    "sc-wwan-count": -1,
                    "c-transfer-duration": this.hs.ADT,
                    bytes: this.hs.NetBytes,
                    "c-total-media-requests": this.hs.fragmentCnt,
                    "cs-guid": this.ps ? null == (e = this.ps) ? void 0 : e.SessionID : "undefined",
                    "c-start-time": this.hs.startPTS,
                    "c-startup-time": this.hs.StartupTime,
                    "c-duration-watched": this.hs.PlayTimeWC / 1e3,
                    "c-frames-dropped": this.hs.ViFrDr,
                    "c-stalls": this.hs.StallCount + this.hs.MediaEngineStallCount,
                    "c-duration-downloaded": this.hs.lastMediaDur ? n - this.hs.lastMediaDur : n,
                    "c-overdue": this.hs.overdue,
                    "c-avg-video-bitrate": 8 * this.hs.videoBytes / (this.hs.videoDuration || 1),
                    "c-observed-max-bitrate": this.hs.obrMax,
                    "c-observed-min-bitrate": this.hs.obrMin,
                    "sc-indicated-bitrate": i.bandwidth || 0,
                    "sc-indicated-avg-bitrate": i.avgBandwidth || 0,
                    "c-observed-bitrate": this.hs.OBRMean,
                    "c-switch-bitrate": this.hs.OBRLast,
                    "c-provisional-entry": !1
                };
                return a["s-playback-type"] = r,
                this.hs.audioBytes && (a["c-avg-audio-bitrate"] = 8 * this.hs.audioBytes / (this.hs.audioDuration || 1)),
                a
            }
            Ts(e, t, i) {
                t = this.Is(t);
                return this.Os(t),
                {
                    date: new Date,
                    "cs-guid": this.ps ? this.ps.SessionID + "-" + e : "undefined",
                    uri: t,
                    "s-ip": this.hs.svrAddr,
                    status: "" + i.code,
                    domain: i.domain
                }
            }
            bs(e, t, i, r) {
                return void 0 !== e && void 0 !== i && (1 < e - (r = void 0 === r ? 0 : r) || 1 < i - t)
            }
            ys(e, t, i, r) {
                i = 8 * i / (r / 1e3);
                return {
                    obr: i,
                    obrLast: 8 * e.bytes / (e.adt / 1e3),
                    obrMean: i / t
                }
            }
            gs(e, t) {
                (!e.obrMax || t > e.obrMax) && (e.obrMax = t),
                (!e.obrMin || t < e.obrMin) && (e.obrMin = t)
            }
            Ss(e) {
                var t = null == (t = null == (t = this.cs) ? void 0 : t.entity(e)) ? void 0 : t.sessionControlRecord.curLevelUrl
                  , i = null == (e = null == (i = null == (i = this.cs) ? void 0 : i.entity(e)) ? void 0 : i.sessionControlRecord.manifestData) ? void 0 : e.variantList;
                return t && i && i[t] ? i[t] : {}
            }
        }
        class jh {
            constructor(e, t, i) {
                this.Qn = e,
                this.R = t,
                this.Gt = i,
                this.ks = new Set(this.Gt.rtcExcludeKeysList)
            }
            setReportingAgent(e) {
                this.Ms = e
            }
            sendPlayEnded(e) {
                var t = o.PlayEnded;
                this.Es(t, this.Qn.playEnded(e))
            }
            sendPlayStalled(e) {
                var t = o.PlayStalled;
                this.Es(t, this.Qn.playStalled(e))
            }
            sendMediaEngineStalled(e) {
                var t = o.MediaEngineStalled;
                this.Es(t, this.Qn.mediaEngineStalled(e))
            }
            sendKeySessionComplete(e) {
                var t = o.KeySessionComplete;
                this.Es(t, this.Qn.keySessionComplete(e))
            }
            sendPlayLikelyToKeepUp(e) {
                var t = o.PlayLikelyToKeepUp;
                this.Es(t, this.Qn.playLikelyToKeepUp(e))
            }
            sendPlayRateChange(e) {
                var t = o.PlayRateChanged;
                this.Es(t, this.Qn.playRateChanged(e))
            }
            sendSwitchComplete(e) {
                var t = o.SwitchComplete;
                this.Es(t, this.Qn.switchComplete(e))
            }
            sendSeekComplete(e) {
                var t = o.SeekComplete;
                this.Es(t, this.Qn.seekComplete(e))
            }
            sendVariantEnded(e) {
                var t = o.VariantEnded;
                this.Es(t, this.Qn.variantEnded(e))
            }
            sendPlayError(e) {
                var t = o.PlayError;
                this.Es(t, this.Qn.playError(e))
            }
            sendNwError(e) {
                var t = o.NwError;
                this.Es(t, this.Qn.nwError(e))
            }
            sendDebugInfo(e) {
                var t = o.DebugInfo;
                this.Es(t, this.Qn.debugInfo(e))
            }
            sendTeardownDebugInfo(e) {
                var t = o.DebugInfo;
                this.Es(t, e)
            }
            sendPeriodic(e) {
                var t = o.Periodic;
                this.Es(t, this.Qn.periodic(e))
            }
            sendInterstitialStart(e) {
                var t = o.InterstitialStarted;
                this.Es(t, this.Qn.periodic(e))
            }
            sendInterstitialAssetStart(e) {
                var t = o.InterstitialAssetStarted;
                this.Es(t, this.Qn.periodic(e))
            }
            sendInterstitialAssetEnd(e) {
                var t = o.InterstitialAssetEnded;
                this.Es(t, this.Qn.periodic(e))
            }
            sendInterstitialEnd(e) {
                var t = o.InterstitialEnded;
                this.Es(t, this.Qn.periodic(e))
            }
            sendErrorRecovery(e) {
                var t = o.ErrorRecovery;
                this.Es(t, this.Qn.errorRecovery(e))
            }
            Es(e, t) {
                if (t && (e !== o.Periodic || t.PlayTimeWC || t.ADT)) {
                    (r = void 0 || {})[r.BatchEvent = 0] = "BatchEvent",
                    r[r.RealTimeEvent = 1] = "RealTimeEvent";
                    var r = e === o.PlayEnded || e === o.Periodic ? 1 : 0;
                    if (this.Ms) {
                        let i = {};
                        Object.entries(t).forEach( ([e,t]) => {
                            this.ks.has(e) || ("object" == typeof (t = re(t) ? Number(Number(t).toFixed(2)) : t) ? "ServerInfo" === e ? Object.entries(null != t ? t : {}).forEach( ([e,t]) => {
                                i[e] = t
                            }
                            ) : this.As(e) && (i[e] = t) : i[e] = t)
                        }
                        ),
                        i = JSON.parse(JSON.stringify(i));
                        try {
                            this.Ms.issueReportingEvent(e, i, r, (e, t, i) => {}
                            )
                        } catch (e) {}
                    }
                }
            }
            As(e) {
                return "VariantFragLoadInfo" === e || "AudioFragLoadInfo" === e || "VariantBufferInfo" === e || "AudioBufferInfo" === e || "KeySystemEvents" === e || "KeySystemInitEvents" === e
            }
        }
        class qh {
            constructor(e, t) {
                this.Ns = e,
                this.R = t
            }
            entity(e) {
                return this.Ns.getEntity(e)
            }
            playEnded(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.playEndedRecord
            }
            periodic(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.periodicRecord
            }
            sessionControlRecord(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.sessionControlRecord
            }
            playStalled(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.playStalledRecord
            }
            mediaEngineStalled(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.mediaEngineStalledRecord
            }
            keySessionComplete(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.keySessionCompleteRecord
            }
            playLikelyToKeepUp(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.playLikelyToKeepUpRecord
            }
            playRateChanged(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.playRateChangedRecord
            }
            switchComplete(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.switchCompleteRecord
            }
            seekComplete(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.seekCompleteRecord
            }
            variantEnded(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.variantEndedRecord
            }
            playError(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.playErrorRecord
            }
            nwError(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.nwErrorRecord
            }
            debugInfo(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.debugInfoRecord
            }
            interstitialPlayTime(e) {
                return null != (e = null == (e = this.Ns.getEntity(e)) ? void 0 : e.periodicRecord.InterstitialPlayTime) ? e : 0
            }
            errorRecovery(e) {
                return null == (e = this.Ns.getEntity(e)) ? void 0 : e.errorRecoveryRecord
            }
        }
        class Gh {
            constructor(e) {
                this.R = e,
                this.Bn = {}
            }
            createEntity(e, t, i, r=!1, n=void 0) {
                t = {
                    itemId: e,
                    sessionControlRecord: {
                        state: "RTC_STATE_INIT",
                        rate: 0,
                        oldRate: 0,
                        eventStartTime: performance.now(),
                        sessionStartTime: performance.now(),
                        lastLikelyToKeepUpTime: performance.now(),
                        lastPeriodicTime: performance.now(),
                        lastWaitForCanPlay: performance.now(),
                        playLikelyToKeepUpEventCounter: 1,
                        periodicEventCounter: 1,
                        keySessionCompleteEventCounter: 1,
                        activeKeySessions: {},
                        intervalVariantList: {},
                        sessionVariantList: {}
                    },
                    playEndedRecord: {
                        HLSJSVersion: t,
                        InterstitialsEnabled: i,
                        IsLoopingPlayer: r
                    },
                    periodicRecord: {},
                    playStalledRecord: {},
                    keySessionCompleteRecord: {},
                    playLikelyToKeepUpRecord: {},
                    playRateChangedRecord: {},
                    playErrorRecord: {},
                    mediaEngineStalledRecord: {},
                    switchCompleteRecord: {},
                    variantEndedRecord: {},
                    nwErrorRecord: {},
                    debugInfoRecord: {},
                    seekCompleteRecord: {},
                    errorRecoveryRecord: {}
                };
                n && (t.playEndedRecord.TestGroupId = n),
                this.Bn[e] = t
            }
            addEntity(e) {
                this.Bn[e.itemId] = e
            }
            removeEntityByID(e) {
                delete this.Bn[e]
            }
            resetStore() {
                this.Bn = {}
            }
            getEntity(e) {
                if (e)
                    return this.Bn[e]
            }
            updateEnded(e, t) {
                this.Rs(e, t)
            }
            updatePeriodic(e, t, i) {
                this.Ps(e, {
                    currentTime: t,
                    isFinal: i
                })
            }
            updateBufferStalled(e, t) {
                var i, r, n, a = this.getEntity(e);
                a && ({sessionControlRecord: a, variantEndedRecord: i, periodicRecord: r, playEndedRecord: n} = a,
                a.rate = 0,
                i.StallCount = (i.StallCount || 0) + 1,
                r.StallCount = (r.StallCount || 0) + 1,
                n.StallCount = (n.StallCount || 0) + 1,
                this.Cs(e, t))
            }
            updateKeyLoaded(e, t) {
                const i = this.getEntity(e);
                if (i) {
                    var r = i["sessionControlRecord"];
                    if (r.activeKeySessions)
                        if ("AES-128" === t.method) {
                            const e = {}
                              , i = t.timestamp;
                            e.keyFormat = "identity",
                            e.keyDeliveryTime = t.adt,
                            e.currentMediaTime = t.currentTime,
                            e.forInterstitial = t.forInterstitial,
                            e.mediaOptionId = t.mediaOptionId,
                            e.keyInitTime = i - r.sessionStartTime,
                            r.activeKeySessions[t.keyuri] = e
                        } else
                            r.activeKeySessions[t.keyuri].mediaOptionId = t.mediaOptionId;
                    this.Ds(e, t)
                }
            }
            updateLicenseResponseProcessed(e, t) {
                var i = this.getEntity(e);
                if (i) {
                    i = i["sessionControlRecord"];
                    if (i.activeKeySessions) {
                        const e = i.activeKeySessions[t.keyuri];
                        e.licenseResponseProcessTime = t.timestamp - (e.licenseResponseSubmitTime || 0),
                        i.lastKeyDeliveryTime = e.keyDeliveryTime = t.timestamp - (e.licenseChallengeStartTime || 0),
                        e.currentMediaTime = t.currentTime,
                        i.finishedKeyUri = t.keyuri
                    }
                    this.Ds(e, t)
                }
            }
            updateLicenseChallengeError(e, t) {
                e = this.getEntity(e);
                if (e) {
                    var i = e["sessionControlRecord"];
                    if (i.activeKeySessions) {
                        const e = i.activeKeySessions[t.keyuri];
                        i.lastKeyErrorType = e.keyErrorType = "licenseChallengeError"
                    }
                }
            }
            updateLicenseResponseError(e, t) {
                e = this.getEntity(e);
                if (e) {
                    var i = e["sessionControlRecord"];
                    if (i.activeKeySessions) {
                        const e = i.activeKeySessions[t.keyuri];
                        i.lastKeyErrorType = e.keyErrorType = "licenseResponseError"
                    }
                }
            }
            updateKeyAborted(e, t) {
                var i = this.getEntity(e);
                i && (i = i["sessionControlRecord"],
                i.activeKeySessions && (i.activeKeySessions[t.keyuri].keyErrorType = "keyAborted",
                i.finishedKeyUri = t.keyuri),
                this.Ds(e, t))
            }
            updateKeyErrorThrown(e, i) {
                var r;
                const n = this.getEntity(e);
                if (n) {
                    var a = n["sessionControlRecord"];
                    if (a.activeKeySessions) {
                        let t = "";
                        (null != (r = i.mediaOptionIds) ? r : []).forEach(e => t += e + ","),
                        t = t.substring(0, t.length - 1);
                        const n = a.activeKeySessions[i.keyuri];
                        n.mediaOptionId = i.mediaOptionId,
                        n.mediaOptionIdsForKey = t,
                        a.finishedKeyUri = i.keyuri
                    }
                    this.Ds(e, i)
                }
            }
            updateCanPlay(e, t) {
                var i, r, n, a, s = this.getEntity(e);
                s && ({sessionControlRecord: s, playLikelyToKeepUpRecord: i, playRateChangedRecord: r} = s,
                {sessionStartTime: s, lastWaitForCanPlay: n, playLikelyToKeepUpEventCounter: a} = (this.xs(t.oldRate, t.newRate) ? s.iFrameToggle = !0 : s.iFrameToggle = !1,
                s),
                a = performance.now() - (1 === a ? s : n),
                i.StartupTime = r.StartupTime = a,
                this.Ls(e, t))
            }
            updateRateChanged(e, t) {
                var i = this.getEntity(e);
                i && (i = i["sessionControlRecord"],
                i.rate = 100 * t.rate,
                0 < t.rate && 0 === i.oldRate && (i.playInfo || (i.playInfo = []),
                i.playInfo.push({
                    latency: t.latency
                }),
                i.curLevelUrl || "" === t.url || (i.curLevelUrl = t.url)),
                this._s(e, t))
            }
            updateMediaError(e, t) {
                var i = this.getEntity(e);
                if (i) {
                    var {sessionControlRecord: i, periodicRecord: r, playEndedRecord: n} = i;
                    if (r.PlayerErrCount = (r.PlayerErrCount || 0) + 1,
                    n.PlayerErrCount = (n.PlayerErrCount || 0) + 1,
                    t.fatal)
                        i.rate = 0,
                        r.FatalPlayerErrCount = (r.FatalPlayerErrCount || 0) + 1,
                        n.FatalPlayerErrCount = (n.FatalPlayerErrCount || 0) + 1,
                        n.ErrCode = t.details,
                        n.ErrReason = t.code,
                        n.ErrIsFatal = !0,
                        n.ErrDomain = "mediaError",
                        this.Fs(e, t);
                    else {
                        const e = t.details + "/" + t.code;
                        i.nonFatalPlayErrList || (i.nonFatalPlayErrList = {}),
                        i.nonFatalPlayErrList[e] = (i.nonFatalPlayErrList[e] || 0) + 1
                    }
                }
            }
            prepareNonFatalPlayError(e) {
                var t, i, r, n, a, e = this.getEntity(e);
                return !(!e || ({sessionControlRecord: e, playEndedRecord: t, playErrorRecord: i} = e,
                r = null != (r = e.nonFatalPlayErrList) ? r : {},
                (a = null != (a = Object.keys(r)) ? a : []).length <= 0) || (n = a[0],
                a = a[0].split("/"),
                i.ErrDomain = "mediaError",
                i.ErrIsFatal = !1,
                i.ErrCode = a[0],
                i.ErrReason = parseInt(a[1]),
                i.PlayerErrCount = r[n],
                this.js(i, t),
                this.Us(i, e),
                this.Bs(i, t.PlayTimeWC || 0, t.PlayTime || 0),
                delete r[n],
                0))
            }
            updateMediaElementError(e, t, i) {
                let r;
                try {
                    r = JSON.parse(t.message)
                } catch (e) {}
                var n = r ? parseInt(r.ErrReason) : void 0
                  , a = r ? parseInt(r.ErrDetail) : void 0;
                this.Fs(e, {
                    domain: "mediaElementError",
                    mediaElemCode: t.code,
                    mediaElemReason: n,
                    mediaElemDetail: a,
                    code: void 0,
                    details: void 0,
                    fatal: void 0,
                    forInterstitial: i
                })
            }
            updateDebugInfo(e, t) {
                this.$s(e, {
                    details: t.details,
                    code: t.code,
                    domain: t.domain === he.NETWORK_ERROR ? "networkError" : "mediaError",
                    stack: t.stack,
                    logs: t.logs,
                    contentUrl: t.contentUrl
                })
            }
            updateErrorRecoveryRecord(e, t) {
                this.Vs(e, t)
            }
            updateMediaEngineStalled(e, t) {
                var i, r, n, a = this.getEntity(e);
                a && ({sessionControlRecord: a, variantEndedRecord: i, periodicRecord: r, playEndedRecord: n} = a,
                a.rate = 0,
                i.MediaEngineStallCount = (i.MediaEngineStallCount || 0) + 1,
                r.MediaEngineStallCount = (r.MediaEngineStallCount || 0) + 1,
                n.MediaEngineStallCount = (n.MediaEngineStallCount || 0) + 1,
                this.qs(e, t))
            }
            updateLevelSwitched(i, r) {
                var n = this.getEntity(i);
                if (n) {
                    var {sessionControlRecord: n, switchCompleteRecord: a, periodicRecord: s, playEndedRecord: o} = n
                      , s = (s.SwCnt = (s.SwCnt || 0) + 1,
                    o.SwCnt = (o.SwCnt || 0) + 1,
                    performance.now())
                      , o = n.curLevelUrl
                      , l = r.url
                      , d = this.Ks(o, n)
                      , u = this.Ks(l, n);
                    let e, t = !1;
                    o ? (e = u.bandwidth < d.bandwidth ? "Down" : "Up",
                    t = u.iframes) : e = "Up",
                    a.BadSw = this.Hs(e, n.lastSwitchDir, t, n.lastLevelIsIframe, s, n.lastSwitchTime, r.isSeeking),
                    n.lastSwitchDir = e,
                    n.lastSwitchTime = s,
                    n.lastLevelIsIframe = t,
                    n.curLevelUrl = l,
                    n.variantStartTimeMedia = null != r.currentTime ? r.currentTime : void 0,
                    this.zs(i, r)
                }
            }
            updateLevelLoadError(i, r) {
                const n = this.getEntity(i);
                if (n) {
                    var {sessionControlRecord: a, switchCompleteRecord: s, periodicRecord: o, playEndedRecord: l} = n
                      , d = performance.now();
                    let e, t = !1;
                    if (a.curLevelUrl) {
                        const i = this.Ks(a.curLevelUrl, a)
                          , n = this.Ks(r.url, a);
                        e = n.bandwidth < i.bandwidth ? "Down" : "Up",
                        t = n.iframes
                    } else
                        e = "Up";
                    o.SwCnt = (o.SwCnt || 0) + 1,
                    l.SwCnt = (l.SwCnt || 0) + 1,
                    s.BadSw = this.Hs(e, a.lastSwitchDir, t, a.lastLevelIsIframe, d, a.lastSwitchTime, r.isSeeking),
                    s.SwFail = !0,
                    this.zs(i, r)
                }
            }
            updateVariantEnd(e, t) {
                this.Qs(e, t)
            }
            updateNwError(e, t) {
                var i = this.getEntity(e);
                if (i) {
                    var {sessionControlRecord: i, periodicRecord: r, playEndedRecord: n} = i;
                    if (r.NwErrCount = (r.NwErrCount || 0) + 1,
                    n.NwErrCount = (n.NwErrCount || 0) + 1,
                    t.fatal)
                        i.rate = 0,
                        r.FatalNwErrCount = (r.FatalNwErrCount || 0) + 1,
                        n.FatalNwErrCount = (n.FatalNwErrCount || 0) + 1,
                        n.ErrCode = t.details,
                        n.ErrReason = t.code,
                        n.ErrIsFatal = !0,
                        n.ErrDomain = "networkError",
                        this.Gs(e, t);
                    else {
                        const e = t.details + "/" + t.code;
                        i.nonFatalNwErrList || (i.nonFatalNwErrList = {}),
                        i.nonFatalNwErrList[e] = (i.nonFatalNwErrList[e] || 0) + 1
                    }
                }
            }
            prepareNonFatalNwError(e) {
                var t, i, r, n, a, e = this.getEntity(e);
                return !(!e || ({sessionControlRecord: e, playEndedRecord: t, nwErrorRecord: i} = e,
                r = null != (r = e.nonFatalNwErrList) ? r : {},
                (a = null != (a = Object.keys(r)) ? a : []).length <= 0) || (n = a[0],
                a = a[0].split("/"),
                i.ErrDomain = "networkError",
                i.ErrIsFatal = !1,
                i.ErrCode = a[0],
                i.ErrReason = parseInt(a[1]),
                i.NwErrCount = r[n],
                this.js(i, t),
                this.Us(i, e),
                this.Bs(i, t.PlayTimeWC || 0, t.PlayTime || 0),
                delete r[n],
                0))
            }
            updateInterstitialPlayTime(e, t) {
                var i, r, n, a, s, e = this.getEntity(e);
                e && ({playEndedRecord: e, periodicRecord: i, variantEndedRecord: r, playStalledRecord: n, playErrorRecord: a, mediaEngineStalledRecord: s} = e,
                e.InterstitialPlayTime = (e.InterstitialPlayTime || 0) + t,
                i.InterstitialPlayTime = (i.InterstitialPlayTime || 0) + t,
                r.InterstitialPlayTime = (r.InterstitialPlayTime || 0) + t,
                n.InterstitialPlayTime = (n.InterstitialPlayTime || 0) + t,
                a.InterstitialPlayTime = (a.InterstitialPlayTime || 0) + t,
                s.InterstitialPlayTime = (s.InterstitialPlayTime || 0) + t)
            }
            finalize(t, e) {
                var i = this.getEntity(t);
                if (i) {
                    var r = i["sessionControlRecord"];
                    switch (e) {
                    case o.PlayEnded:
                        r.state = "RTC_STATE_STOP",
                        r.oldRate = 0,
                        i.playEndedRecord = {};
                        break;
                    case o.Periodic:
                        {
                            r.lastPeriodicTime = performance.now(),
                            r.periodicEventCounter += 1,
                            r.bufferAppendInfo = [],
                            r.playInfo = [],
                            r.seekInfo = [],
                            r.liveEdgeInfo = [];
                            const t = r.intervalVariantList;
                            t && Object.keys(t).forEach(e => {
                                t[e].playTime = 0
                            }
                            ),
                            i.periodicRecord = {};
                            break
                        }
                    case o.PlayStalled:
                        r.state = "RTC_STATE_STALL",
                        r.oldRate = 0,
                        i.playStalledRecord = {};
                        break;
                    case o.KeySessionComplete:
                        r.keySessionCompleteEventCounter += 1,
                        r.activeKeySessions && r.finishedKeyUri && delete r.activeKeySessions[r.finishedKeyUri],
                        delete r.keySystemInitEvents,
                        i.keySessionCompleteRecord = {};
                        break;
                    case o.PlayLikelyToKeepUp:
                        "RTC_STATE_PLAY" === r.state && !r.iFrameToggle || (r.state = "RTC_STATE_CANPLAY",
                        r.lastLikelyToKeepUpTime = performance.now(),
                        r.playLikelyToKeepUpEventCounter += 1),
                        r.startupLatencyInfo = [],
                        i.playLikelyToKeepUpRecord = {};
                        break;
                    case o.PlayRateChanged:
                        {
                            const {playEndedRecord: t, playStalledRecord: e, mediaEngineStalledRecord: n, playErrorRecord: a, nwErrorRecord: s} = i;
                            0 !== r.rate ? (r.state = "RTC_STATE_PLAY",
                            delete t.LastStall,
                            delete t.LastMediaEngineStall,
                            delete t.LastPause,
                            delete a.LastPause,
                            delete s.LastPause) : (r.state = "RTC_STATE_PAUSE",
                            delete e.LastResume,
                            delete n.LastResume,
                            delete a.LastResume,
                            delete s.LastResume),
                            r.oldRate = r.rate,
                            i.playRateChangedRecord = {};
                            break
                        }
                    case o.PlayError:
                        r.state = "RTC_STATE_PLAYERROR",
                        i.playErrorRecord = {};
                        break;
                    case o.MediaEngineStalled:
                        r.state = "RTC_STATE_MEDIAENGINESTALL",
                        r.oldRate = 0,
                        i.mediaEngineStalledRecord = {};
                        break;
                    case o.SwitchComplete:
                        i.switchCompleteRecord = {},
                        r.prevLevelUrl = r.curLevelUrl;
                        break;
                    case o.VariantEnded:
                        r.decodedFramesForVariant = 0,
                        r.decodedFramesForVariantSampleCount = 0,
                        i.variantEndedRecord = {};
                        break;
                    case o.SeekComplete:
                        i.seekCompleteRecord = {};
                        break;
                    case o.NwError:
                        r.state = "RTC_STATE_NWERROR",
                        i.nwErrorRecord = {};
                        break;
                    case o.DebugInfo:
                        i.debugInfoRecord = {}
                    }
                    r.eventStartTime = performance.now()
                }
            }
            updatePlaybackInfo(e, t) {
                var i, r, n, a, e = this.getEntity(e);
                e && ({sessionControlRecord: e, periodicRecord: i, playEndedRecord: r} = e,
                re(t.liveEdgeDistance) && (e.liveEdgeInfo ? e.liveEdgeInfo.push({
                    liveEdgeDist: t.liveEdgeDistance
                }) : e.liveEdgeInfo = [{
                    liveEdgeDist: t.liveEdgeDistance
                }]),
                e.bufferedRangeTuple = t.bufferedRangeTuple,
                e.droppedVideoFrames && t.droppedVideoFrames < e.droppedVideoFrames && (e.droppedVideoFrames = 0),
                e.decodedFrameCount && t.decodedFrameCount < e.decodedFrameCount && (e.decodedFrameCount = 0),
                n = t.droppedVideoFrames - (e.droppedVideoFrames || 0),
                a = t.decodedFrameCount - (e.decodedFrameCount || 0),
                e.droppedVideoFrames = t.droppedVideoFrames,
                e.decodedFrameCount = t.decodedFrameCount,
                e.decodedFramesForVariant ? e.decodedFramesForVariant += a : e.decodedFramesForVariant = a,
                e.decodedFramesForVariantSampleCount ? e.decodedFramesForVariantSampleCount += 1 : e.decodedFramesForVariantSampleCount = 1,
                n) && (3 <= n ? (i.GroupViFrDr = (i.GroupViFrDr || 0) + n,
                i.GroupViFrDrEvtCount = (i.GroupViFrDrEvtCount || 0) + 1,
                r.GroupViFrDr = (r.GroupViFrDr || 0) + n,
                r.GroupViFrDrEvtCount = (r.GroupViFrDrEvtCount || 0) + 1) : (i.SparseViFrDr = (i.SparseViFrDr || 0) + n,
                i.SparseViFrDrEvtCount = (i.SparseViFrDrEvtCount || 0) + 1,
                r.SparseViFrDr = (r.SparseViFrDr || 0) + n,
                r.SparseViFrDrEvtCount = (r.SparseViFrDrEvtCount || 0) + 1))
            }
            updateBufferAppended(e, t) {
                var i, e = this.getEntity(e);
                e && (e = e["sessionControlRecord"],
                e.bufferAppendInfo || (e.bufferAppendInfo = []),
                e.bufferAppendInfo.push({
                    latency: t.endAppend - t.startAppend,
                    size: t.bytesAppend
                }),
                this.Ws(e, {
                    type: "BufferAppend",
                    tbegin: t.startAppend,
                    tend: t.endAppend
                }),
                (i = null != (i = e.lastBufferAppendTimeForType) ? i : {})[t.fragmentType] = Math.round(t.endAppend - e.sessionStartTime),
                e.lastBufferAppendTimeForType = i)
            }
            updateSeek(e, t, i) {
                var e = this.getEntity(e);
                e && (e = e["seekCompleteRecord"],
                e.SeekStart = t.startPos,
                e.SeekEnd = t.pos,
                e.FromEvent = t.fromEvent,
                e.IsSeekPosBuffered = i.some(e => e.start <= t.pos && t.pos <= e.end))
            }
            updateSeeked(e, t) {
                var i, r, n = this.getEntity(e);
                n && ({sessionControlRecord: n, playEndedRecord: i, seekCompleteRecord: r} = n,
                n.seekInfo || (n.seekInfo = []),
                n.seekInfo.push(t),
                r.SeekLatency = t.latency,
                this.js(r, i),
                this.Us(r, n),
                this.Bs(r, i.PlayTimeWC || 0, i.PlayTime || 0),
                this.Xs(e))
            }
            updateManifestParsed(e, t) {
                e = this.getEntity(e);
                if (e) {
                    const {sessionControlRecord: i, playLikelyToKeepUpRecord: r, periodicRecord: n, playEndedRecord: a} = e
                      , s = (r.MasterPlaylistADT = t.adt,
                    n.MasterPlaylistADT = t.adt,
                    a.MasterPlaylistADT = t.adt,
                    this.Ws(i, {
                        type: "PlaylistParse",
                        tbegin: t.tparsed.tbegin,
                        tend: t.tparsed.tend
                    }),
                    this.Ys(t.levels));
                    a.IsAudioOnly = t.isAudioOnly,
                    a.IsGapless = t.isGapless,
                    a.IsFirstItem = t.isFirstItem,
                    a.ForInterstitial = t.forInterstitial,
                    a.ItemID = t.itemID,
                    a.MaxVideoQltyIndex = s.maxVideoQltyIndex,
                    a.MaxReWd = s.maxWidth,
                    a.MaxReHt = s.maxHeight,
                    Object.keys(s.variantList).forEach(e => {
                        e = s.variantList[e].width || 0;
                        3800 <= e ? i.support4KStart = performance.now() : 1850 <= e && e < 2e3 && (i.supportHDStart = performance.now())
                    }
                    ),
                    i.manifestData = {
                        variantList: s.variantList,
                        varListString: s.varListString
                    }
                }
            }
            updateFragLoaded(e, t) {
                e = this.getEntity(e);
                if (e) {
                    var {sessionControlRecord: e, periodicRecord: i, playEndedRecord: r} = e;
                    i.MediaRequestsSent = (i.MediaRequestsSent || 0) + 1,
                    r.MediaRequestsSent = (r.MediaRequestsSent || 0) + 1;
                    const a = t.stats
                      , s = null == a ? void 0 : a.contentType
                      , o = null == a ? void 0 : a.loaded
                      , l = (null == a ? void 0 : a.tload) - (null == a ? void 0 : a.trequest)
                      , d = (null == a ? void 0 : a.tload) - (null == a ? void 0 : a.tfirst);
                    null != a && a.cdnServer && (r.LastMediaCDNServer = null == (n = a.cdnServer) ? void 0 : n.toLowerCase()),
                    t.serverInfo && (r.ServerInfo = t.serverInfo),
                    e.segmentMimeTypes || (e.segmentMimeTypes = []),
                    e.segmentMimeTypes.findIndex(e => e == s) < 0 && e.segmentMimeTypes.push(s);
                    var n = [Math.round((o || 0) / 1e3), Math.round(l), Math.round(performance.now() - e.sessionStartTime)];
                    this.Ws(e, {
                        type: "SegmentLoad",
                        tbegin: a.trequest,
                        tend: a.tload
                    }),
                    t.fragType === se.Variant ? (e.variantVideoBytes = (e.variantVideoBytes || 0) + o,
                    e.variantVideoDuration = (e.variantVideoDuration || 0) + t.duration,
                    e.intervalVideoBytes = (e.intervalVideoBytes || 0) + o,
                    e.intervalVideoDuration = (e.intervalVideoDuration || 0) + t.duration,
                    e.sessionVideoBytes = (e.sessionVideoBytes || 0) + o,
                    e.sessionVideoDuration = (e.sessionVideoDuration || 0) + t.duration,
                    e.variantFragLoadInfo || (e.variantFragLoadInfo = []),
                    e.variantFragLoadInfo.push(n),
                    5 < e.variantFragLoadInfo.length && e.variantFragLoadInfo.shift(),
                    e.obrLast = 8 * o / (l / 1e3),
                    r.NetBytes && r.ADT && (e.obrMean = 8 * r.NetBytes / (r.ADT / 1e3)),
                    i.NetBytes = (i.NetBytes || 0) + o,
                    i.ADT = (i.ADT || 0) + l,
                    i.SegmentProcessTime = (i.SegmentProcessTime || 0) + d,
                    r.ADT = (r.ADT || 0) + l,
                    r.NetBytes = (r.NetBytes || 0) + o,
                    r.SegmentProcessTime = (r.SegmentProcessTime || 0) + d) : t.fragType === se.AltAudio && (e.variantAudioBytes = (e.variantAudioBytes || 0) + o,
                    e.variantAudioDuration = (e.variantAudioDuration || 0) + t.duration,
                    e.intervalAudioBytes = (e.intervalAudioBytes || 0) + o,
                    e.intervalAudioDuration = (e.intervalAudioDuration || 0) + t.duration,
                    e.sessionAudioBytes = (e.sessionAudioBytes || 0) + o,
                    e.sessionAudioDuration = (e.sessionAudioDuration || 0) + t.duration,
                    e.audioFragLoadInfo || (e.audioFragLoadInfo = []),
                    e.audioFragLoadInfo.push(n),
                    5 < e.audioFragLoadInfo.length) && e.audioFragLoadInfo.shift()
                }
            }
            updateFragParsed(e, t) {
                var i, r, n, a, e = this.getEntity(e);
                e && ({sessionControlRecord: e, playEndedRecord: i, periodicRecord: r} = e,
                a = null != (a = null == (a = null == t ? void 0 : t.initFragSample) ? void 0 : a.tparsed) ? a : {
                    tbegin: 0,
                    tend: 0
                },
                n = null != (n = null == (n = null == t ? void 0 : t.fragSample) ? void 0 : n.tparsed) ? n : {
                    tbegin: 0,
                    tend: 0
                },
                this.Ws(e, {
                    type: "SegmentParse",
                    tbegin: a.tbegin,
                    tend: a.tend
                }),
                this.Ws(e, {
                    type: "SegmentParse",
                    tbegin: n.tbegin,
                    tend: n.tend
                }),
                a = 1e3 * Math.round((t.largestVideoSampleSize || 0) / 1e3),
                (!i.LargestVideoSampleSize || a > i.LargestVideoSampleSize) && (i.LargestVideoSampleSize = a),
                !r.LargestVideoSampleSize || a > r.LargestVideoSampleSize) && (r.LargestVideoSampleSize = a)
            }
            updateFragBuffered(e, t) {
                var i, e = this.getEntity(e);
                e && ({periodicRecord: e, playEndedRecord: i} = e,
                t.fragType === se.Variant) && (e.SegmentParseTime = (e.SegmentParseTime || 0) + t.parseTime,
                i.SegmentParseTime = (i.SegmentParseTime || 0) + t.parseTime)
            }
            updateLevelLoaded(e, t) {
                e = this.getEntity(e);
                if (e) {
                    const {sessionControlRecord: n, periodicRecord: a, playEndedRecord: s} = e
                      , o = t.stats
                      , l = o.tload - o.trequest;
                    this.Ws(n, {
                        type: "PlaylistLoad",
                        tbegin: o.trequest,
                        tend: o.tload
                    }),
                    a.PlaylistADT = (a.PlaylistADT || 0) + l,
                    s.PlaylistADT = (s.PlaylistADT || 0) + l,
                    a.MaxPlaylistDT = Math.max(a.MaxPlaylistDT || 0, l),
                    s.MaxPlaylistDT = Math.max(s.MaxPlaylistDT || 0, l),
                    s.PlayType = t.playType,
                    s.ContentDur || (s.ContentDur = 300 * Math.round((t.totalduration || 0) / 300)),
                    this.Js(t.url, t.targetduration, n),
                    n.playlistMimeTypes || (n.playlistMimeTypes = []),
                    n.playlistMimeTypes.findIndex(e => e == o.contentType) < 0 && n.playlistMimeTypes.push(o.contentType);
                    var e = n.levelUrlLoaded = t.url
                      , t = this.Ks(e, n)
                      , i = n.intervalVariantList
                      , r = n.sessionVariantList;
                    i && !i[e] && (i[e] = Object.assign({}, t)),
                    r && !r[e] && (r[e] = Object.assign({}, t))
                }
            }
            updateLevelParsed(e, t) {
                var e = this.getEntity(e);
                e && (e = e["sessionControlRecord"],
                this.Ws(e, {
                    type: "PlaylistParse",
                    tbegin: t.tbegin,
                    tend: t.tend
                }))
            }
            updateLevelsChanged(e, t) {
                e = this.getEntity(e);
                if (e) {
                    const {sessionControlRecord: r, playEndedRecord: i} = e
                      , n = this.Ys(t.levels);
                    i.MaxVideoQltyIndex = n.maxVideoQltyIndex,
                    i.MaxReWd = n.maxWidth,
                    i.MaxReHt = n.maxHeight,
                    r.manifestData = {
                        variantList: n.variantList,
                        varListString: n.varListString
                    },
                    Object.keys(n.variantList).forEach(e => {
                        var t = r.intervalVariantList
                          , i = r.sessionVariantList
                          , t = (t && t[e] && (t[e].brRnk = n.variantList[e].brRnk),
                        i && i[e] && (i[e].brRnk = n.variantList[e].brRnk),
                        n.variantList[e].width || 0);
                        3800 <= t ? r.support4KStart = performance.now() : 1850 <= t && t < 2e3 && (r.supportHDStart = performance.now())
                    }
                    )
                }
            }
            updateKeySystemEvents(e, t) {
                e = this.getEntity(e);
                if (e) {
                    var i = e["sessionControlRecord"];
                    if (t.eventId === $o.CreateSession && t.keyuri) {
                        const e = {};
                        i.activeKeySessions && (i.activeKeySessions[t.keyuri] = e)
                    }
                    var r = [t.eventId, t.keyRequestState, Math.round(t.range.tbegin - i.sessionStartTime), Math.round(t.range.tend - i.sessionStartTime)];
                    if (i.activeKeySessions && t.keyuri && i.activeKeySessions[t.keyuri]) {
                        const e = i.activeKeySessions[t.keyuri];
                        e.keySystemEvents || (e.keySystemEvents = []),
                        e.keySystemEvents.push(r)
                    } else
                        1 === i.keySessionCompleteEventCounter && (i.keySystemInitEvents || (i.keySystemInitEvents = []),
                        i.keySystemInitEvents.push(r))
                }
            }
            updateLicenseChallengeRequested(t, i) {
                const r = this.getEntity(t);
                if (r) {
                    t = r["sessionControlRecord"];
                    if (t.activeKeySessions) {
                        let e = t.activeKeySessions[i.keyuri];
                        e || (t.activeKeySessions[i.keyuri] = e = {});
                        const r = i.timestamp;
                        e.licenseChallengeStartTime = r,
                        e.forInterstitial = i.forInterstitial,
                        "RTC_STATE_INIT" === t.state && (e.keyInitTime = r - t.sessionStartTime)
                    }
                }
            }
            updateLicenseChallengeReceived(e, t) {
                e = this.getEntity(e);
                if (e) {
                    var i = e["sessionControlRecord"];
                    if (i.activeKeySessions) {
                        const e = i.activeKeySessions[t.keyuri];
                        e.licenseChallengeRequestTime = t.timestamp - (e.licenseChallengeStartTime || 0)
                    }
                }
            }
            updateLicenseChallengeSubmitted(e, t) {
                e = this.getEntity(e);
                if (e) {
                    var i = e["sessionControlRecord"];
                    if (i.activeKeySessions) {
                        const e = i.activeKeySessions[t.keyuri];
                        e.keyFormat = t.keyFormat,
                        e.licenseChallengeSubmitTime = t.timestamp
                    }
                }
            }
            updateLicenseChallengeCreated(e, t) {
                e = this.getEntity(e);
                if (e) {
                    var i = e["sessionControlRecord"];
                    if (i.activeKeySessions) {
                        const e = i.activeKeySessions[t.keyuri];
                        e.cdmVersion = t.cdmVersion,
                        e.licenseChallengeCreationTime = t.timestamp - (e.licenseChallengeSubmitTime || 0)
                    }
                }
            }
            updateLicenseResponseRequested(e, t) {
                var e = this.getEntity(e);
                e && (e = e["sessionControlRecord"],
                e = e.activeKeySessions ? e.activeKeySessions[t.keyuri] : void 0) && (e.licenseResponseRequestTime = t.timestamp)
            }
            updateLicenseResponseReceived(e, t) {
                var e = this.getEntity(e);
                e && (e = e["sessionControlRecord"],
                e = e.activeKeySessions ? e.activeKeySessions[t.keyuri] : void 0) && (e.licenseResponseReceiveTime = t.timestamp - (e.licenseResponseRequestTime || 0))
            }
            updateLicenseResponseSubmitted(e, t) {
                var e = this.getEntity(e);
                e && (e = e["sessionControlRecord"],
                e = e.activeKeySessions ? e.activeKeySessions[t.keyuri] : void 0) && (e.licenseResponseSubmitTime = t.timestamp)
            }
            updateWaitForCanPlay(e) {
                var e = this.getEntity(e);
                e && (e = e["sessionControlRecord"],
                e.lastWaitForCanPlay = performance.now())
            }
            Rs(e, r) {
                var n = this.getEntity(e);
                if (n) {
                    var {sessionControlRecord: n, playEndedRecord: a} = n
                      , s = (a.AvgVideoBitrate = 8 * (n.sessionVideoBytes || 0) / (n.sessionVideoDuration || 1),
                    a.AvgAudioBitrate = 8 * (n.sessionAudioBytes || 0) / (n.sessionAudioDuration || 1),
                    1e3 * Math.round((a.NetBytes || 0) / 1e3))
                      , o = (a.NetBytes = s,
                    a.ADT || 1)
                      , l = o + (a.SegmentProcessTime || 1)
                      , d = o + (a.SegmentProcessTime || 0) + (a.SegmentParseTime || 1)
                      , o = (a.TWOBR = 8 * s / (o / 1e3),
                    a.PerceivedTWOBR = 8 * s / (l / 1e3),
                    a.NetTWOBR = 8 * s / (d / 1e3),
                    this.Zs("RTC_STATE_PLAY" === n.state ? performance.now() - n.eventStartTime : 0, n.sessionVariantList || {}, n.curLevelUrl))
                      , s = (a.PlayerTWIBR = o.twIBR,
                    a.PlayerTWIABR = o.twIABR,
                    a.TWBitRk = o.twBRnk,
                    null != (l = n.curLevelUrl) ? l : n.levelUrlLoaded)
                      , d = this.Ks(s, n);
                    a.TargetDur = d.targetduration,
                    a.Codecs = d.codecs,
                    a.VariantList = null == (o = n.manifestData) ? void 0 : o.varListString;
                    let t = ""
                      , i = (n.playlistMimeTypes && (n.playlistMimeTypes.forEach(e => {
                        t += e + ","
                    }
                    ),
                    t = t.slice(0, -1)),
                    "");
                    n.segmentMimeTypes && (n.segmentMimeTypes.forEach(e => {
                        i += e + ","
                    }
                    ),
                    i = i.slice(0, -1)),
                    a.PlaylistMimeType = t,
                    a.SegmentMimeType = i,
                    a.Rate = n.rate,
                    a.CurrentMediaTime = re(r) ? 1e3 * r : void 0;
                    l = this.eo(n.bufferedRangeTuple);
                    a.VariantBufferInfo = l[oe.Variant],
                    a.AudioBufferInfo = l[oe.AltAudio],
                    this.Us(a, n),
                    this.Xs(e)
                }
            }
            Ps(t, i) {
                var r = this.getEntity(t);
                if (r) {
                    var {sessionControlRecord: r, periodicRecord: n, playEndedRecord: a} = r;
                    n.EventCounter = r.periodicEventCounter,
                    n.PInterval = performance.now() - r.lastPeriodicTime,
                    n.AvgVideoBitrate = 8 * (r.intervalVideoBytes || 0) / (r.intervalVideoDuration || 1),
                    n.AvgAudioBitrate = 8 * (r.intervalAudioBytes || 0) / (r.intervalAudioDuration || 1);
                    let e = n.NetBytes || 0;
                    i.isFinal && (n.NetBytes = e = 1e3 * Math.round(e / 1e3),
                    n.IsLastPeriodic = !0);
                    var s = n.ADT || 1
                      , o = s + (n.SegmentProcessTime || 1)
                      , l = s + (n.SegmentProcessTime || 0) + (n.SegmentParseTime || 1)
                      , s = (n.TWOBR = 8 * e / (s / 1e3),
                    n.PerceivedTWOBR = 8 * e / (o / 1e3),
                    n.NetTWOBR = 8 * e / (l / 1e3),
                    this.Zs("RTC_STATE_PLAY" === r.state ? performance.now() - r.eventStartTime : 0, r.sessionVariantList || {}, r.curLevelUrl))
                      , o = (n.PlayerTWIBR = s.twIBR,
                    n.PlayerTWIABR = s.twIABR,
                    n.TWBitRk = s.twBRnk,
                    this.Ks(r.curLevelUrl, r))
                      , s = (n.TargetDur = o.targetduration,
                    n.VariantList = null == (l = r.manifestData) ? void 0 : l.varListString,
                    n.Rate = r.rate,
                    n.CurrentMediaTime = re(i.currentTime) ? 1e3 * i.currentTime : void 0,
                    this.eo(r.bufferedRangeTuple))
                      , o = (n.VariantBufferInfo = s[oe.Variant],
                    n.AudioBufferInfo = s[oe.AltAudio],
                    this.io(r));
                    o && (n.MedianBufferAppendLatency = o.bufLatencyInfo.median,
                    n.MaxBufferAppendLatency = o.bufLatencyInfo.max,
                    n.MedianBufferAppendSize = o.bufSizeInfo.median,
                    n.MaxBufferAppendSize = o.bufSizeInfo.max,
                    n.MedianSeekLatency = o.seekLatencyInfo.median,
                    n.MaxSeekLatency = o.seekLatencyInfo.max,
                    n.MedianPlayLatency = o.playLatencyInfo.median,
                    n.MaxPlayLatency = o.playLatencyInfo.max,
                    n.MedianLiveEdgeDist = o.liveEdgeDistInfo.median,
                    n.MaxLiveEdgeDist = o.liveEdgeDistInfo.max),
                    n.VariantFragLoadInfo = r.variantFragLoadInfo,
                    n.AudioFragLoadInfo = r.audioFragLoadInfo,
                    n.LastVariantBufferAppendTime = null == (l = r.lastBufferAppendTimeForType) ? void 0 : l[se.Variant],
                    n.LastAudioBufferAppendTime = null == (i = r.lastBufferAppendTimeForType) ? void 0 : i[se.AltAudio],
                    this.js(n, a),
                    this.Us(n, r),
                    this.Xs(t)
                }
            }
            Cs(e, t) {
                var i, r, n, a, s, o = this.getEntity(e);
                o && ({sessionControlRecord: o, playStalledRecord: i, playEndedRecord: r} = o,
                n = this.Ks(o.curLevelUrl, o),
                a = performance.now(),
                i.CurrentMediaTime = re(t.currentTime) ? 1e3 * t.currentTime : void 0,
                s = this.eo(o.bufferedRangeTuple),
                i.VariantBufferInfo = s[oe.Variant],
                i.AudioBufferInfo = s[oe.AltAudio],
                i.MediaDur = t.mediaDur,
                i.Codecs = n.codecs,
                i.LastLikelyToKeepUp = a - o.lastLikelyToKeepUpTime,
                i.LastSwitch = a - (o.lastSwitchTime || 0),
                i.StallDetectionTime = t.stallDurationMs,
                i.StallType = t.type,
                i.BufferLength = t.bufferLen,
                "networkError" === r.ErrDomain && (i.NwErrTime = r.NwErrTime,
                i.NwErrCode = r.ErrCode),
                i.LaSwDir = o.lastSwitchDir,
                i.TargetDur = n.targetduration,
                i.Rate = o.rate,
                i.ForInterstitial = t.forInterstitial,
                i.VariantFragLoadInfo = o.variantFragLoadInfo,
                i.AudioFragLoadInfo = o.audioFragLoadInfo,
                i.LastVariantBufferAppendTime = null == (s = o.lastBufferAppendTimeForType) ? void 0 : s[se.Variant],
                i.LastAudioBufferAppendTime = null == (a = o.lastBufferAppendTimeForType) ? void 0 : a[se.AltAudio],
                this.js(i, r),
                this.Us(i, o),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            Ds(e, t) {
                var i, r, n, a = this.getEntity(e);
                a && ({sessionControlRecord: a, keySessionCompleteRecord: i, playEndedRecord: r} = a,
                t = a.activeKeySessions ? a.activeKeySessions[t.keyuri] : void 0) && (i.EventCounter = a.keySessionCompleteEventCounter,
                1 === a.keySessionCompleteEventCounter && (i.KeySystemInitEvents = a.keySystemInitEvents),
                i.KeySystemEvents = t.keySystemEvents,
                i.KeyFormat = t.keyFormat,
                i.CDMVersion = t.cdmVersion,
                i.MediaOptionId = null != (n = t.mediaOptionId) ? n : "keyRenewal",
                i.LicenseChallengeRequestTime = t.licenseChallengeRequestTime,
                i.LicenseChallengeCreationTime = t.licenseChallengeCreationTime,
                i.LicenseResponseReceiveTime = t.licenseResponseReceiveTime,
                i.LicenseResponseProcessTime = t.licenseResponseProcessTime,
                i.KeyDeliveryTime = t.keyDeliveryTime,
                i.CurrentMediaTime = re(t.currentMediaTime) ? 1e3 * t.currentMediaTime : void 0,
                n = this.eo(a.bufferedRangeTuple),
                i.VariantBufferInfo = n[oe.Variant],
                i.AudioBufferInfo = n[oe.AltAudio],
                i.LargestVideoSampleSize = r.LargestVideoSampleSize,
                i.KeyInitTime = t.keyInitTime,
                t.keyErrorType && (i.KeyErrorType = t.keyErrorType,
                i.MediaOptionIdsForKey = t.mediaOptionIdsForKey),
                i.ForInterstitial = t.forInterstitial,
                this.js(i, r),
                this.Us(i, a),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            Ls(e, t) {
                var i, r, n, a = this.getEntity(e);
                a && ({sessionControlRecord: a, playLikelyToKeepUpRecord: i, playEndedRecord: r} = a,
                n = this.Ks(a.curLevelUrl, a),
                i.EventCounter = a.playLikelyToKeepUpEventCounter,
                i.MediaDur = t.mediaDur,
                i.Codecs = n.codecs,
                i.TargetDur = n.targetduration,
                i.ForInterstitial = t.forInterstitial,
                i.PlayerStartPos = t.playStartTime,
                i.CurrentMediaTime = re(t.playStartTime) ? 1e3 * t.playStartTime : void 0,
                n = this.eo(a.bufferedRangeTuple),
                i.VariantBufferInfo = n[oe.Variant],
                i.AudioBufferInfo = n[oe.AltAudio],
                i.PlaylistADT = this.ro(a.startupLatencyInfo, "PlaylistLoad"),
                i.PlaylistParseTime = this.ro(a.startupLatencyInfo, "PlaylistParse"),
                i.ADT = this.ro(a.startupLatencyInfo, "SegmentLoad"),
                i.SegmentParseTime = this.ro(a.startupLatencyInfo, "SegmentParse"),
                i.BufferAppendTime = this.ro(a.startupLatencyInfo, "BufferAppend"),
                this.js(i, r),
                this.Us(i, a),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            _s(e, t) {
                var i, r, n, a, s = this.getEntity(e);
                s && ({sessionControlRecord: s, playRateChangedRecord: i, playEndedRecord: r} = s,
                n = this.Ks(s.curLevelUrl, s),
                i.Rate = s.rate,
                i.StNPT = t.currentTime,
                i.CurrentMediaTime = re(t.currentTime) ? 1e3 * t.currentTime : void 0,
                a = this.eo(s.bufferedRangeTuple),
                i.VariantBufferInfo = a[oe.Variant],
                i.AudioBufferInfo = a[oe.AltAudio],
                i.MediaDur = t.mediaDur,
                i.Codecs = n.codecs,
                i.ForInterstitial = t.forInterstitial,
                this.js(i, r),
                this.Us(i, s),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            Fs(e, t) {
                var i, r, n, a, s, o = this.getEntity(e);
                o && ({sessionControlRecord: o, playErrorRecord: i, playEndedRecord: r} = o,
                n = null != (n = o.curLevelUrl) ? n : o.levelUrlLoaded,
                n = this.Ks(n, o),
                a = performance.now(),
                "mediaElementError" == t.domain ? (i.ErrDomain = i.ErrCode = "mediaElementError",
                i.ErrIsFatal = !0,
                i.ErrCodeMediaElement = t.mediaElemCode,
                i.ErrReason = t.mediaElemReason,
                i.ErrDetail = t.mediaElemDetail) : (i.ErrCode = t.details,
                i.ErrReason = t.code,
                i.ErrIsFatal = t.fatal,
                i.ErrDomain = "mediaError"),
                i.PlayerErrCount = t.count || 1,
                i.MediaDur = t.mediaDur,
                i.CurrentMediaTime = re(t.currentTime) ? 1e3 * t.currentTime : void 0,
                s = this.eo(o.bufferedRangeTuple),
                i.VariantBufferInfo = s[oe.Variant],
                i.AudioBufferInfo = s[oe.AltAudio],
                i.Codecs = n.codecs,
                i.LastLikelyToKeepUp = a - o.lastLikelyToKeepUpTime,
                i.LastSwitch = a - (o.lastSwitchTime || 0),
                i.LargestVideoSampleSize = r.LargestVideoSampleSize,
                i.VideoQltyIndex = n.qltyIndex,
                i.Rate = o.rate,
                i.KeyErrorType = o.lastKeyErrorType,
                i.KeyDeliveryTime = o.lastKeyDeliveryTime,
                i.ForInterstitial = t.forInterstitial,
                i.VariantFragLoadInfo = o.variantFragLoadInfo,
                i.AudioFragLoadInfo = o.audioFragLoadInfo,
                i.LastVariantBufferAppendTime = null == (s = o.lastBufferAppendTimeForType) ? void 0 : s[se.Variant],
                i.LastAudioBufferAppendTime = null == (a = o.lastBufferAppendTimeForType) ? void 0 : a[se.AltAudio],
                this.js(i, r),
                this.Us(i, o),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            qs(e, t) {
                var i, r, n, a, s, o = this.getEntity(e);
                o && ({sessionControlRecord: o, mediaEngineStalledRecord: i, playEndedRecord: r} = o,
                n = performance.now(),
                a = this.Ks(o.curLevelUrl, o),
                i.MediaDur = t.mediaDur,
                i.CurrentMediaTime = re(t.currentTime) ? 1e3 * t.currentTime : void 0,
                s = this.eo(o.bufferedRangeTuple),
                i.VariantBufferInfo = s[oe.Variant],
                i.AudioBufferInfo = s[oe.AltAudio],
                i.Codecs = a.codecs,
                i.LastLikelyToKeepUp = n - o.lastLikelyToKeepUpTime,
                i.LastSwitch = n - (o.lastSwitchTime || 0),
                i.StallDetectionTime = t.stallDurationMs,
                i.StallType = t.type,
                i.BufferLength = t.bufferLen,
                i.LaSwDir = o.lastSwitchDir,
                i.TargetDur = a.targetduration,
                i.Rate = o.rate,
                i.ForInterstitial = t.forInterstitial,
                i.VariantFragLoadInfo = o.variantFragLoadInfo,
                i.AudioFragLoadInfo = o.audioFragLoadInfo,
                i.LastVariantBufferAppendTime = null == (s = o.lastBufferAppendTimeForType) ? void 0 : s[se.Variant],
                i.LastAudioBufferAppendTime = null == (n = o.lastBufferAppendTimeForType) ? void 0 : n[se.AltAudio],
                this.js(i, r),
                this.Us(i, o),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            zs(e, t) {
                var i, r, n, a, s, o = this.getEntity(e);
                o && ({sessionControlRecord: o, switchCompleteRecord: i, playEndedRecord: r} = o,
                n = this.Ks(o.prevLevelUrl, o),
                a = this.Ks(o.curLevelUrl, o),
                i.FrBitRnk = n.brRnk,
                i.ToBitRnk = a.brRnk,
                i.TimeToBitrate = performance.now() - o.sessionStartTime,
                i.MediaDur = t.mediaDur,
                i.CurrentMediaTime = re(t.currentTime) ? 1e3 * t.currentTime : void 0,
                s = this.eo(o.bufferedRangeTuple),
                i.VariantBufferInfo = s[oe.Variant],
                i.AudioBufferInfo = s[oe.AltAudio],
                i.Rate = o.rate,
                i.LastPlayerIBR = n.bandwidth,
                i.LastPlayerIABR = n.avgBandwidth,
                i.ForInterstitial = t.forInterstitial,
                this.so(e, a),
                this.js(i, r),
                this.Us(i, o),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            Qs(e, t) {
                var i, r, n, a, s = this.getEntity(e);
                s && ({sessionControlRecord: s, variantEndedRecord: i, playEndedRecord: r} = s,
                n = this.Ks(s.curLevelUrl, s),
                i.Rate = s.rate,
                i.VarAvgBitrate = n.avgBandwidth,
                i.VarPeakBitrate = n.bandwidth,
                i.VarBitRk = n.brRnk,
                i.VarSTTime = s.variantStartTimeMedia,
                i.VarEndTime = t.currentTime ? 1e3 * t.currentTime : 0,
                i.CurrentMediaTime = re(t.currentTime) ? 1e3 * t.currentTime : void 0,
                a = this.eo(s.bufferedRangeTuple),
                i.VariantBufferInfo = a[oe.Variant],
                i.AudioBufferInfo = a[oe.AltAudio],
                i.IFR = n.framerate,
                s.decodedFramesForVariant && s.decodedFramesForVariantSampleCount && (i.ODR = s.decodedFramesForVariant / s.decodedFramesForVariantSampleCount),
                i.Codecs = n.codecs,
                i.AvgVideoBitrate = 8 * (s.variantVideoBytes || 0) / (s.variantVideoDuration || 1),
                i.AvgAudioBitrate = 8 * (s.variantAudioBytes || 0) / (s.variantAudioDuration || 1),
                i.ForInterstitial = t.forInterstitial,
                this.js(i, r),
                this.Us(i, s),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            Gs(e, t) {
                var i, r, n, a, s = this.getEntity(e);
                s && ({sessionControlRecord: s, nwErrorRecord: i, playEndedRecord: r} = s,
                n = null != (n = s.curLevelUrl) ? n : s.levelUrlLoaded,
                n = this.Ks(n, s),
                i.ErrCode = t.details,
                i.ErrReason = t.code,
                i.ErrIsFatal = t.fatal,
                i.NwErrCount = t.count || 1,
                i.ErrDomain = "networkError",
                i.CurrentMediaTime = re(t.currentTime) ? 1e3 * t.currentTime : void 0,
                a = this.eo(s.bufferedRangeTuple),
                i.VariantBufferInfo = a[oe.Variant],
                i.AudioBufferInfo = a[oe.AltAudio],
                i.Codecs = n.codecs,
                i.Rate = s.rate,
                i.KeyErrorType = s.lastKeyErrorType,
                i.KeyDeliveryTime = s.lastKeyDeliveryTime,
                i.ForInterstitial = t.forInterstitial,
                i.VariantFragLoadInfo = s.variantFragLoadInfo,
                i.AudioFragLoadInfo = s.audioFragLoadInfo,
                i.LastVariantBufferAppendTime = null == (a = s.lastBufferAppendTimeForType) ? void 0 : a[se.Variant],
                i.LastAudioBufferAppendTime = null == (n = s.lastBufferAppendTimeForType) ? void 0 : n[se.AltAudio],
                this.js(i, r),
                this.Us(i, s),
                this.Bs(i, r.PlayTimeWC || 0, r.PlayTime || 0),
                this.Xs(e))
            }
            $s(e, t) {
                var i, r, n = this.getEntity(e);
                n && ({playEndedRecord: n, debugInfoRecord: i, sessionControlRecord: r} = n,
                i.ErrCode = t.details,
                i.ErrReason = t.code,
                i.ErrDomain = t.domain,
                i.ErrStack = t.stack,
                i.LogHistory = t.logs,
                i.ContentUrl = t.contentUrl,
                this.js(i, n),
                this.Us(i, r),
                this.Bs(i, n.PlayTimeWC || 0, n.PlayTime || 0),
                this.Xs(e))
            }
            Vs(e, t) {
                var i, r, n = this.getEntity(e);
                n && ({playEndedRecord: n, errorRecoveryRecord: i, sessionControlRecord: r} = n,
                i.ErrCode = t.details,
                i.ErrReason = t.code,
                i.ContentUrl = t.contentUrl,
                i.MediaOptionId = t.levelId,
                i.EventCounter = t.isFirstAttempt ? 1 : 2,
                this.js(i, n),
                this.Us(i, r),
                this.Bs(i, n.PlayTimeWC || 0, n.PlayTime || 0),
                this.Xs(e))
            }
            js(e, t) {
                e.HLSJSVersion = t.HLSJSVersion,
                e.PlayType = t.PlayType,
                e.LastMediaCDNServer = t.LastMediaCDNServer,
                e.MaxVideoQltyIndex = t.MaxVideoQltyIndex,
                e.MaxReWd = t.MaxReWd,
                e.MaxReHt = t.MaxReHt,
                e.InterstitialsEnabled = t.InterstitialsEnabled,
                e.IsGapless = t.IsGapless,
                e.IsLoopingPlayer = t.IsLoopingPlayer,
                e.IsAudioOnly = t.IsAudioOnly,
                e.IsFirstItem = t.IsFirstItem,
                e.ItemID = t.ItemID,
                e.ServerInfo = t.ServerInfo,
                e.TestGroupId = t.TestGroupId
            }
            Us(e, t) {
                e.OBRLast = t.obrLast,
                e.OBRMean = t.obrMean;
                var i = null != (i = t.curLevelUrl) ? i : t.levelUrlLoaded
                  , i = this.Ks(i, t);
                e.ReWd = i.width,
                e.ReHt = i.height,
                e.PlayerIBR = i.bandwidth,
                e.PlayerIABR = i.avgBandwidth,
                e.BitRnk = i.brRnk
            }
            Bs(e, t, i) {
                e.PlayTimeWC = t,
                e.PlayTime = i
            }
            Ys(e) {
                const r = {};
                let n = 0
                  , a = 0
                  , s = 0
                  , o = 0;
                const l = this.oo(e);
                e.forEach(e => {
                    var t = this.ao(e.levelCodec)
                      , i = this.lo(t, e.videoRange) || 0
                      , t = {
                        codecs: e.levelCodec,
                        width: e.width,
                        height: e.height,
                        bandwidth: e.bandwidth,
                        avgBandwidth: e.avgBandwidth,
                        framerate: e.frameRate,
                        iframes: e.iframes,
                        brRnk: this.uo(e.bandwidth, t, l),
                        qltyIndex: i,
                        targetduration: 0,
                        playTime: 0
                    }
                      , i = (o = i > o ? i : o,
                    e.url && (r[e.url] = t),
                    (e.width || 0) * (e.height || 0));
                    i > s && (s = i,
                    n = e.width || 0,
                    a = e.height || 0)
                }
                );
                e = 0 < Object.keys(r).length ? Object.values(r).map(e => e.bandwidth + ":" + e.avgBandwidth).join(",") : "";
                return {
                    variantList: r,
                    varListString: e,
                    maxVideoQltyIndex: o,
                    maxWidth: n,
                    maxHeight: a
                }
            }
            oo(e) {
                let i = 0;
                return e.forEach(e => {
                    var t = e.bandwidth || 0
                      , e = this.co(t, this.ao(e.levelCodec))
                      , t = Math.max(t, e);
                    i = t > i ? t : i
                }
                ),
                i
            }
            co(e, t) {
                return t && "object" == typeof sl[t] ? 1.5 * e : 1 * e
            }
            ao(e) {
                return e && e.split(",").map(e => e.split(".")[0].trim()).find(e => !!sl[e])
            }
            lo(e, t) {
                if (e)
                    return "object" == typeof sl[e] && t ? sl[e][t] : sl[e]
            }
            uo(e, t, i) {
                e = Math.max(1, this.co(e, t));
                return Math.ceil(100 * e / i)
            }
            Ws(e, t) {
                1 === e.playLikelyToKeepUpEventCounter && (e.startupLatencyInfo || (e.startupLatencyInfo = []),
                e.startupLatencyInfo.push(t))
            }
            ro(e, t) {
                const i = null == e ? void 0 : e.filter(e => e.type === t).sort( (e, t) => e.tbegin - t.tbegin)
                  , r = [];
                return null != i && i.forEach(e => {
                    var t = r[r.length - 1];
                    0 === r.length || t.tend < e.tbegin ? r.push({
                        tbegin: e.tbegin,
                        tend: e.tend
                    }) : t.tend = Math.max(t.tend, e.tend)
                }
                ),
                r.reduce( (e, t) => e + (t.tend - t.tbegin), 0)
            }
            Zs(o, l, d) {
                var e = {
                    twBRnk: 0,
                    twIBR: 0,
                    twIABR: 0
                };
                if (l) {
                    let i = 0
                      , r = 0
                      , n = 0
                      , a = 0
                      , s = 0;
                    Object.values(l).forEach(e => {
                        let t = e.playTime;
                        d && e === l[d] && (t += o || 0),
                        t && (r += e.bandwidth * t,
                        i += e.brRnk * t,
                        n += t,
                        e.avgBandwidth) && (a += e.avgBandwidth * t,
                        s += t)
                    }
                    ),
                    n && (e.twBRnk = i / n,
                    e.twIBR = r / n),
                    a && s && (e.twIABR = a / s)
                }
                return e
            }
            io(e) {
                const t = e.bufferAppendInfo
                  , i = []
                  , r = [];
                t && t.forEach && t.forEach(e => {
                    i.push(e.latency),
                    r.push(e.size)
                }
                );
                var n = this.ho(i)
                  , a = this.ho(r)
                  , s = e.seekInfo
                  , s = this.ho((null != s ? s : []).map(e => e.latency))
                  , o = e.playInfo
                  , o = this.ho((null != o ? o : []).map(e => e.latency))
                  , e = e.liveEdgeInfo;
                return {
                    bufLatencyInfo: n,
                    bufSizeInfo: a,
                    seekLatencyInfo: s,
                    playLatencyInfo: o,
                    liveEdgeDistInfo: this.ho((null != e ? e : []).map(e => e.liveEdgeDist))
                }
            }
            ho(e) {
                let t = 0
                  , i = 0;
                if (e) {
                    var r = e.filter(e => 0 < e);
                    if (0 < r.length) {
                        t = r.reduce( (e, t) => Math.max(e, t));
                        const e = r.length
                          , n = r.sort( (e, t) => e - t)
                          , a = Math.ceil(e / 2);
                        i = e % 2 == 0 ? (n[a] + n[a - 1]) / 2 : n[a - 1]
                    }
                }
                return {
                    max: t,
                    median: i
                }
            }
            Ks(e, t) {
                return e && t.manifestData && t.manifestData.variantList && t.manifestData.variantList[e] ? t.manifestData.variantList[e] : {}
            }
            eo(e) {
                var t;
                const i = null != (t = null == e ? void 0 : e[oe.Variant]) ? t : []
                  , r = []
                  , n = (0 < i.length && i.forEach(e => {
                    r.push([Number(e.start.toFixed(2)), Number(e.end.toFixed(2))])
                }
                ),
                null != (t = null == e ? void 0 : e[oe.AltAudio]) ? t : [])
                  , a = [];
                return 0 < n.length && n.forEach(e => {
                    a.push([Number(e.start.toFixed(2)), Number(e.end.toFixed(2))])
                }
                ),
                [0 < r.length ? r : void 0, 0 < a.length ? a : void 0]
            }
            Js(e, t, i) {
                e && i.manifestData && i.manifestData.variantList && i.manifestData.variantList[e] && (i.manifestData.variantList[e].targetduration = t)
            }
            so(e, t) {
                var i, r, e = this.getEntity(e);
                e && ({playEndedRecord: e, switchCompleteRecord: i, sessionControlRecord: r} = e,
                !e.StallCount && !e.MediaEngineStallCount && t.height && t.width && (r.support4KStart && 3800 <= t.width && (r.maxReWd || 0) < 3800 ? i.TimeTo4K = performance.now() - r.support4KStart - (e.PauseTime || 0) : r.supportHDStart && 1850 <= t.width && t.width < 2e3 && (r.maxReWd || 0) < 1850 && (i.TimeToHD = performance.now() - r.supportHDStart - (e.PauseTime || 0))),
                r.maxReWd = Math.max(r.maxReWd || 0, t.width || 0),
                r.maxReHt = Math.max(r.maxReHt || 0, t.height || 0))
            }
            xs(e, t) {
                e = Math.abs(e),
                t = Math.abs(t);
                return e !== t && (1 < e || 1 < t) && !(1 < e && 1 < t)
            }
            Hs(e, t, i, r, n, a, s) {
                let o = a && t && (!0 === r || !1 === r) && n - a < 1e4 && t !== e && r === i && !s ? !0 : !1;
                return o
            }
            Xs(e) {
                const t = this.getEntity(e);
                if (t) {
                    var {sessionControlRecord: i, playStalledRecord: r, mediaEngineStalledRecord: n, switchCompleteRecord: a, playRateChangedRecord: s, variantEndedRecord: o, playErrorRecord: l, nwErrorRecord: d, periodicRecord: u, playEndedRecord: c} = t
                      , h = performance.now() - i.eventStartTime;
                    switch (i.state) {
                    case "RTC_STATE_INIT":
                    case "RTC_STATE_CANPLAY":
                        u.InitTime = (u.InitTime || 0) + h,
                        c.InitTime = (c.InitTime || 0) + h;
                        break;
                    case "RTC_STATE_PAUSE":
                        u.PauseTime = (u.PauseTime || 0) + h,
                        c.PauseTime = (c.PauseTime || 0) + h,
                        s.LastPause = (s.LastPause || 0) + h,
                        c.LastPause = (c.LastPause || 0) + h,
                        l.LastPause = (l.LastPause || 0) + h,
                        d.LastPause = (d.LastPause || 0) + h;
                        break;
                    case "RTC_STATE_STALL":
                        o.StallTime = (o.StallTime || 0) + h,
                        u.StallTime = (u.StallTime || 0) + h,
                        c.StallTime = (c.StallTime || 0) + h,
                        s.LastStall = (s.LastStall || 0) + h,
                        l.LastStall = (l.LastStall || 0) + h,
                        c.LastStall = (c.LastStall || 0) + h;
                        break;
                    case "RTC_STATE_MEDIAENGINESTALL":
                        o.MediaEngineStallTime = (o.MediaEngineStallTime || 0) + h,
                        u.MediaEngineStallTime = (u.MediaEngineStallTime || 0) + h,
                        c.MediaEngineStallTime = (c.MediaEngineStallTime || 0) + h,
                        s.LastMediaEngineStall = (s.LastMediaEngineStall || 0) + h,
                        l.LastMediaEngineStall = (l.LastMediaEngineStall || 0) + h,
                        c.LastMediaEngineStall = (c.LastMediaEngineStall || 0) + h;
                        break;
                    case "RTC_STATE_NWERROR":
                        c.NwErrTime = (c.NwErrTime || 0) + h,
                        u.NwErrTime = (u.NwErrTime || 0) + h;
                        break;
                    case "RTC_STATE_PLAYERROR":
                        u.PlayErrTime = (u.PlayErrTime || 0) + h,
                        c.PlayErrTime = (c.PlayErrTime || 0) + h;
                        break;
                    case "RTC_STATE_PLAY":
                        {
                            s.RateChangePlayTime = (s.RateChangePlayTime || 0) + h,
                            a.PlayTimeLastSW = (a.PlayTimeLastSW || 0) + h * (i.oldRate / 100),
                            r.LastResume = (r.LastResume || 0) + h,
                            n.LastResume = (n.LastResume || 0) + h,
                            l.LastResume = (l.LastResume || 0) + h,
                            d.LastResume = (d.LastResume || 0) + h;
                            const e = (r.StallDetectionTime || 0) + (n.StallDetectionTime || 0)
                              , t = (o.VarPlayTimeWC = (o.VarPlayTimeWC || 0) + h - e,
                            o.VarPlayTime = (o.VarPlayTime || 0) + h * (i.oldRate / 100) - e,
                            u.PlayTimeWC = (u.PlayTimeWC || 0) + h - e,
                            u.PlayTime = (u.PlayTime || 0) + h * (i.oldRate / 100) - e,
                            c.PlayTimeWC = (c.PlayTimeWC || 0) + h - e,
                            c.PlayTime = (c.PlayTime || 0) + h * (i.oldRate / 100) - e,
                            i.curLevelUrl);
                            if (t && i.intervalVariantList && i.sessionVariantList) {
                                let e = i.intervalVariantList[t];
                                e && (e.playTime = (e.playTime || 0) + h),
                                (e = i.sessionVariantList[t]) && (e.playTime = (e.playTime || 0) + h)
                            }
                            break
                        }
                    }
                }
            }
        }
        const $h = {
            name: "rtc-service"
        };
        class Wh {
            constructor(e, t, i, r, n, a) {
                this.Gt = t,
                this.hlsjsVersion = i,
                this.do = r,
                this.R = n,
                this.fo = a,
                this._i = new z,
                this.vo = !1,
                this.po = null,
                this.yo = 0,
                this.playStart = Number.NEGATIVE_INFINITY,
                this.oldRate = 0,
                this.newRate = 0,
                this.Oi = e,
                this.bo = t.rtcIntervalTimeout || 3e5,
                this.So = null,
                this.rtcStore = new Gh(this.R),
                this.rtcQuery = new qh(this.rtcStore,this.R),
                this.rtcComponent = new jh(this.rtcQuery,this.R,this.Gt),
                r.setRTCQuery(this.rtcQuery)
            }
            destroy() {
                this._i.next(),
                this.wo(),
                this.rtcStore.resetStore(),
                this.Oi = void 0
            }
            detachMedia() {
                this.wo();
                try {
                    var e = this.rtcEventItemId(!0);
                    this.To(e)
                } catch (e) {}
            }
            endItem(e, t, i) {
                this.wo(),
                this.To(e),
                this.rtcStore.removeEntityByID(e)
            }
            handleErrorRecovery(e, t, i, r, n) {
                this.rtcStore.updateErrorRecoveryRecord(i, {
                    details: e.details,
                    code: e.response,
                    contentUrl: n,
                    isFirstAttempt: t,
                    levelId: r
                }),
                this.sendAndFinalize(i, o.ErrorRecovery)
            }
            handleFatalError(e, t, i) {
                if (this.Oi) {
                    var r = this.Gt.rtcErrStackNumLines ? e.stack : void 0
                      , t = {
                        fatal: !0,
                        details: e.details,
                        code: e.response,
                        forInterstitial: t,
                        currentTime: null != (t = this.Oi.realCurrentTime) ? t : void 0,
                        domain: e.type,
                        stack: !(0 < (t = this.Gt.rtcErrStackNumLines)) || null == r ? void 0 : r.split("\n").slice(0, t).join("\n"),
                        logs: function(e, i) {
                            if (e && 0 !== e.length && !(void 0 !== i && i <= 0)) {
                                const r = new Date(e[0].timestampMs).getTime();
                                return e.map(e => {
                                    var t = JSON.stringify(e.messages);
                                    return JSON.stringify([new Date(e.timestampMs).getTime() - r, t.slice(0, i), e.level, +(void 0 !== i && t.length > i)])
                                }
                                ).join("\n")
                            }
                        }(null == (r = this.fo) ? void 0 : r.call(this), this.Gt.rtcLogHistoryMaxLineLength),
                        contentUrl: i
                    };
                    if (e.type === he.NETWORK_ERROR ? (this.rtcStore.updateNwError(this.rtcEventItemId(), t),
                    this.sendAndFinalize(this.rtcEventItemId(), o.NwError)) : (this.rtcStore.updateMediaError(this.rtcEventItemId(), t),
                    this.sendAndFinalize(this.rtcEventItemId(), o.PlayError)),
                    this.Gt.rtcErrStackNumLines || this.Gt.rtcLogHistoryNumLines)
                        if (this.rtcEventItemId())
                            this.rtcStore.updateDebugInfo(this.rtcEventItemId(), t),
                            this.sendAndFinalize(this.rtcEventItemId(), o.DebugInfo);
                        else {
                            const e = {
                                ErrCode: t.details,
                                ErrReason: t.code,
                                ErrDomain: t.domain,
                                ErrStack: t.stack,
                                LogHistory: t.logs,
                                ContentUrl: t.contentUrl,
                                HLSJSVersion: this.hlsjsVersion,
                                InterstitialsEnabled: this.Gt.enableInterstitialPlayback,
                                ItemID: "teardown-fatal-err",
                                TestGroupId: this.Gt.testGroupId
                            };
                            this.rtcComponent.sendTeardownDebugInfo(e)
                        }
                }
            }
            handleMediaElementError(e, t) {
                this.rtcStore.updateMediaElementError(this.rtcEventItemId(), e, t),
                this.sendAndFinalize(this.rtcEventItemId(), o.PlayError)
            }
            handleNonFatalError(e, t) {
                var i;
                this.Oi && (e.type === he.NETWORK_ERROR ? this.rtcStore.updateNwError(this.rtcEventItemId(), {
                    fatal: !1,
                    details: e.details,
                    code: e.response,
                    forInterstitial: t,
                    currentTime: null != (i = this.Oi.realCurrentTime) ? i : void 0
                }) : this.rtcStore.updateMediaError(this.rtcEventItemId(), {
                    fatal: !1,
                    details: e.details,
                    code: e.response,
                    forInterstitial: t,
                    currentTime: null != (i = this.Oi.realCurrentTime) ? i : void 0
                }))
            }
            handleFragLoaded(e, t, i) {
                var r;
                this.Oi && this.Io(t.mediaOptionType) && (this.rtcStore.updateFragLoaded(e, {
                    fragType: t.mediaOptionType,
                    duration: t.duration,
                    stats: i,
                    serverInfo: null != (r = this.serverInfoInstance) ? r : {}
                }),
                this.do.updateFragLoaded(e, this.vo, {
                    fragType: t.mediaOptionType,
                    bytes: i.loaded,
                    duration: t.duration,
                    adt: i.tload - i.trequest,
                    processTime: i.tload - i.tfirst,
                    startPTS: t.start,
                    endPTS: t.start + t.duration
                }))
            }
            handleFragParsed(e) {
                this.rtcStore.updateFragParsed(this.rtcEventItemId(), e)
            }
            handleFragBuffered(t) {
                if (this.Io(t.fragmentType)) {
                    let e = 0;
                    t.endDataAppend && t.startDataAppend && (e = t.endDataAppend - t.startDataAppend);
                    var i = t.fragmentType
                      , t = t.dataBytesAppend;
                    void 0 !== i && void 0 !== t && this.rtcStore.updateFragBuffered(this.rtcEventItemId(), {
                        fragType: i,
                        bytes: t,
                        parseTime: e
                    })
                }
            }
            handleLevelLoaded(e, t, i) {
                if (t && t.mediaOptionType === se.Variant) {
                    const e = t.url
                      , r = t.targetduration || 0
                      , n = t.totalduration || 0;
                    e && this.rtcStore.updateLevelLoaded(this.rtcEventItemId(), {
                        url: e,
                        targetduration: r,
                        totalduration: n,
                        stats: i,
                        playType: t.type
                    })
                }
            }
            handleLevelParsed(e) {
                this.rtcStore.updateLevelParsed(this.rtcEventItemId(), e)
            }
            handleLevelLoadError(e, t) {
                this.Oi && (this.rtcStore.updateLevelLoadError(this.rtcEventItemId(), {
                    url: e,
                    mediaDur: this.Oi.bufferedDuration,
                    isSeeking: this.vo,
                    forInterstitial: t,
                    currentTime: null != (e = this.Oi.realCurrentTime) ? e : void 0
                }),
                this.sendAndFinalize(this.rtcEventItemId(), o.SwitchComplete))
            }
            handleLevelSwitched(e, t) {
                var i;
                this.Oi && (i = {
                    url: e.url,
                    isSeeking: this.vo,
                    mediaDur: this.Oi.bufferedDuration,
                    currentTime: null != (i = this.Oi.realCurrentTime) ? i : void 0,
                    forInterstitial: t
                },
                e.oldVariant && (this.rtcStore.updateVariantEnd(this.rtcEventItemId(), {
                    currentTime: null != (e = this.Oi.realCurrentTime) ? e : void 0,
                    forInterstitial: t
                }),
                this.sendAndFinalize(this.rtcEventItemId(), o.VariantEnded)),
                this.rtcStore.updateLevelSwitched(this.rtcEventItemId(), i),
                this.sendAndFinalize(this.rtcEventItemId(), o.SwitchComplete))
            }
            handleLevelSwitching(e) {
                this.levelSwitchingUrl = e
            }
            handleLevelsChanged(e) {
                this.rtcStore.updateLevelsChanged(this.rtcEventItemId(), {
                    levels: e
                })
            }
            handleManifestParsed(e) {
                var t;
                this.Oi && (t = e.stats.tload - e.stats.trequest,
                this.rtcStore.updateManifestParsed(this.rtcEventItemId(), {
                    levels: e.levels,
                    adt: t,
                    tparsed: e.stats.tparsed,
                    contentType: e.stats.contentType,
                    isAudioOnly: this.Oi.inGaplessMode,
                    isGapless: this.Oi.inGaplessMode,
                    isFirstItem: this.Oi.isFirstItem,
                    itemID: ((null == (t = this.Oi.reportingAgent) ? void 0 : t.SessionID) || Ga()) + "-" + this.rtcEventItemId(),
                    forInterstitial: this.Oi.interstitialActive
                }),
                this.rtcEventItemId())
            }
            handleSeek(e, t=null, i=[]) {
                if ("SEEKING" === e && t)
                    this.vo = !0,
                    this.po = performance.now(),
                    this.rtcStore.updateSeek(this.rtcEventItemId(!0), t, i),
                    this.rtcStore.updateWaitForCanPlay(this.rtcEventItemId(!0));
                else if ("SEEKED" === e) {
                    this.vo = !1;
                    let e = 0;
                    this.po && (e = performance.now() - this.po),
                    this.po = null,
                    this.rtcStore.updateSeeked(this.rtcEventItemId(!0), {
                        latency: e
                    }),
                    this.sendAndFinalize(this.rtcEventItemId(!0), o.SeekComplete)
                }
            }
            handleDesiredRateChanged(e, t) {
                var i;
                if (this.Oi) {
                    if (0 === t || 1 < Math.abs(e) && 1 < Math.abs(t)) {
                        const e = null != (i = this.Oi.bufferedDuration) ? i : 0
                          , r = null != (i = this.Oi.realCurrentTime) ? i : 0;
                        this.levelSwitchingUrl && (this.rtcStore.updateRateChanged(this.rtcEventItemId(!0), {
                            rate: t,
                            latency: 0,
                            mediaDur: e,
                            currentTime: r,
                            url: this.levelSwitchingUrl,
                            forInterstitial: this.Oi.interstitialActive
                        }),
                        this.sendAndFinalize(this.rtcEventItemId(!0), o.PlayRateChanged))
                    } else
                        1 !== e && 1 === t && (this.playStart = performance.now()),
                        this.rtcStore.updateWaitForCanPlay(this.rtcEventItemId(!0));
                    this.oldRate = e,
                    this.newRate = t
                }
            }
            handleBufferAppended(e) {
                re(e.startAppend) && re(e.endAppend) && this.rtcStore.updateBufferAppended(this.rtcEventItemId(), e)
            }
            handleStalled(e, t, i) {
                var r;
                this.Oi && (t = {
                    type: e.type,
                    stallDurationMs: e.stallDurationMs,
                    bufferLen: t,
                    mediaDur: this.Oi.bufferedDuration,
                    currentTime: null != (t = this.Oi.realCurrentTime) ? t : void 0,
                    forInterstitial: i
                },
                i = this.rtcEventItemId(!0)) && (r = null == (r = this.rtcQuery) ? void 0 : r.entity(i)) && (this.rtcStore.updateWaitForCanPlay(i),
                i = r.sessionControlRecord.state,
                e.type === ru.LowBuffer || e.type === ru.Seek && e.isLowBufferStall ? "RTC_STATE_PLAY" === i && (this.rtcStore.updateBufferStalled(this.rtcEventItemId(!0), t),
                this.sendAndFinalize(this.rtcEventItemId(!0), o.PlayStalled)) : "RTC_STATE_PLAY" === i && (this.rtcStore.updateMediaEngineStalled(this.rtcEventItemId(!0), t),
                this.sendAndFinalize(this.rtcEventItemId(!0), o.MediaEngineStalled)))
            }
            handlePlaybackInfo(e, t, i, r) {
                this.rtcStore.updatePlaybackInfo(this.rtcEventItemId(!0), {
                    droppedVideoFrames: e,
                    decodedFrameCount: t,
                    liveEdgeDistance: i,
                    bufferedRangeTuple: r
                }),
                this.do.updatePlaybackInfo(this.rtcEventItemId(!0), {
                    droppedVideoFrames: e,
                    decodedFrameCount: t
                })
            }
            Io(e) {
                return void 0 !== e && (e === se.Variant || e === se.AltAudio || (this.R.error($h, 'Should not have media option type = "%s" in RTC', Bs[e]),
                !1))
            }
            rtcEventItemId(e=!1, t=!1) {
                if (!this.Oi)
                    return null;
                let i = this.Oi.currentItem;
                return null == (i = this.Oi.isPreloading ? e ? this.Oi.playingItem : this.Oi.loadingItem : i) ? null : !t && null != (e = i.parentItemId) ? e : i.itemId
            }
            itemTransitioned(e, t) {
                this.To(e),
                this.setPeriodic(t)
            }
            removeItemList(e) {
                e.forEach(e => {
                    this.rtcStore.removeEntityByID(e)
                }
                )
            }
            keyRequestStarted(e, t) {
                e.timestamp = performance.now(),
                e.forInterstitial = t,
                this.rtcStore.updateLicenseChallengeRequested(this.rtcEventItemId(), e)
            }
            keyLoaded(e, t) {
                this.Oi && (e.timestamp = performance.now(),
                e.currentTime = this.Oi.realCurrentTime,
                e.forInterstitial = t,
                this.rtcStore.updateKeyLoaded(this.rtcEventItemId(), e),
                this.sendAndFinalize(this.rtcEventItemId(), o.KeySessionComplete))
            }
            keySystemEvents(e) {
                this.rtcStore.updateKeySystemEvents(this.rtcEventItemId(), e)
            }
            licenseChallengeReceived(e) {
                this.rtcStore.updateLicenseChallengeReceived(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyuri: e.keyuri
                })
            }
            licenseChallengeSubmitted(e) {
                this.rtcStore.updateLicenseChallengeSubmitted(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyFormat: e.keyFormat,
                    keyuri: e.keyuri
                })
            }
            licenseChallengeCreated(e) {
                this.rtcStore.updateLicenseChallengeCreated(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    cdmVersion: e.cdmVersion,
                    keyuri: e.keyuri
                }),
                this.rtcStore.updateLicenseResponseRequested(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyuri: e.keyuri
                })
            }
            licenseResponseSubmitted(e) {
                this.rtcStore.updateLicenseResponseReceived(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyuri: e.keyuri
                }),
                this.rtcStore.updateLicenseResponseSubmitted(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyuri: e.keyuri
                })
            }
            licenseResponseProcessed(e) {
                this.Oi && this.rtcStore.updateLicenseResponseProcessed(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyuri: e.keyuri,
                    currentTime: null != (e = this.Oi.realCurrentTime) ? e : void 0
                })
            }
            licenseChallengeError(e) {
                this.rtcStore.updateLicenseChallengeError(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyuri: e.keyuri
                })
            }
            licenseResponseError(e) {
                this.rtcStore.updateLicenseResponseError(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyuri: e.keyuri
                })
            }
            keyAborted(e) {
                var t, i = this.rtcEventItemId();
                i && (t = null == (t = this.rtcQuery) ? void 0 : t.entity(i)) && t.sessionControlRecord.activeKeySessions && null != t.sessionControlRecord.activeKeySessions[e.keyuri] && (this.rtcStore.updateKeyAborted(this.rtcEventItemId(), {
                    timestamp: performance.now(),
                    keyuri: e.keyuri
                }),
                this.sendAndFinalize(this.rtcEventItemId(), o.KeySessionComplete))
            }
            keyErrorThrown(e) {
                var t, i = this.rtcEventItemId();
                i && (t = null == (t = this.rtcQuery) ? void 0 : t.entity(i)) && t.sessionControlRecord.activeKeySessions && null != t.sessionControlRecord.activeKeySessions[e.keyuri] && (this.rtcStore.updateKeyErrorThrown(this.rtcEventItemId(), e),
                this.sendAndFinalize(this.rtcEventItemId(), o.KeySessionComplete))
            }
            setPeriodic(e) {
                this.wo(),
                this.So = setInterval(this.Oo.bind(this, e), this.bo)
            }
            interstitialStarted(e) {
                this.sendAndFinalize(e, o.InterstitialStarted)
            }
            interstitialAssetStarted(e) {
                this.sendAndFinalize(e, o.InterstitialAssetStarted)
            }
            interstitialAssetEnded(e, t) {
                this.rtcStore.updateInterstitialPlayTime(e, t),
                this.sendAndFinalize(e, o.InterstitialAssetEnded)
            }
            interstitialEnded(e) {
                this.sendAndFinalize(e, o.InterstitialEnded)
            }
            Oo(e) {
                var t;
                this.Oi && (this.ko(e),
                this.rtcStore.updatePeriodic(e, null != (t = this.Oi.realCurrentTime) ? t : void 0, !1),
                this.sendAndFinalize(e, o.Periodic))
            }
            wo() {
                this.So && clearInterval(this.So),
                this.So = null
            }
            ko(e) {
                for (; this.rtcStore.prepareNonFatalNwError(e); )
                    this.rtcComponent.sendNwError(e);
                for (; this.rtcStore.prepareNonFatalPlayError(e); )
                    this.rtcComponent.sendPlayError(e)
            }
            To(e) {
                var t;
                e && this.Oi && (this.rtcStore.updateVariantEnd(e, {
                    currentTime: null != (t = this.Oi.realCurrentTime) ? t : void 0,
                    forInterstitial: this.Oi.interstitialActive
                }),
                this.sendAndFinalize(e, o.VariantEnded),
                this.ko(e),
                this.rtcStore.updatePeriodic(e, null != (t = this.Oi.realCurrentTime) ? t : void 0, !0),
                this.sendAndFinalize(e, o.Periodic),
                this.rtcStore.updateEnded(e, null != (t = this.Oi.realCurrentTime) ? t : void 0),
                this.sendAndFinalize(e, o.PlayEnded))
            }
            sendAndFinalize(e, t) {
                if (e) {
                    switch (this.do.addPlayTime(e),
                    t) {
                    case o.PlayEnded:
                        this.rtcComponent.sendPlayEnded(e);
                        break;
                    case o.Periodic:
                        this.rtcComponent.sendPeriodic(e);
                        break;
                    case o.PlayStalled:
                        this.do.updateStallCount(e),
                        this.rtcComponent.sendPlayStalled(e);
                        break;
                    case o.KeySessionComplete:
                        this.rtcComponent.sendKeySessionComplete(e);
                        break;
                    case o.PlayLikelyToKeepUp:
                        this.do.updateCanPlay(e),
                        this.rtcComponent.sendPlayLikelyToKeepUp(e);
                        break;
                    case o.PlayRateChanged:
                        this.rtcComponent.sendPlayRateChange(e);
                        break;
                    case o.PlayError:
                        this.do.addToErrorLog(e, "mediaError"),
                        this.rtcComponent.sendPlayError(e);
                        break;
                    case o.MediaEngineStalled:
                        this.do.updateMediaEngineStallCount(e),
                        this.rtcComponent.sendMediaEngineStalled(e);
                        break;
                    case o.SwitchComplete:
                        this.do.addToAccessLog(e),
                        this.rtcComponent.sendSwitchComplete(e);
                        break;
                    case o.SeekComplete:
                        this.rtcComponent.sendSeekComplete(e);
                        break;
                    case o.VariantEnded:
                        this.rtcComponent.sendVariantEnded(e);
                        break;
                    case o.NwError:
                        this.do.addToErrorLog(e, "networkError"),
                        this.rtcComponent.sendNwError(e);
                        break;
                    case o.DebugInfo:
                        this.rtcComponent.sendDebugInfo(e);
                        break;
                    case o.InterstitialStarted:
                        this.rtcComponent.sendInterstitialStart(e);
                        break;
                    case o.InterstitialAssetStarted:
                        this.rtcComponent.sendInterstitialAssetStart(e);
                        break;
                    case o.InterstitialAssetEnded:
                        this.rtcComponent.sendInterstitialAssetEnd(e);
                        break;
                    case o.InterstitialEnded:
                        this.rtcComponent.sendInterstitialEnd(e);
                        break;
                    case o.ErrorRecovery:
                        this.rtcComponent.sendErrorRecovery(e);
                        break;
                    default:
                        return void this.R.error($h, `Unknown rtc event eventGroupId:` + e)
                    }
                    this.rtcStore.finalize(e, t)
                }
            }
        }
        const zh = {
            setCombinedEstimate: function(t, i, e, r) {
                if (void 0 !== t.storage.set) {
                    var n = t.bandwidthHistoryStorageKey
                      , a = {
                        avgLatencyMs: i.avgLatencyMs,
                        avgBandwidth: i.avgBandwidth
                    }
                      , a = Object.assign({}, a, {
                        expires: Date.now() + t.bandwidthHistoryTTL
                    });
                    try {
                        t.storage.set(n, JSON.stringify(a))
                    } catch (t) {}
                    n = {
                        maxDuration: i.maxDurationSec,
                        avgFragParseTimeMs: i.avgParseTimeMs,
                        avgFragBufferCreationDelayMs: i.avgBufferCreateMs,
                        avgPlaylistLoadTimeMs: i.avgPlaylistLoadTimeMs,
                        avgPlaylistParseTimeMs: i.avgPlaylistParseTimeMs,
                        avgInitFragAppendMs: i.avgInitFragAppendMs,
                        avgDataFragAppendMs: i.avgDataFragAppendMs
                    };
                    let e = t.storageKeyPrefix;
                    r && (e += r);
                    try {
                        t.storage.set(e, JSON.stringify(n))
                    } catch (t) {}
                }
            },
            getCombinedEstimate: function(t, i, r) {
                let n = {};
                if (void 0 !== t.storage.get) {
                    try {
                        const i = t.storage.get(t.bandwidthHistoryStorageKey);
                        var a = null != (a = i ? JSON.parse(i) : null) && a.expires && a.expires < Date.now() ? null : {
                            avgLatencyMs: null == a ? void 0 : a.avgLatencyMs,
                            avgBandwidth: null == a ? void 0 : a.avgBandwidth
                        };
                        n = Object.assign(Object.assign({}, n), a)
                    } catch (t) {}
                    let e = t.storageKeyPrefix;
                    r && (e += r);
                    try {
                        const i = t.storage.get(e)
                          , r = i ? JSON.parse(i) : null;
                        n = Object.assign(Object.assign({}, n), r)
                    } catch (t) {}
                }
                return this.convertStorageJsonToCombinedEstimate(n)
            },
            convertStorageJsonToCombinedEstimate: function(e) {
                return {
                    avgLatencyMs: (null == e ? void 0 : e.avgLatencyMs) || NaN,
                    avgBandwidth: (null == e ? void 0 : e.avgBandwidth) || NaN,
                    maxDurationSec: (null == e ? void 0 : e.maxDuration) || NaN,
                    avgParseTimeMs: (null == e ? void 0 : e.avgFragParseTimeMs) || NaN,
                    avgBufferCreateMs: (null == e ? void 0 : e.avgFragBufferCreationDelayMs) || NaN,
                    avgPlaylistLoadTimeMs: (null == e ? void 0 : e.avgPlaylistLoadTimeMs) || NaN,
                    avgPlaylistParseTimeMs: (null == e ? void 0 : e.avgPlaylistParseTimeMs) || NaN,
                    avgInitFragAppendMs: (null == e ? void 0 : e.avgInitFragAppendMs) || NaN,
                    avgDataFragAppendMs: (null == e ? void 0 : e.avgDataFragAppendMs) || NaN
                }
            },
            getBandwidthEstimate: function(e, t, i) {
                e = this.getCombinedEstimate(e, t, i),
                t = {
                    avgLatencyMs: null == e ? void 0 : e.avgLatencyMs,
                    avgBandwidth: null == e ? void 0 : e.avgBandwidth
                };
                return re(t.avgLatencyMs) || (t.avgLatencyMs = NaN),
                re(t.avgBandwidth) || (t.avgBandwidth = NaN),
                t
            },
            getPlaylistEstimate: function(e, t, i) {
                e = this.getCombinedEstimate(e, t, i),
                t = {
                    avgPlaylistLoadTimeMs: null == e ? void 0 : e.avgPlaylistLoadTimeMs,
                    avgPlaylistParseTimeMs: null == e ? void 0 : e.avgPlaylistParseTimeMs
                };
                return re(t.avgPlaylistLoadTimeMs) || (t.avgPlaylistLoadTimeMs = NaN),
                re(t.avgPlaylistParseTimeMs) || (t.avgPlaylistParseTimeMs = NaN),
                t
            },
            getFragEstimate: function(e, t, i) {
                e = this.getCombinedEstimate(e, t, i),
                t = {
                    maxDurationSec: null == e ? void 0 : e.maxDurationSec,
                    avgParseTimeMs: null == e ? void 0 : e.avgParseTimeMs
                };
                return re(t.maxDurationSec) || (t.maxDurationSec = NaN),
                re(t.avgParseTimeMs) || (t.avgParseTimeMs = NaN),
                t
            },
            getBufferEstimate: function(e, t, i) {
                e = this.getCombinedEstimate(e, t, i),
                t = {
                    avgBufferCreateMs: null == e ? void 0 : e.avgBufferCreateMs,
                    avgInitFragAppendMs: null == e ? void 0 : e.avgInitFragAppendMs,
                    avgDataFragAppendMs: null == e ? void 0 : e.avgDataFragAppendMs
                };
                return re(t.avgBufferCreateMs) || (t.avgBufferCreateMs = NaN),
                re(t.avgInitFragAppendMs) || (t.avgInitFragAppendMs = NaN),
                re(t.avgDataFragAppendMs) || (t.avgDataFragAppendMs = NaN),
                t
            }
        };
        var Xh, Yh, Jh, Zh, ep, tp, ip = zh;
        const rp = s => (e, t, i) => {
            let r = 0
              , n = 0;
            for (const {timestamp: i, value: a} of e) {
                const e = Math.pow(Math.max(0, i - t) / 1e3, s);
                r += e * a,
                n += e
            }
            return r / n
        }
          , np = {
            "uniform-time-weighted": rp(0),
            "linear-time-weighted": rp(1),
            "quadratic-time-weighted": rp(2),
            "quadratic-window-weighted": (e, t, i) => {
                let r = 0
                  , n = 0;
                for (var {timestamp: a, value: s, duration: o} of e) {
                    const e = Math.pow(Math.max(0, a - t) / 1e3, 2) * o / i;
                    r += e * s,
                    n += e
                }
                return r / n
            }
        };
        function ap(e, t) {
            return e.start !== t.start ? e.start - t.start : e.end - t.end
        }
        function sp(e, t, i) {
            let r = e.length - 1;
            for (; 0 <= r && i(t, e[r]) <= 0; )
                --r;
            e.splice(r + 1, 0, t)
        }
        class op {
            constructor(e, t="quadratic-time-weighted", i={
                avgLatencyMs: NaN,
                avgBandwidth: NaN
            }) {
                this.Mo = e,
                this.Eo = t,
                this.Ao = [],
                this.No = [],
                this.Ro = 1,
                this.Po = this.Po.bind(this),
                this.Co = new pn(i)
            }
            get estimate$() {
                return this.Co.asObservable()
            }
            record(e) {
                var {trequest: e, tfirst: t, tload: i, bitsDownloaded: r} = e;
                e === i || t === i || (this.Do(e, t),
                this.xo(t, i, 1e3 * r / (i - t)),
                this.Co.closed) || (e = this.getEstimate(),
                this.Co.next(e))
            }
            getEstimate() {
                var e, t, i, r;
                return this.Ao.length < this.Ro ? {
                    avgLatencyMs: NaN,
                    avgBandwidth: NaN
                } : (e = performance.now() - this.Mo,
                t = np[this.Eo],
                i = this.Ao.map( ({start: e, end: t}) => {
                    e = t - e;
                    return {
                        timestamp: t,
                        value: e,
                        duration: e
                    }
                }
                ),
                this.No = function(r) {
                    for (var t = [], n = function(t, i) {
                        if (t.length) {
                            for (let e = 0; e < t.length; e++)
                                if (t[e].start > i.start || t[e].start === i.start && t[e].end > i.end) {
                                    t.splice(e, 0, i);
                                    break
                                }
                        } else
                            t.push(i)
                    }; r.length; ) {
                        var a = r[0];
                        r.shift();
                        let e = {
                            start: -1,
                            end: -1,
                            bitsPerSec: 0
                        };
                        if (t.length && (e = t[t.length - 1]),
                        0 === t.length || e.end <= a.start)
                            t.push(a);
                        else if (a.start === e.start)
                            a.end === e.end ? e.bitsPerSec += a.bitsPerSec : a.end < e.end || (e.bitsPerSec += a.bitsPerSec,
                            a.start = e.end,
                            n(r, a));
                        else {
                            var s = e.end
                              , o = e.bitsPerSec
                              , i = (e.end = a.start,
                            {
                                start: a.start,
                                end: Math.min(s, a.end),
                                bitsPerSec: a.bitsPerSec + o
                            });
                            if (t.push(i),
                            s !== a.end) {
                                let e = 0
                                  , t = 0
                                  , i = 0;
                                i = s < a.end ? (e = s,
                                t = a.end,
                                a.bitsPerSec) : (e = a.end,
                                t = s,
                                o),
                                n(r, {
                                    start: e,
                                    end: t,
                                    bitsPerSec: i
                                })
                            }
                        }
                    }
                    return t
                }(this.No),
                r = this.No.map( ({start: e, end: t, bitsPerSec: i}) => ({
                    timestamp: t,
                    duration: t - e,
                    value: i
                })),
                {
                    avgLatencyMs: t(i, e, this.Mo),
                    avgBandwidth: t(r, e, this.Mo)
                })
            }
            getLatest() {
                var e, t;
                return 0 === this.Ao.length ? {
                    avgLatencyMs: NaN,
                    avgBandwidth: NaN
                } : (e = this.Ao[this.Ao.length - 1],
                t = this.No[this.No.length - 1],
                {
                    avgLatencyMs: e.end - e.start,
                    avgBandwidth: t.bitsPerSec
                })
            }
            Do(e, t) {
                sp(this.Ao, {
                    start: e,
                    end: t
                }, ap),
                this.Lo(t)
            }
            xo(e, t, i) {
                sp(this.No, {
                    start: e,
                    end: t,
                    bitsPerSec: i
                }, ap),
                this.Lo(t)
            }
            _o(e) {
                this.Fo = setTimeout(this.Po, Math.max(e - performance.now(), 0)),
                this.jo = e
            }
            Uo() {
                void 0 !== this.Fo && (clearTimeout(this.Fo),
                this.Fo = void 0),
                this.jo = void 0
            }
            Lo(e) {
                e += this.Mo;
                (!this.jo || e < this.jo) && (this.Uo(),
                this._o(e))
            }
            Po() {
                this.Uo();
                const t = performance.now() - this.Mo;
                if (this.Ao = this.Ao.filter(e => e.end >= t),
                this.No = this.No.filter(e => e.end >= t),
                this.Co.closed || this.Co.next(this.getEstimate()),
                0 < this.Ao.length || 0 < this.No.length) {
                    const t = Math.min(...this.Ao.map(e => e.end), ...this.No.map(e => e.end));
                    this.Lo(t)
                }
            }
            destroy() {
                this.Uo()
            }
        }
        class lp {
            constructor(e=0) {
                this.Bo = e,
                this.$o = 0,
                this.Vo = Number.NEGATIVE_INFINITY,
                this.qo = 0
            }
            get avg() {
                return this.qo < this.Bo ? NaN : this.$o / this.qo
            }
            get max() {
                return 0 < this.count ? this.Vo : NaN
            }
            get count() {
                return this.qo
            }
            reset() {
                this.$o = 0,
                this.qo = 0,
                this.Vo = Number.NEGATIVE_INFINITY
            }
            add(e) {
                this.$o += e,
                this.Vo = Math.max(this.Vo, e),
                ++this.qo
            }
        }
        class dp extends ja {
            constructor(e, t, i) {
                super(e),
                this.Ko = e,
                this.id = t,
                this.R = i
            }
            getBandwidthEstimate(e, t, i=!0) {
                var r = null != (r = Object.assign({}, null == (r = this.statsEntity) ? void 0 : r.bandwidthEstimate)) ? r : {};
                return re(r.avgBandwidth) && re(r.avgLatencyMs) ? {
                    avgBandwidth: r.avgBandwidth,
                    avgLatencyMs: r.avgLatencyMs
                } : null != e && e.storage && i ? s(r, zh.getBandwidthEstimate(e, this.R, t)) : (r.avgBandwidth = NaN,
                r.avgLatencyMs = NaN,
                {
                    avgBandwidth: r.avgBandwidth,
                    avgLatencyMs: r.avgLatencyMs
                })
            }
            getPlaylistEstimate(e, t, i=!0) {
                let r = null != (n = Object.assign({}, null == (n = this.statsEntity) ? void 0 : n.playlistEstimate)) ? n : {};
                var n = e => re(e.avgPlaylistLoadTimeMs) && re(e.avgPlaylistParseTimeMs);
                if (!n(r)) {
                    if (null != e && e.storage && i) {
                        const i = s(r, zh.getPlaylistEstimate(e, this.R, t));
                        if (n(i))
                            return i
                    }
                    if (null != e && e.statDefaults) {
                        const t = e.statDefaults;
                        r = s(r, {
                            avgPlaylistLoadTimeMs: t.playlistLoadTimeMs,
                            avgPlaylistParseTimeMs: t.playlistParseTimeMs
                        })
                    }
                }
                return r
            }
            getBufferEstimate(e, t, i=!0) {
                let r = null != (n = Object.assign({}, null == (n = this.statsEntity) ? void 0 : n.bufferEstimate)) ? n : {};
                var n = e => re(e.avgBufferCreateMs) && re(e.avgDataFragAppendMs) && re(e.avgInitFragAppendMs);
                if (!n(r)) {
                    if (null != e && e.storage && i) {
                        const i = s(r, zh.getBufferEstimate(e, this.R, t));
                        if (n(i))
                            return i
                    }
                    if (null != e && e.statDefaults) {
                        const t = e.statDefaults;
                        r = s(r, {
                            avgBufferCreateMs: t.fragBufferCreationDelayMs,
                            avgInitFragAppendMs: t.initFragAppendMs,
                            avgDataFragAppendMs: t.dataFragAppendMs
                        })
                    }
                }
                return r
            }
            getFragEstimate(e, t, i=!0) {
                let r = null != (n = Object.assign({}, null == (n = this.statsEntity) ? void 0 : n.fragEstimate)) ? n : {};
                var n = e => re(e.maxDurationSec) && re(e.avgParseTimeMs);
                if (!n(r)) {
                    if (null != e && e.storage && i) {
                        const i = s(r, zh.getFragEstimate(e, this.R, t));
                        if (n(i))
                            return i
                    }
                    null != e && e.statDefaults && (r = s(r, {
                        avgParseTimeMs: e.statDefaults.fragParseTimeMs,
                        maxDurationSec: e.defaultTargetDuration
                    }))
                }
                return r
            }
            getCombinedEstimate(e, t, i=!0) {
                return Object.assign(Object.assign(Object.assign(Object.assign({}, this.getFragEstimate(e, t, i)), this.getPlaylistEstimate(e, t, i)), this.getBufferEstimate(e, t, i)), this.getBandwidthEstimate(e, t, i))
            }
            get statsEntity() {
                return this.getEntity(this.id)
            }
            get bandwidthSample() {
                var e;
                return null == (e = null == (e = this.Ko) ? void 0 : e.getSamplesForService(this.id)) ? void 0 : e.bandwidthSample
            }
            get bandwidthStatus() {
                var e;
                return null != (e = null == (e = this.statsEntity) ? void 0 : e.bandwidthStatus) ? e : {
                    bandwidthSampleCount: 0,
                    instantBw: 0
                }
            }
            get initFragSample() {
                var e;
                return null == (e = this.statsEntity) ? void 0 : e.initFragSample
            }
            get fragSample() {
                var e;
                return null == (e = null == (e = this.Ko) ? void 0 : e.getSamplesForService(this.id)) ? void 0 : e.fragSample
            }
            get playlistSample() {
                var e;
                return null == (e = null == (e = this.Ko) ? void 0 : e.getSamplesForService(this.id)) ? void 0 : e.playlistSample
            }
            get bufferMetric() {
                var e;
                return null == (e = null == (e = this.Ko) ? void 0 : e.getSamplesForService(this.id)) ? void 0 : e.bufferMetric
            }
            get samplesUpdated$() {
                var e;
                return null == (e = null == (e = this.Ko) ? void 0 : e.getSamplesForService(this.id)) ? void 0 : e.samplesUpdated$
            }
            get bandwidthEstimate$() {
                return this.selectEntity(this.id, "bandwidthEstimate").pipe(Kl())
            }
            get fragEstimate$() {
                return this.selectEntity(this.id, "fragEstimate").pipe(Kl())
            }
            get playlistEstimate$() {
                return this.selectEntity(this.id, "playlistEstimate").pipe(Kl())
            }
            get bufferEstimate$() {
                return this.selectEntity(this.id, "bufferEstimate").pipe(Kl())
            }
            combinedEstimate$(e, t) {
                return Fr([this.bandwidthEstimate$.pipe(Rn(this.getBandwidthEstimate(e, t))), this.fragEstimate$.pipe(Rn(this.getFragEstimate(e, t))), this.playlistEstimate$.pipe(Rn(this.getPlaylistEstimate(e, t))), this.bufferEstimate$.pipe(Rn(this.getBufferEstimate(e, t)))]).pipe(W( ([e,t,i,r]) => Object.assign(Object.assign(Object.assign(Object.assign({}, e), t), i), r)))
            }
        }
        class up extends Ua {
            constructor() {
                super({}, {
                    name: "stats-store",
                    resettable: !0
                }),
                this.lastSampleValues = {}
            }
            initStatsSamplesForService(e) {
                e in this.lastSampleValues || (this.lastSampleValues[e] = {
                    samplesUpdated$: new z
                })
            }
            updateBandwithSample(e, t) {
                e = this.lastSampleValues[e];
                null != e && (e.bandwidthSample = t,
                e.samplesUpdated$.next())
            }
            updateFragSample(e, t) {
                e = this.lastSampleValues[e];
                null != e && (e.fragSample = t,
                e.samplesUpdated$.next())
            }
            updatePlaylistSample(e, t) {
                e = this.lastSampleValues[e];
                null != e && (e.playlistSample = t,
                e.samplesUpdated$.next())
            }
            updateBufferMetric(e, t) {
                e = this.lastSampleValues[e];
                null != e && (e.bufferMetric = t,
                e.samplesUpdated$.next())
            }
            getSamplesForService(e) {
                return this.lastSampleValues[e]
            }
            clearSamplesForService(e) {
                delete this.lastSampleValues[e]
            }
            clearSamplesForAllServices() {
                this.lastSampleValues = {}
            }
        }
        class cp {
            constructor(e, t, i) {
                this.Ko = e,
                this.R = t,
                this.Ho = new Map,
                this.ri = new ja(e),
                this.zo = new lp(i.minPlaylistCount),
                this.Qo = new lp(i.minPlaylistCount),
                this.Go = new lp,
                this.Wo = new lp(i.minFragmentCount),
                this.Xo = new op(i.bandwidthHistoryWindowSize,i.bandwidthHistoryAggregationMethod,{
                    avgLatencyMs: NaN,
                    avgBandwidth: NaN
                }),
                this.Yo = new lp,
                this.Jo = new lp,
                this.Zo = new lp(i.minFragmentCount)
            }
            getQueryForId(e) {
                let t = this.Ho.get(e);
                return t || (t = new dp(this.Ko,e,this.R),
                this.Ho.set(e, t)),
                t
            }
            remove(e) {
                this.Ho.delete(e),
                this.Ko.clearSamplesForService(e),
                this.Ko.remove(e)
            }
            removeAll() {
                this.Ho.clear(),
                this.Ko.clearSamplesForAllServices(),
                this.Ko.remove()
            }
            destroy() {
                this.Ko.destroy()
            }
            setBandwidthSample(t) {
                var i, r = this.ri.getActiveId();
                if (r) {
                    var n = this.getQueryForId(r);
                    if (n) {
                        this.Ko.updateBandwithSample(r, t);
                        let e = NaN;
                        n = {
                            bandwidthSampleCount: null != (r = null == (i = n.bandwidthStatus) ? void 0 : i.bandwidthSampleCount) ? r : 0,
                            instantBw: e = t.mediaOptionType === se.Variant ? 8e3 * t.loaded / (t.tload - t.tfirst) : e
                        };
                        if (this.setBandwidthStatus(n),
                        t.complete) {
                            this.Xo.record({
                                trequest: t.trequest,
                                tfirst: t.tfirst,
                                tload: t.tload,
                                bitsDownloaded: 8 * t.loaded
                            });
                            const i = this.Xo.getEstimate();
                            this.setBandwidthEstimate(i)
                        }
                    }
                }
            }
            setInitFragSample(e) {
                this.Ko.updateActive({
                    initFragSample: e
                })
            }
            setFragSample(e) {
                var t = this.ri.getActiveId();
                t && (this.Ko.updateFragSample(t, e),
                this.Go.add(e.durationSec),
                this.Wo.add(e.parseTimeMs),
                this.setFragEstimate({
                    maxDurationSec: this.Go.max,
                    avgParseTimeMs: this.Wo.avg
                }))
            }
            setPlaylistSample(e) {
                var t = this.ri.getActiveId();
                t && (this.Ko.updatePlaylistSample(t, e),
                this.zo.add(e.playlistLoadTimeMs),
                this.Qo.add(e.playlistParseTimeMs),
                t = {
                    avgPlaylistLoadTimeMs: this.zo.avg,
                    avgPlaylistParseTimeMs: this.Qo.avg
                },
                this.setPlaylistEstimate(t))
            }
            setBufferMetric(e) {
                var t = this.ri.getActiveId();
                t && (this.Ko.updateBufferMetric(t, e),
                re(e.bufferCreationStart) && re(e.bufferCreationEnd) && this.Yo.add(e.bufferCreationEnd - e.bufferCreationStart),
                re(e.startInitAppend) && re(e.endInitAppend) && this.Jo.add(e.endInitAppend - e.startInitAppend),
                re(e.startDataAppend) && re(e.endDataAppend) && this.Zo.add(e.endDataAppend - e.startDataAppend),
                this.setBufferEstimate({
                    avgBufferCreateMs: this.Yo.avg,
                    avgInitFragAppendMs: this.Jo.avg,
                    avgDataFragAppendMs: this.Zo.avg
                }))
            }
            setBandwidthEstimate(e) {
                var t;
                _(null == (t = this.ri.getActive()) ? void 0 : t.bandwidthEstimate, e) || this.Ko.updateActive({
                    bandwidthEstimate: e
                })
            }
            setBandwidthStatus(e) {
                this.Ko.updateActive({
                    bandwidthStatus: e
                })
            }
            setFragEstimate(e) {
                var t;
                _(null == (t = this.ri.getActive()) ? void 0 : t.fragEstimate, e) || this.Ko.updateActive({
                    fragEstimate: e
                })
            }
            setPlaylistEstimate(e) {
                var t;
                _(null == (t = this.ri.getActive()) ? void 0 : t.playlistEstimate, e) || this.Ko.updateActive({
                    playlistEstimate: e
                })
            }
            setBufferEstimate(e) {
                var t;
                _(null == (t = this.ri.getActive()) ? void 0 : t.bufferEstimate, e) || this.Ko.updateActive({
                    bufferEstimate: e
                })
            }
            setActive(e) {
                this.Ko.setActive(e),
                this.Ko.initStatsSamplesForService(e)
            }
            addEmptyEntity(e) {
                const t = {
                    id: e,
                    bandwidthEstimate: {
                        avgLatencyMs: NaN,
                        avgBandwidth: NaN
                    },
                    bandwidthStatus: {
                        bandwidthSampleCount: 0,
                        instantBw: NaN
                    },
                    fragEstimate: {
                        maxDurationSec: NaN,
                        avgParseTimeMs: NaN
                    },
                    playlistEstimate: {
                        avgPlaylistLoadTimeMs: NaN,
                        avgPlaylistParseTimeMs: NaN
                    },
                    bufferEstimate: {
                        avgBufferCreateMs: NaN,
                        avgInitFragAppendMs: NaN,
                        avgDataFragAppendMs: NaN
                    }
                };
                ae( () => {
                    this.Ko.add(t),
                    this.setActive(e)
                }
                )
            }
        }
        const hp = {
            "art-lojban": "jbo",
            "en-gb-oed": "en-GB-oxendict",
            "i-ami": "ami",
            "i-bnn": "bnn",
            "i-hak": "hak",
            "i-klingon": "tlh",
            "i-lux": "lb",
            "i-navajo": "nv",
            "i-pwn": "pwn",
            "i-tao": "tao",
            "i-tay": "tay",
            "i-tsu": "tsu",
            "no-bok": "nb",
            "no-nyn": "nn",
            "sgn-be-fr": "sfb",
            "sgn-be-nl": "vgt",
            "sgn-ch-de": "sgg",
            "zh-guoyu": "cmn",
            "zh-hakka": "hak",
            "zh-minnan": "nan",
            "zh-min-nan": "nan",
            "zh-xiang": "hsn"
        }
          , pp = {
            afr: "af",
            aka: "ak",
            amh: "am",
            ara: "ar",
            arg: "an",
            asm: "as",
            ava: "av",
            ave: "ae",
            aym: "ay",
            aze: "az",
            bam: "bm",
            bel: "be",
            ben: "bn",
            bih: "bh",
            bod: "bo",
            bos: "bs",
            bre: "br",
            bul: "bg",
            cat: "ca",
            ces: "cs",
            cha: "ch",
            che: "ce",
            chu: "cu",
            chv: "cv",
            cor: "kw",
            cos: "co",
            cre: "cr",
            cym: "cy",
            dan: "da",
            deu: "de",
            div: "dv",
            dzo: "dz",
            ell: "el",
            eng: "en",
            epo: "eo",
            est: "et",
            eus: "eu",
            ewe: "ee",
            fao: "fo",
            fas: "fa",
            fin: "fi",
            fra: "fr",
            fry: "fy",
            ful: "ff",
            gla: "gd",
            gle: "ga",
            glg: "gl",
            glv: "gv",
            grn: "gn",
            guj: "gu",
            hat: "ht",
            heb: "he",
            her: "hz",
            hin: "hi",
            hmo: "ho",
            hrv: "hr",
            hun: "hu",
            hye: "hy",
            ibo: "ig",
            ido: "io",
            iii: "ii",
            iku: "iu",
            ile: "ie",
            ina: "ia",
            ind: "id",
            isl: "is",
            ita: "it",
            jav: "jv",
            jpn: "ja",
            kal: "kl",
            kan: "kn",
            kas: "ks",
            kat: "ka",
            kau: "kr",
            kaz: "kk",
            khm: "km",
            kik: "ki",
            kin: "rw",
            kir: "ky",
            kom: "kv",
            kon: "kg",
            kor: "ko",
            kua: "kj",
            kur: "ku",
            lao: "lo",
            lat: "la",
            lav: "lv",
            lim: "li",
            lit: "lt",
            ltz: "lb",
            lub: "lu",
            lug: "lg",
            mah: "mh",
            mal: "ml",
            mar: "mr",
            mkd: "mk",
            mlg: "mg",
            mlt: "mt",
            mol: "mo",
            mon: "mn",
            mri: "mi",
            msa: "ms",
            mya: "my",
            nav: "nv",
            nbl: "nr",
            nde: "nd",
            ndo: "ng",
            nep: "ne",
            nld: "nl",
            nno: "nn",
            nob: "nb",
            nya: "ny",
            oci: "oc",
            oji: "oj",
            ori: "or",
            orm: "om",
            oss: "os",
            pan: "pa",
            pli: "pi",
            pol: "pl",
            por: "pt",
            pus: "ps",
            que: "qu",
            roh: "rm",
            ron: "ro",
            run: "rn",
            rus: "ru",
            san: "sa",
            sin: "si",
            slk: "sk",
            slv: "sl",
            sme: "se",
            snd: "sd",
            som: "so",
            spa: "es",
            sqi: "sq",
            srd: "sc",
            srp: "sr",
            sun: "su",
            swa: "sw",
            swe: "sv",
            tah: "ty",
            tam: "ta",
            tat: "tt",
            tel: "te",
            tgk: "tg",
            tgl: "tl",
            tha: "th",
            tir: "ti",
            ton: "to",
            tuk: "tk",
            tur: "tr",
            uig: "ug",
            ukr: "uk",
            urd: "ur",
            uzb: "uz",
            ven: "ve",
            vie: "vi",
            wln: "wa",
            yid: "yi",
            zha: "za",
            zho: "zh"
        }
          , mp = {
            in: "id",
            iw: "he",
            ji: "yi",
            jw: "jv",
            mo: "ro",
            scc: "sr",
            scr: "hr",
            aam: "aas",
            adp: "dz",
            aue: "ktz",
            ayx: "nun",
            bgm: "bcg",
            bjd: "drl",
            ccq: "rki",
            cjr: "mom",
            cka: "cmr",
            cmk: "xch",
            coy: "pij",
            cqu: "quh",
            drh: "mn",
            gav: "dev",
            gfx: "vaj",
            ggn: "gvr",
            gti: "nyc",
            guv: "duz",
            hrr: "jal",
            ibi: "opa",
            ilw: "gal",
            jeg: "oyb",
            kgc: "tdf",
            kgh: "kml",
            koj: "kwv",
            krm: "bmf",
            ktr: "dtp",
            kvs: "gdj",
            kwq: "yam",
            kxe: "tvd",
            kzj: "dtp",
            kzt: "dtp",
            lii: "raq",
            lmm: "rmx",
            meg: "cir",
            mst: "mry",
            mwj: "vaj",
            myt: "mry",
            nad: "xny",
            ncp: "kdz",
            nnx: "ngv",
            nts: "pij",
            oun: "vaj",
            pcr: "adx",
            pmc: "huw",
            pmu: "phr",
            ppa: "bfy",
            ppr: "lcq",
            pry: "prt",
            puz: "pub",
            sca: "hle",
            skk: "oyb",
            tdu: "dtp",
            thc: "tpo",
            thx: "oyb",
            tie: "ras",
            tkk: "twm",
            tlw: "weo",
            tmp: "tyj",
            tne: "kak",
            tsf: "taj",
            uok: "ema",
            xba: "cax",
            xia: "acn",
            xkh: "waw",
            xsj: "suj",
            ybd: "rki",
            yma: "lrr",
            ymt: "mtm",
            yos: "zom",
            yuu: "yug",
            asd: "snz",
            dit: "dif",
            llo: "ngt",
            myd: "aog",
            nns: "nbr",
            no: "nb",
            tl: "fil",
            aju: "jrb",
            als: "sq",
            arb: "ar",
            ayr: "ay",
            azj: "az",
            bcc: "bal",
            bcl: "bik",
            bxk: "luy",
            bxr: "bua",
            cld: "syr",
            cmn: "zh",
            cwd: "cr",
            dgo: "doi",
            dhd: "mwr",
            dik: "din",
            diq: "zza",
            lbk: "bnc",
            ekk: "et",
            emk: "man",
            esk: "ik",
            fat: "ak",
            fuc: "ff",
            gaz: "om",
            gbo: "grb",
            gno: "gon",
            gug: "gn",
            gya: "gba",
            hdn: "hai",
            hea: "hmn",
            ike: "iu",
            kmr: "ku",
            knc: "kr",
            kng: "kg",
            knn: "kok",
            kpv: "kv",
            lvs: "lv",
            mhr: "chm",
            mup: "raj",
            khk: "mn",
            npi: "ne",
            ojg: "oj",
            ory: "or",
            pbu: "ps",
            pes: "fa",
            plt: "mg",
            pnb: "lah",
            quz: "qu",
            rmy: "rom",
            spy: "kln",
            src: "sc",
            swh: "sw",
            ttq: "tmh",
            tw: "ak",
            umu: "del",
            uzn: "uz",
            xpe: "kpe",
            xsl: "den",
            ydd: "yi",
            zai: "zap",
            zsm: "ms",
            zyb: "za",
            him: "srx",
            mnk: "man",
            bh: "bho",
            aar: "aa",
            abk: "ab",
            bak: "ba",
            bis: "bi",
            fij: "fj",
            hau: "ha",
            ipk: "ik",
            lat: "la",
            lin: "ln",
            nau: "na",
            nor: "nb",
            sag: "sg",
            smo: "sm",
            sna: "sn",
            ssw: "ss",
            sot: "st",
            tsn: "tn",
            tso: "ts",
            twi: "ak",
            vol: "vo",
            wol: "wo",
            xho: "xh",
            yor: "yo",
            zul: "zu",
            alb: "sq",
            arm: "hy",
            baq: "eu",
            bur: "my",
            chi: "zh",
            cze: "cs",
            dut: "nl",
            fre: "fr",
            geo: "ka",
            ger: "de",
            gre: "el",
            ice: "is",
            mac: "mk",
            mao: "mi",
            may: "ms",
            per: "fa",
            rum: "ro",
            slo: "sk",
            tib: "bo",
            wel: "cy"
        }
          , fp = [[{
            lang: "drw"
        }, {
            lang: "fa",
            region: "af"
        }], [{
            lang: "tnf"
        }, {
            lang: "fa",
            region: "af"
        }], [{
            lang: "sgn",
            region: "br"
        }, {
            lang: "bzs"
        }], [{
            lang: "sgn",
            region: "co"
        }, {
            lang: "csn"
        }], [{
            lang: "sgn",
            region: "de"
        }, {
            lang: "gsg"
        }], [{
            lang: "sgn",
            region: "dk"
        }, {
            lang: "dsl"
        }], [{
            lang: "sgn",
            region: "fr"
        }, {
            lang: "fsl"
        }], [{
            lang: "sgn",
            region: "gb"
        }, {
            lang: "bfi"
        }], [{
            lang: "sgn",
            region: "gr"
        }, {
            lang: "gss"
        }], [{
            lang: "sgn",
            region: "ie"
        }, {
            lang: "isg"
        }], [{
            lang: "sgn",
            region: "it"
        }, {
            lang: "ise"
        }], [{
            lang: "sgn",
            region: "jp"
        }, {
            lang: "jsl"
        }], [{
            lang: "sgn",
            region: "ni"
        }, {
            lang: "ncs"
        }], [{
            lang: "sgn",
            region: "nl"
        }, {
            lang: "dse"
        }], [{
            lang: "sgn",
            region: "no"
        }, {
            lang: "nsi"
        }], [{
            lang: "sgn",
            region: "pt"
        }, {
            lang: "psr"
        }], [{
            lang: "sgn",
            region: "se"
        }, {
            lang: "swl"
        }], [{
            lang: "sgn",
            region: "us"
        }, {
            lang: "ase"
        }], [{
            lang: "sgn",
            region: "za"
        }, {
            lang: "sfs"
        }], [{
            baseName: "no-bokmal"
        }, {
            lang: "nb"
        }], [{
            baseName: "no-nynorsk"
        }, {
            lang: "nn"
        }], [{
            baseName: "aa-saaho"
        }, {
            lang: "ssy"
        }], [{
            lang: "sh"
        }, {
            lang: "sr",
            script: "latn"
        }], [{
            lang: "cnr"
        }, {
            lang: "sr",
            region: "me"
        }], [{
            lang: "az",
            region: "az"
        }, {
            lang: "az",
            script: "latn",
            region: "az"
        }], [{
            lang: "bs",
            region: "ba"
        }, {
            lang: "bs",
            script: "latn",
            region: "ba"
        }], [{
            lang: "ha",
            script: "latn",
            region: "gh"
        }, {
            lang: "ha",
            region: "gh"
        }], [{
            lang: "ha",
            script: "latn",
            region: "ne"
        }, {
            lang: "ha",
            region: "ne"
        }], [{
            lang: "ha",
            script: "latn",
            region: "ng"
        }, {
            lang: "ha",
            region: "ng"
        }], [{
            lang: "kk",
            script: "cyrl",
            region: "kz"
        }, {
            lang: "kk",
            region: "kz"
        }], [{
            lang: "kk",
            script: "cyrl",
            region: "kg"
        }, {
            lang: "kk",
            region: "kg"
        }], [{
            lang: "ks",
            script: "arab",
            region: "in"
        }, {
            lang: "ks",
            region: "in"
        }], [{
            lang: "mn",
            script: "cyrl",
            region: "mn"
        }, {
            lang: "mn",
            region: "mn"
        }], [{
            lang: "ms",
            script: "latn",
            region: "bn"
        }, {
            lang: "ms",
            region: "bn"
        }], [{
            lang: "ms",
            script: "latn",
            region: "my"
        }, {
            lang: "ms",
            region: "my"
        }], [{
            lang: "ms",
            script: "latn",
            region: "my"
        }, {
            lang: "ms",
            region: "my"
        }], [{
            lang: "ms",
            script: "latn",
            region: "sg"
        }, {
            lang: "ms",
            region: "sg"
        }], [{
            lang: "pa",
            region: "in"
        }, {
            lang: "pa",
            script: "guru",
            region: "in"
        }], [{
            lang: "pa",
            region: "pk"
        }, {
            lang: "pa",
            script: "arab",
            region: "pk"
        }], [{
            lang: "shi",
            region: "ma"
        }, {
            lang: "shi",
            script: "tfng",
            region: "ma"
        }], [{
            lang: "sr",
            region: "ba"
        }, {
            lang: "sr",
            script: "cyrl",
            region: "ba"
        }], [{
            lang: "sr",
            region: "me"
        }, {
            lang: "sr",
            script: "latn",
            region: "me"
        }], [{
            lang: "sr",
            region: "rs"
        }, {
            lang: "sr",
            script: "cyrl",
            region: "rs"
        }], [{
            lang: "sr",
            region: "xk"
        }, {
            lang: "sr",
            script: "cyrl",
            region: "xk"
        }], [{
            lang: "tzm",
            script: "latn",
            region: "ma"
        }, {
            lang: "tzm",
            region: "ma"
        }], [{
            lang: "ug",
            script: "arab",
            region: "cn"
        }, {
            lang: "ug",
            region: "cn"
        }], [{
            lang: "uz",
            region: "af"
        }, {
            lang: "uz",
            script: "arab",
            region: "af"
        }], [{
            lang: "uz",
            region: "uz"
        }, {
            lang: "uz",
            script: "latn",
            region: "uz"
        }], [{
            lang: "vai",
            region: "lr"
        }, {
            lang: "vai",
            script: "vaii",
            region: "lr"
        }], [{
            lang: "yue",
            region: "cn"
        }, {
            lang: "yue",
            script: "hans",
            region: "cn"
        }], [{
            lang: "yue",
            region: "hk"
        }, {
            lang: "yue",
            script: "hant",
            region: "hk"
        }], [{
            lang: "zh",
            region: "cn"
        }, {
            lang: "zh",
            script: "hans",
            region: "cn"
        }], [{
            lang: "zh",
            region: "hk"
        }, {
            lang: "zh",
            script: "hant",
            region: "hk"
        }], [{
            lang: "zh",
            region: "mo"
        }, {
            lang: "zh",
            script: "hant",
            region: "mo"
        }], [{
            lang: "zh",
            region: "sg"
        }, {
            lang: "zh",
            script: "hans",
            region: "sg"
        }], [{
            lang: "zh",
            region: "tw"
        }, {
            lang: "zh",
            script: "hant",
            region: "tw"
        }], [{
            lang: "prs"
        }, {
            lang: "fa",
            region: "af"
        }], [{
            lang: "swc"
        }, {
            lang: "sw",
            region: "cd"
        }], [{
            lang: "hbs"
        }, {
            lang: "sr",
            region: "latn"
        }]]
          , gp = {
            qaai: "zinh"
        }
          , yp = {
            bu: "mm",
            ct: "ki",
            dd: "de",
            dy: "bj",
            fx: "fr",
            hv: "bf",
            jt: "um",
            mi: "um",
            nh: "vu",
            nq: "aq",
            pu: "um",
            pz: "pa",
            qu: "eu",
            rh: "zw",
            tp: "tl",
            uk: "gb",
            vd: "vn",
            wk: "um",
            yd: "ye",
            zr: "cd"
        }
          , vp = ["mni-beng-in", "mni-mtei-in", "sat-deva-in", "sat-olck-in", "shi-latn-ma", "shi-tfng-ma", "vai-latn-lr", "vai-vaii-lr", "yue-hans-cn", "yue-hant-hk", "az-arab-ir", "az-cyrl-az", "az-latn-az", "bm-nkoo-ml", "bs-cyrl-ba", "bs-latn-ba", "en-dsrt-us", "ff-adlm-gn", "ff-latn-sn", "ha-arab-ng", "hi-latn-in", "iu-latn-ca", "ks-arab-in", "ks-deva-in", "mn-mong-cn", "ms-arab-my", "pa-arab-pk", "pa-guru-in", "sd-arab-pk", "sd-deva-in", "sr-cyrl-rs", "sr-latn-rs", "su-latn-id", "uz-arab-af", "uz-cyrl-uz", "uz-latn-uz", "zh-hans-cn", "zh-hant-tw", "mni-beng", "sat-olck", "shi-tfng", "vai-vaii", "yue-hant", "az-latn", "bs-latn", "ff-latn", "jbo-001", "ks-arab", "pa-guru", "prg-001", "sd-arab", "sr-cyrl", "su-latn", "uz-latn", "zh-hans", "agq-cm", "ar-001", "arn-cl", "asa-tz", "ast-es", "bas-cm", "bem-zm", "bez-tz", "bgn-pk", "blt-vn", "brx-in", "bss-cm", "byn-er", "cad-us", "cch-ng", "ccp-bd", "ceb-ph", "cgg-ug", "chr-us", "cic-us", "ckb-iq", "dav-ke", "dje-ne", "doi-in", "dsb-de", "dua-cm", "dyo-sn", "ebu-ke", "eo-001", "ewo-cm", "fil-ph", "fur-it", "gaa-gh", "gez-et", "gsw-ch", "guz-ke", "haw-us", "hsb-de", "ia-001", "ife-tg", "io-001", "jgo-cm", "jmc-tz", "kab-dz", "kaj-ng", "kam-ke", "kcg-ng", "kde-tz", "kea-cv", "ken-cm", "khq-ml", "kkj-cm", "kln-ke", "kok-in", "kpe-lr", "ksb-tz", "ksf-cm", "ksh-de", "lag-tz", "lkt-us", "lrc-ir", "luo-ke", "luy-ke", "mai-in", "mas-ke", "mer-ke", "mfe-mu", "mgh-mz", "mgo-cm", "moh-ca", "mua-cm", "mus-us", "myv-ru", "mzn-ir", "naq-na", "nds-de", "nmg-cm", "nnh-cm", "nqo-gn", "nso-za", "nus-ss", "nyn-ug", "osa-us", "pcm-ng", "quc-gt", "rof-tz", "rwk-tz", "sah-ru", "saq-ke", "sbp-tz", "scn-it", "sdh-ir", "seh-mz", "ses-ml", "sid-et", "sma-se", "smj-se", "smn-fi", "sms-fi", "ssy-er", "syr-iq", "szl-pl", "teo-ug", "tig-er", "trv-tw", "trw-pk", "twq-ne", "tzm-ma", "vo-001", "vun-tz", "wae-ch", "wal-et", "wbp-au", "xog-ug", "yav-cm", "yi-001", "zgh-ma", "aa-et", "af-za", "ak-gh", "am-et", "an-es", "as-in", "ba-ru", "be-by", "bg-bg", "bm-ml", "bn-bd", "bo-cn", "br-fr", "ca-es", "ce-ru", "co-fr", "cs-cz", "cu-ru", "cv-ru", "cy-gb", "da-dk", "dv-mv", "dz-bt", "ee-gh", "el-gr", "et-ee", "eu-es", "fa-ir", "fy-nl", "ga-ie", "gd-gb", "gl-es", "gn-py", "gu-in", "gv-im", "ha-ng", "he-il", "hi-in", "hy-am", "id-id", "ig-ng", "ii-cn", "iu-ca", "ja-jp", "jv-id", "ka-ge", "ki-ke", "kk-kz", "kl-gl", "km-kh", "kn-in", "ko-kr", "ku-tr", "kw-gb", "ky-kg", "lb-lu", "lg-ug", "ln-cd", "lo-la", "lt-lt", "lu-cd", "mi-nz", "ml-in", "mr-in", "ms-my", "mt-mt", "my-mm", "nb-no", "nd-zw", "ne-np", "nn-no", "nr-za", "nv-us", "ny-mw", "oc-fr", "om-et", "or-in", "os-ge", "ps-af", "qu-pe", "rm-ch", "rn-bi", "sa-in", "sc-it", "se-no", "sg-cf", "si-lk", "sl-si", "sn-zw", "sq-al", "ss-za", "st-za", "sv-se", "sw-tz", "ta-in", "te-in", "tg-tj", "th-th", "ti-et", "tk-tm", "tn-za", "ts-za", "tt-ru", "ug-cn", "uk-ua", "ur-pk", "ve-za", "vi-vn", "wa-be", "wo-sn", "xh-za", "yo-ng", "zu-za"];
        function Sp(e) {
            return e.lang + (e.script ? "-" + e.script : "") + (e.region ? "-" + e.region : "")
        }
        function Ip(e, t=!1) {
            let i, r, n;
            var e = function(e) {
                let t = 0
                  , i = -1;
                for (var r = []; t < e.length; ++t)
                    if (45 === e.charCodeAt(t)) {
                        const n = e.slice(i + 1, t);
                        r.push(n),
                        i = t
                    }
                if (i < t - 1) {
                    const n = e.slice(i + 1, t);
                    r.push(n),
                    i = t
                }
                return r
            }(e.toLowerCase())
              , a = e.length
              , s = e[0];
            let o = {
                baseName: n = 3 <= a ? 3 < e[2].length ? 3 < e[1].length ? s + "-" + (r = e[1]) : s + "-" + (i = e[1]) : (i = e[2],
                s + "-" + (r = e[1]) + "-" + i) : 2 === a ? 3 < e[1].length ? s + "-" + (r = e[1]) : (i = e[1],
                e[0] + "-" + i) : e[0],
                lang: s,
                script: r,
                region: i
            };
            return o = t ? ((a = o).lang = null == (e = a.lang) ? void 0 : e.toLowerCase(),
            a.script = (e = null != (e = a.script) ? e : "").length ? e[0].toUpperCase() + e.substring(1) : "",
            a.region = null == (e = a.region) ? void 0 : e.toUpperCase(),
            a.lang && (a.baseName = Sp(a)),
            a) : o
        }
        const bp = {}
          , Tp = {
            is3LetterLangCode: e => e in pp,
            toLocale(e, t=!1) {
                let i = {
                    baseName: void 0,
                    lang: void 0,
                    script: void 0,
                    region: void 0
                };
                return e && (r = e.toLowerCase(),
                e = null != (n = hp[r]) ? n : r,
                (i = Ip(e)).baseName = void 0,
                (i = function(t, e) {
                    if ((o = t).lang && o.lang in mp && (o.lang = mp[o.lang]),
                    t = o,
                    e)
                        for (let e = 0; e < fp.length; ++e) {
                            var [i,r] = fp[e]
                              , i = function(e, t) {
                                let i = [];
                                e.baseName = void 0;
                                for (const n in e)
                                    if (Object.prototype.hasOwnProperty.call(e, n)) {
                                        var r = e[n];
                                        if (r !== t[n]) {
                                            i = null;
                                            break
                                        }
                                        r && i.push(n)
                                    }
                                return i
                            }(i, t);
                            if (i && 0 < i.length) {
                                s = a = n = void 0;
                                var n = t
                                  , a = r
                                  , s = i;
                                for (const l in n)
                                    Object.prototype.hasOwnProperty.call(n, l) && s.includes(l) && (n[l] = a[l]);
                                break
                            }
                        }
                    var o;
                    return t
                }(i, t)).lang && Tp.is3LetterLangCode(i.lang) && (i.lang = pp[i.lang]),
                i = Ip(function(t) {
                    for (let e = 0; e < vp.length; ++e)
                        t === vp[e] && (t = t.split("-").slice(0, -1).join("-"));
                    return t
                }(Sp(i = function(e) {
                    for (const t in yp)
                        if (Object.prototype.hasOwnProperty.call(yp, t) && e.region === t) {
                            e.region = yp[t];
                            break
                        }
                    for (const i in gp)
                        if (Object.prototype.hasOwnProperty.call(gp, i) && e.script === i) {
                            e.script = gp[i];
                            break
                        }
                    return e
                }(i))), !0)),
                i;
                var r, n
            },
            shortenLanguageCode(e) {
                if (!e)
                    return "";
                let t = bp[e];
                return null == t && (bp[e] = t = null != (e = null == (e = this.toLocale(e)) ? void 0 : e.baseName) ? e : ""),
                t
            }
        }
          , Ep = {
            isWebkitMediaElement: e => "webkitDroppedFrameCount"in e,
            isHtmlVideoElement: e => "getVideoPlaybackQuality"in e,
            timeRangeToArray(t) {
                var i = [];
                for (let e = 0; e < t.length; e++)
                    i.push([t.start(e), t.end(e)]);
                return i
            }
        };
        function Ap(e) {
            return new pe(he.MEDIA_ERROR,Q.STEERING_MANIFEST_PARSING_ERROR,!1,H.FormatError,e)
        }
        function Op(t) {
            var i = Object.keys(t);
            for (let e = 0; e < i.length; e++) {
                var r = i[e];
                if ("string" != typeof r || "string" != typeof t[r])
                    return Ap(`invalid steering manifest URI-REPLACEMENT item data type, ` + r)
            }
        }
        function Rp(e) {
            return "string" != typeof e ? Ap("invalid steering manifest PATHWAY-PRIORITY list item data type") : /^[\w\-\.]+$/.test(e) ? void 0 : Ap("steering manifest contains invalid pathway ID: " + e)
        }
        function wp(t, i, r, n) {
            let a, s, o;
            n.child({
                name: "content-steering"
            });
            try {
                try {
                    a = JSON.parse(t)
                } catch (t) {
                    throw Ap("steering manifest JSON format is malformed")
                }
                if (null == a)
                    throw Ap("steering manifest is empty");
                if (o = {
                    version: a.VERSION,
                    ttl: a.TTL,
                    universal: a.UNIVERSAL,
                    pathwayPriority: a["PATHWAY-PRIORITY"]
                },
                null != a["RELOAD-URI"]) {
                    if ("string" != typeof a["RELOAD-URI"])
                        throw Ap("invalid steering manifest RELOAD-URI data type");
                    o.reloadURI = es.buildAbsoluteURL(i, a["RELOAD-URI"])
                }
                if (null != a["PATHWAY-CLONES"]) {
                    const t = a["PATHWAY-CLONES"];
                    o.pathwayClones = [];
                    for (let e = 0; e < t.length; e++) {
                        const n = t[e]
                          , a = Object.prototype.hasOwnProperty.call(n, "BASE-ID")
                          , s = Object.prototype.hasOwnProperty.call(n, "ID")
                          , pe = Object.prototype.hasOwnProperty.call(n, "URI-REPLACEMENT");
                        if (!(a && s && pe))
                            throw Ap("invalid steering manifest PATHWAY-CLONE required attributes missing");
                        l = void 0;
                        var l = n;
                        if ("string" != typeof l["BASE-ID"])
                            throw Ap("invalid steering manifest PATHWAY-CLONES list item data type");
                        if ("string" != typeof l.ID)
                            throw Ap("invalid steering manifest PATHWAY-CLONES list item data type");
                        if ("object" != typeof l["URI-REPLACEMENT"])
                            throw Ap("invalid steering manifest URI-REPLACEMENT data type");
                        if (!r.has(n.ID)) {
                            const t = n["URI-REPLACEMENT"]
                              , i = {
                                "BASE-ID": n["BASE-ID"],
                                ID: n.ID,
                                "URI-REPLACEMENT": {}
                            }
                              , a = function(e) {
                                if (e["URI-REPLACEMENT"].HOST && "string" != typeof e["URI-REPLACEMENT"].HOST)
                                    return Ap("invalid steering manifest URI-REPLACEMENT item data type");
                                if (e["URI-REPLACEMENT"].PARAMS && "object" != typeof e["URI-REPLACEMENT"].PARAMS)
                                    return Ap("invalid steering manifest URI-REPLACEMENT item data type");
                                if (e["URI-REPLACEMENT"].PARAMS && "object" == typeof e["URI-REPLACEMENT"].PARAMS) {
                                    var t = Op(e["URI-REPLACEMENT"].PARAMS);
                                    if (null != t)
                                        return t
                                }
                                if (e["URI-REPLACEMENT"]["PER-RENDITION-URIS"] && "object" != typeof e["URI-REPLACEMENT"]["PER-RENDITION-URIS"])
                                    return Ap("invalid steering manifest URI-REPLACEMENT item data type");
                                if (e["URI-REPLACEMENT"]["PER-RENDITION-URIS"] && "object" == typeof e["URI-REPLACEMENT"]["PER-RENDITION-URIS"]) {
                                    t = Op(e["URI-REPLACEMENT"]["PER-RENDITION-URIS"]);
                                    if (null != t)
                                        return t
                                }
                                if (e["URI-REPLACEMENT"]["PER-VARIANT-URIS"] && "object" != typeof e["URI-REPLACEMENT"]["PER-VARIANT-URIS"])
                                    return Ap("invalid steering manifest URI-REPLACEMENT item data type");
                                if (e["URI-REPLACEMENT"]["PER-VARIANT-URIS"] && "object" == typeof e["URI-REPLACEMENT"]["PER-VARIANT-URIS"]) {
                                    t = Op(e["URI-REPLACEMENT"]["PER-VARIANT-URIS"]);
                                    if (null != t)
                                        return t
                                }
                            }(n);
                            if (null != a)
                                throw a;
                            for (const r of ["HOST", "PARAMS", "PER-VARIANT-URIS", "PER-RENDITION-URIS"])
                                "HOST" === r && t[r] ? i["URI-REPLACEMENT"].HOST = t[r] : "PARAMS" !== r && "PER-VARIANT-URIS" !== r && "PER-RENDITION-URIS" !== r || !t[r] || (i["URI-REPLACEMENT"][r] = t[r]);
                            o.pathwayClones.push(i)
                        }
                    }
                }
                const n = function(e) {
                    if ("number" != typeof e.version)
                        return Ap("invalid steering manifest VERSION data type");
                    if (e.version < 1 || 1 < e.version)
                        return Ap("steering manifest VERSION " + e.version + " is unsupported");
                    if ("number" != typeof e.ttl)
                        return Ap("invalid steering manifest TTL data type");
                    if (e.ttl < 0)
                        return Ap("invalid steering manifest TTL value");
                    if (null != e.reloadURI && "string" != typeof e.reloadURI)
                        return Ap("invalid steering manifest RELOAD-URI data type");
                    if (null != e.universal && "boolean" != typeof e.universal)
                        return Ap("invalid steering manifest UNIVERSAL data type");
                    if (!Nt(e.pathwayPriority))
                        return Ap("invalid steering manifest PATHWAY-PRIORITY data type");
                    for (const t of e.pathwayPriority) {
                        const e = Rp(t);
                        if (null != e)
                            return e
                    }
                    return e.pathwayClones && !Nt(e.pathwayClones) ? Ap("invalid steering manifest PATHWAY-CLONES data type") : void 0
                }(o);
                if (null != n)
                    throw n;
                return o
            } catch (t) {
                throw s = t instanceof pe ? t : Ap(`unknown exception when parsing steering manifest: ` + t)
            }
        }
        function Pp(e) {
            return null != e.partTargetDuration
        }
        function Mp(e) {
            return e.every(e => null == e || !1 === e.liveOrEvent)
        }
        function Cp(e) {
            return e.every(e => null == e || e.ptsKnown)
        }
        function kp(e, t) {
            switch (e) {
            case Jh.SendAlternateToPenaltyBox:
                e = Jh.RetryRequest,
                401 !== t && 403 !== t && 407 !== t && t !== H.CorruptStream && t !== H.LivePlaylistUpdateError || (e = Jh.SendEndCallback);
                break;
            case Jh.RemoveAlternatePermanently:
                e = Jh.SendEndCallback
            }
            return e
        }
        function Lp(t, i, r, n, a, s, o, l=!1) {
            if (!re(a))
                return t;
            var d = s.mediaOptionListQueries[a].mediaOptionFromId(n);
            if (!d)
                return t;
            var u = 0 != (t.errorActionFlags & Zh.MoveAllAlternatesMatchingHost)
              , c = o.getFallbackMediaOptionTupleFromMediaOptionId(s, a, n, d.backingMediaOptionId, !1, u, l);
            let {errorAction: h, errorActionFlags: p} = t;
            if (s.isValidMediaOptionTuple(c))
                s.enabledVariantMediaOption && vs(s.enabledVariantMediaOption, c[a]) && (p &= ~Zh.MoveAllAlternatesMatchingHost);
            else {
                i || (h = kp(h, r),
                p = 0);
                const a = null == (c = s.mediaOptionListQueries[se.Variant].mediaOptionListInfo) ? void 0 : c.pathwayPriority;
                let e;
                if (Wa(d))
                    e = d.pathwayID,
                    !0 === d.iframes ? (h = Jh.DoNothing,
                    p = 0) : !i && o.canSwitchToSDR(s, n, u, l) && (h = t.errorAction,
                    p = Zh.SwitchToSDR);
                else {
                    const i = s.enabledMediaOptionIdByType(se.Variant)
                      , r = s.variantMediaOptionById(i);
                    if (!r)
                        return t;
                    e = null == r ? void 0 : r.pathwayID
                }
                if (a && e && o.isContentSteeringEnabled() && a.indexOf(e) < a.length - 1)
                    return h = Jh.SendPathwayToPenaltyBox,
                    p = Zh.SwitchPathway,
                    {
                        errorAction: h,
                        errorActionFlags: p
                    };
                r === H.ContentHasGap && (h = Jh.DoNothing,
                p = 0)
            }
            return {
                errorAction: h,
                errorActionFlags: p
            }
        }
        function Np(e) {
            let t, i = 0;
            switch (e) {
            case 0:
                t = Jh.SendAlternateToPenaltyBox,
                i = Zh.MoveAllAlternatesMatchingHost;
                break;
            case 410:
                t = Jh.RemoveAlternatePermanently;
                break;
            case 500:
            case 502:
            case 503:
            case 504:
            case 404:
            case 409:
            case 401:
            case 403:
            case 407:
            case H.LivePlaylistUpdateError:
            case H.PlaylistNotReceived:
            default:
                t = Jh.SendAlternateToPenaltyBox,
                i = 0
            }
            return {
                errorAction: t,
                errorActionFlags: i
            }
        }
        function Dp(e, t, i, r, n) {
            var a = e.response;
            let s = Np(a);
            var {mediaOptionId: o, mediaOptionType: l} = e;
            return t ? s.errorActionFlags &= ~Zh.MoveAllAlternatesMatchingHost : s = function(e, t, i, r, n) {
                let {errorAction: a, errorActionFlags: s} = t;
                if (e.isTimeout) {
                    const t = e["mediaOptionType"]
                      , o = null != (n = null == (e = n.getErrorInfoByType(t)) ? void 0 : e.timeouts.load) ? n : 0;
                    !i && r <= o && (a = Jh.SendEndCallback,
                    s = 0)
                }
                return {
                    errorAction: a,
                    errorActionFlags: s
                }
            }(e, s, t, i, r),
            s = Lp(s, t, a, o, l, r, n, e.isTimeout),
            e instanceof zs && !e.fatal && (null != (i = n.rtcService) && i.handleLevelLoadError(e.url, r.isInterstitial)),
            s
        }
        function xp(i, r, n, a, s, o, l, d) {
            r.fatal || null == (e = a.rtcService) || e.handleNonFatalError(r, n.isInterstitial);
            var e, {errorAction: u, errorActionFlags: c} = i;
            let t = !0;
            if (null == o || null == l)
                return r.handled = !1;
            switch (u) {
            case Jh.RemoveAlternatePermanently:
            case Jh.SendAlternateToPenaltyBox:
                {
                    const i = n.itemId;
                    let e = l
                      , t = n.mediaOptionListQueries[o].mediaOptionFromId(l);
                    null != t && t.backingMediaOptionId && (e = t.backingMediaOptionId,
                    t = n.mediaOptionListQueries[o].mediaOptionFromId(e));
                    var h = 0 != (c & Zh.MoveAllAlternatesMatchingHost)
                      , p = 0 != (c & Zh.MoveAllAlternatesMatchingHDCP)
                      , m = 0 != (c & Zh.SwitchToSDR)
                      , f = u === Jh.RemoveAlternatePermanently;
                    if (t && p && "hdcpLevel"in t) {
                        const r = null != (p = t.hdcpLevel) ? p : "NONE";
                        a.setMaxHdcpLevel(i, r)
                    }
                    m && a.switchToSDROnly(i, s),
                    h && t ? a.moveAllWithMatchingHosts(i, o, t, f) : f ? a.removePermanently(i, o, e) : a.addToPenaltyBox(i, o, e),
                    n.enabledMediaOptionIdByType(o) === l && (p = [de, de, de],
                    p = a.getFallbackMediaOptionTupleFromMediaOptionId(n, o, l, void 0, m, h, d),
                    n.isValidMediaOptionTuple(p) || (r.fatal = !0),
                    r.fatal || a.setEnabledMediaOptions(n.itemId, p));
                    break
                }
            case Jh.SendPathwayToPenaltyBox:
                {
                    let e = n.mediaOptionListQueries[o].mediaOptionFromId(l);
                    if (!Wa(e)) {
                        const r = n.enabledMediaOptionIdByType(se.Variant);
                        e = n.variantMediaOptionById(r)
                    }
                    Wa(e) && a.addToPathwayPenaltyBox(n.itemId, e),
                    0 != (c & Zh.SwitchPathway) && a.doPathwaySwitch(n.itemId);
                    break
                }
            case Jh.SendEndCallback:
                r.fatal = !0;
                break;
            case Jh.RetryRequest:
            case Jh.DoNothing:
            default:
                t = !1
            }
            r.handled = t
        }
        function Fp(e, t) {
            t instanceof Ws || t instanceof zs || t instanceof Ys || (t instanceof Bo || t instanceof Fo) && f(t.keyuri)
        }
        function Bp(e, t, i, r, n, a) {
            return e.fatal || null == a || a.handleNonFatalError(e, n),
            e.handled = !0,
            i && t < i.maxNumRetry && re(i.retryDelayMs) ? (a = "linear" === i.backoff ? (t + 1) * i.retryDelayMs : Math.pow(2, t) * i.retryDelayMs,
            a = Math.min(i.maxRetryDelayMs, a),
            Fp(0, e),
            yr(a)) : (e.fatal = !0,
            Fp(0, e),
            R( () => e))
        }
        function Up(e, t, i, r, n, a, s, o, l, d=!1) {
            return (null == r ? void 0 : r.errorAction) === Jh.RetryRequest ? Bp(e, t, i, a.logger, n.isInterstitial, a.rtcService) : _p(e, 0, r, n, a, s, o, l, d)
        }
        function _p(e, t, i, r, n, a, s, o, l=!1) {
            var d;
            const u = new mn;
            return i || e.fatal || null == (d = n.rtcService) || d.handleNonFatalError(e, r.isInterstitial),
            ae( () => {
                i && (Fp(n.logger, e),
                xp(i, e, r, n, a, s, o, l)),
                u.error(e)
            }
            ),
            u
        }
        function Vp(e, t, i, r, n, a, s) {
            return _p(e, 0, Lp({
                errorAction: Jh.RemoveAlternatePermanently,
                errorActionFlags: 0
            }, !1, e.response, i, t, a, n), a, n, s, t, i).pipe($(e => {
                throw !1 === e.fatal && r.resetMediaSource(),
                e
            }
            ))
        }
        function Qp(r, n, a=!1) {
            var {discoToMSNMap: s, endSN: o} = r
              , l = Object.keys(s);
            for (let i = 0; i < l.length; i++) {
                var d = +l[i]
                  , u = s[d][0];
                let e = s[d][1];
                if (!a && o < u)
                    return;
                let t = i === l.length - 1;
                if (!a && e > o && (t = !0,
                e = o),
                t) {
                    const a = function(e, t) {
                        var {fragments: e, parts: i, endSN: r} = e;
                        return t <= r ? hc(e, t) : m(i, e => e.mediaSeqNum === t)
                    }(r, e)
                      , c = a && !a.part && (a.isLastFragment || r.liveOrEvent) ? 1 : 0;
                    if ((null == a ? void 0 : a.start) + (null == a ? void 0 : a.duration) + c > n)
                        return d
                } else {
                    const a = Yp(r, s[+l[i + 1]][0]);
                    if ((null == a ? void 0 : a.start) > n)
                        return d
                }
            }
        }
        function Kp(e, t, i) {
            var r = 0 < i.duration
              , n = i.start + i.duration
              , e = null == e || e < n || e - n < 1 && i.isLastFragment
              , n = !re(t) || i.discoSeqNum === t;
            return r && e && n
        }
        function Hp(e, t, i, r=!1) {
            var n = null == (n = i.discoToMSNMap[t]) ? void 0 : n[0]
              , [a,s,o=NaN,l=!1] = [i, Kp.bind(null, e, t), n, r]
              , d = a.fragments;
            for (let e = o > a.startSN ? o - a.startSN : 0; e < d.length; ++e) {
                const a = d[e]
                  , o = a["start"];
                if (s(a))
                    return {
                        timelineOffset: o,
                        mediaFragment: a
                    }
            }
            if (l && null != (l = a.parts) && l.length) {
                const l = a.parts;
                for (let e = 0; e < l.length; ++e)
                    if (!re(o) || l[e].mediaSeqNum >= o) {
                        const o = l[e];
                        if (s(o)) {
                            const a = o["start"];
                            return {
                                timelineOffset: a,
                                mediaFragment: o
                            }
                        }
                    }
            }
            return null
        }
        function jp(e, t, i, r, n, a, s) {
            n = null != n ? n : [],
            o = e;
            var n = Qc.isTimeRangeContainedInRanges(n, {
                start: o.start,
                end: o.start + o.duration
            }) || function(t, e, i, r, n) {
                var a, s, o;
                if (!n)
                    if (t.part) {
                        if (null != i.find(e => jc(t, e.frag) || !e.frag.part && Gc(e.frag, t)))
                            return !0
                    } else {
                        const n = i.find(e => jc(t, e.frag) || e.frag.part && Gc(t, e.frag));
                        if (null != n)
                            return !(!n.frag.part && (a = t,
                            e = e,
                            (s = n).evicting || !s.rebuffered && (a = a,
                            o = s,
                            s = i,
                            i = r,
                            e = e) && re(o.appendEnd) && re(o.appendStart) && ((e = e["end"]) + i < o.appendStart && e >= a.start || (r = a.start + a.duration,
                            e >= o.appendEnd && e <= r) || (r = r > o.appendEnd + i,
                            e >= o.appendStart && e <= o.appendEnd && r && s.some(e => {
                                return t = o.frag,
                                e = e.frag,
                                t.itemId === e.itemId && t.mediaOptionId === e.mediaOptionId && t.mediaSeqNum === e.mediaSeqNum + 1 && t.discoSeqNum === e.discoSeqNum;
                                var t
                            }
                            )) || a.isLastFragment)))
                    }
                return !1
            }(e, i, r, a, s)
              , o = s || !i.len ? t : i.end
              , r = !n && Kp(o, e.discoSeqNum, e);
            return {
                shouldLoad: !n && r,
                alreadyBuffered: n
            }
        }
        function qp(e, t) {
            var i = e.start + e.duration / 2;
            let r = null
              , n = !1;
            for (let e = t.length - 1; 0 <= e && (null == r || !n); --e) {
                var a = t[e];
                !r && a.startPTS < i && a.endPTS > i && (r = a),
                n = n || 0 < a.frag.framesWithoutIDR
            }
            return (null == r ? void 0 : r.frag.mediaOptionId) !== e.mediaOptionId && n
        }
        function Gp(e) {
            var t, i, r, n, a, s, o, l, d, u;
            return e ? ({itemId: e, mediaOptionId: t, mediaSeqNum: i, discoSeqNum: r, iframe: n, start: a, duration: s, mediaOptionType: o, isLastFragment: l, part: d=!1, partIndex: u=NaN} = e,
            {
                itemId: e,
                mediaOptionId: t,
                mediaSeqNum: i,
                discoSeqNum: r,
                iframe: n,
                start: a,
                duration: s,
                mediaOptionType: o,
                isLastFragment: l,
                part: d,
                partIndex: u
            }) : null
        }
        function $p(i, r, n, a, s, o, l, d, u, c=NaN, h=!1) {
            const p = 0 <= a ? 1 : -1;
            let m = null;
            if (!isFinite(c)) {
                const {startSN: c, endSN: b} = i;
                let t = null;
                for (let e = r; e >= c && e <= b && null == m; e += p) {
                    const r = hc(i.fragments, e);
                    if (null != r && r.iframe)
                        f = r,
                        g = Math.max(0, n + s.len * a),
                        y = a,
                        f.iframe && (0 < y && g >= f.start + f.duration || y < 0 && g < f.start) && !(0 < a && r === i.fragments[i.fragments.length - 1]) || (m = r);
                    else if (r) {
                        const {shouldLoad: i, alreadyBuffered: a} = jp(r, n, s, o, l, d, u);
                        a || (t = t || r),
                        i && (m = r)
                    }
                }
                if (!1 === (null == (m = m || !t || !i.liveOrEvent || i.ptsKnown || h && n > Xp(i, !1) && n <= Xp(i, !0) ? m : t) ? void 0 : m.iframe) && !u) {
                    const r = hc(i.fragments, m.mediaSeqNum - p);
                    (null == r ? void 0 : r.discoSeqNum) === m.discoSeqNum && qp(r, o) && (m = r)
                }
            }
            var f, g, y;
            if (h && Jc(a) && !m) {
                var v, S, I = i["parts"];
                let t = null;
                for (let e = 0; e < (null == I ? void 0 : I.length) && null == m; e++) {
                    const h = I[e]
                      , {mediaSeqNum: b, partIndex: p} = h;
                    b < r || b === r && re(c) && p < c || ({shouldLoad: v, alreadyBuffered: S} = jp(h, n, s, o, l, d, u),
                    S || (t = t || h),
                    !(m = v ? h : m) && t && i.liveOrEvent && !i.ptsKnown && (m = t))
                }
            }
            return m
        }
        function Wp(e, t=!1) {
            var i;
            let r = 1 / 0
              , n = (null != (i = e.fragments) && i.length && (r = e.fragments[0].start),
            1 / 0);
            return null != (i = e.parts) && i.length && t && (n = e.parts[0].start),
            re(r) || re(n) ? Math.min(r, n) : 0
        }
        function zp(e, t=!1) {
            var i;
            let r = -1 / 0;
            if (null != (i = e.fragments) && i.length) {
                const t = e.fragments[e.fragments.length - 1];
                r = t.start + t.duration
            }
            let n = -1 / 0;
            if (null != (i = e.parts) && i.length && t) {
                const t = e.parts[e.parts.length - 1];
                n = t.start + t.duration
            }
            return re(r) || re(n) ? Math.max(r, n) : 0
        }
        function Xp(e, t=!1) {
            return zp(e, t) - Wp(e, t)
        }
        function Yp(e, t) {
            var {fragments: e, parts: i, endSN: r} = e;
            return t <= r ? hc(e, t) : 0 < (null == i ? void 0 : i.length) ? hc(i, t, 0) : void 0
        }
        function Jp(e, t, i) {
            return e * i.instantBwDurationFactor * 1e3 / t
        }
        function Zp(e, n, i, a, t, r=!1) {
            var {pos: s, combined: i, playingFrags: o} = i;
            if (!i || 0 === i.len)
                return !1;
            let l = Yc(a) || i.len >= t;
            var i = n["avDetails"]
              , [d,u] = i
              , i = Mp(i);
            let c = zp(d, r)
              , h = (u && (c = Math.min(c, zp(u, r))),
            NaN);
            for (const n of e)
                if (null != n) {
                    h = n.discoSeqNum;
                    break
                }
            if (i)
                l = l || s >= c - t;
            else {
                let e = hc(d.fragments, d.endSN)
                  , t = d.targetduration;
                if (r) {
                    const i = d.parts;
                    null != i && i.length && 0 < (null == i ? void 0 : i.length) && (e = i[i.length - 1]),
                    t = null != (u = d.partTargetDuration) ? u : null == e ? void 0 : e.duration
                }
                const i = e ? e.duration : t;
                l = l && s <= c - (null != i ? i : 0)
            }
            return l = l || o.every( (e, t) => {
                var i, r, t = n.avDetails[t];
                return null == t || null != e && (i = e["discoSeqNum"],
                !(t.discoToMSNMap[i] && (!re(h) || i === h)) || ([i,r] = t.discoToMSNMap[i],
                a < 0 && e.mediaSeqNum === i) || 0 <= a && e.mediaSeqNum === r && (!t.liveOrEvent || e.mediaSeqNum !== t.endSN))
            }
            )
        }
        function em(r, e, t, i) {
            if (!e || !t)
                return NaN;
            let n = null != (e = null == (e = hc(e.fragments, t.mediaSeqNum, t.partIndex)) ? void 0 : e.bitrate) ? e : NaN;
            if (!re(n))
                if (i || t.mediaOptionType === se.AltAudio) {
                    const e = function() {
                        var e = r.audioCodec
                          , t = r.bitrate;
                        if (!t)
                            return NaN;
                        let i = 128e3;
                        return e && (q.isEC3(e) ? i = 768e3 : q.isAC3(e) && (i = 64e4)),
                        Math.min(t / 2, i)
                    }();
                    n = t.mediaOptionType === se.Variant ? r.bitrate - e : e
                } else
                    n = r.bitrate;
            return n
        }
        function tm(e, t, i, r, n, a, s, o=!1) {
            var l = e[i];
            if (!l)
                return 1 / 0;
            var d = l.state;
            let u = l.tstart
              , c = 0;
            switch (d) {
            case "loading":
                c = function(e, t, i, r, n, a=!1) {
                    var s = e[i];
                    if (!s)
                        return 0;
                    var {bwSample: s, duration: o} = s
                      , l = im(s)
                      , o = rm(s, t[i], o)
                      , d = n.avgBandwidth;
                    let u = d
                      , c = 0;
                    if (s && re(null == s ? void 0 : s.tfirst)) {
                        const e = performance.now() - s.tfirst;
                        if (e >= r && 0 < e) {
                            const t = l / e * 1e3;
                            u = a ? t : Math.min(t, d)
                        }
                    } else
                        c += n.avgLatencyMs / 1e3;
                    s = oe.AltAudio - i,
                    l = e[s];
                    if (u === d && null != l && l.bwSample) {
                        const e = t[s]
                          , i = rm(l.bwSample, e, l.duration)
                          , r = Math.min(i, o);
                        c += r / (.5 * u) + (o - r) / u
                    } else
                        c += o / u;
                    return c
                }(e, t, i, r, n, o),
                u = l.tstart + 1e3 * c;
            case "loaded":
            case "parsing":
                c += lc(u, a),
                u = l.tstart + 1e3 * c;
            case "parsed":
            case "appending":
                c += dc(u, s);
                break;
            default:
                c = 1 / 0
            }
            return c
        }
        function im(e) {
            return e && re(null == e ? void 0 : e.loaded) ? 8 * e.loaded : 0
        }
        function rm(e, t, i) {
            return t = t,
            i = i,
            ((r = e) && re(null == r ? void 0 : r.total) ? 8 * r.total : Math.ceil(i * t)) - im(e);
            var r
        }
        function nm(e, t, i, r, n, a, s) {
            var o = r.mediaQuery
              , t = (t = t.child({
                name: "haveEnough"
            }),
            o.getMediaBufferInfo(o.desiredPos, e.maxBufferHole))
              , l = i.enabledVariantMediaOption
              , d = i.enabledAlternateMediaOptionByType(se.AltAudio)
              , u = l ? n.getQueryForOption(l).mediaOptionDetails : null
              , n = null != d && d.url ? n.getQueryForOption(d).mediaOptionDetails : void 0
              , d = o.haveEnough
              , s = null != s ? s : i.getInFlightFrags();
            return l && u && s && (l = {
                variant: l,
                avDetails: i = [u, n]
            },
            u = o.desiredRate,
            n = null != (n = null == (n = s[se.Variant]) ? void 0 : n.duration) ? n : i[se.Variant].targetduration,
            d = !!o.withinFragDurationOfContentGap(o.currentTime, n) || function(g, y, v, S, e, I, b, T) {
                var t;
                const i = S["combined"]
                  , r = null != (t = null == i ? void 0 : i.len) ? t : 0
                  , E = ac(g, v.avDetails[se.Variant], S);
                let n = Zp(y, v, S, e, E);
                if (!n && y.some(e => e)) {
                    const e = y.map( (e, t) => {
                        {
                            var i = y, r = v, n = E, a = S, s = I, o = b, l = T, d = g, u, {sbTuple: c, pos: h} = a, p = d["maxBufferHole"], c;
                            if (null != (c = null == (c = c[t]) ? void 0 : c.buffered) && c.len && c.len >= n)
                                return 0;
                            const {avDetails: m, variant: f} = r;
                            return m[t] ? (r = i[t],
                            c && r && (u = r.start + r.duration) > c.end && (r.start - c.end <= p || r.start <= c.end) && n <= u - h ? 0 === c.len && "appending" === r.state ? 0 : (p = m.map( (e, t) => {
                                return em(f, null != e ? e : void 0, null != (e = i[t]) ? e : void 0, null != m[se.AltAudio])
                            }
                            ),
                            n = Jp(r.duration, a.playbackRate, d),
                            tm(i, p, t, n, s, o, l)) : 1 / 0) : 0
                        }
                    }
                    );
                    n = e.reduce( (e, t) => Math.max(e, t), 0) <= r
                }
                return n
            }(e, s, l, t, u, a.getBandwidthEstimate(e, void 0, !1), a.getFragEstimate(e, void 0, !1), a.getBufferEstimate(e, void 0, !1)),
            r.haveEnough = d),
            d
        }
        (r = Xh = Xh || {})[r.Low = 100] = "Low",
        r[r.Normal = 500] = "Normal",
        r[r.High = 900] = "High",
        (e = Yh = Yh || {}).ContentSteering = "Content Steering",
        e.RateChange = "RateChange",
        e.VariantSwitch = "Variant Switch",
        e.AudioSwitch = "Audio Switch",
        e.SubtitleSwitch = "Subtitle Switch",
        e.RendererSwitch = "RendererSwitch",
        e.Idle = "Idle",
        (rd = Jh = Jh || {})[rd.DoNothing = 0] = "DoNothing",
        rd[rd.SendEndCallback = 1] = "SendEndCallback",
        rd[rd.SendAlternateToPenaltyBox = 2] = "SendAlternateToPenaltyBox",
        rd[rd.RemoveAlternatePermanently = 3] = "RemoveAlternatePermanently",
        rd[rd.InsertDiscontinuity = 4] = "InsertDiscontinuity",
        rd[rd.RetryRequest = 5] = "RetryRequest",
        rd[rd.SendPathwayToPenaltyBox = 6] = "SendPathwayToPenaltyBox",
        (sd = Zh = Zh || {})[sd.DoNothing = 0] = "DoNothing",
        sd[sd.MoveAllAlternatesMatchingHost = 1] = "MoveAllAlternatesMatchingHost",
        sd[sd.MoveAllAlternatesMatchingHDCP = 2] = "MoveAllAlternatesMatchingHDCP",
        sd[sd.SwitchToSDR = 4] = "SwitchToSDR",
        sd[sd.SwitchPathway = 8] = "SwitchPathway";
        const am = {
            minValidBitrate: 2e6,
            maxValidBitrate: 5e6,
            maxPreferredBitrate: 3e6,
            minValidHeight: 480,
            maxValidHeight: 720
        }
          , sm = 3
          , om = 2;
        function lm(e, t) {
            let i = sm * e.targetduration;
            return e.serverControls && re(e.serverControls.holdBack) && (i = Math.max(i, e.serverControls.holdBack)),
            re(t.liveSyncDuration) ? i = Math.max(i, t.liveSyncDuration) : re(t.liveSyncDurationCount) && (i = Math.max(i, t.liveSyncDurationCount * e.targetduration)),
            i
        }
        function dm(e) {
            let t = om * e.partTargetDuration;
            return t = re(t) && e.serverControls && re(e.serverControls.partHoldBack) ? Math.max(t, e.serverControls.partHoldBack) : t
        }
        function um(e, t) {
            let i = lm(e, t);
            t = t["liveAllowLowLatencyPlayback"];
            if (t && Pp(e)) {
                const t = dm(e);
                re(t) && (i = t)
            }
            return Math.max(e.fragments[0].start, zp(e, t) - i)
        }
        function cm(e, t) {
            var i = Wp(e, t.liveAllowLowLatencyPlayback)
              , r = zp(e, t.liveAllowLowLatencyPlayback)
              , t = um(e, t);
            return {
                start: i,
                end: r,
                edge: t,
                boundary: Math.max(0, t - 2 * e.targetduration)
            }
        }
        function hm(e, t) {
            var i = cm(e[se.Variant], t)
              , r = e[se.AltAudio];
            if (r) {
                const e = cm(r, t);
                i.start = Math.max(i.start, e.start),
                i.end = Math.max(i.start, Math.min(i.end, e.end)),
                i.edge = Math.max(i.start, Math.min(i.edge, e.edge)),
                i.boundary = Math.min(i.boundary, e.boundary)
            }
            return i
        }
        function pm(e, t, i) {
            t = hm(t, i);
            return Math.max(t.start, Math.min(t.edge, e))
        }
        function mm(e, t, i) {
            return !(e.start > t.end + i || e.end < t.start - i)
        }
        function fm() {
            return [new Lu({
                name: "Remove Filter",
                priority: 0,
                filterFn: (t, e, i) => !i || i.removed.every(e => t.mediaOptionId !== e)
            }), new Lu({
                name: "Penalty Box Filter",
                priority: 1,
                filterFn: (t, e, i) => {
                    const r = performance.now();
                    return !i || i.penaltyBoxQueue.every(e => e.expiry <= r || t.mediaOptionId !== e.id)
                }
            }), new Lu({
                name: "Compatible IDs Filter",
                priority: 1,
                filterFn: (t, e, i) => !i || null == i.compatibleIds || i.compatibleIds.some(e => e === t.mediaOptionId)
            })]
        }
        class gm extends ja {
            constructor(e, t, i) {
                super(e),
                this.itemId = t,
                this.mediaOptionType = i,
                this.ta = [],
                this.allowFilters = this._initFilters()
            }
            get mediaOptionList() {
                var e;
                return (null == (e = this.mediaOptionListInfo) ? void 0 : e.mediaOptions) || null
            }
            get mediaOptionList$() {
                return this.mediaOptionListInfo$.pipe(W( ({mediaOptions: e}) => e))
            }
            mediaOptionFromId(t) {
                return this.mediaOptionList.find(e => e.mediaOptionId === t)
            }
            get hasOptionWithUrl() {
                var e;
                return this.mediaOptionList && null == this.ea && (this.ea = this.mediaOptionList.some(xs)),
                null != (e = this.ea) && e
            }
            _getFilteredList(e) {
                return Nu(e.mediaOptions, this.allowFilters, e)
            }
            _infoChanged(i) {
                var e = this._cachedInfo;
                return null != e && null == i || null == e && null != i || e && i && (e.mediaOptions !== i.mediaOptions || e.penaltyBoxQueue.length !== i.penaltyBoxQueue.length || e.penaltyBoxQueue.some( (e, t) => i.penaltyBoxQueue[t] !== e) || e.removed.length !== i.removed.length || e.removed.some( (e, t) => i.removed[t] !== e) || e.compatibleIds !== i.compatibleIds)
            }
            dispose() {
                this._cachedInfo = void 0,
                this.ta = []
            }
            get filteredMediaOptionList() {
                const t = performance.now();
                var e, i;
                return this.mediaOptionListInfo ? ({penaltyBoxQueue: i, removed: e} = this.mediaOptionListInfo,
                i = i.filter(e => !(e.expiry <= t)),
                i = Object.assign(Object.assign({}, this.mediaOptionListInfo), {
                    penaltyBoxQueue: i,
                    removed: e.slice()
                }),
                this._infoChanged(i) && (this._cachedInfo = i,
                this.ta = this._getFilteredList(this.mediaOptionListInfo))) : (this._cachedInfo = void 0,
                this.ta = []),
                this.ta
            }
            getFilteredMediaOptionList$(e=!1) {
                return (e ? this.mediaOptionListInfo$.pipe(On(1)) : this.mediaOptionListInfo$).pipe(te(e => {
                    var t = [ue]
                      , i = performance.now();
                    for (const r of e.penaltyBoxQueue)
                        re(r.expiry) && r.expiry > i && t.push(yr(r.expiry - i));
                    return ne(...t).pipe(W( () => this.filteredMediaOptionList))
                }
                ), J( (e, i) => e === i || (null == e ? void 0 : e.length) === (null == i ? void 0 : i.length) && (null == e ? void 0 : e.every( (e, t) => e === i[t]))))
            }
            triggerPenaltyBoxExpiry(e) {
                var t = []
                  , i = performance.now();
                for (const r of e)
                    re(r.expiry) && r.expiry > i && t.push(yr(r.expiry - i));
                const r = Y(e)
                  , n = ne(...t).pipe(W( () => e));
                return ne(r, n).pipe(W(e => e.filter(e => !(e.expiry <= performance.now()))))
            }
            get penaltyBoxChanged$() {
                return this.mediaOptionListInfo$.pipe(te(e => this.triggerPenaltyBoxExpiry(e.penaltyBoxQueue)), _n())
            }
            get removedListChanged$() {
                return this.mediaOptionListInfo$.pipe(W(e => null == e ? void 0 : e.removed), _n())
            }
            get compatibleIdsListChanged$() {
                return this.mediaOptionListInfo$.pipe(W(e => null == e ? void 0 : e.compatibleIds), _n())
            }
            get commonFilterParamChanges$() {
                return ma([this.penaltyBoxChanged$, this.removedListChanged$, this.compatibleIdsListChanged$])
            }
        }
        function ym(e) {
            return "PQ" === e.videoRange || "HLG" === e.videoRange
        }
        (t = ep = ep || {})[t.Better = 1] = "Better",
        t[t.Same = 0] = "Same",
        t[t.Worse = -1] = "Worse";
        class vm extends gm {
            constructor(e, t) {
                super(e, t, se.Variant)
            }
            static makeFilters() {
                return [...fm().concat([new Lu({
                    name: "HDR Filter",
                    priority: 1,
                    filterFn: (e, t, i) => !i || (i.hasHdrLevels && i.preferHDR) === ym(e)
                }), new Lu({
                    name: "Viewport Filter",
                    priority: 1,
                    firstPassFn: (e, t, i) => {
                        if (i && e && !e.iframes && e.videoCodec) {
                            const t = !i.lowestBitrate || e.bitrate < i.lowestBitrate ? e.bitrate : i.lowestBitrate;
                            i.lowestBitrate = t
                        }
                    }
                    ,
                    filterFn: (e, t, i) => !(e && i && i.viewportInfo && e.videoCodec && i.lowestBitrate) || Xu({
                        width: e.width,
                        height: e.height
                    }, i.viewportInfo) || e.bitrate === i.lowestBitrate
                }), new Lu({
                    name: "HDCP Filter",
                    priority: 2,
                    filterFn: (e, t, i) => !i || !Cu(i.maxHdcpLevel) || ku(e.hdcpLevel) < ku(i.maxHdcpLevel)
                })])].sort( (e, t) => {
                    return (null != (e = e.priority) ? e : Number.MAX_SAFE_INTEGER) - (null != (e = t.priority) ? e : Number.MAX_SAFE_INTEGER)
                }
                )
            }
            _initFilters() {
                return vm.kAllowFilters
            }
            get mediaOptionListInfo() {
                var e;
                return null != (e = null == (e = this.getEntity(this.itemId)) ? void 0 : e.mediaOptionListTuple[se.Variant]) ? e : null
            }
            get mediaOptionListInfo$() {
                return this.selectEntity(this.itemId, e => {
                    return null == (e = null == e ? void 0 : e.mediaOptionListTuple) ? void 0 : e[se.Variant]
                }
                ).pipe(Kl())
            }
            _infoChanged(i) {
                var e, t = this._cachedInfo;
                return super._infoChanged(i) || null != t && null != i && (t.hasHdrLevels !== i.hasHdrLevels || t.preferHDR !== i.preferHDR || t.maxHdcpLevel !== i.maxHdcpLevel || (null == (e = t.viewportInfo) ? void 0 : e.height) !== (null == (e = i.viewportInfo) ? void 0 : e.height) || (null == (e = t.viewportInfo) ? void 0 : e.width) !== (null == (e = i.viewportInfo) ? void 0 : e.width) || t.hasScore !== i.hasScore || (null == (e = t.pathwayPriority) ? void 0 : e.length) !== (null == (e = i.pathwayPriority) ? void 0 : e.length) || (null == (e = t.pathwayPriority) ? void 0 : e.some( (e, t) => i.pathwayPriority[t] !== e))) || t.pathwayPenaltyBox.length !== i.pathwayPenaltyBox.length || t.pathwayPenaltyBox.some( (e, t) => i.pathwayPenaltyBox[t] !== e)
            }
            get hdrMode$() {
                return this.mediaOptionListInfo$.pipe(W(e => !0 === e.preferHDR && e.hasHdrLevels), J())
            }
            get maxHdcpLevel$() {
                return this.selectEntity(this.itemId, e => {
                    e = null == (e = null == e ? void 0 : e.mediaOptionListTuple) ? void 0 : e[se.Variant];
                    return null == e ? void 0 : e.maxHdcpLevel
                }
                ).pipe(J())
            }
            get viewportInfo$() {
                return this.selectEntity(this.itemId, e => {
                    e = null == (e = null == e ? void 0 : e.mediaOptionListTuple) ? void 0 : e[se.Variant];
                    return null == e ? void 0 : e.viewportInfo
                }
                ).pipe(Kl(), J( (e, t) => e.width === t.width && e.height === t.height))
            }
            get pathwayPenaltyBoxChanged$() {
                return this.selectEntity(this.itemId, e => e.mediaOptionListTuple[se.Variant].pathwayPenaltyBox).pipe(te(e => this.triggerPenaltyBoxExpiry(e = null != e ? e : [])), _n())
            }
            listFallbackVariants(t, e, i, r, n, a=void 0) {
                var s, o = this.mediaOptionListInfo, l = null == (l = this.mediaOptionList) ? void 0 : l.find(e => e.mediaOptionId === t);
                return l && o ? (e = this.ia(l, e, a)).length < 1 ? e : ({hasScore: o, pathwayPriority: s} = o,
                vm._listFallbackVariants(e, l, o, s, n, i, r, a)) : []
            }
            ia(e, t, i=void 0) {
                if (!e || !this.mediaOptionList || !this.mediaOptionListInfo)
                    return [];
                e = Object.assign({}, this.mediaOptionListInfo);
                t && (e.compatibleIds = null,
                e.preferHDR = !1);
                let r = Nu(Array.from(this.mediaOptionList), this.allowFilters, e);
                return r.length < 1 || i && 0 < i.length && (r = r.filter(e => !i.includes(e.mediaOptionId))),
                r
            }
            get hasIframes() {
                return this.filteredMediaOptionList.some(e => e.iframes)
            }
            static _listFallbackVariants(e, n, t, i, r, a, s=!1, o=null) {
                let l = !1;
                const d = [];
                e.forEach(e => {
                    var t, i = !(e.iframes !== n.iframes || a && vs(n, e)), r = (t = e,
                    r = n.stableVariantID && t.stableVariantID === n.stableVariantID,
                    s ? !r && t.bitrate < n.bitrate : r || t.bitrate <= n.bitrate || Math.abs(t.bitrate - n.bitrate) <= 1 || d.some(e => Math.abs(t.bitrate - e.bitrate) <= 1)), i = i && r;
                    n.mediaOptionId !== e.mediaOptionId ? i && d.push(e) : l = i
                }
                );
                [e,{hasScore: t, pivotVariant: i, pathwayPriority: r, enableSteering: u, preferHostOverQuality: c, preferCloseToPivotQuality: h}] = [d, {
                    pivotVariant: n,
                    hasScore: t,
                    pathwayPriority: i,
                    enableSteering: r,
                    preferHostOverQuality: !1,
                    preferCloseToPivotQuality: !0
                }],
                (p = [...e]).sort(Zu(e.length, {
                    hasScore: t,
                    pivotVariant: i,
                    pathwayPriority: r,
                    enableSteering: u,
                    preferHostOverQuality: c,
                    preferCloseToPivotQuality: h
                }));
                var u, c, h, p, e = p;
                return !l || o && o.includes(n.mediaOptionId) || e.push(n),
                e
            }
            getMatchingVariant(e, t) {
                var i, r, n = this.mediaOptionFromId(e), a = t.mediaOptionType === se.AltAudio ? "audioAlternates" : "subtitleAlternates";
                let s = null;
                this.mediaOptionListInfo.hasScore;
                for (const e of this.filteredMediaOptionList)
                    if ((e[a] && 0 < e[a].length ? e[a][0].groupId : void 0) === t.groupId) {
                        if (!n) {
                            s = e;
                            break
                        }
                        o = n,
                        i = e;
                        var o = !(r = s) || i.bitrate > r.bitrate && i.bitrate <= o.bitrate ? ep.Better : i.bitrate === r.bitrate ? ep.Same : ep.Worse;
                        o !== ep.Better && (o !== ep.Same || s.mediaOptionId === n.mediaOptionId || e.mediaOptionId !== n.mediaOptionId && !vs(n, e)) || (s = e)
                    }
                return s
            }
        }
        vm.kAllowFilters = vm.makeFilters();
        const Sm = {
            name: "abr"
        };
        function Im(e) {
            return re(null == e ? void 0 : e.avgBandwidth)
        }
        function bm(e) {
            return 0 !== e.playbackRate ? Math.abs(e.playbackRate) : 1
        }
        function Tm(e, t) {
            return e.getCurrentWaterLevelByType(oe.Variant, t) / bm(e)
        }
        function Em(t, i, e, r) {
            if (e)
                return t;
            let n = -1;
            if (!(t < 0))
                for (let e = t; e < i.length; ++e) {
                    const t = Rm(i[e], r);
                    if (t.altAudio && t.subtitle) {
                        n = e;
                        break
                    }
                }
            return n
        }
        function Am(t, e, i, r, n) {
            if (r.enableBoss && e) {
                const a = i ? os.ABRIframe : os.ABR
                  , s = e.getQuery(t.itemId, n).variantsFor(a)
                  , o = t.rootPlaylistEntity.mediaOptionListTuple[se.Variant];
                return s.sort(Zu(s.length, {
                    hasScore: o.hasScore,
                    pivotVariant: t.enabledVariantMediaOption,
                    pathwayPriority: o.pathwayPriority,
                    enableSteering: r.enableContentSteering,
                    preferHostOverQuality: !0,
                    preferCloseToPivotQuality: !1
                })),
                s
            }
            const a = t.enabledVariantMediaOption
              , s = t.mediaOptionListQueries[se.Variant].filteredMediaOptionList.filter(e => e.iframes === i);
            let o = s.filter(e => vs(a, e))
              , l = (i && !o.length && (o = null != t.currentPathwayID ? s.filter(e => ys(e.pathwayID, t.currentPathwayID)) : s),
            0);
            const d = t.nextMinAutoOptionId;
            if (d !== de.mediaOptionId) {
                const t = o.findIndex(e => e.mediaOptionId === d);
                0 <= t && (l = t)
            }
            if ((l = Em(l, o, i, t)) < 0)
                return [];
            let u = o.length - 1;
            const c = t.nextMaxAutoOptionId;
            if (c !== de.mediaOptionId) {
                const t = o.findIndex(e => e.mediaOptionId === c);
                0 <= t && (u = t)
            }
            e = Math.max(0, Math.min(o.length - 1, u)),
            n = Math.max(0, Math.min(o.length - 1, l));
            return o.slice(n, e + 1)
        }
        function Om(e, t, i, r, n, a, s, o) {
            var s = Am(i, s, e, t, o)
              , o = i.variantMediaOptionById(r.mediaOptionId)
              , l = r.mediaOptionDetails
              , o = (null == o ? void 0 : o.iframes) !== e ? 0 : Tm(n, t.maxBufferHole);
            let d, u;
            if (e) {
                const e = t.desiredIframeFPS;
                u = l ? l.targetduration / e : 0,
                u = Math.max(1 / e, u)
            } else
                u = l ? l.targetduration : 0;
            var c = t.abrBandWidthUpFactor
              , h = t.abrBandWidthFactor
              , p = mc(t.liveAllowLowLatencyPlayback, n.isPlayingAtLive, null != (p = null == (p = null == l ? void 0 : l.parts) ? void 0 : p.length) ? p : 0) && Pp(l) ? Math.min(dm(l) / t.liveSyncDurationCount, o) : o;
            return (d = Mm(s, 0, p, e, a.getCombinedEstimate(t, void 0, !1), a.bandwidthStatus, h, c, t, i, r, n)).variantMediaOption === de.mediaOptionId && (d = Mm(s, 0, p + sc(u, t.maxStarvationDelay), e, a.getCombinedEstimate(t, void 0, !1), a.bandwidthStatus, h, c, t, i, r, n)).variantMediaOption === de.mediaOptionId && 0 < s.length && (d.variantMediaOption = s[0].mediaOptionId,
            d.alternates = e ? void 0 : Rm(s[0], i)),
            d
        }
        function Rm(e, t) {
            var i = t.enabledMediaOptionKeys
              , r = i[se.AltAudio]
              , r = Ds(r) ? t.mediaOptionListQueries[se.AltAudio].getMatchingAlternate(r.mediaOptionId, e) : de
              , i = i[se.Subtitle];
            return {
                altAudio: r,
                subtitle: Ds(i) ? t.mediaOptionListQueries[se.Subtitle].getMatchingAlternate(i.mediaOptionId, e) : de
            }
        }
        const wm = 4
          , Pm = 1.8;
        function Mm(e, i, B, U, _, V, Q, K, t, H, j, q) {
            t.abrAlgorithm;
            {
                var r = e, G = B, n = U, a = _, s = V, o = Q, l = K, d = t, u = H, c = (e = j,
                q), h, p, m, f;
                const E = s.bandwidthSampleCount
                  , A = u.abrStatus
                  , O = c.maxBufferSize
                  , $ = d.minTargetDurations || 1
                  , R = u.mediaOptionListQueries[se.Variant].mediaOptionListInfo
                  , W = null != (h = null == R ? void 0 : R.hasScore) && h;
                if (!r.length)
                    return {
                        variantMediaOption: de.mediaOptionId,
                        holdOffDuration: -1
                    };
                const w = u.enabledMediaOptionIdByType(se.Variant)
                  , P = u.variantMediaOptionById(w)
                  , z = null != r.find(e => e.mediaOptionId === w)
                  , M = P && P.iframes === n
                  , C = P && M ? P.score : void 0
                  , k = P && M ? P.frameRate : void 0
                  , L = P && M ? P.height : void 0
                  , N = M ? Tm(c, d.maxBufferHole) : 0
                  , X = c.getMediaBufferInfo(c.desiredPos, d.maxBufferHole)
                  , D = mc(d.liveAllowLowLatencyPlayback, c.isPlayingAtLive, null != (f = null == (m = null == (p = e.mediaOptionDetails) ? void 0 : p.parts) ? void 0 : m.length) ? f : 0)
                  , x = e.mediaOptionDetailsEntityRecord
                  , Y = Cm(a.avgBandwidth, l, o, E);
                let i;
                for (let e = r.length - 1; 0 <= e; e--) {
                    const o = r[e];
                    let t = o.mediaOptionId;
                    const c = o.score
                      , F = x && x[t] ? x[t].mediaOptionDetails : void 0
                      , J = x && x[t] ? x[t].lastUpdateMillis : null
                      , h = pc(F, d, D)
                      , p = null != P && o.bitrate > P.bitrate
                      , m = null != P && o.bitrate < P.bitrate
                      , f = o.frameRate
                      , E = o.height
                      , R = !(null != k && re(f) && (p && f < k || m && f > k))
                      , Z = !(p && null != L && re(E) && L > E)
                      , ee = !(m && (o.bitrate === P.bitrate - 1 || o.bitrate === P.bitrate + 1))
                      , te = !(W && p && null != C && re(c) && (c < C || c === C && P && o.bitrate >= P.bitrate))
                      , ie = o.iframes === n;
                    if (re(h) && ie && R && Z && ee && te) {
                        let e;
                        var g = !n
                          , {adjustedbw: y, adjustedBitrate: v, fetchDuration: S, rejectLevelDueToPeakBW: I, canFitMultipleSegments: b, validFlowRate: T} = (g && ((e = Rm(o, u)).altAudio && e.subtitle || (e = void 0)),
                        function(e, t, i, r, n, a, s, o, l, d, u, c, h) {
                            var s = s ? d.bwUp : d.bwDown
                              , d = e["trickPlaybackConfig"]
                              , p = ic(t, d)
                              , m = pc(i, e, u)
                              , {totalTime: e, avgTime: i} = nc(e, t, i, u, l, n, h, o)
                              , u = ic({
                                bitrate: t.bandwidth,
                                iframes: t.iframes,
                                frameRate: t.frameRate
                            }, d);
                            return {
                                adjustedbw: s,
                                adjustedBitrate: p,
                                fetchDuration: e,
                                rejectLevelDueToPeakBW: p < s && s < u && r <= 2 * m,
                                canFitMultipleSegments: a * ((u || t.bitrate || 0) * m) / 8 <= c,
                                validFlowRate: i <= m && (2 * m <= r || e < .5 * r || e < m)
                            }
                        }(d, o, F, N, X, $, p, (null == P ? void 0 : P.mediaOptionId) !== o.mediaOptionId, a, Y, D, O, J));
                        if ((n || g && Boolean(e)) && (i = t),
                        v < y && b && !I && T && (!g || Boolean(e)) && (n || !S || S < G)) {
                            if (A && (b = y,
                            I = A,
                            T = (T = s).instantBw,
                            I.fragDownloadSlow || I.fragDownloadTooSlow || re(T) && T < b) && z && M)
                                if (N <= 2 * h && p)
                                    t = w;
                                else if (p && l * s.instantBw < v)
                                    continue;
                            return {
                                variantMediaOption: t,
                                holdOffDuration: S,
                                alternates: e,
                                lowestCandidate: i
                            }
                        }
                    }
                }
                return {
                    variantMediaOption: de.mediaOptionId,
                    holdOffDuration: -1,
                    lowestCandidate: i
                }
            }
        }
        function Cm(e, t, i, r) {
            let n, a;
            return r >= wm ? (n = e * t,
            a = e * i) : n = a = e / Pm,
            {
                bwUp: n,
                bwDown: a
            }
        }
        function km(t, e) {
            let i = 1 / 0;
            if (t !== de.mediaOptionId) {
                var r = e.find(e => e.mediaOptionId === t);
                if (!r)
                    return 1 / 0;
                const n = r.iframes
                  , a = r.bitrate
                  , s = r.frameRate
                  , o = e.find(e => e.iframes === n && (void 0 === s || !re(e.frameRate) || e.frameRate >= s) && e.bitrate > a);
                o && (i = o.bitrate)
            }
            return i
        }
        function Lm(e) {
            return "loading" === (null == e ? void 0 : e.state) && re(null == (e = e.bwSample) ? void 0 : e.trequest)
        }
        function Nm(e, t) {
            e.fragDownloadSlow = t.fragDownloadSlow || e.fragDownloadSlow,
            e.fragDownloadTooSlow = t.fragDownloadTooSlow || e.fragDownloadTooSlow
        }
        const Dm = 2e3
          , xm = 1e3
          , Fm = 100
          , Bm = 25;
        function Um(e, t, i, r) {
            let {fragDownloadSlow: n, fragDownloadTooSlow: a} = t;
            t = i.variantMediaOptionById(e.mediaOptionId),
            i = null == t ? void 0 : t.bitrate,
            t = e.bwSample,
            r = r.child(Sm),
            r = function(e, t, i) {
                let r = 0;
                i = re(t) ? Math.round(i * t / 8) : null;
                return e && (re(e.total) ? r = e.total : re(e.loaded) && re(i) ? r = Math.max(e.loaded, i) : re(e.loaded) ? r = e.loaded : re(i) && (r = i)),
                r
            }(t, i, e.duration),
            i = t && t.complete ? t.tload : performance.now(),
            i = t && re(t.tfirst) ? i - t.tfirst : 0,
            t = t && re(t.loaded) && 0 < r ? t.loaded * e.duration * 1e3 / r : 0;
            return (e.part && i >= Fm && i - t >= Bm || i >= Dm && i - t >= xm) && (n = !0),
            i >= 1e3 * e.duration && (a = !0),
            {
                fragDownloadSlow: n,
                fragDownloadTooSlow: a
            }
        }
        function _m(e, t, i) {
            var {rootPlaylistService: r, rootPlaylistQuery: n} = i
              , e = Vm(e, t, i);
            return e && r.setEnabledMediaOptions(n.itemId, e),
            null != e
        }
        function Vm(e, t, i) {
            var r, n, {rootPlaylistService: i, mediaSink: a, rootPlaylistQuery: p, statsService: s, config: o, mediaLibraryService: l, mediaSelectionBossService: m} = i, a = a.mediaQuery, l = l.getQueryForOption(t), f = i.logger.child(Sm), t = a.isIframeRate, d = p.enabledMediaOptionKeys[se.Variant];
            if (e === ds.None)
                return null;
            if (t && e !== ds.IframeModeChange && a.getBufferedSegmentsByType(oe.Variant).filter(e => e.frag.iframe).length < o.minFramesBeforeSwitchingLevel)
                return null;
            var s = s.getQueryForId(null != (s = p.statsId) ? s : "")
              , u = [de, de, de];
            if (e === ds.IframeModeChange) {
                const e = p.enabledMediaOptionsBeforeTrickplay;
                if (i.saveEnabledOptionsForTrickplay(p.itemId, t),
                !t && e) {
                    const t = function(e, t, i) {
                        const r = Am(p, m, !1, t, f)
                          , n = t.targetStartupMs
                          , a = {
                            avgPlaylistParseTimeMs: 0,
                            avgPlaylistLoadTimeMs: 0
                        }
                          , s = i.getFragEstimate(t)
                          , o = {
                            avgBufferCreateMs: 0,
                            avgInitFragAppendMs: 0,
                            avgDataFragAppendMs: 0
                        }
                          , l = s.maxDurationSec
                          , d = i.getBandwidthEstimate(t)
                          , u = {
                            targetDuration: l,
                            targetStartupMs: n,
                            metricsOverride: {
                                maxValidHeight: 0,
                                maxValidBitrate: 0,
                                maxPreferredBitrate: 0
                            },
                            enableBoss: t.enableBoss,
                            enableContentSteering: t.enableContentSteering
                        }
                          , c = r.filter(e => !e.iframes && (!e.width || !e.height || e.width * e.height <= 2488320));
                        let h = e;
                        0 < c.length && (h = c[0].mediaOptionId);
                        i = c.filter(e => Ku(e, d, u, a, s, o));
                        return h = 0 < i.length ? i[i.length - 1].mediaOptionId : h
                    }(e[se.Variant].mediaOptionId, o, s);
                    if (t) {
                        i.setNextMaxAutoOptionId(p.itemId, t);
                        const e = p.variantMediaOptionById(t);
                        null != m && m.setTransformer(p.itemId, le.BitrateFilter, new Nc(0,null != (r = null == e ? void 0 : e.bitrate) ? r : 0))
                    }
                }
            }
            var c = function(t, i, r, n, a, s, o, l) {
                var e, d, u = i.nextMaxAutoOptionId, c = null != (c = null == (c = i.abrStatus) ? void 0 : c.fragDownloadTooSlow) && c;
                if (u === de.mediaOptionId || !c && Im(s.getBandwidthEstimate(t)))
                    return c = t,
                    t = i,
                    n = n,
                    e = a,
                    s = s,
                    o = o,
                    l = l.child({
                        name: "abr"
                    }),
                    d = e.isIframeRate,
                    t.enabledMediaOptionIdByType(se.Variant),
                    Om(d, c, t, n, e, s, o, l);
                if (a.isIframeRate)
                    return {
                        variantMediaOption: u,
                        holdOffDuration: 0,
                        alternates: void 0
                    };
                {
                    const t = i.variantMediaOptionById(u)
                      , n = i.enabledAlternateMediaOptionByType(se.Subtitle)
                      , a = i.enabledAlternateMediaOptionByType(se.AltAudio)
                      , s = null == a ? void 0 : a.persistentID
                      , o = null == n ? void 0 : n.persistentID
                      , l = !i.preferHDR;
                    let e;
                    return (e = t ? r.getBestMediaOptionTupleFromVariantAndPersistentId(i, t, s, o, void 0, [], void 0, l, !1, !1, !1) : e) && i.isValidMediaOptionTuple(e) ? {
                        variantMediaOption: e[se.Variant].mediaOptionId,
                        holdOffDuration: 0,
                        alternates: {
                            altAudio: e[se.AltAudio],
                            subtitle: e[se.Subtitle]
                        }
                    } : {
                        variantMediaOption: i.enabledMediaOptionKeys[se.Variant].mediaOptionId,
                        holdOffDuration: 0
                    }
                }
            }(o, p, i, l, a, s, m, f);
            if (t || e !== ds.IframeModeChange || (i.setNextMaxAutoOptionId(p.itemId, de.mediaOptionId),
            null == m) || m.removeTransformer(p.itemId, le.BitrateFilter),
            c.variantMediaOption === d.mediaOptionId)
                return null;
            u[se.Variant] = {
                itemId: p.itemId,
                mediaOptionId: c.variantMediaOption
            };
            for (const e of [se.AltAudio, se.Subtitle]) {
                const t = p.enabledMediaOptionIdByType(e);
                if (t !== de.mediaOptionId) {
                    const i = e === se.AltAudio ? null == (n = c.alternates) ? void 0 : n.altAudio : null == (n = c.alternates) ? void 0 : n.subtitle;
                    u[e] = i || {
                        itemId: p.itemId,
                        mediaOptionId: t
                    }
                }
            }
            return u
        }
        function Qm(e) {
            return 1e3 * (e.averagetargetduration || e.targetduration)
        }
        function Km(e, t) {
            var i;
            return e.liveOrEvent && (null != (i = e.serverControls) && i.canBlockReload || (i = Qm(e),
            performance.now() - t >= i))
        }
        function Hm(e, t) {
            return null == e || t.endSN !== e.endSN || t.liveOrEvent !== e.liveOrEvent
        }
        function jm(e, t) {
            return null == e || e.partEndSN !== t.partEndSN || e.partEndIndex !== t.partEndIndex
        }
        const qm = {
            NONE: "",
            "AES-128": "",
            "ISO-23001-7": "",
            "SAMPLE-AES": "",
            "SAMPLE-AES-CTR": ""
        }
          , Gm = {
            getRichestVideoCodec(e) {
                if (e && e.length)
                    return e && B(e, gc)
            },
            getRichestAudioCodec(e) {
                if (e && e.length)
                    return e && B(e, vc)
            },
            getAlternateWithRichestChannelLayoutForGroupId(e) {
                if (e && e.length)
                    return B(null != e ? e : [], e => q.getChannelCount(e.channels))
            }
        };
        class $m {
            constructor() {
                this.na = null,
                this.ra = null,
                this.relurl = "",
                this.baseurl = null,
                this.isInitSegment = !1,
                this.mediaSeqNum = NaN,
                this.discoSeqNum = NaN,
                this.iframe = !1,
                this.bitrate = NaN,
                this.start = NaN,
                this.duration = NaN,
                this.lastByteRangeEndOffset = NaN,
                this.gap = !1,
                this.part = !1,
                this.partIndependent = !1,
                this.partGap = !1,
                this.partIndex = NaN,
                this.iframe = !1
            }
            getMediaFragment(e, t, i) {
                i = {
                    mediaOptionType: i,
                    relativeUrl: this.relurl,
                    start: this.start,
                    duration: this.duration,
                    mediaSeqNum: this.mediaSeqNum,
                    discoSeqNum: this.discoSeqNum,
                    mediaOptionId: t,
                    itemId: e,
                    isLastFragment: !1,
                    isInitSegment: this.isInitSegment,
                    gap: this.gap
                };
                return this.part && (i.part = this.part,
                i.partIndependent = this.partIndependent,
                i.partGap = this.partGap,
                i.partIndex = this.partIndex),
                null != (t = this.byteRange) && t.length && re(this.byteRangeStartOffset) && re(this.byteRangeEndOffset) && (i.byteRangeOffset = {
                    start: this.byteRangeStartOffset,
                    end: this.byteRangeEndOffset
                }),
                this.iframe && (i.iframe = this.iframe),
                this.levelkey && (i.keyTagInfo = this.levelkey),
                this.programDateTime && (i.programDateTime = this.programDateTime),
                re(this.bitrate) && (i.bitrate = this.bitrate),
                i
            }
            get programDateTime() {
                return !this.na && this.rawProgramDateTime && (this.na = Date.parse(this.rawProgramDateTime)),
                this.na
            }
            get byteRange() {
                var e, t, i;
                return !this.ra && this.rawByteRange && (e = new Array(2),
                1 === (t = this.rawByteRange.split("@", 2)).length ? (i = this["lastByteRangeEndOffset"],
                e[0] = i || 0) : e[0] = parseInt(t[1]),
                e[1] = parseInt(t[0]) + e[0],
                this.ra = e),
                this.ra
            }
            get byteRangeStartOffset() {
                var e;
                return null == (e = this.byteRange) ? void 0 : e[0]
            }
            get byteRangeEndOffset() {
                var e;
                return null == (e = this.byteRange) ? void 0 : e[1]
            }
            get rangeString() {
                return 0 <= this.start && 0 <= this.duration ? this.start.toFixed(2) + `-` + (this.start + this.duration).toFixed(2) : "N/A"
            }
            get fragTag() {
                return `msn/dsn/partIndex: ${this.mediaSeqNum}/${this.discoSeqNum}/` + this.partIndex
            }
        }
        const Wm = {
            parseMediaCharacteristics: e => e ? e.split(/\s*,\s*/) : new Array,
            addMediaToSelectionArray(e, t, i) {
                var r;
                if (void 0 === e)
                    return -1;
                e = e.MediaSelectionGroupOptions;
                let n = e.find(e => e.MediaSelectionOptionsMediaType === t.mediaType && e.MediaSelectionOptionsName === t.name && e.MediaSelectionOptionsExtendedLanguageTag === t.lang);
                return n || (n = {
                    MediaSelectionOptionsMediaType: null != (r = t.mediaType) ? r : O.UNKNOWN,
                    MediaSelectionOptionsExtendedLanguageTag: t.lang,
                    MediaSelectionOptionsIsDefault: null != (r = t.default) && r,
                    MediaSelectionOptionsName: t.name,
                    MediaSelectionOptionsPersistentID: i,
                    MediaSelectionOptionsTaggedMediaCharacteristics: null != (r = t.characteristics) ? r : [],
                    MediaSelectionOptionsIsAutoSelect: null != (r = t.autoselect) && r
                },
                t.mediaType === O.SUBTITLE && (n.MediaSelectionOptionsDisplaysNonForcedSubtitles = t.forced ? ls.NO : ls.YES),
                i++,
                e.push(n)),
                t.persistentID = n.MediaSelectionOptionsPersistentID,
                i
            },
            makeDefaultClosedCaptionOption: (e, t) => ({
                itemId: e,
                mediaOptionType: se.Subtitle,
                id: 0,
                mediaOptionId: "cc1_" + Ga(),
                mediaType: O.CLOSEDCAPTION,
                inStreamID: "CC1",
                groupId: "cc",
                name: "English-CC",
                type: "CLOSED-CAPTIONS",
                default: !1,
                autoselect: !1,
                forced: !1,
                lang: "en",
                characteristics: ["public.accessibility.transcribes-spoken-dialog", "public.accessibility.describes-music-and-sound"],
                persistentID: t,
                relativeUrl: void 0
            })
        }
          , zm = /^(\d+)x(\d+)$/
          , Xm = /\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g;
        class Ym {
            constructor(e) {
                this.sa = e
            }
            get keys() {
                return Object.keys(this.sa)
            }
            hasKey(e) {
                return e in this.sa
            }
            getInt(e) {
                var e = this.sa[e];
                if (e)
                    return (e = parseInt(e)) > Number.MAX_SAFE_INTEGER ? 1 / 0 : e
            }
            getFloat(e) {
                e = this.sa[e];
                if (e)
                    return parseFloat(e)
            }
            getResolution(e) {
                e = this.sa[e],
                e = zm.exec(e);
                let t;
                return t = null !== e ? {
                    width: parseInt(e[1], 10),
                    height: parseInt(e[2], 10)
                } : t
            }
            getHex(e) {
                const t = this.sa[e];
                if (t) {
                    var i = (1 & (i = (t || "0x").slice(2)).length ? "0" : "") + i
                      , r = new Uint8Array(i.length / 2);
                    for (let e = 0; e < i.length / 2; e++) {
                        const t = parseInt(i.slice(2 * e, 2 * e + 2), 16);
                        if (!re(t))
                            return;
                        r[e] = t
                    }
                    return r
                }
            }
            getString(e, t=!0) {
                let i = this.sa[e];
                if (i)
                    return 34 === i.charCodeAt(0) && 34 === i.charCodeAt(i.length - 1) && (i = i.slice(1, -1)),
                    t ? fe(i) : i
            }
            matchesEnum(e, t) {
                e = this.sa[e];
                return null != e && e === t
            }
        }
        class Jm {
            static parseTags(e) {
                var t, i = {};
                if (e)
                    for (Xm.lastIndex = 0; null !== (t = Xm.exec(e)); ) {
                        const e = t[1]
                          , r = t[2];
                        i[e] = r
                    }
                return new Ym(i)
            }
        }
        const Zm = {
            ExtractVariableParameter: /{\$(.*?)}/g,
            LevelPlaylistFast: /#EXTINF:(\d*(?:\.\d+)?)(?:,(.*))?|(?!#)(\S.+)|#EXT-X-BYTERANGE:(.+)|#EXT-X-PROGRAM-DATE-TIME:(.+)|#EXT-X-BITRATE:(.+)|#EXT-X-DATERANGE:(.+)|#EXT-X-PART:(.+)|(#EXT-X-.*)/g,
            LevelPlaylistSlow: /#EXT-X-(PLAYLIST-TYPE|MEDIA-SEQUENCE|TARGETDURATION|KEY|START|DISCONTINUITY-SEQUENCE|DISCONTINUITY|VERSION|MAP|DEFINE|ENDLIST|I-FRAMES-ONLY|GAP|SERVER-CONTROL|PART-INF|SKIP|RENDITION-REPORT|PRELOAD-HINT)(?::(.+)){0,1}/,
            MasterPlaylist: /#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)|#EXT-X-I-FRAME-STREAM-INF:([^\r\n]+)|#EXT-X-DEFINE:([^\n\r]*)|#EXT-X-CONTENT-STEERING:([^\n\r]*)|#EXT-X-START:([^\n\r]*)/g,
            MasterPlaylistAlternateMedia: /#EXT-X-MEDIA:(.*)/g,
            SessionData: /#EXT-X-SESSION-DATA[^:]*:(.*)/g,
            SessionKeys: /#EXT-X-SESSION-KEY:([^\n\r]*)/g,
            VARIABLE_PLAYLIST_REGEX: /(NAME|VALUE)=\"(.*)\",(NAME|VALUE)=\"(.*)\"|(IMPORT)=\"(.*)\"/
        };
        (i = tp = tp || {})[i.Audio = 0] = "Audio",
        i[i.Subtitle = 1] = "Subtitle";
        class ef {
            static isValidPlaylist(e) {
                return e.startsWith("#EXTM3U")
            }
            static isMediaPlaylist(e) {
                return 0 < e.indexOf("#EXTINF:") || 0 < e.indexOf("#EXT-X-PLAYLIST-TYPE:")
            }
            static replaceVariables(e, t, i) {
                let r = e ? fe(e) : void 0;
                return r = r && 0 < Object.keys(t).length ? r.replace(Zm.ExtractVariableParameter, e => {
                    Zm.ExtractVariableParameter.lastIndex = 0;
                    e = Zm.ExtractVariableParameter.exec(e),
                    e = null == e ? void 0 : e[1];
                    if (e && "string" == typeof t[e])
                        return t[e];
                    throw new pe(he.MEDIA_ERROR,i ? Q.MANIFEST_PARSING_ERROR : Q.LEVEL_LOAD_ERROR,!1,H.PlaylistErrorInvalidEXTXDEFINE)
                }
                ) : r
            }
            static parseDecryptData(e, t, i) {
                var r;
                const n = Jm.parseTags(e)
                  , a = n.getString("METHOD")
                  , s = (e = a) && e in qm ? a : null;
                var o = null != (r = n.getString("KEYFORMAT")) ? r : "";
                if (s && ef.shouldSelectKeyTag(o, s, i)) {
                    const e = n.getString("URI")
                      , i = n.getHex("IV");
                    if (e && n.hasKey("IV") && !i) {
                        const e = new pe(he.MEDIA_ERROR,Q.MANIFEST_PARSING_ERROR,!0,H.PlaylistErrorInvalidEntry,`Invalid IV: ` + n.getString("IV", !1));
                        throw e.url = t,
                        e
                    }
                    const r = e ? es.buildAbsoluteURL(t, e, {
                        alwaysNormalize: !0
                    }) : ""
                      , a = (n.getString("KEYFORMATVERSIONS") || "1").split("/").map(Number).filter(isFinite);
                    return new rl(s,r,i,o,a)
                }
            }
            static shouldSelectKeyTag(e, t, i) {
                return "AES-128" === t || "NONE" === t || null == i || e === Vu.getKeySystemFormat(i)
            }
            static optOutClosedCaption(t) {
                let i = !1
                  , r = !1;
                if (t)
                    for (let e = 0; e < t.length; ++e) {
                        var n = t[e];
                        if (n.videoCodec && (r = !0) !== n.iframes && n.closedcaption && "none" === n.closedcaption.toLowerCase()) {
                            i = !0;
                            break
                        }
                    }
                return !r || i
            }
            static parseRootPlaylistAlternateMediaOptions(o, l, d, u, c, h, p) {
                var m, f = {
                    MediaSelectionGroupAllowEmptySelection: 1,
                    MediaSelectionGroupMediaCharacteristics: ["public.audible"],
                    MediaSelectionGroupMediaType: O.AUDIO,
                    MediaSelectionGroupOptions: []
                }, g = {
                    MediaSelectionGroupAllowEmptySelection: 1,
                    MediaSelectionGroupMediaCharacteristics: ["public.legible"],
                    MediaSelectionGroupMediaType: O.SUBTITLE,
                    MediaSelectionGroupOptions: []
                }, y = {
                    videoAlternateOptions: [],
                    audioAlternateOptions: [],
                    subtitleAlternateOptions: [],
                    audioMediaSelectionGroup: f,
                    subtitleMediaSelectionGroup: g,
                    audioGroupMapping: new Map,
                    subtitleGroupMapping: new Map
                };
                let v = 0;
                for (Zm.MasterPlaylistAlternateMedia.lastIndex = 0; null != (S = Zm.MasterPlaylistAlternateMedia.exec(l)); ) {
                    const l = ef.replaceVariables(S[1], c, !0)
                      , d = Jm.parseTags(l);
                    let e, t, i, r = O.UNKNOWN;
                    const T = Wm.parseMediaCharacteristics(d.getString("CHARACTERISTICS"))
                      , E = d.getString("GROUP-ID")
                      , A = d.getString("CHANNELS");
                    let n, a = [];
                    var S = d.getString("TYPE");
                    switch (S) {
                    case "VIDEO":
                        r = O.VIDEO,
                        n = se.Variant,
                        t = y.videoAlternateOptions;
                        break;
                    case "AUDIO":
                        r = O.AUDIO,
                        n = se.AltAudio,
                        t = y.audioAlternateOptions,
                        i = f;
                        const o = u.find(e => {
                            return (null == (e = h.get(e.mediaOptionId)) ? void 0 : e[0]) === E
                        }
                        );
                        a = o && null != (m = o.audioCodecList) ? m : [];
                        break;
                    case "SUBTITLES":
                        r = O.SUBTITLE,
                        n = se.Subtitle,
                        t = y.subtitleAlternateOptions,
                        i = g;
                        break;
                    case "CLOSED-CAPTIONS":
                        r = O.CLOSEDCAPTION,
                        n = se.Subtitle,
                        e = d.getString("INSTREAM-ID"),
                        t = y.subtitleAlternateOptions,
                        i = g
                    }
                    if (null == n || !E || !S || !t)
                        break;
                    var I = Tp.shortenLanguageCode(null != (I = d.getString("LANGUAGE")) ? I : "");
                    let s = null != (b = d.getString("NAME")) ? b : "";
                    "" === s && (s = I,
                    S === O.CLOSEDCAPTION) && (s += " CC");
                    var b = {
                        itemId: o,
                        mediaOptionType: n,
                        mediaType: r,
                        relativeUrl: d.getString("URI"),
                        groupId: E,
                        channels: A,
                        groupCodecList: a,
                        name: s,
                        type: S,
                        default: d.matchesEnum("DEFAULT", "YES"),
                        autoselect: d.matchesEnum("AUTOSELECT", "YES"),
                        forced: d.matchesEnum("FORCED", "YES"),
                        characteristics: T,
                        persistentID: v,
                        id: t.length,
                        mediaOptionId: n + `_` + t.length.toString(16),
                        lang: I,
                        isInterstitial: p
                    }
                      , S = d.getString("STABLE-RENDITION-ID");
                    S && (b.stableRenditionID = S),
                    b.mediaType === O.CLOSEDCAPTION && e && (b.inStreamID = e),
                    t.push(b),
                    y.audioGroupMapping && b.mediaOptionType === se.AltAudio && (y.audioGroupMapping.has(E) ? null != (I = y.audioGroupMapping.get(E)) && I.push(b) : y.audioGroupMapping.set(E, [b])),
                    y.subtitleGroupMapping && b.mediaOptionType === se.Subtitle && (y.subtitleGroupMapping.has(E) ? null != (S = y.subtitleGroupMapping.get(E)) && S.push(b) : y.subtitleGroupMapping.set(E, [b])),
                    v = Wm.addMediaToSelectionArray(i, b, v)
                }
                return {
                    alternateMediaInfo: y
                }
            }
            static parseMediaOptionPlaylist(n, a, s, o, l, d, u, c, h=0, p=!1, m) {
                var f, g;
                let y = 0
                  , v = 0;
                var S = {
                    itemId: l,
                    mediaOptionId: d,
                    mediaOptionType: u,
                    type: "",
                    version: 0,
                    url: a,
                    relativeUrl: a,
                    initSegments: {},
                    fragments: [],
                    liveOrEvent: !0,
                    startSN: 0,
                    endSN: 0,
                    iframesOnly: p,
                    targetduration: 0,
                    totalduration: 0,
                    averagetargetduration: 0,
                    ptsKnown: !1,
                    discoToMSNMap: {},
                    pdtToMSN: []
                };
                let I, b, T = new rl("NONE"), E = !1, A = !1, O = 0, t = null, R = new $m, r = NaN;
                var w = {};
                let i, P, U = !0, M = !0, _ = !1, C = 0, k = 0;
                Zm.LevelPlaylistFast.lastIndex = 0;
                for (var V = () => new pe(he.MEDIA_ERROR,Q.MANIFEST_PARSING_ERROR,!0,H.IncompatibleAsset,"Invalid key system preference for the playlist"); null !== (I = Zm.LevelPlaylistFast.exec(n)); ) {
                    const n = I[1];
                    if (n)
                        R.duration = parseFloat(n),
                        R.title = fe(I[2]);
                    else if (I[3] || I[8]) {
                        if (I[8] && (R.part = !0),
                        R.part) {
                            const n = I[8]
                              , a = Jm.parseTags(n)
                              , s = a.getFloat("DURATION");
                            if (!re(s))
                                break;
                            R.duration = s,
                            (i = ef.replaceVariables(a.getString("URI", !1), w, !1)) && (R.relurl = i),
                            R.partIndependent = a.matchesEnum("INDEPENDENT", "YES"),
                            S.hasPartIndependentTag = S.hasPartIndependentTag || null != a.getString("INDEPENDENT");
                            const o = a.getString("BYTERANGE");
                            if (o && (R.rawByteRange = o,
                            t)) {
                                const n = t.byteRangeEndOffset;
                                n && (R.lastByteRangeEndOffset = n)
                            }
                            R.partGap = a.matchesEnum("GAP", "YES")
                        }
                        if (re(R.duration)) {
                            if (A && !E)
                                throw V();
                            E = !1,
                            A = !1;
                            let e = 0;
                            if (R.part ? (e = y,
                            re(S.partStartSN) || (S.partStartSN = e),
                            R.partIndex = C++,
                            R.start = v + k + h,
                            S.partEndSN = e,
                            S.partEndIndex = R.partIndex) : (e = y++,
                            C = 0,
                            k = 0,
                            R.start = v + h,
                            (i = ef.replaceVariables(I[3], w, !1)) && (R.relurl = i)),
                            R.levelkey = T,
                            R.mediaSeqNum = e,
                            R.discoSeqNum = O,
                            R.iframe = S.iframesOnly,
                            R.baseurl = a,
                            re(R.byteRangeEndOffset) && re(R.byteRangeStartOffset) ? R.bitrate = 8 * (R.byteRangeEndOffset - R.byteRangeStartOffset) / R.duration : R.bitrate = r,
                            !(_ = m && S.startSN >= m.startSN && S.startSN <= m.endSN ? !0 : _) || !R.part && m && e > m.endSN || R.part && m && re(m.partEndSN) && re(m.partEndIndex) && (e > m.partEndSN || e === m.partEndSN && R.partIndex > m.partEndIndex)) {
                                if (null != b && (R.rawProgramDateTime = b,
                                (null == t ? void 0 : t.discoSeqNum) !== O)) {
                                    const n = R.programDateTime;
                                    n && S.pdtToMSN.push([n, R.mediaSeqNum])
                                }
                                S.discoToMSNMap[R.discoSeqNum] ? S.discoToMSNMap[R.discoSeqNum][1] = R.mediaSeqNum : S.discoToMSNMap[R.discoSeqNum] = [R.mediaSeqNum, R.mediaSeqNum],
                                R.part ? (S.parts || (S.parts = []),
                                k += R.duration,
                                S.parts.push(R.getMediaFragment(l, d, u))) : (S.fragments.push(R.getMediaFragment(l, d, u)),
                                v += R.duration)
                            }
                            if (b = void 0,
                            t = R,
                            U || !S.initSegments[O] || M)
                                if (S.iframesOnly && R.byteRangeStartOffset && 0 < R.byteRangeStartOffset && !S.initSegments[O] && !M) {
                                    const n = new $m;
                                    if (n.relurl = R.relurl,
                                    n.rawByteRange = Math.min(R.byteRangeStartOffset, 1316) + "@0",
                                    n.baseurl = a,
                                    n.isInitSegment = !0,
                                    n.discoSeqNum = O,
                                    n.levelkey = T,
                                    n.iframe = !0,
                                    A && !E)
                                        throw V();
                                    E = !1,
                                    A = !1,
                                    S.initSegments[O] = Object.assign(Object.assign({}, n.getMediaFragment(l, d, u)), {
                                        isInitSegment: !0
                                    })
                                } else
                                    P && (S.initSegments[O] = Object.assign(Object.assign({}, P), {
                                        discoSeqNum: O,
                                        isInitSegment: !0
                                    }));
                            U = !1,
                            M = !1,
                            R = new $m
                        }
                    } else if (I[4]) {
                        if (R.rawByteRange = fe(I[4]),
                        t) {
                            const n = t.byteRangeEndOffset;
                            n && (R.lastByteRangeEndOffset = n)
                        }
                    } else if (I[5])
                        b = fe(I[5]);
                    else if (I[6]) {
                        const n = parseInt(I[6]);
                        re(n) && (r = 1e3 * n)
                    } else if (I[7]) {
                        const n = I[7]
                          , a = Jm.parseTags(n)
                          , s = a.getString("ID")
                          , o = a.getString("START-DATE");
                        if (s && o) {
                            let e = {
                                ID: s,
                                "START-DATE": o
                            };
                            for (const s of a.keys)
                                switch (s) {
                                case "ID":
                                case "START-DATE":
                                    break;
                                case "DURATION":
                                case "PLANNED-DURATION":
                                    e[s] = a.getFloat(s);
                                    break;
                                default:
                                    e[s] = a.getString(s)
                                }
                            S.daterangeTags || (S.daterangeTags = {}),
                            S.daterangeTags[s] && (e = ef.validateAndUpdateDateRangeTag(S.daterangeTags[s], e, c)),
                            S.daterangeTags[s] = e
                        }
                    } else if (null != (I = I[9].match(Zm.LevelPlaylistSlow))) {
                        const n = I[1]
                          , c = ef.replaceVariables(I[2], w, !1);
                        switch (n) {
                        case "PLAYLIST-TYPE":
                            S.type = null == c ? void 0 : c.toUpperCase(),
                            "VOD" === S.type && (S.liveOrEvent = !1);
                            break;
                        case "MEDIA-SEQUENCE":
                            0 === S.fragments.length && c && (y = S.startSN = parseInt(c));
                            break;
                        case "TARGETDURATION":
                            c && (S.targetduration = parseFloat(c));
                            break;
                        case "VERSION":
                            c && (S.version = parseInt(c));
                            break;
                        case "ENDLIST":
                            S.liveOrEvent = !1;
                            break;
                        case "DISCONTINUITY":
                            O++,
                            U = !0;
                            break;
                        case "DISCONTINUITY-SEQUENCE":
                            c && (O = parseInt(c));
                            break;
                        case "KEY":
                            const n = c;
                            if (A = !0,
                            !E) {
                                const o = ef.parseDecryptData(n, a, s);
                                o && (T = o,
                                E = !0)
                            }
                            break;
                        case "START":
                            const h = c
                              , p = Jm.parseTags(h).getFloat("TIME-OFFSET");
                            re(p) && (S.startTimeOffset = p);
                            break;
                        case "I-FRAMES-ONLY":
                            S.iframesOnly = !0;
                            break;
                        case "MAP":
                            const f = Jm.parseTags(c)
                              , g = f.getString("URI")
                              , v = (g && (R.relurl = g),
                            R.rawByteRange)
                              , I = R.lastByteRangeEndOffset;
                            if (R.rawByteRange = f.getString("BYTERANGE"),
                            R.baseurl = a,
                            R.isInitSegment = !0,
                            R.levelkey = T,
                            A && !E)
                                throw V();
                            E = !1,
                            A = !1,
                            P = R.getMediaFragment(l, d, u),
                            M = !0,
                            (R = new $m).rawByteRange = v,
                            R.lastByteRangeEndOffset = I;
                            break;
                        case "DEFINE":
                            const b = Zm.VARIABLE_PLAYLIST_REGEX.exec(null != c ? c : "");
                            let e, t, i, r;
                            if (b && (e = "NAME" === b[1] ? b[2] : b[4],
                            t = "VALUE" === b[1] ? b[2] : b[4],
                            i = b[5],
                            r = b[6]),
                            !e && !t && "IMPORT" === i && r && o.hasOwnProperty(r))
                                w[r] = o[r];
                            else {
                                if (!e || i || (null == b ? void 0 : b[1]) === (null == b ? void 0 : b[3]) || w.hasOwnProperty(e) || !t)
                                    throw new pe(he.MEDIA_ERROR,Q.MANIFEST_PARSING_ERROR,!0,H.PlaylistErrorMissingImportReference);
                                w[e] = t
                            }
                            break;
                        case "GAP":
                            R.gap = !0;
                            break;
                        case "SERVER-CONTROL":
                            S.serverControls = {
                                canSkipUntil: NaN,
                                canSkipDateRanges: !1,
                                canBlockReload: !1
                            };
                            const fe = Jm.parseTags(c)
                              , C = fe.getFloat("CAN-SKIP-UNTIL")
                              , k = (re(C) && (S.serverControls.canSkipUntil = C),
                            S.serverControls.canSkipDateRanges = fe.matchesEnum("CAN-SKIP-DATERANGES", "YES"),
                            fe.getFloat("HOLD-BACK"));
                            re(k) && (S.serverControls.holdBack = k);
                            var L = fe.getFloat("PART-HOLD-BACK");
                            re(L) && (S.serverControls.partHoldBack = L),
                            S.serverControls.canBlockReload = fe.matchesEnum("CAN-BLOCK-RELOAD", "YES");
                            break;
                        case "PART-INF":
                            L = Jm.parseTags(c).getFloat("PART-TARGET");
                            re(L) && (S.partTargetDuration = L);
                            break;
                        case "SKIP":
                            var N = Jm.parseTags(c)
                              , D = N.getInt("SKIPPED-SEGMENTS")
                              , D = (re(D) && (S.skippedSegments = D,
                            y += D),
                            N.getString("RECENTLY-REMOVED-DATERANGES"));
                            if (D && (S.recentlyRemovedDateranges = D),
                            m && m.daterangeTags) {
                                S.daterangeTags || (S.daterangeTags = {});
                                const n = new Set(null == D ? void 0 : D.split("\t"));
                                for (const a of Object.keys(m.daterangeTags))
                                    S.daterangeTags[a] || n.has(a) || (S.daterangeTags[a] = m.daterangeTags[a])
                            }
                            break;
                        case "RENDITION-REPORT":
                            N = Jm.parseTags(c),
                            D = N.getString("URI");
                            D && (F = {
                                relUri: D,
                                lastMSN: N.getInt("LAST-MSN"),
                                lastPart: N.getInt("LAST-PART")
                            },
                            S.renditionReports ? S.renditionReports.push(F) : S.renditionReports = [F]);
                            break;
                        case "PRELOAD-HINT":
                            var x, F = Jm.parseTags(c), B = F.getString("TYPE");
                            B && (x = F.getString("URI")) && (B = {
                                resourceType: B,
                                Uri: x
                            },
                            re(x = F.getInt("BYTERANGE-START")) && (B.byteRangeStart = x),
                            re(x = F.getInt("BYTERANGE-LENGTH")) && (B.byteRangeLength = x),
                            S.preloadHints ? S.preloadHints.push(B) : S.preloadHints = [B])
                        }
                    }
                }
                if ((R = t ? t : R) && !R.relurl && (R.part ? (null != (f = S.parts) && f.pop(),
                k -= R.duration) : (S.fragments.pop(),
                v -= R.duration)),
                !S.liveOrEvent && 0 < S.fragments.length && (S.fragments[S.fragments.length - 1].isLastFragment = !0),
                S.totalduration = v,
                S.averagetargetduration = v / S.fragments.length,
                S.endSN = y - 1,
                null != (g = S.parts) && g.length) {
                    const n = S.parts.length - 1;
                    S.partEndSN = S.parts[n].mediaSeqNum,
                    S.partEndIndex = S.parts[n].partIndex
                }
                return {
                    mediaOptionDetails: S,
                    isDeltaPlaylist: _
                }
            }
            static parseRootPlaylistWithAlternates(e, t, i, r) {
                var n, a = ef.parseRootPlaylist(e, t, i);
                if (a.playlistParsingError)
                    throw a.playlistParsingError;
                var {variantMediaOptions: s, masterVariableList: o, variantIdToAlternateGroupIdTuple: l} = a
                  , t = ef.parseRootPlaylistAlternateMediaOptions(e, t, i, a.variantMediaOptions, o, l, r)
                  , {audioGroupMapping: d, subtitleGroupMapping: u, subtitleAlternateOptions: i, subtitleMediaSelectionGroup: o} = t.alternateMediaInfo;
                let c, h, p;
                0 !== i.length || ef.optOutClosedCaption(s) || (c = Wm.makeDefaultClosedCaptionOption(e, 0),
                i.push(c),
                u.set(c.groupId, [c]),
                Wm.addMediaToSelectionArray(o, c, 0));
                for (const e of s) {
                    c && (e.closedcaption = c.groupId);
                    const t = null == (n = l.get(e.mediaOptionId)) ? void 0 : n[tp.Audio]
                      , i = null == (n = l.get(e.mediaOptionId)) ? void 0 : n[tp.Subtitle]
                      , r = e.closedcaption;
                    if (t && d && (e.audioAlternates = null != (n = d.get(t)) ? n : []),
                    t || (h = h || this.consolidateAlterateEntries(d),
                    e.audioAlternates = h),
                    i && u && (e.subtitleAlternates = null != (n = u.get(i)) ? n : []),
                    r && u)
                        if (e.subtitleAlternates && 0 < e.subtitleAlternates.length) {
                            const t = u.get(r);
                            t && 0 < t.length && (e.subtitleAlternates = e.subtitleAlternates.concat(t))
                        } else
                            e.subtitleAlternates = u.get(r);
                    i || r || (p = p || this.consolidateAlterateEntries(u),
                    e.subtitleAlternates = p)
                }
                return Object.assign(Object.assign({}, a), t)
            }
            static consolidateAlterateEntries(e) {
                var t;
                let i = [];
                for (const r of e.keys())
                    i = i.concat(null != (t = e.get(r)) ? t : []);
                return i
            }
            static parseRootPlaylist(t, i, e) {
                const r = []
                  , n = {}
                  , a = new Map
                  , s = {};
                let o, l, d, u, c = 0, h = null, p = !0, m = NaN;
                for (Zm.MasterPlaylist.lastIndex = 0; null != (o = Zm.MasterPlaylist.exec(i)); )
                    if (o[4]) {
                        let e, t, i;
                        if ((o = Zm.VARIABLE_PLAYLIST_REGEX.exec(o[4])) && (e = "NAME" === o[1] ? o[2] : o[4],
                        t = "VALUE" === o[1] ? o[2] : o[4],
                        i = o[5]),
                        !e || n.hasOwnProperty(e) || i || (null == o ? void 0 : o[1]) === (null == o ? void 0 : o[3]) || !t) {
                            u = new pe(he.MEDIA_ERROR,Q.MANIFEST_PARSING_ERROR,!0,H.PlaylistErrorInvalidEXTXDEFINE);
                            break
                        }
                        n[e] = t
                    } else if (o[5]) {
                        const t = ef.replaceVariables(o[5], n, !0)
                          , i = Jm.parseTags(t)
                          , f = i.getString("SERVER-URI");
                        if ("string" != typeof f) {
                            u = new pe(he.MEDIA_ERROR,Q.MANIFEST_PARSING_ERROR,!0,H.PlaylistErrorInvalidSERVERURI);
                            break
                        }
                        const r = i.getString("PATHWAY-ID");
                        if (i.hasKey("PATHWAY-ID") && "string" != typeof r) {
                            u = new pe(he.MEDIA_ERROR,Q.MANIFEST_PARSING_ERROR,!0,H.PlaylistErrorInvalidPATHWAYID);
                            break
                        }
                        h = {
                            serverURI: ps(f, e),
                            initPathwayID: r || ".",
                            initPathwayPriority: []
                        }
                    } else if (o[6]) {
                        const t = Jm.parseTags(o[6]).getFloat("TIME-OFFSET");
                        re(t) && (m = t)
                    } else {
                        d = ef.replaceVariables(o[1] || o[3], n, !0);
                        const i = Jm.parseTags(d)
                          , e = (l = ef.replaceVariables(o[2] || i.getString("URI"), n, !0),
                        i.getFloat("SCORE"));
                        if (void 0 !== e && !re(e) || e && e < 0) {
                            u = new pe(he.MEDIA_ERROR,Q.MANIFEST_PARSING_ERROR,!0,H.PlaylistErrorInvalidSCORE),
                            p = !1;
                            break
                        }
                        p && void 0 === e && (p = !1);
                        const h = i.getInt("BANDWIDTH")
                          , m = i.getInt("AVERAGE-BANDWIDTH")
                          , S = m || h;
                        if (!S)
                            continue;
                        var f = null != (f = i.getString("VIDEO-RANGE")) ? f : "SDR";
                        if (null == (g = f) || !$a.includes(g))
                            continue;
                        var g = se.Variant + `_` + r.length.toString(16)
                          , y = (a.set(g, [void 0, void 0]),
                        i.getString("AUDIO"));
                        if (y) {
                            const t = a.get(g);
                            t && (t[tp.Audio] = y)
                        }
                        y = i.getString("SUBTITLES");
                        if (y) {
                            const t = a.get(g);
                            t && (t[tp.Subtitle] = y)
                        }
                        var y = i.getString("CODECS")
                          , v = {
                            itemId: t,
                            mediaOptionId: g,
                            mediaOptionType: se.Variant,
                            relativeUrl: null != l ? l : "",
                            name: i.getString("NAME"),
                            iframes: !!o[3],
                            bandwidth: h || S,
                            avgBandwidth: m,
                            bitrate: S,
                            videoRange: f,
                            frameRate: i.getFloat("FRAME-RATE"),
                            allowedCPCMap: ef.parseAllowedCPC(i.getString("ALLOWED-CPC", !1)),
                            closedcaption: i.getString("CLOSED-CAPTIONS"),
                            levelCodec: y,
                            score: i.getFloat("SCORE"),
                            pathwayID: i.getString("PATHWAY-ID") || "."
                        }
                          , g = i.getString("STABLE-VARIANT-ID")
                          , f = (g && (v.stableVariantID = g),
                        i.getString("HDCP-LEVEL"))
                          , g = (Cu(f) && (v.hdcpLevel = f),
                        i.getResolution("RESOLUTION"));
                        if (g && (v.width = g.width,
                        v.height = g.height),
                        y) {
                            v.videoCodecList = new Array,
                            v.audioCodecList = new Array;
                            const t = y.split(/[ ,]+/)
                              , i = t["length"];
                            for (let e = 0; e < i; e++) {
                                const i = t[e];
                                switch (i.slice(0, 4)) {
                                case "avc1":
                                    v.videoCodec = q.avc1toavcoti(i),
                                    v.videoCodecList.push(v.videoCodec);
                                    break;
                                case "mjpg":
                                case "jpeg":
                                    v.imageCodec = i;
                                case "avc3":
                                case "dvav":
                                case "dva1":
                                case "hev1":
                                case "hvc1":
                                case "dvh1":
                                case "dvhe":
                                case "vp09":
                                case "av01":
                                    v.videoCodec = i,
                                    v.videoCodecList.push(v.videoCodec);
                                    break;
                                case "mp4a":
                                case "ec-3":
                                case "ac-3":
                                    v.audioCodec = i,
                                    v.audioCodecList.push(v.audioCodec);
                                    break;
                                case "stpp":
                                case "wvtt":
                                    break;
                                default:
                                    v.audioCodec = i,
                                    v.audioCodecList.push(v.audioCodec)
                                }
                            }
                            1 < v.audioCodecList.length && (v.audioCodec = Gm.getRichestAudioCodec(v.audioCodecList)),
                            1 < v.videoCodecList.length && (v.videoCodec = Gm.getRichestVideoCodec(v.videoCodecList))
                        }
                        if (null != (u = Rp(v.pathwayID)))
                            break;
                        Object.prototype.hasOwnProperty.call(s, v.pathwayID) || (s[v.pathwayID] = c++),
                        r.push(v)
                    }
                null != (null == h ? void 0 : h.initPathwayID) && (s[h.initPathwayID] = -1,
                h.initPathwayPriority = Object.keys(s).sort( (e, t) => s[e] - s[t]));
                const S = {
                    variantMediaOptions: r,
                    contentSteeringOption: h,
                    masterVariableList: n,
                    variantIdToAlternateGroupIdTuple: a,
                    playlistParsingError: u,
                    scoreAvailable: p
                };
                return re(m) && (S.startTimeOffset = m),
                S
            }
            static parseAllowedCPC(e) {
                if ("string" == typeof e) {
                    const r = {};
                    return e.split(",").forEach(e => {
                        e = e.split(":");
                        let t, i;
                        if (2 === e.length)
                            t = e[0].trim(),
                            i = e[1].trim();
                        else {
                            if (!(2 < e.length))
                                return;
                            i = e[e.length - 1].trim(),
                            e.pop(),
                            t = e.join(":")
                        }
                        if (!(t in r)) {
                            let e = new Array;
                            "" !== i && (e = fe(i).split("/").map(e => e.trim())),
                            r[fe(t)] = e
                        }
                    }
                    ),
                    r
                }
            }
            static parseSessionKeys(e, t, i) {
                var r, n = [];
                for (Zm.SessionData.lastIndex = 0; r = Zm.SessionKeys.exec(e); )
                    try {
                        const e = ef.parseDecryptData(r[1], t, i);
                        e && e.isEncrypted && n.push(e)
                    } catch (e) {}
                return n
            }
            static parseSessionData(t, i, r) {
                let n;
                var a = []
                  , s = new Set;
                for (Zm.SessionData.lastIndex = 0; null != (n = Zm.SessionData.exec(t)); ) {
                    const t = Jm.parseTags(n[1]);
                    let e = t.getString("LANGUAGE");
                    var o = t.getString("DATA-ID");
                    if (null != o) {
                        const r = (e = Tp.shortenLanguageCode(e)) ? o + "|" + e : void 0;
                        if (!r || !s.has(r)) {
                            const n = {
                                "DATA-ID": o,
                                LANGUAGE: e
                            };
                            for (const i of t.keys) {
                                const r = t.getString(i);
                                "VALUE" === i && r && "com.apple.hls.other-tags" === o && (n[i] = function(t) {
                                    let i;
                                    try {
                                        i = JSON.parse(Xo.base64DecodeToStr(t))
                                    } catch (e) {
                                        i = t
                                    }
                                    return i
                                }(r)),
                                i in n || (n[i] = r)
                            }
                            a.push(n),
                            r && s.add(r)
                        }
                    } else
                        r.error(`Error processing DATA-ID ${o} and LANGUAGE ` + e)
                }
                return {
                    itemList: a,
                    baseUrl: i
                }
            }
            static validateAndUpdateDateRangeTag(e, t, i) {
                let r = !0;
                var n = Object.assign({}, e);
                for (const e in t)
                    if ("ID" !== e) {
                        var a = t[e];
                        if (Object.prototype.hasOwnProperty.call(n, e)) {
                            if (n[e] !== a) {
                                i.error(`Date Range Tag for attribute: "${e}" does not match for ID: "${t.ID}". This violates HLS spec`),
                                r = !1;
                                break
                            }
                        } else
                            n[e] = a
                    }
                return r ? n : e
            }
        }
        var tf, rf, nf, af = ef;
        function sf(e) {
            var {tloadMillis: e, age: t, partTargetDuration: i=NaN, targetduration: r} = e;
            return !(!re(e) || !re(t)) && (1e3 * i < (i = performance.now() - e + 1e3 * t) || 1e3 * r < i)
        }
        const of = (e, t, s, i, o, r, n, l, d, u, a, c, h) => {
            const {itemId: p, mediaOptionId: m, mediaOptionType: f, relativeUrl: g} = e;
            if (!g)
                return R( () => new Gs("Missing URL in loadMediaOptionDetails",400));
            const y = !!Wa(e) && e.iframes
              , v = eo(e, r);
            let S = null != (r = e.url) ? r : ps(g, t);
            return c && c.liveOrEvent && null != (e = c.serverControls) && e.canBlockReload ? S = function(e, t, i) {
                var r, n, a = new URL(e);
                if (i.liveAllowLowLatencyPlayback) {
                    const {nextMSN: e, nextPart: i} = function(e) {
                        var t, i, r, n = sf(e), {endSN: a, partEndSN: s=NaN, partEndIndex: o=NaN} = e, l = re(null == e ? void 0 : e.partEndIndex);
                        return n ? ({tloadMillis: n, age: e, partTargetDuration: i=NaN, targetduration: t} = e,
                        n = performance.now() - n + 1e3 * e,
                        l ? (0,
                        e = Math.round(t / i),
                        i = Math.round(n / (1e3 * i)),
                        r = o + 1,
                        {
                            nextMSN: s + Math.floor((i + r) / e),
                            nextPart: (i + r) % e
                        }) : {
                            nextMSN: a + Math.floor(n / (1e3 * t)) + 1,
                            nextPart: NaN
                        }) : l ? s === a ? {
                            nextMSN: s + 1,
                            nextPart: 0
                        } : {
                            nextMSN: s,
                            nextPart: o + 1
                        } : {
                            nextMSN: a + 1,
                            nextPart: NaN
                        }
                    }(t);
                    if (re(e) && (a.searchParams.set("_HLS_msn", e.toString()),
                    re(i)) && a.searchParams.set("_HLS_part", i.toString()),
                    re(null == (r = null == t ? void 0 : t.serverControls) ? void 0 : r.canSkipUntil) && re(t.tloadMillis) && t.fragments.length) {
                        const e = performance.now() - t.tloadMillis
                          , i = t.fragments[t.fragments.length - 1]
                          , r = i.start + i.duration
                          , s = r + e / 1e3 - (null != (n = null == (n = null == t ? void 0 : t.serverControls) ? void 0 : n.canSkipUntil) ? n : 0) < r;
                        s && !1 === (null == (n = t.serverControls) ? void 0 : n.canSkipDateRanges) && a.searchParams.set("_HLS_skip", "YES"),
                        s && null != (n = t.serverControls) && n.canSkipDateRanges && a.searchParams.set("_HLS_skip", "V2")
                    }
                } else
                    a.searchParams.set("_HLS_msn", (t.endSN + 1).toString());
                return a.href
            }(S, c, i) : null != h && h.renditionReports && (S = function(t, e, i) {
                var r, n, a = null == (r = e.renditionReports) ? void 0 : r.find(e => us.buildAbsoluteURL(t, e.relUri, {
                    alwaysNormalize: !0
                }) === t);
                if (a) {
                    const s = new URL(t)
                      , r = i && null != (n = e.partEndSN) ? n : e.endSN
                      , o = null != (n = a.lastMSN) ? n : r
                      , l = o === e.partEndSN ? e.partEndIndex : 0
                      , d = null != (n = a.lastPart) ? n : l;
                    return s.searchParams.set("_HLS_msn", o.toString()),
                    i && re(d) && s.searchParams.set("_HLS_part", d.toString()),
                    s.href
                }
                return t
            }(S, h, i.liveAllowLowLatencyPlayback)),
            Mo({
                url: S,
                xhrSetup: i.xhrSetup
            }, v, a, n).pipe(Pr(Zn), W( ({responseText: e, stats: t}) => {
                var i = performance.now()
                  , e = ef.parseMediaOptionPlaylist(e, S, d, null != u ? u : {}, p, m, f, l, s, y, c);
                let r = [];
                f === se.Variant && (r = Lh(e.mediaOptionDetails, p, o)),
                ao(e.mediaOptionDetails);
                var n = performance.now()
                  , a = e["mediaOptionDetails"]
                  , i = (a.tloadMillis = t.tload,
                re(t.age) && (a.age = t.age),
                {
                    playlistLoadTimeMs: t.tload - t.trequest,
                    playlistParseTimeMs: n - i,
                    tparsed: {
                        tbegin: i,
                        tend: n
                    }
                });
                return {
                    mediaOptionDetails: a,
                    isDeltaPlaylist: e.isDeltaPlaylist,
                    interstitials: r,
                    bwSample: t,
                    playlistSample: i
                }
            }
            ), ro(f, m, !1, S))
        }
          , lf = (m, e, f, t, g) => Y(e).pipe(te(e => {
            const {keyTagInfo: t, isInitSegment: i, iframe: r, byteRangeOffset: n} = m
              , a = null == t ? void 0 : t.method
              , {start: s, end: o} = null != n ? n : {};
            if ("AES-128" !== a)
                return Y(e);
            {
                null == t || !t.uri || t.iv || t.format && "identity" !== t.format || (t.iv = function(t) {
                    var i = new Uint8Array(16);
                    for (let e = 12; e < 16; e++)
                        i[e] = t >> 8 * (15 - e) & 255;
                    return i
                }(m.mediaSeqNum));
                const n = e
                  , a = null == (e = null == t ? void 0 : t.key) ? void 0 : e.buffer
                  , l = null == (e = null == t ? void 0 : t.iv) ? void 0 : e.buffer
                  , d = re(s) && re(o) && (r || i) ? o - s : 0
                  , u = !f.enableWebCrypto || !!d
                  , c = null != (e = null == a ? void 0 : a.slice(0)) ? e : new ArrayBuffer(0)
                  , h = null != (e = null == l ? void 0 : l.slice(0)) ? e : new ArrayBuffer(0)
                  , p = {
                    useJSCrypto: u,
                    plainTextLength: d
                };
                return g.decrypt(c, h, "AES-CBC", n, p)
            }
        }
        ));
        function df(e, t, i) {
            return e.findIndex(e => e.mediaSeqNum === t && e.partIndex === i)
        }
        function uf(e) {
            const {itemId: t, mediaOptionId: i, mediaOptionType: r, relativeUrl: n, byteRangeOffset: a} = e;
            let s = t + i + r.toString() + n;
            if (re(null == a ? void 0 : a.start)) {
                const {start: e, end: t} = a;
                s = s + e.toString() + t.toString()
            }
            return s
        }
        function cf(e) {
            var {itemId: e, mediaOptionId: t, mediaOptionType: i, relativeUrl: r, byteRangeOffset: n} = e
              , e = {
                itemId: e,
                mediaOptionId: t,
                mediaOptionType: i,
                redactedUrl: f(r),
                start: NaN,
                end: NaN
            };
            re(null == n ? void 0 : n.start) && (e.start = n.start,
            e.end = n.end),
            JSON.stringify(e)
        }
        function hf(e, t) {
            if (t.part) {
                const i = e.parts;
                return jc(t, i[df(i, t.mediaSeqNum, t.partIndex)])
            }
            const i = e.fragments
              , r = t.mediaSeqNum - e.startSN;
            return 0 <= r && r < e.fragments.length && jc(t, i[r])
        }
        function pf(i, e, r, t, n=!1, a=!1) {
            var {startPts: s, endPts: e} = e
              , o = i[r];
            o.startPts = s,
            o.endPts = e,
            o.start = t,
            o.duration = x(e, s);
            for (let e = r, t = !0; 0 < e && (a || t); e--)
                t = ff(i, e, e - 1, s.timescale, n);
            for (let e = r, t = !0; e < i.length - 1 && (a || t); e++)
                t = ff(i, e, e + 1, s.timescale, n)
        }
        function mf(t, i, r, n=!1, a=!1, e=!1) {
            if (hf(t, i)) {
                if (i.part) {
                    let e = t.parts;
                    var s = df(e, i.mediaSeqNum, i.partIndex)
                      , o = e[s];
                    n && ((e = t.parts = t.parts.slice())[s] = Object.assign({}, o)),
                    pf(e, i, s, r, n, a)
                } else {
                    let e = t.fragments;
                    o = i.mediaSeqNum - t.startSN,
                    s = hc(e, i.mediaSeqNum);
                    n && ((e = t.fragments = t.fragments.slice())[o] = Object.assign({}, s)),
                    pf(e, i, o, r, n, a)
                }
                t.totalduration = Xp(t, e),
                t.ptsKnown = !0
            }
        }
        function ff(e, t, i, r, n=!1) {
            var a = e[t];
            let s = e[i]
              , o = s.start;
            null == s.startPts && (o = t < i ? a.start + a.duration : Math.max(a.start - s.duration, 0));
            t = re(r) ? 1 / r : Number.EPSILON,
            a = Math.abs(s.start - o) > t;
            return !!a && (n && (s = e[i] = Object.assign({}, s)),
            a && (s.start = o),
            !0)
        }
        function gf(t, i, r, n, a) {
            return e => e.pipe($(e => {
                if (t.logger.error(`Got demux error ` + e.message),
                e instanceof A || e instanceof N)
                    return Jh.SendAlternateToPenaltyBox,
                    _p(e, 0, {
                        errorAction: e.fatal ? Jh.SendEndCallback : e instanceof N ? Jh.SendAlternateToPenaltyBox : Jh.RemoveAlternatePermanently,
                        errorActionFlags: 0
                    }, i, t, r, n, a);
                throw e
            }
            ))
        }
        function yf(t, m, i, f, g, y, v, S, I) {
            return g = Math.max(0, g),
            e => e.pipe(ie( () => {
                null != i && S.updateConsecutiveTimeouts(t, i, !1, "load")
            }
            ), bn(e => e.pipe(te( (n, a) => {
                {
                    var s = n, o = a, l = (a = to(n, f),
                    n = y,
                    g), d = v, u = S, c = I, h = m, p;
                    if (!(s instanceof b))
                        return R(s);
                    let e, t, i, r = !1;
                    if (s instanceof Ws)
                        i = {
                            errorAction: kp(Np((p = s).response)["errorAction"], p.response),
                            errorActionFlags: 0
                        };
                    else {
                        ({mediaOptionType: t, mediaOptionId: e, isTimeout: r} = s);
                        const o = null == (p = d.mediaOptionListQueries[t]) ? void 0 : p.mediaOptionFromId(e);
                        if (!n && s.isTimeout && null != o && (!("iframes"in o) || !0 !== o.iframes) && (u.updateConsecutiveTimeouts(d.itemId, s.mediaOptionType, !0, "load"),
                        s instanceof Ys) && s.stats) {
                            const o = performance.now();
                            c.setBandwidthSample(Object.assign(Object.assign({}, s.stats), {
                                tfirst: s.stats.tfirst || o,
                                tload: s.stats.tload || o,
                                complete: !0,
                                mediaOptionType: t
                            }))
                        }
                        i = Dp(s, n, l, d, u)
                    }
                    return Up(s, o, a, i, d, u, h, t, e, r)
                }
            }
            ))))
        }
        function vf(n, a, r, s, o=!1) {
            var l, d, u, c = n.mediaOptionId === a.mediaOptionId;
            if ("VOD" !== n.type && n.iframesOnly === a.iframesOnly && (!r || c)) {
                s = s.child({
                    name: "live"
                });
                let e = re(null == (v = a.parts) ? void 0 : v.length);
                o || e && (a.parts = [],
                a.partStartSN = a.partEndSN = a.partEndIndex = NaN,
                a.partTargetDuration = NaN,
                e = !1);
                var h = n.fragments
                  , p = a.fragments
                  , m = null != (s = n.parts) ? s : []
                  , f = null != (v = a.parts) ? v : []
                  , s = re(null == p ? void 0 : p.length) && 0 < p.length;
                let t, i;
                {
                    var g = n;
                    var y = a;
                    var g = g.fragments
                      , v = y.fragments;
                    let r = 0;
                    var g = hc(g, y.startSN)
                      , S = hc(v, y.startSN);
                    if (0 !== (r = g && S ? g.discoSeqNum - S.discoSeqNum : r)) {
                        const g = {};
                        v.forEach(e => {
                            var t = e.discoSeqNum
                              , i = t + r;
                            y.initSegments[t] && (g[i] = y.initSegments[t],
                            g[i].discoSeqNum = i),
                            e.discoSeqNum = i
                        }
                        ),
                        y.initSegments = g
                    }
                }
                if (c && (s && (t = Sf(h, p)),
                e) && (i = Sf(m, f)),
                t || i) {
                    if (i && (mf(a, i, i.start, !1, !0),
                    !t) && s && 0 === i.partIndex && (t = hc(p, i.mediaSeqNum, NaN)) && (If(t, i),
                    mf(a, t, t.start, !1, !0)),
                    t && (mf(a, t, t.start, !1, !0),
                    !i) && e) {
                        const n = df(f, t.mediaSeqNum, 0);
                        0 <= n && (If(i = f[n], t),
                        mf(a, i, i.start, !1, !0))
                    }
                } else
                    (p.length || e) && (p.length && bf(h, p, n),
                    e) && bf(m, f, n);
                if (r) {
                    const r = a.startSN - n.startSN
                      , s = null == (g = h[r]) ? void 0 : g.discoSeqNum;
                    if (re(s)) {
                        for (const [r,o] of Object.entries(n.initSegments)) {
                            const n = Number(r);
                            n >= s && !a.initSegments[n] && (a.initSegments[n] = o)
                        }
                        for (const [r,o] of Object.entries(n.discoToMSNMap)) {
                            const n = Number(r);
                            if (n >= s) {
                                const r = Math.max(a.startSN, Math.min(null != (l = null == (l = a.discoToMSNMap[n]) ? void 0 : l[0]) ? l : 1 / 0, o[0]))
                                  , s = null != (l = null == (l = a.discoToMSNMap[n]) ? void 0 : l[1]) ? l : o[1];
                                a.discoToMSNMap[n] = [r, s]
                            }
                        }
                    }
                    const o = h.slice(r)
                      , v = o[o.length - 1].keyTagInfo;
                    if (v)
                        for (const n of p) {
                            if ((null == (d = n.keyTagInfo) ? void 0 : d.uri) !== v.uri || (null == (d = n.keyTagInfo) ? void 0 : d.iv) !== v.iv)
                                break;
                            n.keyTagInfo = v
                        }
                    if (a.fragments = o.concat(p),
                    e) {
                        const r = df(null != (S = n.parts) ? S : [], a.partStartSN, 0)
                          , s = m.slice(r)
                          , o = s[s.length - 1].keyTagInfo;
                        if (o)
                            for (const n of f) {
                                if ((null == (u = n.keyTagInfo) ? void 0 : u.uri) !== o.uri || (null == (u = n.keyTagInfo) ? void 0 : u.iv) !== o.iv)
                                    break;
                                n.keyTagInfo = o
                            }
                        a.parts = s.concat(f)
                    }
                    a.fragments.length ? a.averagetargetduration = (zp(a, !1) - Wp(a, !1)) / a.fragments.length : a.averagetargetduration = a.targetduration,
                    (0 < a.pdtToMSN.length || 0 < n.pdtToMSN.length) && (a.pdtToMSN = function(i, r) {
                        var n = i.fragments;
                        let e = i.pdtToMSN;
                        if (r.startSN > i.startSN) {
                            const l = r.fragments[0]
                              , t = r.startSN
                              , a = i.pdtToMSN.findIndex( ([,e]) => {
                                if (e >= t)
                                    return !0
                            }
                            );
                            if (!(e = -1 !== a ? i.pdtToMSN.slice(a) : []).length || e[0][1] !== t) {
                                let t = l.programDateTime;
                                if (!re(t)) {
                                    let e = 0;
                                    i.pdtToMSN.length && (e = i.pdtToMSN[0][0]),
                                    t = e + 1e3 * (l.start - n[0].start)
                                }
                                e.unshift([t, r.startSN])
                            }
                        }
                        const t = Yp(i, i.endSN)
                          , a = null == t ? void 0 : t.discoSeqNum
                          , s = r.pdtToMSN
                          , o = s.findIndex( ([,e]) => {
                            e = Yp(r, e),
                            e = null == e ? void 0 : e.discoSeqNum;
                            if (re(e) && re(a) && e > a)
                                return !0
                        }
                        );
                        return e = -1 !== o ? e.concat(s.slice(o)) : e.concat(s)
                    }(n, a))
                }
                v = Wp(a, o),
                s = zp(a, o);
                a.ptsKnown = a.ptsKnown || c && !0 === n.ptsKnown && n.endSN >= a.startSN,
                a.totalduration = s - v
            }
        }
        function Sf(t, i) {
            let r;
            for (let e = 0; e < (null == i ? void 0 : i.length); e++) {
                var n = i[e]
                  , a = hc(t, n.mediaSeqNum, n.partIndex);
                n && null != (null == a ? void 0 : a.startPts) && (n.start = a.start,
                n.duration = a.duration,
                n.startPts = a.startPts,
                n.endPts = a.endPts,
                r = n)
            }
            return r
        }
        function If(e, t) {
            e.start = t.start,
            e.startPts = t.startPts,
            w(t.startPts) && (e.endPts = c(t.startPts, e.duration))
        }
        function bf(e, t, i) {
            var r, n, a, s, o = t[0], l = Math.max(0, o.start);
            let d = 0;
            const u = hc(e, o.mediaSeqNum, o.partIndex);
            if (u)
                d = u.start - l;
            else if (o.part) {
                const t = e[e.length - 1];
                if (t) {
                    const e = t.mediaSeqNum
                      , p = t.partIndex
                      , u = null != (r = o.partIndex) ? r : 0;
                    if (e === o.mediaSeqNum && p === u - 1 || e === o.mediaSeqNum - 1 && 0 === o.partIndex)
                        d = t.start + t.duration - l;
                    else {
                        const e = null != (a = i.partTargetDuration) ? a : 1;
                        if (null != (n = i.fragments) && n.length) {
                            const t = zp(i, !1)
                              , p = o.mediaSeqNum - i.endSN - 1
                              , r = null != (a = o.partIndex) ? a : 0;
                            d = t + p * i.averagetargetduration + r * e - l
                        } else {
                            const t = zp(i, !0)
                              , p = null != (s = i.partEndSN) ? s : 0
                              , r = null != (s = i.partEndIndex) ? s : 0
                              , a = null != (s = o.partIndex) ? s : 0
                              , n = Math.ceil(i.targetduration / e);
                            d = t + ((o.mediaSeqNum - p - 1) * n + n - r - 1 + a) * e - l
                        }
                    }
                }
            } else
                d = zp(i) + (o.mediaSeqNum - i.endSN - 1) * i.averagetargetduration - l;
            var c = t
              , h = d;
            h < 0 && (h = 0);
            for (let e = 0; e < c.length; ++e)
                c[e].start += h
        }
        class Tf extends ja {
            constructor(e, t) {
                super(e);
                var {itemId: e, mediaOptionId: t} = this.mediaOption = t;
                this.mediaOption = {
                    itemId: e,
                    mediaOptionId: t
                }
            }
            get itemId() {
                var e;
                return null == (e = this.mediaOption) ? void 0 : e.itemId
            }
            get mediaOptionId() {
                return this.mediaOption.mediaOptionId
            }
            get initSegmentEntities() {
                var e;
                return null == (e = this.mediaOptionDetailsEntity) ? void 0 : e.initSegmentCacheEntities
            }
            get mediaLibraryEntity() {
                return this.getEntity(this.itemId)
            }
            get mediaOptionDetailsEntityRecord() {
                var e;
                return null == (e = this.mediaLibraryEntity) ? void 0 : e.mediaOptionDetailsEntityRecord
            }
            lastUpdatedDetailsEntityByType(t) {
                var i, r = this.mediaOptionDetailsEntityRecord;
                if (r) {
                    let e;
                    for (const a of Object.keys(r)) {
                        var n = r[a];
                        (t === (null == (i = n.mediaOptionDetails) ? void 0 : i.mediaOptionType) && n && !e || n && e && (null == n ? void 0 : n.lastUpdateMillis) < (null == e ? void 0 : e.lastUpdateMillis)) && (e = n)
                    }
                    return e
                }
            }
            get mediaOptionDetailsEntity() {
                return this.mediaOptionDetailsEntityRecord ? this.mediaOptionDetailsEntityRecord[this.mediaOptionId] : null
            }
            get mediaOptionDetails() {
                var e;
                return null == (e = this.mediaOptionDetailsEntity) ? void 0 : e.mediaOptionDetails
            }
            get playlistDuration() {
                var e;
                return null == (e = this.mediaOptionDetailsEntity) ? void 0 : e.playlistDuration
            }
            get mediaOptionDetailsEntity$() {
                const {itemId: e, mediaOptionId: t} = this;
                return this.selectEntity(e, e => null == e || !e.mediaOptionDetailsEntityRecord || null == e ? void 0 : e.mediaOptionDetailsEntityRecord[t])
            }
            get mediaOptionDetails$() {
                return this.selectEntity(this.itemId, e => {
                    return null == (e = null == e ? void 0 : e.mediaOptionDetailsEntityRecord[this.mediaOptionId]) ? void 0 : e.mediaOptionDetails
                }
                ).pipe(Kl())
            }
            get playlistDuration$() {
                return this.mediaOptionDetailsEntity$.pipe(W(e => null == e ? void 0 : e.playlistDuration), Kl(), J())
            }
            get live$() {
                return this.mediaOptionDetails$.pipe(W(e => null == e ? void 0 : e.liveOrEvent), J())
            }
            get liveEdgeGrows$() {
                return this.mediaOptionDetails$.pipe(W(e => e.endSN), J( (e, t) => t <= e), On(1), rn(!0))
            }
        }
        class Ef extends Ua {
            constructor() {
                super({}, {
                    name: "media-library-store",
                    idKey: "itemId"
                })
            }
        }
        function Af(e, t) {
            var {trequest: t, tfirst: i, tload: r, loaded: n} = t;
            e.trequest = t,
            e.tfirst = i,
            e.tload = r,
            e.loaded = n
        }
        function Of(e) {
            return e.itemId + e.mediaOptionId + e.mediaSeqNum + e.discoSeqNum + (null != (e = e.partIndex) ? e : "")
        }
        function Rf(e) {
            return e.itemId + e.mediaOptionId
        }
        ($l = tf = tf || {})[$l.DISABLED = 0] = "DISABLED",
        $l[$l.ERRORED = 1] = "ERRORED",
        $l[$l.SUCCESS = 2] = "SUCCESS",
        $l[$l.IN_PROGRESS = 3] = "IN_PROGRESS",
        (ed = rf = rf || {})[ed.Manifest = 0] = "Manifest",
        ed[ed.Playlist = 1] = "Playlist",
        ed[ed.Segment = 2] = "Segment";
        class wf {
            constructor(e, t) {
                this.oa = e,
                this.aa = t,
                this.inFlightDetails = null,
                this.la = {},
                this.ua = [void 0, void 0],
                this.Ho = new Map,
                this.ca = null,
                this.inFlightFragStats = [],
                this.prefetchItems = {},
                this.preloadHints = {},
                this.ri = new ja(e)
            }
            get query() {
                return this.ri
            }
            getQueryForOption(e) {
                var t = Rf(e);
                let i = this.Ho.get(t);
                return i || (i = new Tf(this.oa,{
                    itemId: e.itemId,
                    mediaOptionId: e.mediaOptionId
                }),
                this.Ho.set(t, i)),
                i
            }
            createMediaLibraryEntity(e) {
                this.oa.add({
                    itemId: e,
                    mediaOptionDetailsEntityRecord: {}
                })
            }
            ha(t, i, r) {
                var n = t["mediaOptionId"]
                  , t = this.getQueryForOption(t);
                if (r || null != (r = t.mediaOptionDetailsEntityRecord) && r[n]) {
                    r = t.mediaOptionDetailsEntityRecord;
                    let e = null == r ? void 0 : r[n];
                    return e = e || {
                        initSegmentCacheEntities: {},
                        unchangedCount: 0
                    },
                    {
                        mediaOptionDetailsEntityRecord: Object.assign(Object.assign({}, r), {
                            [n]: Object.assign(Object.assign({}, e), i)
                        })
                    }
                }
            }
            da(e, t, i) {
                t = this.ha(e, t, i);
                t && this.oa.update(e.itemId, t)
            }
            setDetailsLoading(e, t=!0) {
                this.da(e, {
                    detailsLoading: t
                }, !0)
            }
            setLastAccessed(e) {
                var t = Rf(e);
                this.ca !== t && (this.ca = t,
                this.da(e, {
                    lastAccessedMillis: performance.now()
                }, !1))
            }
            retrieveMediaOptionDetails(i, e, t=!1, r=!1, n=!1) {
                if (null == e || !Ds(e))
                    return Y(null);
                var a = e["itemId"]
                  , s = this.getQueryForOption(e);
                s.hasEntity(a) || this.createMediaLibraryEntity(a);
                const {rootPlaylistQuery: o, rootPlaylistService: l, logger: d, config: u} = i
                  , c = u.enableItemPreloading && this.fa(o.appItemId);
                if (c) {
                    const i = c.cache["details"]
                      , t = i;
                    if (t && t.mediaOptionId === e.mediaOptionId && t.url === e.url)
                        return t.fragments.forEach(e => {
                            e.start += o.itemStartPosition
                        }
                        ),
                        this.archiveMediaOptionDetails(l, t, {
                            tfirst: 0,
                            tload: 0,
                            total: 1,
                            trequest: 0,
                            loaded: 1,
                            complete: !0
                        }, !0),
                        Y(t)
                }
                a = s.mediaOptionDetailsEntity,
                s = s.mediaOptionDetails;
                return null == s || r || "VOD" !== s.type && (!s.liveOrEvent || Km(s, a.lastUpdateMillis)) ? (this.setDetailsLoading(e),
                this.va(i, e, t).pipe(ie(e => {
                    var t;
                    this.pa(u.livePreloadHintCacheAge, d),
                    n && u.liveAllowLowLatencyPlayback && 0 < (null == (t = e.preloadHints) ? void 0 : t.length) && this.ma(i, e)
                }
                ))) : (this.setLastAccessed(e),
                Y(s).pipe().pipe(tn(1)))
            }
            va(e, r, t) {
                const {logger: n, config: a, rootPlaylistQuery: s, rootPlaylistService: o, statsService: l, rtcService: d, interstitialService: u, customUrlLoader: i, itemQueue: c, playerEvents: h} = e
                  , p = a.playlistLoadPolicy
                  , m = a.keySystemPreference
                  , f = s.masterVariableList
                  , g = this.aa.query.extendMaxTTFB
                  , y = this.getQueryForOption(r)
                  , v = null == y ? void 0 : y.mediaOptionDetails
                  , S = null == y ? void 0 : y.lastUpdatedDetailsEntityByType(r.mediaOptionType)
                  , I = null == S ? void 0 : S.mediaOptionDetails
                  , b = (null != h && h.handleLevelLoading(r),
                {
                    trequest: NaN,
                    tfirst: NaN,
                    tload: NaN,
                    tparse: NaN,
                    tparsed: NaN,
                    loaded: 0
                });
                return of(r, s.baseUrl, s.itemStartPosition, a, a, p, i, n, m, f, g, v, I).pipe(W(e => {
                    Af(b, e.bwSample),
                    b.tparsed = performance.now(),
                    b.tparse = b.tparsed - e.playlistSample.playlistParseTimeMs,
                    null != d && d.handleLevelParsed(e.playlistSample.tparsed),
                    null != h && h.handleLevelLoaded(r, e.mediaOptionDetails, e.bwSample);
                    var e = Pf(r, s, o, this, u, l, a, n)(e)
                      , {itemId: t, mediaOptionId: i} = e
                      , t = this.ha({
                        itemId: t,
                        mediaOptionId: i
                    }, {}, !1)
                      , t = null == (t = null == t ? void 0 : t.mediaOptionDetailsEntityRecord) ? void 0 : t[i];
                    return null != t && t.detailsLoading || 0 !== (null == t ? void 0 : t.unchangedCount) || null == h || h.handleLevelUpdated(e),
                    e
                }
                ), yf(r.itemId, c, r.mediaOptionType, eo(r, p), a.maxNumAddLevelToPenaltyBox, t, s, o, l))
            }
            archiveMediaOptionDetails(r, n, a, s, e=!1) {
                const {itemId: o, mediaOptionId: l} = n
                  , d = performance.now()
                  , u = zp(n, e);
                Object.isFrozen(n) || Object.freeze(n),
                ae( () => {
                    this.ri.hasEntity(o) || this.createMediaLibraryEntity(o);
                    var e, t, i = this.ha(n, {
                        detailsLoading: !1,
                        lastUpdateMillis: d,
                        lastAccessedMillis: d,
                        stats: a
                    }, !0);
                    i && (t = (e = i.mediaOptionDetailsEntityRecord)[l],
                    s ? (t.mediaOptionDetails = n,
                    t.playlistDuration = u,
                    t.unchangedCount = 0,
                    i.liveOrEvent = n.liveOrEvent) : ++t.unchangedCount,
                    function(t, i, r, n=2) {
                        var a = []
                          , s = Object.values(t).filter(e => {
                            var t;
                            return (null == (t = e.mediaOptionDetails) ? void 0 : t.mediaOptionType) === i && (null == (t = e.mediaOptionDetails) ? void 0 : t.iframesOnly) === r && null != e.lastAccessedMillis
                        }
                        ).sort( (e, t) => e.lastAccessedMillis - t.lastAccessedMillis);
                        for (let e = 0; e < s.length - n; ++e) {
                            const r = s[e].mediaOptionDetails;
                            a.push(r),
                            delete t[r.mediaOptionId]
                        }
                        return a
                    }(e, n.mediaOptionType, n.iframesOnly).forEach(e => {
                        e = Rf(e);
                        this.Ho.delete(e)
                    }
                    ),
                    this.oa.update(o, i),
                    r.setLastLoadedMediaOptionByType(n.itemId, n.mediaOptionType, n))
                }
                )
            }
            archiveInitSegmentEntity(e, t) {
                var i, r, n, a, s;
                (e || t) && ({itemId: i, mediaOptionId: r, discoSeqNum: n} = e || t,
                s = null == (s = null == (a = this.ha({
                    itemId: i,
                    mediaOptionId: r
                }, {}, !1)) ? void 0 : a.mediaOptionDetailsEntityRecord) ? void 0 : s[r]) && (s.initSegmentCacheEntities = Object.assign(Object.assign({}, s.initSegmentCacheEntities), {
                    [n]: [e, t]
                }),
                this.oa.update(i, a))
            }
            retrieveInitSegmentCacheEntity(e, t, i) {
                var {mediaOptionDetailsEntityRecord: r, mediaOptionDetails: n} = this.getQueryForOption(t)
                  , a = t["mediaOptionId"];
                if (null == r || !r[a])
                    throw new j(!1,H.NoSegmentDetailsEntity);
                if (!n)
                    throw new j(!1,H.NoSegmentDetails);
                r = r[a]["initSegmentCacheEntities"];
                if (r[i]) {
                    const [e,t] = r[i];
                    return Y(t || e)
                }
                return this.fetchInitSegmentCacheEntity(e, n, t, i)
            }
            fetchInitSegmentCacheEntity(r, e, n, t) {
                if (!e)
                    throw new j(!1,H.NoSegmentDetails);
                const i = e["initSegments"]
                  , a = i[t];
                if (!Mf(a))
                    return Y(null);
                const s = Of(a);
                let o = this.la[s];
                return o = o || (this.la[s] = na( () => {
                    const i = {
                        trequest: NaN,
                        tfirst: NaN,
                        tload: NaN,
                        tparse: NaN,
                        tparsed: NaN,
                        loaded: 0
                    };
                    return kf(r, a, !1).pipe(Pr(Zn), te( ({loadedData: e, bwSample: t}) => (Af(i, t),
                    i.tparse = performance.now(),
                    this.parseInitSegment(Ae(e), a, n, r))), ie( () => {
                        i.tparsed = performance.now()
                    }
                    ), ee( () => {
                        delete this.la[s]
                    }
                    ))
                }
                ).pipe(Tn()))
            }
            parseInitSegment(e, i, r, n) {
                const {rootPlaylistService: t, rootPlaylistQuery: a, mediaParser: s, itemQueue: o} = n
                  , {mediaOptionId: l, mediaOptionType: d} = i
                  , u = {
                    segment: void 0,
                    initSegment: e,
                    frag: i,
                    ptsKnown: void 0,
                    seeking: void 0,
                    live: void 0,
                    totalDuration: void 0
                }
                  , c = performance.now();
                return s.parseInitSegment(u).pipe(W(e => {
                    var t = performance.now();
                    return n.statsService.setInitFragSample({
                        tparsed: {
                            tbegin: c,
                            tend: t
                        }
                    }),
                    this.archiveInitSegment(e, i, r, n)
                }
                ), gf(t, a, o, d, l))
            }
            archiveInitSegment(e, t, i, r) {
                var {gaplessInstance: r, config: n} = r;
                if (!n.supportGaplessVideo) {
                    const t = e["track"];
                    r.inGaplessMode && q.isVideoCodec(t.codec) && !n.enableInterstitialPlayback && r.dequeueSource("InvalidFormat")
                }
                n = Cf(e, t, i);
                return this.archiveInitSegmentEntity(n),
                n
            }
            cacheFrag(e, t) {
                const i = Of(t)
                  , a = t["mediaOptionType"];
                var r, n;
                if (a !== se.Subtitle)
                    return this.isCachingFrag(t) && this.clearCacheFragRequest(t.mediaOptionType),
                    r = new mn,
                    n = a === se.Variant ? {
                        getData: !1,
                        cb: (e, t, i, r) => {
                            var n = null == (n = this.ua[a]) ? void 0 : n.onProgressCb;
                            return !!n && n(e, t, i, r)
                        }
                        ,
                        samplePeriodMs: e.config.abrSamplePeriodMs
                    } : void 0,
                    this.ua[a] = {
                        id: i,
                        result$: r,
                        sub: this.ya(e, !0, t, n).subscribe(r)
                    },
                    r
            }
            isCachingFrag(e) {
                var t = e["mediaOptionType"];
                return t !== se.Subtitle && (null == (t = this.ua[t]) ? void 0 : t.id) === Of(e)
            }
            clearCacheFragRequest(e) {
                e !== se.Subtitle && this.ua[e] && (this.ua[e].sub.unsubscribe(),
                this.ua[e] = void 0)
            }
            ga(e, t) {
                return e.sessionData.itemList.some(e => "com.apple.hls.AudioSessionKeyInfo" === e["DATA-ID"] || "com.apple.hls.audioAssetMetadata" === e["DATA-ID"])
            }
            ba(t, e, i, r, n, a) {
                var {mediaOptionId: s, mediaOptionType: o, duration: l} = e
                  , n = n.partialAppendDurationSec;
                let d = !1
                  , u = 0;
                if (t && this.ga(r, a) && re(n) && 0 < n && o === se.Variant && !i.liveOrEvent && 0 === e.start && !re(e.startPts)) {
                    const t = r.variantMediaOptionById(s);
                    u = F(t.avgBandwidth, t.bandwidth);
                    let e = 1;
                    const i = r.enabledAlternateMediaOptionByType(se.AltAudio);
                    i && (e = xs(i) && Ds(i) ? 2 : 1),
                    d = 1 === e && !t.videoCodec && re(u) && 0 < u && n < l
                }
                let c = e.byteRangeOffset.end;
                if (d) {
                    const t = e.byteRangeOffset.start + Math.floor(u / 8 * n);
                    t >= c ? d = !1 : c = t
                }
                return d ? {
                    partial: !0,
                    duration: n,
                    end: c
                } : {
                    partial: !1,
                    duration: e.duration,
                    end: c
                }
            }
            Sa(e, t, i, r) {
                const n = Of(i);
                if (!Mf(i) || this.la[n])
                    return null;
                {
                    const e = {
                        start: i.byteRangeOffset.start,
                        end: r.end
                    }
                      , n = Object.assign(Object.assign({}, t), {
                        duration: r.duration,
                        byteRangeOffset: e,
                        dataOffset: t.byteRangeOffset.start - i.byteRangeOffset.start
                    });
                    return r.partial && (n.partialFrag = !0),
                    n
                }
            }
            wa(a, s) {
                return e => e.pipe(Pr(Zn), te(e => {
                    var t, i, {mediaFragment: r, loadedData: n} = e;
                    return re(r.dataOffset) ? (i = r.dataOffset,
                    r = Object.assign(Object.assign({}, s), {
                        keyTagInfo: r.keyTagInfo
                    }),
                    t = Oe(n, i),
                    n = Oe(n, 0, i),
                    i = Object.assign(Object.assign({}, e), {
                        loadedData: t
                    }),
                    aa([this.parseInitSegment(n, r, r, a), Y(i)])) : Y([null, e])
                }
                ))
            }
            Ta(r, n, a, e) {
                const {rootPlaylistQuery: t, config: i} = r
                  , s = a.mediaOptionType;
                if (s === se.Subtitle)
                    throw new j(!1,H.InvalidMediaOptionType);
                var o = t.baseUrl
                  , {rootEntity: l, fragRequest: d} = i.enableItemPreloading && null != (l = this.getPrefetchCache(t.appItemId)) ? l : {};
                return l && o === l.baseUrl && d && d.id === Of(a) ? d.result$.pipe($(e => {
                    throw this.clearPrefetchCache(),
                    e
                }
                ), te(e => {
                    var [e,t] = e
                      , i = n.initSegments[a.discoSeqNum];
                    return e ? aa([this.parseInitSegment(Ae(e.loadedData), i, a, r), Y(t)]) : Y(t).pipe(this.wa(r, i))
                }
                )) : this.isCachingFrag(a) ? (this.ua[s].onProgressCb = null == e ? void 0 : e.cb,
                this.ua[s].result$.pipe(ee( () => {
                    this.clearCacheFragRequest(s)
                }
                ))) : void (this.ua[s] && this.clearCacheFragRequest(s))
            }
            ya(e, t, i, r) {
                var n, a, {config: s, rootPlaylistQuery: o, logger: l} = e, d = i["mediaOptionType"], u = this.getQueryForOption(i), {mediaOptionId: c, discoSeqNum: h} = i, p = u.mediaOptionDetails;
                if (d === se.Subtitle)
                    throw new j(!1,H.InvalidMediaOptionType);
                d = this.Ta(e, p, i, r);
                if (d)
                    return d;
                if ((null == (a = null == (n = u.mediaOptionDetailsEntityRecord[c]) ? void 0 : n.initSegmentCacheEntities) || !a[h]) && Nf(p, i)) {
                    const n = p.initSegments[i.discoSeqNum]
                      , a = this.ba(t, i, u.mediaOptionDetails, o, s, l)
                      , H = this.Sa(e, i, n, a);
                    if (H)
                        return kf(e, H, null == e.rtcService.serverInfoInstance, r).pipe(this.wa(e, n))
                }
                let m = X;
                if (i.part) {
                    cf(i);
                    const e = uf(i)
                      , t = Object.keys(this.preloadHints);
                    for (const r of t)
                        r === e && (m = this.preloadHints[r].cache.result$.pipe(W(e => Object.assign(Object.assign({}, e), {
                            mediaFragment: i
                        })), $( () => X)))
                }
                return aa([this.retrieveInitSegmentCacheEntity(e, i, i.discoSeqNum), kf(e, i, null == e.rtcService.serverInfoInstance, r, m)])
            }
            retrieveMediaFragmentCacheEntity(_, e, t, i) {
                if (e === se.Subtitle)
                    throw new j(!0,H.InvalidMediaOptionType);
                const V = _["rootPlaylistQuery"]
                  , {timelineOffset: Q, mediaFragment: r} = t.foundFrag
                  , K = r["discoSeqNum"]
                  , n = this.ya(_, !1, r, i).pipe(te( ([B,{mediaFragment: t, loadedData: U, bwSample: i, serverInfo: r}]) => {
                    this.inFlightFragStats[e] && Af(this.inFlightFragStats[e], i),
                    _.statsService.setBandwidthSample(Object.assign(Object.assign({}, i), {
                        mediaOptionType: t.mediaOptionType
                    })),
                    r && null == _.rtcService.serverInfoInstance && (_.rtcService.serverInfoInstance = r),
                    _.playerEvents.triggerFragLoaded(t, i),
                    _f(_, e, t, "parsing", null);
                    {
                        var n = Ae(U)
                          , a = null == (r = V.getInitPTS(K)) ? void 0 : r.offsetTimestamp
                          , y = (i = B,
                        t)
                          , v = Q
                          , S = _;
                        const {legibleSystemAdapter: s, rootPlaylistService: o, mediaSink: l, mediaParser: I, rootPlaylistQuery: d, mediaLibraryService: b, itemQueue: u} = S
                          , c = l["mediaQuery"]
                          , T = b.getQueryForOption(y)
                          , {mediaOption: h, mediaOptionDetails: p, mediaOptionDetailsEntityRecord: m} = T
                          , f = p["initSegments"]
                          , {itemId: E, mediaOptionId: A} = h
                          , g = m[A]["initSegmentCacheEntities"]
                          , {discoSeqNum: O, mediaSeqNum: R, mediaOptionType: w, isLastFragment: P, part: M=!1, partIndex: C=NaN} = y
                          , k = c.seeking
                          , L = p.liveOrEvent
                          , N = f[O]
                          , D = g[O]
                          , x = w === se.Variant && p.ptsKnown
                          , F = {
                            segment: n,
                            frag: y,
                            seeking: k,
                            live: L,
                            ptsKnown: x,
                            totalDuration: p.totalduration,
                            defaultInitPTS: a,
                            iframeMediaStart: Hc(y) ? y.iframeMediaStart : void 0,
                            iframeDuration: Hc(y) ? y.iframeMediaDuration : void 0,
                            iframeOriginalStart: Hc(y) ? y.iframeOriginalStart : void 0
                        };
                        let e;
                        if (null != i && (null == (a = y.keyTagInfo) ? void 0 : a.uri) === (null == (a = i.keyTagInfo) ? void 0 : a.uri) && (null == (a = y.keyTagInfo) ? void 0 : a.iv) === (null == (a = i.keyTagInfo) ? void 0 : a.iv)) {
                            if (e = Y(i),
                            D) {
                                const n = D[0];
                                if (n) {
                                    const a = n["data"];
                                    F.initSegment = a
                                }
                            }
                        } else if (null != i && Mf(i.fragment)) {
                            const a = Object.assign(Object.assign({}, i.fragment), {
                                keyTagInfo: y.keyTagInfo
                            })
                              , v = N ? Oe(i.data) : n;
                            e = b.parseInitSegment(v, a, h, S),
                            F.initSegment = v
                        } else
                            Mf(y) ? (e = b.parseInitSegment(n, y, h, S),
                            F.initSegment = n) : e = Y(null);
                        return e.pipe(te(f => {
                            const g = performance.now();
                            return w !== se.Variant || null != s && s.setupForFrag(y),
                            I.parseSegment(F, "").pipe(W(e => {
                                var t, i = performance.now(), {startPTS: e, startDTS: r, endPTS: n, endDTS: a, firstKeyframePts: s, framesWithoutIDR: o, largestVideoSampleSize: l, dropped: d, data1: u, data2: c, captionData: h, id3Samples: p, parsedInitSegment: m} = e, i = {
                                    durationSec: n.baseTime / n.timescale - e.baseTime / e.timescale,
                                    parseTimeMs: i - g,
                                    tparsed: {
                                        tbegin: g,
                                        tend: i
                                    }
                                };
                                if (S.statsService.setFragSample(i),
                                m) {
                                    const {track: g, moovData: e, mimeType: v} = m
                                      , S = g["initSegment"]
                                      , t = (f = null === f ? Cf(m, y, T) : {
                                        itemId: E,
                                        mediaOptionId: A,
                                        discoSeqNum: O,
                                        initParsedData: e,
                                        data: S,
                                        mimeType: v,
                                        keyTagInfo: y.keyTagInfo,
                                        fragment: y
                                    },
                                    D ? D[0] : null);
                                    b.archiveInitSegmentEntity(t, f)
                                }
                                i = y.keyTagInfo,
                                m = {
                                    itemId: E,
                                    mediaOptionId: A,
                                    mediaOptionType: w,
                                    mediaSeqNum: R,
                                    discoSeqNum: O,
                                    part: M,
                                    partIndex: C,
                                    startDtsTs: r,
                                    endDtsTs: a,
                                    timelineOffset: v,
                                    firstKeyframePts: s,
                                    framesWithoutIDR: o,
                                    largestVideoSampleSize: l,
                                    dropped: d,
                                    data1: u,
                                    data2: c,
                                    startPts: e,
                                    endPts: n,
                                    keyTagInfo: i,
                                    isLastFragment: P,
                                    iframe: null != (t = y.iframe) && t,
                                    duration: y.duration,
                                    iframeMediaDuration: Hc(y) ? y.iframeMediaDuration : void 0,
                                    iframeOriginalStart: Hc(y) ? y.iframeOriginalStart : void 0,
                                    captionData: h,
                                    id3Samples: p
                                };
                                return y.partialFrag && (m.partialFrag = !0,
                                I.reset()),
                                [f, m]
                            }
                            ))
                        }
                        ), gf(o, d, u, w, A))
                    }
                }
                ), ie( () => {
                    _f(_, e, r, "parsed", null)
                }
                ));
                return n
            }
            updatePTSDTS(e, t, i, r, n=!1) {
                t = null == (e = this.getQueryForOption({
                    itemId: e,
                    mediaOptionId: t
                })) ? void 0 : e.mediaOptionDetails;
                if (t && hf(t, r) && !i.iframeMode && !r.iframe) {
                    var {startDtsTs: e, mediaSeqNum: a, part: s=!1, partIndex: o=NaN} = r
                      , {variantDTS: i, timelineOffset: l} = i
                      , i = x(e, i) + l
                      , l = Object.assign({}, t);
                    if (mf(l, r, i, !0, !1, n),
                    !s && 0 < (null == (e = l.parts) ? void 0 : e.length)) {
                        const e = l["parts"]
                          , t = df(e, a, 0);
                        -1 !== t && mf(l, Object.assign(Object.assign({}, e[t]), {
                            startPts: r.startPts,
                            endPts: c(r.startPts, e[t].duration),
                            startDtsTs: r.startDtsTs
                        }), i, !0, !1, n)
                    } else if (s) {
                        const e = l["fragments"];
                        if (0 === o) {
                            const t = hc(e, a);
                            t && mf(l, Object.assign(Object.assign({}, t), {
                                startPts: r.startPts,
                                endPts: c(r.startPts, t.duration),
                                startDtsTs: r.startDtsTs
                            }), i, !0, !1, n)
                        }
                    }
                    t = zp(l, n);
                    this.da(l, {
                        mediaOptionDetails: l,
                        playlistDuration: t
                    }, !1)
                }
            }
            remove(e) {
                this.oa.remove(e)
            }
            clear(e=!0, t=!0) {
                this.ua.forEach( (e, t) => this.clearCacheFragRequest(t)),
                e && this.clearPrefetchCache(),
                t && this.Ia(),
                this.la = {},
                this.oa.remove(),
                this.Ho.clear(),
                this.ca = null
            }
            clearPrefetchCache() {
                Object.values(this.prefetchItems).forEach(e => {
                    var t = e.cache["fragRequest"];
                    t && t.sub.unsubscribe(),
                    e.cache = {}
                }
                ),
                this.prefetchItems = {}
            }
            addPrefetchItem(e, t, i) {
                var r = this.prefetchItems[e];
                r && r.cache.rootEntity || (r = {
                    cache: {},
                    status: tf.IN_PROGRESS
                },
                this.prefetchItems[e] = r)
            }
            fa(e) {
                if (e)
                    return this.prefetchItems[e]
            }
            getSegmentRecord(e) {
                return this.fa(e)
            }
            getPrefetchCache(e) {
                return null == (e = this.getSegmentRecord(e)) ? void 0 : e.cache
            }
            cachePrefetchRootEntity(e, t) {
                e = this.fa(e);
                e && (e.cache.rootEntity = t)
            }
            cachePrefetchDetails(e, t) {
                e = this.fa(e);
                e && (e.cache.details = t)
            }
            cachePrefetchSegment(e, t, i, r) {
                const n = this.fa(t);
                if (n) {
                    var {rootEntity: a, fragRequest: s} = n.cache;
                    if (!s)
                        if (a)
                            return s = a.baseUrl,
                            a = new mn,
                            e = {
                                id: Of(r),
                                result$: a,
                                sub: this.Oa(e, s, t, i, r).pipe(no(r, !1), ie(e => {
                                    n && (n.status = tf.SUCCESS)
                                }
                                )).subscribe(a)
                            },
                            (n.cache.fragRequest = e).result$.pipe(W( () => tf.SUCCESS))
                }
            }
            Oa(e, t, i, r, n) {
                var a;
                const s = n["mediaOptionType"];
                if (s === se.Subtitle)
                    throw new j(!1,H.InvalidMediaOptionType);
                var o = null != (d = r.url) ? d : ps(r.relativeUrl, t)
                  , l = null == e.rtcService.serverInfoInstance;
                if (Nf(r, n)) {
                    const t = r.initSegments[n.discoSeqNum]
                      , d = {
                        start: t.byteRangeOffset.start,
                        end: null == (a = n.byteRangeOffset) ? void 0 : a.end,
                        duration: n.duration,
                        partial: !1
                    }
                      , s = this.Sa(e, n, t, d);
                    if (s)
                        return Lf(e, o, s, l).pipe(Df(e, s, i)).pipe(W(e => [null, e]))
                }
                var d = r.initSegments[n.discoSeqNum];
                return aa([d ? Lf(e, o, d, l).pipe(Df(e, d, i)) : Y(null), Lf(e, o, n, l).pipe(Df(e, n, i))])
            }
            setPrefetchErrored(e, t) {
                var i = this.fa(e);
                if (i && (i.status = tf.ERRORED,
                null == t || t === rf.Segment)) {
                    const e = i["cache"];
                    null != (t = e.fragRequest) && t.sub.unsubscribe(),
                    e.fragRequest = void 0
                }
            }
            Ia() {
                Object.values(this.preloadHints).forEach(e => {
                    e.cache.sub.unsubscribe(),
                    e.cache = null
                }
                ),
                this.preloadHints = {}
            }
            pa(t, i) {
                var e;
                if (0 < (null == (e = Object.keys(this.preloadHints)) ? void 0 : e.length)) {
                    const i = e => performance.now() - e.tloadMillis > 1e3 * t;
                    Object.entries(this.preloadHints).forEach( ([e,t]) => {
                        i(t) && (t.cache.sub.unsubscribe(),
                        t.cache = null,
                        delete this.preloadHints[e])
                    }
                    )
                }
            }
            getPreloadHintRecord(e) {
                return this.preloadHints[e]
            }
            getPreloadHintCache(e) {
                return null == (e = this.getPreloadHintRecord(e)) ? void 0 : e.cache
            }
            ma(e, t) {
                for (const s of t.preloadHints) {
                    var i, r = function(e, t) {
                        var {itemId: e, mediaOptionId: i, mediaOptionType: r} = e
                          , {resourceType: t, Uri: n, byteRangeStart: a, byteRangeLength: s} = t
                          , i = {
                            itemId: e,
                            mediaOptionId: i,
                            mediaOptionType: r,
                            relativeUrl: n,
                            start: NaN,
                            duration: NaN,
                            mediaSeqNum: NaN,
                            discoSeqNum: NaN,
                            isLastFragment: !1,
                            isInitSegment: "MAP" === t,
                            byteRangeOffset: {
                                start: NaN,
                                end: NaN
                            }
                        };
                        if (re(a)) {
                            const e = a
                              , t = re(s) ? e + s : Number.MAX_SAFE_INTEGER;
                            i.byteRangeOffset = {
                                start: e,
                                end: t
                            }
                        }
                        return i
                    }(t, s), n = uf(r), a = (cf(r),
                    new mn);
                    this.preloadHints[n] || (i = this.ka(e, t.url, t, r).pipe(no(r, !1)),
                    r = {
                        tloadMillis: t.tloadMillis,
                        fragment: r,
                        cache: {
                            id: n,
                            result$: a,
                            sub: i.subscribe(a)
                        }
                    },
                    this.preloadHints[n] = r)
                }
            }
            ka(e, t, i, r) {
                var n, a = r["mediaOptionType"];
                if (a === se.Subtitle)
                    throw new j(!1,H.InvalidMediaOptionType);
                {
                    a = e;
                    var s = null != (n = i.url) ? n : ps(i.relativeUrl, t)
                      , o = r
                      , l = null == e.rtcService.serverInfoInstance;
                    const {config: d, customUrlLoader: u} = a
                      , c = d.preloadHintLoadPolicy;
                    return new G(e => {
                        go(o, s, d, c, u, 0, void 0, l).pipe().subscribe(e)
                    }
                    )
                }
            }
        }
        function Pf(c, h, p, m, f, g, y, v) {
            return e => {
                const t = m.getQueryForOption(c)
                  , i = t.mediaOptionDetails
                  , {mediaOptionDetails: r, interstitials: n, isDeltaPlaylist: a} = e
                  , {bwSample: s, playlistSample: o} = e;
                let l = !0;
                if (r.liveOrEvent || null != i && i.liveOrEvent)
                    if (r.endSN < (null == i ? void 0 : i.endSN) || r.partEndSN < (null == i ? void 0 : i.partEndSN) || r.partEndSN === (null == i ? void 0 : i.partEndSN) && r.partEndIndex < (null == i ? void 0 : i.partEndIndex))
                        l = !1;
                    else {
                        const c = r["mediaOptionType"]
                          , p = (!(l = Hm(i, r)) && y.liveAllowLowLatencyPlayback && (l = jm(i, r)),
                        "" === r.type && (r.type = "LIVE"),
                        i && vf(i, r, a, v, y.liveAllowLowLatencyPlayback),
                        h.lastLoadedMediaOptionByType(c))
                          , f = p ? null == (e = m.getQueryForOption(p)) ? void 0 : e.mediaOptionDetails : null;
                        !r.ptsKnown && f && f.mediaOptionId !== (null == i ? void 0 : i.mediaOptionId) && vf(f, r, a, v, y.liveAllowLowLatencyPlayback)
                    }
                else
                    "" === r.type && (r.type = "VOD");
                const d = f.interstitialQuery
                  , u = d.getInterstitialAssetForId(r.itemId);
                if (null != u) {
                    const c = d.getInterstitialForId(u.parentIdentifier)
                      , h = u.duration || 0
                      , p = Xp(r, y.liveAllowLowLatencyPlayback)
                      , m = c.duration || 0;
                    ae( () => {
                        f.updateInterstitialAsset(u.identifier, {
                            duration: p
                        }),
                        f.updateInterstitial(c.identifier, {
                            duration: Math.max(m - h, 0) + p
                        })
                    }
                    )
                }
                if (ae( () => {
                    r && m.archiveMediaOptionDetails(p, r, s, l, y.liveAllowLowLatencyPlayback),
                    n && 0 < n.length && f.addInterstitials(n),
                    g.setPlaylistSample(o)
                }
                ),
                !l && t.mediaOptionDetailsEntity.unchangedCount >= y.liveMaxUnchangedPlaylistRefresh)
                    throw new zs(!1,H.LivePlaylistUpdateError,!1,c.mediaOptionType,c.mediaOptionId,i.url);
                return r
            }
        }
        function Mf(e) {
            return !0 === (null == e ? void 0 : e.isInitSegment)
        }
        function Cf(e, t, i) {
            var {itemId: i, mediaOptionId: r} = i
              , {keyTagInfo: n, discoSeqNum: a} = t
              , {track: e, moovData: s, mimeType: o} = e
              , e = e["initSegment"];
            return {
                itemId: i,
                mediaOptionId: r,
                discoSeqNum: a,
                initParsedData: s,
                data: e,
                mimeType: o,
                keyTagInfo: n,
                fragment: t
            }
        }
        function kf(n, i, r, a, s=X) {
            var e;
            const {rootPlaylistQuery: o, rootPlaylistService: l, config: d, statsService: u, customUrlLoader: c, itemQueue: h, hlsService: p} = n
              , {itemId: m, mediaOptionType: f, mediaOptionId: t} = i
              , g = d.fragLoadPolicy
              , y = re(i.mediaSeqNum)
              , v = o.mediaOptionListQueries[f].mediaOptionFromId(t)
              , S = null != (e = v.url) ? e : ps(v.relativeUrl, o.baseUrl)
              , I = "mediaSink"in n
              , b = new G(e => {
                var t = go(i, S, d, g, c, 0, a, r, p.query.extendMaxTTFB).pipe(yf(m, h, f, eo(i, g), d.maxNumAddLevelToPenaltyBox, !1, o, l, u));
                if (ne(s, t).pipe(tn(1), ie( ({mediaFragment: e}) => {
                    y && I && _f(n, e.mediaOptionType, e, "loaded", null)
                }
                )).subscribe(e),
                y && I && (_f(n, f, i, "loading", null),
                i.mediaOptionType !== se.Subtitle)) {
                    const {start: r, duration: a} = i;
                    n.mediaSink.updateInFlightRange(i.mediaOptionType, {
                        start: r,
                        end: r + a
                    })
                }
            }
            );
            return "AES-128" === (null == (e = i.keyTagInfo) ? void 0 : e.method) ? aa([xf(n, i.keyTagInfo, {
                itemId: i.itemId,
                mediaOptionId: i.mediaOptionId,
                appItemId: o.appItemId
            }), b]).pipe(te( ([e,t]) => {
                var {mediaFragment: i, loadedData: r} = t;
                return i.keyTagInfo.key = e.key,
                lf(i, r, d, n.logger, n.rpcClients.crypto).pipe(W(e => Object.assign(Object.assign({}, t), {
                    loadedData: Ae(e)
                })))
            }
            )) : b
        }
        function Lf(e, t, i, r, n) {
            const {config: a, customUrlLoader: s, hlsService: o} = e
              , l = a.fragLoadPolicy;
            return new G(e => {
                go(i, t, a, l, s, 0, n, r, o.query.extendMaxTTFB).pipe().subscribe(e)
            }
            )
        }
        function Nf(e, t) {
            var i;
            return e && null != (e = e.initSegments[t.discoSeqNum]) && null != e.byteRangeOffset && e.byteRangeOffset.end === (null == (i = t.byteRangeOffset) ? void 0 : i.start) && e.url === t.url
        }
        function Df(n, i, r) {
            return e => {
                var t;
                return "AES-128" === (null == (t = i.keyTagInfo) ? void 0 : t.method) ? aa([xf(n, i.keyTagInfo, {
                    itemId: i.itemId,
                    appItemId: r,
                    mediaOptionId: i.mediaOptionId
                }), e]).pipe(te( ([e,t]) => {
                    var {mediaFragment: i, loadedData: r} = t;
                    return i.keyTagInfo.key = e.key,
                    lf(i, r, n.config, n.logger, n.rpcClients.crypto).pipe(W(e => Object.assign(Object.assign({}, t), {
                        loadedData: Ae(e)
                    })))
                }
                )) : e
            }
        }
        function xf(e, t, i) {
            var {keySystemAdapter: e, config: r} = e
              , r = r["keyLoadPolicy"];
            return e.getKeyFromDecryptData(t, i, r)
        }
        function Ff(t) {
            return e => e.pipe(W(e => xs(e) && Ds(e) ? t.getQueryForOption(e) : null))
        }
        function Bf(i, r=NaN) {
            return e => {
                let t = e.pipe(Ff(i), te(e => e ? e.mediaOptionDetails$ : Y(null)));
                return t = re(r) && 0 <= r ? t.pipe(tn(r)) : t
            }
        }
        function Uf(e, t) {
            return Fr([e.enabledMediaOptionByType$(se.Variant).pipe(Bf(t)), e.hasAlternateWithUrl(se.AltAudio) ? e.enabledMediaOptionByType$(se.AltAudio).pipe(Bf(t)) : nl])
        }
        function _f(e, t, i, r, n, a=!0) {
            var {rootPlaylistQuery: s, logger: o, mediaLibraryService: l} = e
              , d = s.itemId;
            if (performance.now(),
            e.rootPlaylistService.updateInflightFrag(d, t, i, r, null, n),
            a && t !== se.Subtitle) {
                const t = s.getInFlightFrags()
                  , {config: i, mediaSink: r, statsService: n} = e;
                nm(i, o, s, r, l, n.getQueryForId(s.statsId), t)
            }
        }
        const Vf = {
            name: "avpipe"
        }
          , Qf = (s, o) => e => {
            var t;
            const {config: d, mediaSink: i, iframeClock: u, rootPlaylistQuery: c, rootPlaylistService: r} = s
              , h = (s.logger.child({
                name: "anchor"
            }),
            i.mediaQuery)
              , p = c.isInterstitial
              , n = h.desiredRate
              , a = s.config.liveAllowLowLatencyPlayback && (0 === n || 1 === n);
            return (h.readyState >= HTMLMediaElement.HAVE_METADATA && !re(null == (t = h.seekTo) ? void 0 : t.pos) && null == s.hlsQuery.pendingSeek ? ne(e.pipe(tn(1), te(e => Y({
                pos: pm(h.currentTime, e, d),
                fromEvent: !1
            }))), h.seekTo$) : h.seekTo$).pipe(J( (e, t) => Math.abs((null == e ? void 0 : e.pos) - (null == t ? void 0 : t.pos)) < Number.EPSILON && (null == e ? void 0 : e.discoSeqNum) === (null == t ? void 0 : t.discoSeqNum)), Kl(), W( (e, t) => ({
                seekTo: e,
                switchInfo: 0 === t ? o : [null, null],
                seekIdx: t
            }))).pipe(te( ({seekTo: s, switchInfo: o, seekIdx: l}) => e.pipe(J( (e, r) => e && r && Cp(e) === Cp(r) && Mp(e) === Mp(r) && e.every( (e, t) => {
                var i;
                return !((null == e ? void 0 : e.endSN) !== (null == (i = r[t]) ? void 0 : i.endSN) || a && jm(e, r[t]))
            }
            )), te(e => ce(h.updating$, e => !e).pipe(rn(e))), te(e => {
                var t = c.enabledMediaOptionKeys
                  , i = e[se.Variant];
                if ((i || de).mediaOptionId !== (null == (t = t[se.Variant]) ? void 0 : t.mediaOptionId))
                    return X;
                t = i.iframesOnly;
                let r = !1;
                i = function(o, l, t, i, r, n, a) {
                    var s, d;
                    const u = o[se.Variant].iframesOnly
                      , c = o[se.Variant].itemId
                      , {maxBufferHole: h, firstAudioMustOverlapVideoStart: p, maxFragLookUpTolerance: m, liveAllowLowLatencyPlayback: e} = a
                      , f = t.getBufferInfo(l.pos, h, n ? c : void 0)
                      , g = t.desiredRate
                      , y = e && o[se.Variant].liveOrEvent && Jc(g)
                      , v = i.map(e => {
                        return null != (e = null == (e = null == e ? void 0 : e.switchContext) ? void 0 : e.userInitiated) && e
                    }
                    )
                      , S = f.reduce( (e, t, i) => {
                        const r = v[i]
                          , n = o[i]
                          , a = y || i === se.AltAudio && p ? 0 : m
                          , s = function(e, t, i, r) {
                            if (!t)
                                return Number.POSITIVE_INFINITY;
                            r = null != r ? r : {
                                start: e,
                                end: e,
                                len: 0
                            };
                            t = null != t && t.iframesOnly ? 0 : a;
                            return i || 0 === r.len ? e : r.end + t
                        }(l.pos, n, r, t.buffered);
                        return Math.min(s, e)
                    }
                    , 1 / 0);
                    let I = NaN
                      , b = NaN
                      , T = NaN;
                    if (T = u ? (I = r.getCurrentTime().seconds,
                    b = S,
                    Qp(o[se.Variant], I)) : (I = S,
                    b = S,
                    re(l.discoSeqNum) ? l.discoSeqNum : Qp(o[se.Variant], I, y)),
                    !re(T))
                        return null;
                    var E = [null, null]
                      , A = [null, null];
                    for (let e = 0; e <= A.length; ++e) {
                        const i = o[e];
                        if (null != i) {
                            const r = null == (s = i.discoToMSNMap[T]) ? void 0 : s[0];
                            if (!re(r))
                                return null;
                            if (u) {
                                const o = t.desiredRate
                                  , n = i.discoToMSNMap[T][1]
                                  , a = 0 <= o ? r : n;
                                E[e] = A[e] = Gp($p(i, a, I, o, f[e].buffered, f[e].bufferedSegments, [], m, v[e]))
                            } else {
                                const o = t.getBufferInfo(I, h, n ? c : void 0)[e]
                                  , {buffered: a, bufferedSegments: O} = o
                                  , s = $p(i, r, I, 1, a, O, t.getContentGapRanges(), m, v[e], NaN, y);
                                (null == s ? void 0 : s.discoSeqNum) === T && (A[e] = Gp(s),
                                (p || s.start + s.duration < I) && e === se.Variant) && (b = I = Math.min(s.start, I))
                            }
                        }
                    }
                    for (let e = 0; !u && e < E.length; ++e) {
                        const t = o[e];
                        if (t) {
                            const i = A[e]
                              , r = (null == i ? void 0 : i.start) + (null == i ? void 0 : i.duration) > b && (null == i ? void 0 : i.start) <= b ? i : null == (d = Hp(b, T, t, y)) ? void 0 : d.mediaFragment;
                            if (E[e] = Gp(r),
                            !r)
                                return null
                        }
                    }
                    return {
                        pos: b,
                        discoSeqNum: T,
                        anchorFrags: E,
                        nextFrags: A,
                        iframeMode: u,
                        switchInfo: i
                    }
                }(e, s, h, o, u, p, d);
                if (!i)
                    return X;
                var n = c.getInFlightFrags()
                  , a = t || function(r, n, e, a, t, s) {
                    var i = e.some(e => null != e) && e.every( (e, t) => !e || qc(e, n[t]) || qc(e, r.anchorFrags[t]))
                      , [o,l] = e;
                    if (!i && (null == o ? void 0 : o.discoSeqNum) === r.discoSeqNum && (null == l ? void 0 : l.discoSeqNum) === r.discoSeqNum && (!t || l.start <= o.start)) {
                        const n = r.pos;
                        let t = -1 / 0
                          , i = !0;
                        if (e.forEach(e => {
                            t = Math.max(e.start),
                            i = i && e.start <= n && e.start + e.duration > n
                        }
                        ),
                        i || a && n <= t && t - n <= s)
                            return !1
                    }
                    return !i
                }(i, null != (a = i.nextFrags) ? a : [null, null], n, h.getBufferInfo(i.pos, d.maxBufferHole).every(e => {
                    return null == (e = null == (e = null == e ? void 0 : e.buffered) ? void 0 : e.len) || e
                }
                ), d.firstAudioMustOverlapVideoStart, d.maxSeekHole);
                if (0 < l && h.readyState >= HTMLMediaElement.HAVE_METADATA && null != (n = h.combinedBuffer) && n.length && !t) {
                    const o = h.getMediaBufferInfo(s.pos, d.maxBufferHole);
                    r = (o.combined.len || 0) < ac(d, e[se.Variant], o)
                }
                return Y({
                    anchorInfo: i,
                    checkForSwitch: r,
                    shouldUpdateAnchor: a,
                    gotValidAnchor: Cp(e) || e[se.Variant].iframesOnly
                })
            }
            ), Mn( ({gotValidAnchor: e}) => !e, !0))), Fa( ({anchorInfo: e, checkForSwitch: t, shouldUpdateAnchor: i}) => {
                i && (t && _m(ds.Seek, c.enabledVariantMediaOption, s) && (e = null),
                r.setAVAnchor(c.itemId, e))
            }
            ))
        }
        ;
        function Kf(t, e, i) {
            return e && e.start + e.duration > t || (null == i ? void 0 : i.some(e => t >= e.start && t < e.end))
        }
        function Hf(e, t, i, r) {
            let n = t;
            return r.stopStreaming ? n = i : r.paused && (n = e),
            n
        }
        function jf(s, e, t, i, o, l) {
            if (null == t)
                return null;
            const {mediaSink: r, config: d, interstitialController: n, rootPlaylistQuery: u, itemQueue: a} = s
              , c = r.mediaQuery
              , h = t["mediaOptionType"]
              , p = n.fragmentIsInterstitialBoundary(t, s);
            if (h === se.Subtitle)
                return null;
            if (t.gap) {
                if (!t.iframe) {
                    const e = new Ys(!1,H.ContentHasGap,!1,{
                        mediaOptionId: t.mediaOptionId,
                        mediaOptionType: t.mediaOptionType
                    })
                      , i = Dp(e, !1, d.maxNumAddLevelToPenaltyBox, s.rootPlaylistQuery, s.rootPlaylistService);
                    i.errorAction === Jh.DoNothing ? r.updateContentGapRanges(Qs(h), {
                        start: t.start,
                        end: t.start + t.duration
                    }) : xp(i, e, s.rootPlaylistQuery, s.rootPlaylistService, a, h, t.mediaOptionId, !1),
                    e.handled = !0
                }
                return null
            }
            const m = Yc(i)
              , f = function(t, i, r, n) {
                let a = t;
                if (t.iframe) {
                    var s = t.start
                      , o = r.end
                      , i = t.duration / Math.abs(i);
                    let e = 1 / n;
                    r.len < .75 && (e = Math.max(e, .25));
                    n = Math.max(i, e);
                    a = Object.assign(Object.assign({}, t), {
                        iframeOriginalStart: s,
                        start: o,
                        iframeMediaStart: o,
                        iframeMediaDuration: n
                    })
                }
                return {
                    foundFrag: {
                        mediaFragment: a,
                        timelineOffset: a.start
                    },
                    nextDisco: NaN
                }
            }(t, i, o, d.trickPlaybackConfig.minIframeDuration);
            let g = f.foundFrag.mediaFragment;
            return m && h === se.AltAudio && (g = Object.assign(Object.assign({}, g), {
                start: o.end
            })),
            _f(s, h, g, "waiting", null, !1),
            p.pipe(te(e => {
                const r = u.enabledMediaOptionSwitchContexts[h];
                if (e)
                    return X;
                const n = null != r && !0 === r.userInitiated
                  , t = null == r ? void 0 : r.triggerEvent
                  , i = []
                  , a = 2 === c.expectedSbCount;
                if (!l && !n) {
                    const s = g.start
                      , e = c.desiredPos
                      , {lowWaterLevelSeconds: r, highWaterLevelSeconds: n, stopStreamingHighWaterLevelSeconds: l} = function(t, i, r, n, a) {
                        const s = r.start
                          , o = r.duration
                          , l = Qs(r.mediaOptionType);
                        let d = a.highWaterLevelSeconds;
                        if (a.gotQuotaExceeded(l)) {
                            let e = 0;
                            re(null == (u = r.byteRangeOffset) ? void 0 : u.start) && re(null == (u = r.byteRangeOffset) ? void 0 : u.end) ? e = r.byteRangeOffset.end - r.byteRangeOffset.start : re(r.bitrate) && (e = r.bitrate * r.duration / 8);
                            const {likelyToExceed: s, safeWaterLevel: o} = a.likelyToExceedBuffer(t, l, e, n, i);
                            s && (d = o)
                        }
                        var u = F(a.lowWaterLevelSeconds, o);
                        return {
                            lowWaterLevelSeconds: u,
                            highWaterLevelSeconds: d = Math.max(u, F(d, o)),
                            stopStreamingHighWaterLevelSeconds: Math.min(Math.max(s - t - o, u), d)
                        }
                    }(e, o, g, d.maxBufferHole, c)
                      , t = Hf(r, n, l, c);
                    if (s - e >= t && i.push(ce(c.timeupdate$, e => {
                        let t = e;
                        var i = c.desiredPos;
                        return 0 === e && i !== e && (t = i),
                        s - t < Hf(r, n, l, c)
                    }
                    )),
                    a) {
                        const e = se.AltAudio - h;
                        Kf(s, u.getInFlightFragByType(e), c.getBufferedRangeByType(e)) || i.push(ce(Fr([u.getInFlightFragByType$(e).pipe(J(jc)), c.getBufferedRangeByType$(e)]), ([e,t]) => Kf(s, e, t)))
                    }
                }
                return i.length ? aa(i).pipe(Pr(Zn), te( () => Yf(0, s, f, h, n, t))) : Yf(0, s, f, h, n, t)
            }
            ))
        }
        function qf(u, e, i, r, n, a) {
            const {mediaSink: s, rootPlaylistQuery: o, rootPlaylistService: l} = u;
            return e => {
                let t = e.pipe(W(i => {
                    var e;
                    let t = NaN;
                    for (const u of i) {
                        const i = null == (e = null == u ? void 0 : u[0]) ? void 0 : e.discoSeqNum;
                        !re(t) && re(i) && (t = i)
                    }
                    {
                        var v = u
                          , r = t
                          , n = i;
                        const {rootPlaylistQuery: a, mediaSink: s, config: S, mediaLibraryService: I} = v
                          , b = s.mediaQuery
                          , o = b.isIframeRate
                          , T = a.isInterstitial;
                        if (n.every(e => null == (null == e ? void 0 : e[0]) && null == (null == e ? void 0 : e[1])))
                            return null;
                        const E = [null, null]
                          , l = a.getInitPTS(r)
                          , A = [null, null];
                        if (n.every(e => null == (null == e ? void 0 : e[1])))
                            return n.forEach( (t, i) => {
                                if (t) {
                                    var [t] = t;
                                    let e = NaN;
                                    t && (e = I.getQueryForOption(t).playlistDuration),
                                    E[i] = {
                                        initSeg: t,
                                        dataSeg: void 0,
                                        offsetTimestamp: void 0,
                                        duration: e
                                    }
                                }
                            }
                            ),
                            {
                                appendDataTuple: E,
                                initPTSInfo: l,
                                inFlightFrags: A
                            };
                        if (null == l)
                            return null;
                        if (r = n[se.Variant],
                        (i = null == r ? void 0 : r[1]) && i.iframe !== o)
                            return null;
                        if (r) {
                            const [d,v] = r;
                            let e = l.offsetTimestamp;
                            if (o) {
                                const d = v.startDtsTs
                                  , n = v.timelineOffset
                                  , a = Math.round(n * d.timescale);
                                e = {
                                    baseTime: d.baseTime - a,
                                    timescale: d.timescale
                                }
                            }
                            let t = NaN;
                            v && (t = I.getQueryForOption(v).playlistDuration),
                            E[oe.Variant] = {
                                initSeg: d,
                                dataSeg: v,
                                offsetTimestamp: e,
                                duration: t
                            }
                        }
                        if (null != (i = n[se.AltAudio])) {
                            const [d,v] = i;
                            let e = NaN
                              , t = (v && (e = I.getQueryForOption(v).playlistDuration),
                            l.offsetTimestamp);
                            if (o) {
                                const d = b.getBufferInfo(b.desiredPos, 0)[oe.AltAudio].buffered.end
                                  , r = v.startPts
                                  , a = D(d, r.timescale);
                                t = {
                                    baseTime: r.baseTime - a.baseTime,
                                    timescale: r.timescale
                                }
                            }
                            E[oe.AltAudio] = {
                                initSeg: d,
                                dataSeg: v,
                                offsetTimestamp: t,
                                duration: e
                            }
                        }
                        const O = s.isCompatibleWithSourceBuffers(E).compatible;
                        return E.forEach( (e, t) => {
                            var i, r = null == e ? void 0 : e.dataSeg;
                            if (r) {
                                var {itemId: n, mediaOptionId: a, mediaSeqNum: s, discoSeqNum: o, startPts: l, endPts: d, duration: u, isLastFragment: c, part: h=!1, partIndex: p=NaN} = r
                                  , e = e["offsetTimestamp"]
                                  , l = x(l, e)
                                  , d = x(d, e)
                                  , e = I.getQueryForOption(r)
                                  , m = null != r.iframeMediaDuration
                                  , f = (b.getBufferedRangeByType(t),
                                E[0])
                                  , g = !f || !f.dataSeg.dropped
                                  , y = b.getBufferInfo(l, S.maxBufferHole, T ? n : void 0);
                                if (O && g && !r.flushBeforeAppend && (null == (g = null == (i = y[t]) ? void 0 : i.buffered) ? void 0 : g.len) >= d - l) {
                                    let e;
                                    if (f) {
                                        const v = l + (d - l) / 2
                                          , i = b.getBufferedSegmentsByType(t).find(e => e.startPTS < v && e.endPTS > v);
                                        e = f.dataSeg.mediaOptionId === (null == i ? void 0 : i.frag.mediaOptionId)
                                    }
                                    if (!f || e)
                                        return E[t] = null,
                                        _f(v, t, null, null, !1, !1),
                                        null
                                }
                                A[t] = {
                                    start: l,
                                    duration: m ? u : d - l,
                                    itemId: n,
                                    mediaOptionId: a,
                                    mediaSeqNum: s,
                                    discoSeqNum: o,
                                    targetDuration: e.mediaOptionDetails.targetduration,
                                    isLastFragment: c,
                                    mediaOptionType: t,
                                    part: h,
                                    partIndex: p
                                }
                            }
                            return null
                        }
                        ),
                        A.every(e => !e) ? null : {
                            appendDataTuple: E,
                            inFlightFrags: A,
                            initPTSInfo: l
                        }
                    }
                }
                ), (f = u,
                g = r,
                y = a,
                e => {
                    const {rootPlaylistQuery: c, rootPlaylistService: h, mediaSink: p, legibleSystemAdapter: m, itemQueue: O} = f;
                    return e.pipe(te(e => {
                        if (!e)
                            return Y(!1);
                        const {appendDataTuple: r, inFlightFrags: s, initPTSInfo: n} = e;
                        s.forEach( (e, t) => {
                            var i;
                            e && (i = p.isCompatibleWithSourceBuffers(r)["compatible"],
                            _f(f, t, e, "appending", i, !0))
                        }
                        ),
                        r.forEach(e => {
                            var t, i = null == e ? void 0 : e.dataSeg;
                            if (i && n) {
                                const e = n.offsetTimestamp
                                  , r = null != (t = null == (t = O.getQueueItemForId(i.itemId)) ? void 0 : t.isInterstitial) && t;
                                m.addLegibleSamples(e, i.captionData, i.id3Samples, i.startPts, i.endPts, r)
                            }
                        }
                        );
                        e = (e, t, i, r, n) => {
                            var f, g, y, v, S, I, b, T, E, A, a = null != (a = null == (a = s[t]) ? void 0 : a.targetDuration) ? a : 10;
                            return f = p,
                            g = e,
                            y = t,
                            v = i,
                            S = a,
                            I = r,
                            b = c,
                            T = h,
                            E = n,
                            A = O,
                            e => e.pipe(ie( () => {
                                T.updateConsecutiveTimeouts(b.itemId, y, !1, "append")
                            }
                            ), bn(e => e.pipe(te( (i, r) => {
                                var n = i instanceof hh && i.isTimeout;
                                if (T.updateConsecutiveTimeouts(b.itemId, y, n, "append"),
                                n) {
                                    var n = i
                                      , a = r
                                      , s = I
                                      , o = y
                                      , l = v
                                      , d = E
                                      , u = b
                                      , c = T
                                      , h = A;
                                    let e = {
                                        errorAction: Jh.SendAlternateToPenaltyBox,
                                        errorActionFlags: 0
                                    };
                                    var p = (d = d.getCurrentWaterLevel(s.maxBufferHole)) < s.almostDryBufferSec;
                                    let t = NaN;
                                    var s = s.appendErrorMaxRetry
                                      , m = (m = u.getErrorInfoByType(o)) ? m.timeouts.append : 0
                                      , p = (p && s <= m || s <= a ? e.errorAction = Jh.SendEndCallback : t = 1e3 * d,
                                    {
                                        retryDelayMs: t,
                                        maxNumRetry: s,
                                        maxRetryDelayMs: t
                                    });
                                    return Up(n, a, p, e = Lp(e, !1, n.response, l, o, u, c), u, c, h, o, l).pipe()
                                }
                                if (i instanceof ph) {
                                    var m = i
                                      , e = g
                                      , d = r
                                      , s = S
                                      , t = I
                                      , a = y
                                      , p = v
                                      , n = E
                                      , u = b
                                      , c = T
                                      , h = A
                                      , o = e.type;
                                    if ((o = n.getCurrentWaterLevelByType(o, t.maxBufferHole)) >= t.almostDryBufferSec && !n.isIframeRate) {
                                        const e = 1e3 * s
                                          , t = {
                                            errorAction: Jh.RetryRequest,
                                            errorActionFlags: 0
                                        };
                                        return 1e3 * o < e && (c.hasFallbackMediaOptionTuple(u, a, p, !1) ? t.errorAction = Jh.SendAlternateToPenaltyBox : t.errorAction = Jh.SendEndCallback),
                                        Up(m, d, {
                                            retryDelayMs: e,
                                            maxNumRetry: 1 / 0,
                                            maxRetryDelayMs: e
                                        }, t, u, c, h, a, p)
                                    }
                                    return d < t.appendErrorMaxRetry ? e.remove(0, Number.POSITIVE_INFINITY) : (m.fatal = !0,
                                    R(m))
                                }
                                if (i instanceof fh) {
                                    const {mediaOptionType: g, mediaOptionId: y} = i;
                                    return Vp(i, g, y, f, T, b, A)
                                }
                                throw i
                            }
                            ))))
                        }
                        ;
                        let t;
                        if (null == g)
                            t = p.avAppend(null, r, e, c.highestVideoCodec);
                        else {
                            const f = Qs(g);
                            t = p.avAppend(f, r, e, c.highestVideoCodec)
                        }
                        var a, o, l, d, i = r[oe.AltAudio];
                        let u;
                        if (null != i && i.dataSeg) {
                            const f = i.dataSeg
                              , {itemId: g, mediaOptionId: y, flushBeforeAppend: e, switchPosition: c, triggerEvent: h} = f;
                            u = {
                                itemId: g,
                                mediaOptionId: y,
                                flushBeforeAppend: e,
                                switchPosition: c,
                                triggerEvent: h
                            }
                        }
                        return t.pipe(W(function(i, e, r, n, a) {
                            const {mediaSink: s, rootPlaylistQuery: t, rootPlaylistService: o, interstitialController: l, rtcService: d, statsService: u, playerEvents: c} = i;
                            let h = {};
                            if (ae( () => {
                                r.forEach( (e, t) => {
                                    e && (_f(i, t, e, "appended", null, !0, h),
                                    t !== se.Variant && t !== se.AltAudio || (s.updateInFlightRange(t, null),
                                    l.fragmentAppended({
                                        isLastFragment: e.isLastFragment,
                                        type: e.mediaOptionType,
                                        itemId: e.itemId
                                    })))
                                }
                                );
                                let t = !1;
                                if (a.forEach(e => {
                                    e && (null != d && d.handleBufferAppended({
                                        fragmentType: e.fragmentType,
                                        startAppend: e.startDataAppend,
                                        endAppend: e.endDataAppend,
                                        bytesAppend: e.dataBytesAppend
                                    }),
                                    e.fragmentType !== se.Variant || t || (t = !0,
                                    u.setBufferMetric(e),
                                    null == d) || d.handleFragBuffered(e))
                                }
                                ),
                                n) {
                                    const {flushBeforeAppend: i, switchPosition: t, triggerEvent: r} = n;
                                    if (i || re(t) || r) {
                                        const {itemId: i, mediaOptionId: t} = n;
                                        o.setEnabledMediaOptionSwitchContextByType(i, se.AltAudio, t, void 0)
                                    }
                                }
                            }
                            ),
                            null != n && n.triggerEvent) {
                                const i = t.enabledAlternateMediaOptionByType(se.AltAudio);
                                c.postAudioTrackSwitched(!0, e, i)
                            }
                            return c.triggerBufferAppended(),
                            !0
                        }
                        .bind(null, f, y, s, u)), (a = p,
                        o = h,
                        l = c,
                        d = O,
                        e => e.pipe($(e => {
                            var t, i;
                            if (e instanceof ch)
                                return {mediaOptionType: t, mediaOptionId: i} = e,
                                Vp(e, t, i, a, o, l, d);
                            throw e
                        }
                        ))))
                    }
                    ))
                }
                ), $(e => {
                    var t;
                    if (e instanceof Zs)
                        return (t = e.candidateMediaOptions) ? (l.setEnabledMediaOptions(u.rootPlaylistQuery.itemId, t),
                        X) : Y(!1);
                    if (e instanceof b && !e.fatal)
                        return Y(!1);
                    throw e
                }
                ), ie(e => {
                    e || _s.forEach(e => {
                        null != r && e !== r || _f(u, e, null, null, !1, !1)
                    }
                    )
                }
                ), ee( () => {
                    ae( () => {
                        _s.forEach(e => {
                            s.updateInFlightRange(e, null)
                        }
                        )
                    }
                    )
                }
                ));
                var f, g, y;
                return (t = r === se.Variant ? t.pipe(te(e => {
                    if (!n)
                        return Y(e);
                    const t = Gf(u, 0, i);
                    return t ? ce(Fr([o.getInFlightFragByType$(se.AltAudio), s.mediaQuery.waterLevelChangedForType$(oe.Variant)]), ([e,t]) => t === nu.AlmostDry || null == e || "appended" === e.state || "waiting" === e.state).pipe(W( () => (l.setEnabledMediaOptions(o.itemId, t),
                    e))) : Y(e)
                }
                )) : t).pipe(ee( () => {
                    null != r && r !== se.Variant || l.setFragLoadSlow(o.itemId, {
                        fragDownloadSlow: !1,
                        fragDownloadTooSlow: !1
                    })
                }
                ))
            }
        }
        function Gf(o, e, t) {
            var {config: i, mediaSelectionBossService: r, mediaSink: n, platformService: a, rootPlaylistService: s, rootPlaylistQuery: l, statsService: d} = o
              , n = n.mediaQuery
              , u = d.getQueryForId(l.statsId);
            if (l.getEntity(l.itemId).manualMode || n.isIframeRate && i.abrTrickplayLevelLocked)
                return null;
            var c = l.enabledVariantMediaOption;
            if (c.mediaOptionId !== t)
                return null;
            let h = ds.None;
            t = a,
            a = null == n ? void 0 : n.clientWidth,
            m = null == n ? void 0 : n.clientHeight,
            p = "object" == typeof window && window.devicePixelRatio ? window.devicePixelRatio : 1,
            a = a && m ? {
                width: a * p,
                height: m * p
            } : void 0,
            m = t.query.viewportInfo || {},
            p = m && a && (m.width !== a.width || m.height !== a.height),
            i.useViewportSizeForLevelCap && p && (t.updateViewportInfo(a),
            !0) && (h = ds.PreferredListChanged);
            var p, m = l.itemId;
            let f = !1;
            p = n,
            t = u,
            a = l.abrStatus,
            l.enabledVariantMediaOption && (n = l.enabledVariantMediaOption.bitrate,
            t = !!a && (a.fragDownloadSlow || a.fragDownloadTooSlow) || t.getBandwidthEstimate().avgBandwidth < n,
            p = re(null == (n = p.seekTo) ? void 0 : n.pos),
            !t || null != a && a.fragDownloadTooSlow || !p) && t ? (h = ds.LowBandwidth,
            l.nextMaxAutoOptionId === de.mediaOptionId && (s.setNextMaxAutoOptionId(c.itemId, c.mediaOptionId),
            f = !0,
            null != r) && r.setTransformer(m, le.BitrateFilter, new Nc(0,c.bitrate))) : (u = i,
            n = l,
            a = d.getQueryForId(null != (a = n.statsId) ? a : n.itemId),
            p = a.getBandwidthEstimate(u),
            t = n.abrStatus,
            n = n.enabledVariantMediaOption,
            Im(p) && t && n && (a = (null == (a = a.bandwidthStatus) ? void 0 : a.bandwidthSampleCount) || 0,
            (p = Cm(p.avgBandwidth, u.abrBandWidthUpFactor, u.abrBandWidthFactor, a)["bwUp"]) > ic(Object.assign(Object.assign({}, n), {
                bitrate: t.highBWTrigger
            }), u.trickPlaybackConfig)) && function() {
                var e, {config: t, mediaSink: i, mediaLibraryService: r, rootPlaylistQuery: n} = o, i = i.mediaQuery, a = n.enabledVariantMediaOption, s = n.enabledAlternateMediaOptionByType(se.AltAudio);
                return a && (e = r.getQueryForOption(a).mediaOptionDetails) && (r = null != s && s.url ? r.getQueryForOption(s).mediaOptionDetails : void 0,
                s = i.desiredPos,
                s = i.getMediaBufferInfo(s, t.maxBufferHole),
                e = ac(t, (a = {
                    variant: a,
                    avDetails: [e, r]
                }).avDetails[se.Variant], s),
                i.gotPlaying || Zp(n.getInFlightFrags(), a, s, i.desiredRate, e, t.liveAllowLowLatencyPlayback))
            }() && (h = ds.HighBandwidth,
            null != r && r.setTransformer(m, le.BitrateFilter, new Nc(c.bitrate,Number.POSITIVE_INFINITY)),
            s.setNextMinAutoOptionId(c.itemId, c.mediaOptionId)));
            i = Vm(h, c, o);
            return f ? s.setNextMaxAutoOptionId(c.itemId, de.mediaOptionId) : h === ds.HighBandwidth && s.setNextMinAutoOptionId(c.itemId, de.mediaOptionId),
            null != r && r.removeTransformer(m, le.BitrateFilter),
            i
        }
        function $f(e, t) {
            var i, r, n;
            return !!e && (!(e.part && (!e.part || !1 !== (null == t ? void 0 : t.hasPartIndependentTag)) && (i = F(e.partIndex, 0),
            t = null != (t = t.parts) ? t : [],
            r = e.mediaSeqNum,
            n = i,
            i = t.find(e => e.mediaSeqNum === r && e.partIndex === n + 1 || e.mediaSeqNum === r + 1 && 0 === e.partIndex))) || i.partIndependent)
        }
        const Wf = (w, P, e) => e => {
            const {discoSeqNum: t, anchorFrags: i, iframeMode: p, switchInfo: r} = P
              , m = i.map(e => {
                var {mediaSeqNum: e=NaN, part: t=!1, partIndex: i=NaN} = e || {};
                return {
                    msn: e,
                    part: t,
                    partIndex: i
                }
            }
            )
              , f = i[0].mediaOptionId
              , {iframeClock: c, mediaSink: n, rootPlaylistQuery: h, mediaLibraryService: g} = w
              , {itemId: y, appItemId: v} = h
              , S = n.mediaQuery
              , I = S.desiredRate
              , a = I < 0 ? -1 : 1
              , {maxBufferHole: b, maxFragLookUpTolerance: T, liveAllowLowLatencyPlayback: s} = w.config
              , E = s && (1 === I || 0 === I)
              , A = {
                firstDisco: !0,
                discoSeqNum: t,
                complete: !1,
                step: a,
                msnsInDisco: [{
                    startMSN: m[0].msn,
                    startPartIndex: m[0].partIndex,
                    length: 0,
                    partlength: NaN
                }, {
                    startMSN: m[1].msn,
                    startPartIndex: m[1].partIndex,
                    length: 0,
                    partlength: NaN
                }],
                nextAnchor: {
                    discoSeqNum: NaN,
                    anchorFrags: [null, null],
                    iframeMode: P.iframeMode,
                    switchInfo: []
                }
            }
              , o = e.pipe(J( (r, e) => null == e ? void 0 : e.every( (e, t) => {
                var i = r[t];
                return null == i && null == e || null != r[t] && !(i.mediaOptionId !== e.mediaOptionId || Hm(i, e) || E && jm(i, e))
            }
            )), $r( (l, d) => {
                var u, e;
                const c = null != (u = P.pos) ? u : S.currentTime;
                if (A.firstDisco = 0 === d,
                0 !== d)
                    return Y(l);
                {
                    const P = [null, null]
                      , d = (_s.forEach(e => {
                        var t, i, r, n, a = l[e];
                        a && ({msn: t, part: i, partIndex: r} = m[e],
                        n = null,
                        n = re(r) ? hc(a.parts, t, r) : hc(a.fragments, t)) && (P[e] = n)
                    }
                    ),
                    n.needSourceBuffers && P.every( (e, t) => {
                        return null == e || (null == (t = l[t].initSegments[e.discoSeqNum]) ? void 0 : t.isInitSegment) && !g.isCachingFrag(e)
                    }
                    ) && !(null != (e = g.getPrefetchCache(v)) && e.fragRequest))
                      , u = d ? [en(nl, nl), en(nl, nl)] : [nl, nl]
                      , h = S.getBufferInfo(c, b, O ? y : void 0);
                    let s = !1
                      , o = !1;
                    if (r) {
                        if (r[se.Variant]) {
                            const {fromId: w, toId: P} = r[se.Variant];
                            s = w && P && w !== P
                        }
                        if (r[se.AltAudio]) {
                            const w = r[se.AltAudio]["switchContext"];
                            o = null != w && !0 === w.userInitiated
                        }
                    }
                    P.forEach( (i, r) => {
                        if (i) {
                            var n = h[r]
                              , a = null != (a = null == n ? void 0 : n.bufferedSegments) ? a : [];
                            let e = !1
                              , t = !1;
                            if (r === se.AltAudio && p && 0 < (null == n ? void 0 : n.buffered.len) && a.some(e => e.frag.discoSeqNum === i.discoSeqNum))
                                e = !0,
                                t = !0;
                            else if (!i.iframe) {
                                const w = i.start + i.duration
                                  , r = a.find(e => {
                                    var t = e.startPTS <= c && c < e.endPTS;
                                    return !e.evicting && t && (t = Math.max(w, F(e.appendEnd, w)),
                                    Math.abs(t - e.endPTS) < T)
                                }
                                );
                                e = null != r,
                                t = null != r && jc(r.frag, i)
                            }
                            if (!(r === se.AltAudio && !o && t || r === se.Variant && (t || e && s && !i.isLastFragment && !qp(i, a)))) {
                                var n = h[r].buffered
                                  , a = [];
                                let e;
                                d && (e = xf(w, i.keyTagInfo, {
                                    itemId: i.itemId,
                                    mediaOptionId: i.mediaOptionId,
                                    appItemId: v
                                }).pipe(te( () => X)),
                                a.push(g.retrieveInitSegmentCacheEntity(w, i, i.discoSeqNum).pipe(W(e => [null == (null == e ? void 0 : e.initParsedData) ? null : e, null])))),
                                a.push(null != (n = jf(w, 0, i, I, n, !0)) ? n : nl);
                                n = a.length ? en(...a) : a[0];
                                u[r] = e ? ne(e, n) : n
                            }
                        }
                    }
                    );
                    const A = u[se.Variant] !== nl && $f(P[se.Variant], l[se.Variant]);
                    return function() {
                        for (var e = [], t = 0; t < arguments.length; t++)
                            e[t] = arguments[t];
                        var a = Ir(e)
                          , s = qr(e);
                        return s.length ? new G(function(i) {
                            var r = s.map(function() {
                                return []
                            })
                              , n = s.map(function() {
                                return !1
                            });
                            i.add(function() {
                                r = n = null
                            });
                            for (var e = 0; !i.closed && e < s.length; e++)
                                !function(t) {
                                    Gi(s[t]).subscribe(Wi(i, function(e) {
                                        r[t].push(e),
                                        r.every(function(e) {
                                            return e.length
                                        }) && (e = r.map(function(e) {
                                            return e.shift()
                                        }),
                                        i.next(a ? a.apply(void 0, Yt([], Xt(e))) : e),
                                        r.some(function(e, t) {
                                            return !e.length && n[t]
                                        })) && i.complete()
                                    }, function() {
                                        n[t] = !0,
                                        r[t].length || i.complete()
                                    }))
                                }(e);
                            return function() {
                                r = n = null
                            }
                        }
                        ) : X
                    }(u).pipe(qf(w, 0, f, null, !1, null == (e = null == r ? void 0 : r[se.AltAudio]) ? void 0 : e.switchContext)).pipe(ln(1), te( () => {
                        var e, t, i;
                        return A && ({rootPlaylistQuery: e, rootPlaylistService: t} = w,
                        i = Gf(w, 0, f)) ? (t.setEnabledMediaOptions(e.itemId, i),
                        X) : Y(l)
                    }
                    ))
                }
            }
            ), function(e, t) {
                return Ht(Vr(e, t, 2 <= arguments.length, !0))
            }( (c, h) => (_s.forEach(i => {
                var e, r = h[i];
                if (r) {
                    const {step: s, discoSeqNum: o, msnsInDisco: t, nextAnchor: l} = c
                      , d = t[i]
                      , u = r.discoToMSNMap[o];
                    if (u) {
                        let e = u[0];
                        0 < s && (e = Math.min(u[1], r.endSN)),
                        d.length = Math.abs(e - d.startMSN) + 1,
                        d.partlength = NaN,
                        E && u[1] > r.endSN && (u[1] === r.partEndSN ? (d.length = u[1] - d.startMSN,
                        d.partlength = r.partEndIndex + 1) : (d.partlength = NaN,
                        d.length = u[1] - d.startMSN + 1))
                    }
                    var n = l.anchorFrags;
                    if (!n[i]) {
                        var a;
                        const t = 0 < (null == (e = r.parts) ? void 0 : e.length);
                        a = E && t ? null == (e = hc(r.parts, r.partEndSN, r.partEndIndex)) ? void 0 : e.discoSeqNum : null == (e = hc(r.fragments, 0 < s ? r.endSN : r.startSN)) ? void 0 : e.discoSeqNum;
                        for (let t = o + s; null != a && (0 < s ? t <= a : t >= a); t += s) {
                            const h = r.discoToMSNMap[t];
                            if (h && (!re(c.nextAnchor.discoSeqNum) || t === c.nextAnchor.discoSeqNum)) {
                                const c = h[0 < s ? 0 : 1];
                                let e = hc(r.fragments, c);
                                e = e || hc(r.parts, c, 0),
                                n[i] = Gp(e),
                                l.discoSeqNum = t;
                                break
                            }
                        }
                    }
                }
            }
            ),
            (Mp(h) || re(c.nextAnchor.discoSeqNum) && c.nextAnchor.anchorFrags.every( (e, t) => null == h[t] || null != e)) && (c.complete = !0),
            c), A), Mn( ({complete: e}) => !e, !0), An({
                bufferSize: 1,
                refCount: !0
            }))
              , O = h.isInterstitial
              , R = [];
            return _s.forEach(l => {
                var e = i[l];
                if (null != e) {
                    const d = g.getQueryForOption(i[l])
                      , u = {
                        frag: 1,
                        part: NaN
                    };
                    e.part && (u.frag = 0,
                    u.part = e.partIndex);
                    e = o.pipe(ie( ({firstDisco: e}) => {
                        var t = S.getBufferedSegmentsByType(Qs(l))[0];
                        null != t && t.partialFrag && e && (u.frag = 0)
                    }
                    ), sn( ({msnsInDisco: e, nextAnchor: t, discoSeqNum: s, step: o, complete: i}) => kr(Y(e[l]), Zn).pipe(on(e => {
                        var t = d.mediaOptionDetails;
                        if (!t || t.mediaOptionId !== h.enabledMediaOptionIdByType(l))
                            return X;
                        if (u.frag > e.length || E && u.frag === e.length && !re(e.partlength) || E && re(e.partlength) && u.frag === e.length && u.part > e.partlength)
                            return X;
                        var i = S.currentTime
                          , r = c.isStarted ? c.getCurrentTime().seconds : i
                          , {buffered: i, bufferedSegments: n} = S.getBufferInfo(i, b, O ? y : void 0)[l]
                          , a = c.isStarted ? [] : S.getContentGapRanges()
                          , r = $p(t, e.startMSN + u.frag * o, r, I, i, n, a, T, !1, u.part, E);
                        if (!r || r.discoSeqNum !== s)
                            return u.frag = e.length,
                            u.part = e.partlength,
                            X;
                        null != r && r.part ? (u.frag = Math.abs(r.mediaSeqNum - e.startMSN),
                        u.part = r.partIndex) : (u.frag = Math.abs(r.mediaSeqNum - e.startMSN) + 1,
                        u.part = NaN);
                        n = $f(r, t);
                        return (null != (a = jf(w, 0, r, I, i, !1)) ? a : nl).pipe(W(e => l === se.Variant ? [e, null] : [null, e]), qf(w, 0, f, l, n), rn(e))
                    }
                    , 1), W( () => ({
                        nextAnchor: t,
                        type: l,
                        complete: i
                    })))), ln(1));
                    R.push(e)
                }
            }
            ),
            0 < R.length ? (1 === R.length ? R[0] : ne(...R).pipe(Mn( ({type: e, complete: t}) => !p || e !== se.Variant || !t, !0))).pipe(ln(1), W( ({nextAnchor: e}) => e), ee( () => {
                ae( () => {
                    _s.forEach(e => {
                        _f(w, e, null, null, null, !1)
                    }
                    )
                }
                )
            }
            )) : X
        }
        ;
        function zf(y, a, e, t) {
            const v = y["rootPlaylistQuery"]
              , i = t.enabledMediaOptionSwitchInfo$.pipe(Kl())
              , s = y.statsService.getQueryForId(v.statsId);
            return y.logger.child(Vf),
            Fr([y.mediaSink.mediaQuery.isIframeRate$, i.pipe(te( (e, t) => {
                var i = v.altMediaOptionHasValidUrl(se.AltAudio, null == (i = e[se.AltAudio]) ? void 0 : i.toId) ? 2 : 1;
                y.mediaSink.setExpectedSbCount(i);
                const r = [];
                e.forEach( ({fromId: e, toId: t}, i) => {
                    i = function(t, i, r, n, a) {
                        var s, o, l, d, u, c, h, p, m;
                        const {rootPlaylistQuery: f, rootPlaylistService: g, mediaSink: y, mediaParser: v, config: S, iframeClock: I, mediaLibraryService: b} = t
                          , T = y.mediaQuery;
                        if (!n || !a || n === a && (r === se.AltAudio || !I.isStarted))
                            return null;
                        switch (r) {
                        case se.Variant:
                            {
                                n !== a && v.reset(se.Variant);
                                const t = Qs(r)
                                  , E = f.variantMediaOptionById(n)
                                  , g = f.variantMediaOptionById(a);
                                if (null == g || null == E)
                                    return ue;
                                if (E.iframes !== g.iframes || g.iframes)
                                    return y.mediaQuery.flushing ? ce(y.mediaQuery.flushing$, e => !e).pipe(W( () => {}
                                    )) : ue;
                                if (!S.allowFastSwitchUp || g.iframes)
                                    return ue;
                                if (null != b.getQueryForOption(E).mediaOptionDetails && null != g && E.bitrate < g.bitrate) {
                                    const r = b.getQueryForOption(g)
                                      , n = r.mediaOptionDetails
                                      , a = (null == (s = r.mediaOptionDetailsEntity) ? void 0 : s.lastUpdateMillis) || 0
                                      , v = T.getCurrentWaterLevelByType(t, S.maxBufferHole)
                                      , A = (s = S,
                                    o = E,
                                    l = g,
                                    d = n,
                                    u = f.abrStatus,
                                    c = i,
                                    h = T,
                                    p = a,
                                    u = u.nextMaxAutoOptionId,
                                    m = c.getCombinedEstimate(s, void 0, !1),
                                    ((u === de.mediaOptionId || Im(m)) && o.mediaOptionId !== l.mediaOptionId && (u = Cm(m.avgBandwidth, s.abrBandWidthUpFactor, s.abrBandWidthFactor, c.bandwidthStatus.bandwidthSampleCount),
                                    c = function() {
                                        let e = 0;
                                        var {avgPlaylistLoadTimeMs: t, avgLatencyMs: i} = m;
                                        return re(t) ? e = t : re(i) && (e = i),
                                        e
                                    }(),
                                    o = l.bitrate > o.bitrate ? u.bwUp : u.bwDown,
                                    null == d || !d.liveOrEvent || d.ptsKnown && !oc(d.totalduration, c, p)) ? (c = re(null == (u = h.seekTo) ? void 0 : u.pos) ? u.pos : h.currentTime,
                                    u = h.getMediaBufferInfo(c, s.maxBufferHole),
                                    nc(s, l, d, mc(s.liveAllowLowLatencyPlayback, h.isPlayingAtLive, null != (l = null == (c = null == d ? void 0 : d.parts) ? void 0 : c.length) ? l : 0), Object.assign(Object.assign({}, m), {
                                        avgBandwidth: o
                                    }), u, p, !0).totalTime) : Number.POSITIVE_INFINITY) + S.maxStarvationDelay)
                                      , I = Math.max(f.itemStartOffsets[t] || 0, T.currentTime) + A
                                      , O = null == (h = null == (s = T.sourceBufferEntityByType(t)) ? void 0 : s.bufferedSegments) ? void 0 : h.find(e => e.startPTS >= I);
                                    let e;
                                    if (O) {
                                        const t = O.endPTS - O.startPTS;
                                        e = O.startPTS + Math.min(Math.max(t - S.maxFragLookUpTolerance, .5 * t), .75 * t)
                                    }
                                    if (re(e) && v >= A)
                                        return y.flushData(t, e, 1 / 0)
                                }
                            }
                            break;
                        case se.AltAudio:
                            d = f,
                            c = a,
                            o = xs("Nah" === (l = n) ? null : d.alternateMediaOptionById(se.AltAudio, l)),
                            l = xs("Nah" === l ? null : d.alternateMediaOptionById(se.AltAudio, c)),
                            !o || l ? a && "Nah" !== a || g.clearMediaOptionSwitchContextByType(f.itemId, se.AltAudio) : (g.setEnabledMediaOptionSwitchContextByType(f.itemId, se.AltAudio, a, void 0),
                            I.isStarted || y.resetMediaSource(T.currentTime)),
                            v.reset(se.AltAudio)
                        }
                        return ue
                    }(y, (a.operation,
                    s), i, e, t);
                    i && r.push(i)
                }
                );
                i = [];
                0 < t && i.push(Y({
                    switching: !0,
                    switchInfo: e
                }));
                const n = {
                    switching: !1,
                    switchInfo: e
                };
                return 0 < r.length ? i.push(aa(r).pipe(W( () => n))) : i.push(Y(n)),
                1 < i.length ? en(...i) : i[0]
            }
            ))]).pipe(te( ([e,{switching: t, switchInfo: i}]) => {
                if (t || e !== (null == (t = v.variantMediaOptionById(i[0].toId)) ? void 0 : t.iframes))
                    return X;
                {
                    var a = y
                      , e = i;
                    const s = a.logger.child(Vf)
                      , {rootPlaylistService: o, rootPlaylistQuery: l, config: r} = a
                      , d = l.itemId
                      , n = r.liveAllowLowLatencyPlayback
                      , u = J( (e, t) => !(e.mediaOptionId !== t.mediaOptionId || Hm(e, t) || n && jm(e, t)))
                      , c = Z(e => {
                        return !(e && e.liveOrEvent && (e = e,
                        t = r,
                        i = null != (i = e.tloadMillis) ? i : 0,
                        performance.now() - i > 1e3 * lm(e, t)));
                        var t, i
                    }
                    )
                      , h = Y(l.variantMediaOptionById(e[se.Variant].toId)).pipe(Bf(a.mediaLibraryService), u, c)
                      , p = l.alternateMediaOptionById(se.AltAudio, e[se.AltAudio].toId)
                      , m = Fr([h, xs(p) ? Y(p).pipe(Bf(a.mediaLibraryService), u, c) : nl])
                      , f = m.pipe(Qf(a, e))
                      , g = l.avAnchor$.pipe(On(1), te(function(e, t) {
                        if (!e || !re(e.discoSeqNum))
                            return X;
                        const {anchorFrags: i, switchInfo: r} = e
                          , n = l.enabledMediaOptionKeys;
                        return i.some( (e, t) => {
                            var i = r[t]
                              , i = i && e && e.mediaOptionId !== i.toId
                              , e = t === se.Variant && (e || de).mediaOptionId !== n[t].mediaOptionId;
                            return i || e
                        }
                        ) ? X : m.pipe(Wf(a, e, s), ie(e => {
                            var t;
                            (null == (t = null == e ? void 0 : e.anchorFrags[se.Variant]) ? void 0 : t.mediaOptionId) === (null == (t = l.enabledVariantMediaOption) ? void 0 : t.mediaOptionId) && o.setAVAnchor(d, e)
                        }
                        ))
                    }));
                    return ne(g, f).pipe(ee( () => {}
                    ))
                }
            }
            ), ee( () => {}
            ))
        }
        function Xf(e, t, i, r, n, a, s) {
            var o = e["rootPlaylistQuery"]
              , l = o.itemId
              , d = t.mediaOptionType
              , l = (e.rootPlaylistService.updateInflightFrag(l, d, t, "loading", a, null),
            o.getInFlightFrags());
            if (d !== se.Variant && "loading" === (null == (t = l[se.Variant]) ? void 0 : t.state) || nm(e.config, e.logger, e.rootPlaylistQuery, e.mediaSink, e.mediaLibraryService, e.statsService.getQueryForId(o.statsId), l),
            d === se.Variant) {
                var u = e
                  , {config: o, mediaSink: d, rootPlaylistQuery: e, rootPlaylistService: l} = (a = l,
                t = i,
                u)
                  , d = d.mediaQuery
                  , i = u.logger.child(Sm)
                  , c = {
                    fragDownloadSlow: null != (c = null == (c = e.abrStatus) ? void 0 : c.fragDownloadSlow) && c,
                    fragDownloadTooSlow: null != (c = null == (c = e.abrStatus) ? void 0 : c.fragDownloadTooSlow) && c
                }
                  , [h] = a;
                if (h && Lm(h) && (!d.isIframeRate || !o.abrTrickplayLevelLocked))
                    try {
                        Nm(c, function(e, t, i, r, n, a) {
                            if (!Lm(e))
                                return n;
                            var s = Um(e, n, t, r)
                              , o = i.bufferMonitorInfo;
                            if (o && a > nu.LowWater) {
                                const e = i.waterLevelForType(oe.Variant)
                                  , t = o["lowWaterLevelSeconds"]
                                  , r = i.waitingForDisco
                                  , n = i.minSBDuration - i.currentTime <= t;
                                re(e) && e <= nu.LowWater && !r && !n && (s.fragDownloadSlow = !0)
                            }
                            return s
                        }(h, e, d, i, c, t)),
                        Nm(c, function(a, s, o) {
                            var l = s.mediaSink.mediaQuery
                              , {rootPlaylistQuery: d, config: t, logger: u, mediaSelectionBossService: c} = s
                              , h = l.desiredRate
                              , p = a[se.Variant];
                            if (0 === h || !Lm(p))
                                return o;
                            var {tfirst: h, trequest: m} = p.bwSample
                              , f = re(h)
                              , f = performance.now() - (f ? h : m)
                              , h = Jp(p.duration, l.playbackRate, t)
                              , m = 1e3 * sc(p.duration, t.maxStarvationDelay);
                            if (f < Math.min(m, h))
                                return o;
                            f = Am(d, c, l.isIframeRate, t, u);
                            if (0 === f.length || f[0].mediaOptionId === p.mediaOptionId)
                                return o;
                            {
                                var g = o
                                  , y = a
                                  , v = f;
                                let {fragDownloadSlow: e, fragDownloadTooSlow: r} = g;
                                var {config: m, rootPlaylistService: h, rootPlaylistQuery: S, mediaSink: d, statsService: c, mediaLibraryService: i, mediaSelectionBossService: l, hlsService: t} = s
                                  , u = s.logger.child(Sm)
                                  , d = d.mediaQuery
                                  , [p] = y
                                  , o = null == p ? void 0 : p.bwSample;
                                if (!o || !re(null == o ? void 0 : o.tfirst))
                                    return g;
                                a = performance.now(),
                                f = a - o.tfirst,
                                s = sc(p.duration, m.maxStarvationDelay);
                                if (d.paused && f / 1e3 < s)
                                    return g;
                                var I = se.Variant
                                  , b = p.mediaOptionId
                                  , T = S.variantMediaOptionById(b);
                                if (!T)
                                    return g;
                                var E = i.getQueryForOption(T)
                                  , A = p.itemId
                                  , O = c.getQueryForId(null != (O = S.statsId) ? O : S.itemId)
                                  , R = O.getCombinedEstimate(m, void 0, !1)
                                  , w = Math.max(1, 8e3 * o.loaded / f)
                                  , P = []
                                  , M = null != (null == (C = S.enabledAlternateMediaOptionByType(se.AltAudio)) ? void 0 : C.url);
                                for (const g of y)
                                    if (g) {
                                        const y = i.getQueryForOption(g).mediaOptionDetails;
                                        y && P.push(em(T, y, g, M))
                                    }
                                var C = tm(y, P, oe.Variant, 0, R, R, R, !0)
                                  , y = Tm(d, m.maxBufferHole);
                                let n;
                                if (re(y) && 0 < y && !re(null == (k = d.seekTo) ? void 0 : k.pos))
                                    n = y;
                                else {
                                    const g = f / 1e3;
                                    n = g < s ? s - g : s
                                }
                                ({fragDownloadSlow: e, fragDownloadTooSlow: r} = Um(p, g, S, u));
                                var k = E.mediaOptionDetails
                                  , g = mc(m.liveAllowLowLatencyPlayback, d.isPlayingAtLive, null != (s = null == (f = null == k ? void 0 : k.parts) ? void 0 : f.length) ? s : 0)
                                  , u = 2 * (pc(k, m, !1) || p.duration);
                                if (g && R.avgLatencyMs / 1e3 + T.bitrate / w < p.duration || y <= u && (C >= n || e)) {
                                    let i;
                                    e = !0,
                                    t.query.extendMaxTTFB || t.setExtendMaxTTFB(6e5);
                                    f = Object.assign(Object.assign({}, R), {
                                        avgBandwidth: w
                                    }),
                                    s = O.bandwidthStatus,
                                    k = T.iframes,
                                    g = C >= n && !k,
                                    u = Em(0, v, k, S);
                                    if (!(u < 0)) {
                                        let t = v.length - 1;
                                        for (let e = 0; e < v.length; e++) {
                                            const y = v[e];
                                            if (y.mediaOptionId === T.mediaOptionId)
                                                t = e - 1;
                                            else if (y.mediaOptionId === S.nextMaxAutoOptionId) {
                                                t = e;
                                                break
                                            }
                                        }
                                        R = Math.max(u, t);
                                        if (g) {
                                            let e = Mm(v.slice(u, R + 1), p.duration, n, k, f, s, 1, 1, m, S, E, d);
                                            const y = de.mediaOptionId;
                                            i = e.variantMediaOption !== y || (e = Mm(v.slice(u, R + 1), p.duration, C, k, f, s, 1, 1, m, S, E, d)).variantMediaOption !== y ? e.variantMediaOption : e.lowestCandidate
                                        } else {
                                            const g = Em(0, v.slice(u, R + 1).reverse(), k, S);
                                            (0 <= g || R === u) && (i = v[R - g].mediaOptionId)
                                        }
                                        if (null != i && i !== (null == (y = S.abrStatus) ? void 0 : y.nextMaxAutoOptionId)) {
                                            h.setNextMaxAutoOptionId(A, i);
                                            const g = S.variantMediaOptionById(i);
                                            null != l && l.setTransformer(A, le.BitrateFilter, new Nc(0,(null == g ? void 0 : g.bitrate) || 0))
                                        }
                                        if (g) {
                                            c.setBandwidthSample(Object.assign(Object.assign({}, o), {
                                                tfirst: o.tfirst || a,
                                                tload: o.tload || a,
                                                complete: !0,
                                                mediaOptionType: I
                                            })),
                                            r = !0;
                                            const g = i ? h.getEnabledAlternatesForVariant(S, i) : [de, de, de];
                                            if (S.isValidMediaOptionTuple(g))
                                                throw new Zs({
                                                    mediaOptionType: I,
                                                    mediaOptionId: b
                                                },g,H.FragmentAbortError)
                                        }
                                    }
                                } else
                                    t.query.extendMaxTTFB && t.setExtendMaxTTFB(0);
                                return {
                                    fragDownloadSlow: e,
                                    fragDownloadTooSlow: r
                                }
                            }
                        }(a, u, c))
                    } catch (u) {
                        if (u instanceof Zs) {
                            const u = {
                                fragDownloadSlow: !0,
                                fragDownloadTooSlow: !0
                            };
                            l.setFragLoadSlow(e.itemId, u)
                        }
                        throw u
                    }
                l.setFragLoadSlow(e.itemId, c)
            }
            return !1
        }
        function Yf(t, n, i, r, a, s) {
            const {mediaSink: o, rootPlaylistQuery: l, config: d, mediaLibraryService: u} = n;
            if (i && null != i.foundFrag) {
                const t = o.mediaQuery
                  , c = i.foundFrag["mediaFragment"]
                  , h = xf(n, c.keyTagInfo, {
                    itemId: c.itemId,
                    mediaOptionId: c.mediaOptionId,
                    appItemId: l.appItemId
                })
                  , p = {
                    getData: !1,
                    cb: Xf.bind(null, n, Gp(c), r === se.Variant ? t.waterLevelForType(oe.Variant) : void 0),
                    samplePeriodMs: d.abrSamplePeriodMs
                };
                let e = u.retrieveMediaFragmentCacheEntity(n, r, i, p).pipe(ie(e => {
                    var t = n.statsService.getQueryForId(l.statsId)
                      , i = t.initFragSample
                      , t = t.fragSample
                      , e = e[1]
                      , r = (null != (r = n.rtcService) && r.handleFragParsed({
                        largestVideoSampleSize: e.largestVideoSampleSize,
                        initFragSample: i,
                        fragSample: t
                    }),
                    o)["mediaQuery"];
                    a && (e.switchPosition = r.currentTime,
                    e.flushBeforeAppend = {
                        start: 0,
                        end: Number.POSITIVE_INFINITY
                    }),
                    e.triggerEvent = s
                }
                ));
                const m = o.mediaQuery.isIframeRate
                  , f = i.foundFrag.mediaFragment.discoSeqNum;
                return r === se.Variant ? e = e.pipe(ie(e => {
                    var t = function(t, i, r) {
                        if (!i)
                            return null;
                        const {rootPlaylistService: n, rootPlaylistQuery: a} = t
                          , s = a.itemId
                          , o = i[1]
                          , l = o.iframe;
                        let d = a.getInitPTS(r);
                        if (null == d || !l && d.iframeMode) {
                            const u = null != (t = o.startDtsTs) ? t : null;
                            if (null == u)
                                return null;
                            let e = null != (t = o.timelineOffset) ? t : 0;
                            l && (e = null != (t = o.iframeOriginalStart) ? t : 0),
                            u.timescale < 1e3 && (u.timescale = 1e3 * u.timescale,
                            u.baseTime = 1e3 * u.baseTime);
                            const i = D(e, u.timescale)
                              , a = {
                                baseTime: u.baseTime - i.baseTime,
                                timescale: u.timescale
                            };
                            n.setInitPTS(s, r, u, e, a, l),
                            d = {
                                variantDTS: u,
                                timelineOffset: e,
                                offsetTimestamp: a,
                                iframeMode: l
                            }
                        }
                        return d
                    }(n, e, f);
                    m || Jf(0, n, e, t)
                }
                )) : m || (e = aa([e, ce(l.initPTS$(f), e => null != e && (m || !e.iframeMode))]).pipe(W( ([e,t]) => (Jf(0, n, e, t),
                e)))),
                aa([h, e]).pipe(W(e => e[1]))
            }
            return nl
        }
        function Jf(e, t, i, r) {
            var {mediaLibraryService: t, rootPlaylistQuery: n, mediaSink: a, config: s} = t
              , n = n.itemId;
            null == r || !a.mediaQuery.isIframeRate && r.iframeMode || i && !re(i[1].iframeMediaDuration) && (performance.now(),
            t.updatePTSDTS(n, i[1].mediaOptionId, r, i[1], s.liveAllowLowLatencyPlayback))
        }
        function Zf(e, t, i, r) {
            return e.rootPlaylistQuery.hasClosedCaption || e.rootPlaylistQuery.hasAlternateWithUrl(se.Subtitle) ? ne(zf(e, t, 0, r), ce((n = e)["mediaSink"].mediaQuery.mediaElementEntity$, e => e).pipe(te(e => {
                return (e => {
                    const {config: t, logger: i, rootPlaylistQuery: a, rootPlaylistService: s, legibleSystemAdapter: o, itemQueue: r, playerEvents: l} = e
                      , n = a.avAnchor$.pipe(Z(e => re(null == e ? void 0 : e.pos)), W( ({pos: e, discoSeqNum: t}) => ({
                        pos: e,
                        discoSeqNum: t
                    })))
                      , d = r.getQueueItemForId(a.itemId)
                      , u = a.enabledAlternateMediaOptionByType(se.Subtitle);
                    if (d.isInterstitial) {
                        const e = a.mediaOptionListQueries[se.Subtitle].filteredMediaOptionList;
                        if (0 === e.length)
                            return X;
                        o.setInterstitialTracks(e, u, a.getDisabledMediaOption(se.Subtitle))
                    } else if (o.endLoadingInterstitials(),
                    o.gotTracks)
                        u ? o.selectedTrack = u : s.clearMediaOptionSwitchContextByType(d.itemId, se.Subtitle);
                    else {
                        const e = a.mediaOptionListQueries[se.Subtitle].filteredMediaOptionList;
                        o.setTracks(e, u, a.getDisabledMediaOption(se.Subtitle)),
                        l.postSubtitleTracksCreated(e, r.activeItem.isInterstitial)
                    }
                    const c = ne(o.nativeSubtitleTrackChange$.pipe(te(e => t.enableInterstitialPlayback ? (i.error("native video controller subtitle selection is incompatible with interstitials playback"),
                    X) : (e.mediaOptionId !== o.selectedMediaOption.mediaOptionId && s.setEnabledMediaOptionByType(e.itemId, se.Subtitle, e, !0, {
                        userInitiated: !0
                    }),
                    X))), a.enabledMediaOptionByType$(se.Subtitle).pipe(W(e => {
                        var t;
                        const i = null === (t = a.enabledMediaOptionSwitchContexts) || void 0 === t ? void 0 : t[se.Subtitle]
                          , r = Ds(e) ? a.alternateMediaOptionById(se.Subtitle, e.mediaOptionId) : e;
                        o.selectedMediaOption = r;
                        const n = !i;
                        return l.postSubtitleTrackSwitch(n, i, r),
                        s.clearMediaOptionSwitchContextByType(d.itemId, se.Subtitle),
                        r
                    }
                    ))).pipe(J( (e, t) => (null == e ? void 0 : e.mediaOptionId) === (null == t ? void 0 : t.mediaOptionId)));
                    return Fr([n, c]).pipe()
                }
                )(n).pipe((s = n,
                e => {
                    const {mediaSink: t, rootPlaylistQuery: r, mediaLibraryService: i} = s
                      , n = t.mediaQuery;
                    return Fr([e, n.isIframeRate$.pipe(Rn(!1), dn(), W(e => e[0] && !e[1]))]).pipe(te( ([e]) => {
                        var [,e] = e;
                        return xs(e) && Ds(e) ? i.getQueryForOption(e).mediaOptionDetails$.pipe(te(a => r.avAnchor$.pipe(Kl(), Z( ({iframeMode: e}) => !e && !n.isIframeRate), $r( ({discoSeqNum: i}) => re(i) || re(i = Qp(a, n.currentTime)) ? ce(r.initPTS$(i), e => e && !e.iframeMode).pipe(te(e => {
                            {
                                var d = s
                                  , u = a
                                  , t = i
                                  , c = e;
                                const {legibleSystemAdapter: r, mediaSink: n} = d;
                                return na( () => {
                                    const e = n.mediaQuery
                                      , i = e.seekTo ? e.seekTo.pos : e.currentTime;
                                    return r.findFrags$(u, t, i).pipe(te(e => {
                                        if (u && null != e && e.foundFrags) {
                                            var r = d
                                              , t = i
                                              , n = c.offsetTimestamp
                                              , a = e
                                              , s = u;
                                            const o = r["legibleSystemAdapter"]
                                              , l = a.foundFrags;
                                            return na( () => {
                                                let i = l.length;
                                                return Lr(l).pipe(W(t => {
                                                    if (t.gap) {
                                                        const n = r["mediaSink"];
                                                        var e;
                                                        return e.frag = t,
                                                        e.cueRange = void 0,
                                                        n.updateContentGapRanges(oe.Variant, {
                                                            start: t.start,
                                                            end: t.start + t.duration
                                                        }),
                                                        Y(e)
                                                    }
                                                    return ( (e, t, i) => {
                                                        const {rootPlaylistQuery: l, legibleSystemAdapter: d} = e;
                                                        return na( () => ( (e, t, i) => {
                                                            const r = e["mediaLibraryService"]
                                                              , n = {
                                                                trequest: NaN,
                                                                tfirst: NaN,
                                                                tload: NaN,
                                                                tparse: NaN,
                                                                tparsed: NaN,
                                                                loaded: 0
                                                            }
                                                              , a = kf(e, i, !1).pipe(W(e => (Af(n, e.bwSample),
                                                            {
                                                                initPTS: t,
                                                                data: e,
                                                                mediaFragment: i
                                                            })));
                                                            return r.retrieveInitSegmentCacheEntity(e, i, i.discoSeqNum).pipe(te(e => aa([Y(e), a])))
                                                        }
                                                        )(e, t, i).pipe(te( ([e,{initPTS: t, data: i, mediaFragment: r}]) => {
                                                            var n, a, s = l.enabledAlternateMediaOptionByType(se.Subtitle);
                                                            let o = !0;
                                                            return null != (e = null == e ? void 0 : e.initParsedData) && e.ttml && (o = !1),
                                                            [e,s,t,i,n,a=!0] = [s, r, t, Ae(i.loadedData), d, o],
                                                            (e ? n.processSubtitleFrag(e, s, t, i, a) : Y(void 0)).pipe(W(e => ({
                                                                frag: r,
                                                                cueRange: e
                                                            })))
                                                        }
                                                        )))
                                                    }
                                                    )(r, n, t).pipe(nn(e => o.checkReadyToLoadNextSubtitleFragment$(t, l).pipe(Z(e => e))), ie( () => {
                                                        i--
                                                    }
                                                    ))
                                                }
                                                ), Gr(r.config.vttConcurrentLoadCount), te(e => o.reviewParsedFrag(t, e, a, s, i) !== Fd.CloseEnough ? (o.tryAgain$.next(Bd.TryAgain),
                                                X) : ue), ee( () => {
                                                    0 === i && o.tryAgain$.next(Bd.Complete)
                                                }
                                                ))
                                            }
                                            )
                                        }
                                        return ue
                                    }
                                    ), ee( () => {}
                                    ))
                                }
                                )
                            }
                        }
                        ), ee( () => {}
                        )) : X), ee( () => {}
                        )))) : Y([null, null, null])
                    }
                    ))
                }
                ));
                var s
            }
            ), ee( () => {}
            ))) : zf(e, t, 0, r);
            var n
        }
        function eg(t, e, i, r, n, a) {
            return e.pipe(te(e => i.getEntity(i.itemId) ? e.length < 1 ? X : e.some(e => e.priority > t.priority || e.priority === t.priority && t.priority !== Xh.Low) ? ue : n.combinedBuffer$.pipe(te( () => {
                var e = i.enabledVariantMediaOption
                  , e = r.getQueryForOption(e).mediaOptionDetails
                  , t = function(e, t) {
                    t = e.getCombinedBufferInfo(e.currentTime, t);
                    return t ? t.len / bm(e) : 0
                }(n, a.maxBufferHole);
                return e && t >= Math.min(a.minSteeringRunway * e.targetduration, a.maxBufferLength / 2) ? ue : X
            }
            )) : ue))
        }
        class tg {
            constructor(e) {
                this.Ma = e
            }
            destroy() {
                this.Ma = void 0
            }
            recoverFromFatalError() {
                this.Ma.recoverFromFatalError()
            }
            shouldAttemptErrorRecovery(e) {
                return this.Ma.shouldAttemptErrorRecovery(e)
            }
        }
        function ig(e, t, i, r) {
            var n = null != (n = null == e ? void 0 : e.mediaOptionKeys) ? n : [];
            for (const {mediaOptionId: e} of n)
                for (const n of i.mediaOptionListQueries)
                    null != n.mediaOptionFromId(e) && r.updateConsecutiveTimeouts(i.itemId, n.mediaOptionType, t, "key")
        }
        function rg(i, t, e, r, n, a) {
            const s = r.query.getActiveId()
              , o = i.keyuri
              , l = n.getKeyInfo(o);
            if (!l || !l.mediaOptionKeys.some( ({itemId: e}) => e === s))
                return X;
            const d = r.getQueryForId(s)
              , u = r.logger
              , c = d.enabledMediaOptionKeys
              , h = [];
            for (const t of i.mediaOptionIds) {
                const i = c.some(e => e.mediaOptionId === t)
                  , e = d.mediaOptionListQueries.find(e => null != e.mediaOptionFromId(t));
                if (e) {
                    const r = e.mediaOptionType
                      , n = {
                        mediaOptionId: t,
                        mediaOptionType: r
                    };
                    i ? h.push(n) : h.unshift(n)
                }
            }
            let p, m = !1;
            if (ae( () => {
                const e = i instanceof Fo;
                ig(n.getKeyInfo(o), e, d, r);
                for (const {mediaOptionId: e, mediaOptionType: t} of h)
                    p = function(e, t, i, r, n) {
                        let a = {
                            errorAction: Jh.SendAlternateToPenaltyBox,
                            errorActionFlags: 0
                        };
                        if (e instanceof Fo)
                            a.errorAction = Jh.SendAlternateToPenaltyBox;
                        else {
                            const t = e.isOkToRetry;
                            e.keyErrorReason === To.OutputRestricted ? (a.errorAction = Jh.RemoveAlternatePermanently,
                            a.errorActionFlags |= Zh.MoveAllAlternatesMatchingHDCP) : t ? a = Np(e.response) : a.errorAction = Jh.RemoveAlternatePermanently
                        }
                        a.errorActionFlags &= ~Zh.MoveAllAlternatesMatchingHost;
                        var s = r.enabledMediaOptionIdByType(i);
                        return t === s ? Lp(a, !1, e.response, s, i, r, n, e.isTimeout) : a
                    }(i, e, t, d, r),
                    u.error(`[Keys] handleNetworkError uri=${f(i.keyuri)} mediaOptionId=${e} mediaOptionType=${t} action=` + JSON.stringify(p)),
                    p.errorAction === Jh.RetryRequest && (m = !0),
                    xp(p, i, d, r, a, t, e)
            }
            ),
            m)
                return Bp(i, t, e, r.logger, d.isInterstitial, r.rtcService);
            throw Fp(0, i),
            i
        }
        class ng {
            constructor(e, t, i, r, n, a) {
                this.Oi = e,
                this.R = t,
                this.Ea = i,
                this.Re = r,
                this.Aa = n,
                this.Na = a,
                this._i = new z,
                this.Ra = new pn(null),
                this.Pa = new pn(null),
                this.Ca = new pn(null),
                this.Da = NaN,
                this.xa = new z,
                this.R = t.child({
                    name: "hls-player-events"
                }),
                this.La()
            }
            destroy() {
                this._i.next(),
                this.setRootPlaylistQuery(null),
                this.setMediaElementQuery(null),
                this.setInterstitialQuery(null),
                this.Oi = void 0
            }
            setRootPlaylistQuery(e) {
                this.Ra.next(e)
            }
            setMediaElementQuery(e) {
                this.Pa.next(e)
            }
            setInterstitialQuery(e) {
                this.Ca.next(e)
            }
            La() {
                var e = [this.Re.gotRequest$.pipe(ie(this._a.bind(this))), this.Fa(this.Oi.itemQueue), this.ja(), this.Ra.pipe(te(this.Ua.bind(this))), this.Pa.pipe(te(this.Ba.bind(this)))];
                this.Oi.config.enableInterstitialPlayback && e.push(this.Ca.pipe(te(e => this.$a(e, this.Oi.itemQueue)))),
                ne(...e).pipe($(e => {
                    var t = e.message;
                    return this.R.error(`Got error in HlsPlayerEvents ` + t, e),
                    X
                }
                ), Pn(this._i), ee( () => {}
                )).subscribe()
            }
            Fa(e) {
                return e.activeItemById$.pipe(Kl(), ie(e => {
                    e = e.url;
                    this.Oi.trigger(K.MANIFEST_LOADING, {
                        url: e
                    })
                }
                ))
            }
            postSubtitleTracksCreated(e, t) {
                this.Va({
                    eventName: K.SUBTITLE_TRACKS_UPDATED,
                    payload: {
                        subtitleTracks: e,
                        fromInterstitial: t
                    }
                }),
                this.Va({
                    eventName: K.SUBTITLE_TRACKS_CREATED
                })
            }
            _a(e) {
                this.Oi.trigger(K.UNRESOLVED_URI_LOADING, e)
            }
            Ua(e) {
                var t, i, r;
                return e ? (t = e.enabledMediaOptionByType$(se.Variant).pipe(ie(function(e) {
                    var t;
                    if (!e)
                        return X;
                    e.url && null != (t = this.Ea) && t.handleLevelSwitching(e.url),
                    this.Oi.trigger(K.LEVEL_SWITCHING, e)
                }
                .bind(this))),
                i = [],
                e = (e.sessionData && i.push(ce(e.sessionData$, e => null != e.complete).pipe(ie(e => {
                    this.Oi.trigger(K.SESSION_DATA_COMPLETE, e)
                }
                ))),
                e)["mediaOptionListQueries"],
                [e,r] = e,
                i.push(e.getFilteredMediaOptionList$(!0).pipe(ie(e => {
                    var t;
                    null != (t = this.Ea) && t.handleLevelsChanged(e),
                    e.forEach(e => {}
                    ),
                    this.Oi.trigger(K.LEVELS_CHANGED, {
                        requiresReset: !1,
                        levels: e
                    })
                }
                ))),
                i.push(r.getFilteredMediaOptionList$(!1).pipe(ie(e => {
                    var t = null != (t = null == (t = this.Oi.itemQueue.activeItem) ? void 0 : t.isInterstitial) && t;
                    this.Oi.trigger(K.AUDIO_TRACKS_UPDATED, {
                        audioTracks: e,
                        fromInterstitial: t
                    })
                }
                ))),
                ne(t, kr(ne(...i), sr))) : X
            }
            Ba(s) {
                var e, t, i, r;
                return s ? (e = s.desiredRate$.pipe(Rn(0), dn(), ie( ([e,t]) => this.desiredRateChanged(e, t))),
                t = s.seekTo$.pipe(ie(e => {
                    var t;
                    e && re(e.pos) ? (null != (t = this.Ea) && t.handleSeek("SEEKING", e, s.combinedBuffer),
                    this.Oi.trigger(K.SEEKING, {
                        seekToPos: e.pos
                    })) : (null != (t = this.Ea) && t.handleSeek("SEEKED", e),
                    this.Oi.trigger(K.SEEKED))
                }
                )),
                i = s.playbackLikelyToKeepUp$.pipe(ie(e => this.Oi.trigger(K.PLAYER_STATE_CHANGE, {
                    playbackLikelyToKeepUp: e
                }))),
                r = s.gotFirstAppend$(sr).pipe(te( () => {
                    var e = [];
                    return e.push(s.stallInfo$.pipe(Pr(sr), Kl(), ie(e => {
                        var t;
                        null != (t = this.Ea) && t.handleStalled(e, null != (t = null == (t = s.getCombinedBufferInfo(e.currentTime, 0)) ? void 0 : t.len) ? t : 0, this.Oi.interstitialActive),
                        this.Oi.trigger(K.STALLED, e)
                    }
                    ))),
                    e.push(ne(s.timeupdate$.pipe(kn(1e3)), s.gotPlaying$.pipe(Z(e => !!e))).pipe(W( () => {
                        const t = s.currentTime
                          , e = s.getBufferedSegmentsByType(oe.Variant);
                        return null == e ? void 0 : e.find(e => e.startPTS <= t && e.endPTS > t)
                    }
                    ), Kl(), Rn(null), dn(), ie( ([e,t]) => {
                        var i;
                        const r = null == t ? void 0 : t.frag
                          , n = null == e ? void 0 : e.frag;
                        if ((r && !n || r && n && !jc(n, r)) && (this.Oi.trigger(K.FRAG_CHANGED, t),
                        this.Oi.inGaplessMode && this.qa(s, t, this.R),
                        !n || r.mediaOptionId !== n.mediaOptionId)) {
                            const s = this.Aa.query.getEntity(r.itemId)
                              , e = null == s ? void 0 : s.mediaOptionListTuple[se.Variant].mediaOptions.find(e => e.mediaOptionId === r.mediaOptionId);
                            if (e) {
                                const t = n ? n.mediaOptionId : ""
                                  , a = r.mediaOptionId;
                                e.url && null != (i = this.Ea) && i.handleLevelSwitched({
                                    url: e.url,
                                    mediaOptionId: e.mediaOptionId,
                                    oldVariant: "" !== t ? t : void 0,
                                    newVariant: a
                                }, this.Oi.interstitialActive),
                                this.Oi.trigger(K.LEVEL_SWITCHED, e)
                            }
                        }
                    }
                    ))),
                    this.Oi.inGaplessMode && e.push(kr(s.isBufferedToEnd$(this.Oi.config.maxBufferHole, !1), sr).pipe(Z(e => !0 === e), ie(e => {
                        if (e && !this.Oi.itemQueue.isPreloading() && this.Oi.inGaplessMode) {
                            const e = s.getCombinedBufferInfo(s.currentTime, 0);
                            var t, i = 0;
                            e && (i = e.end,
                            t = s.mediaElementDuration,
                            0 < i) && t - s.currentTime < 10 && this.Oi.trigger(K.READY_FOR_NEXT_ITEM, {
                                duration: i
                            })
                        }
                    }
                    ))),
                    ne(...e)
                }
                )),
                kr(ne(e, t, i, r), Zn)) : X
            }
            $a(s, e) {
                return s ? ne(s.interstitials$.pipe(ie(e => {
                    this.Oi.trigger(K.INTERSTITIALS_UPDATED, {
                        events: e
                    })
                }
                )), s.playingInterstitialId$.pipe(dn(), xn(e.activeItemById$), ie( ([[e,t],i]) => {
                    var r, n = null != (r = null == i ? void 0 : i.parentItemId) ? r : null == i ? void 0 : i.itemId;
                    if (!n)
                        return X;
                    if (null == e && null != t) {
                        const e = s.getInterstitialForId(t);
                        this.Oi.trigger(K.INTERSTITIAL_STARTED, e ? {
                            event: e
                        } : void 0),
                        !n || null != (r = this.Ea) && r.interstitialStarted(n)
                    } else if (null != e && null == t) {
                        const t = s.getInterstitialForId(e);
                        this.Oi.trigger(K.INTERSTITIAL_ENDED, t ? {
                            event: t
                        } : void 0),
                        !n || null != (i = this.Ea) && i.interstitialEnded(n)
                    } else if (null != e && null != t && e !== t) {
                        const i = s.getInterstitialForId(e)
                          , r = s.getInterstitialForId(t);
                        this.Oi.trigger(K.INTERSTITIAL_ENDED, i ? {
                            event: i
                        } : void 0),
                        this.Oi.trigger(K.INTERSTITIAL_STARTED, r ? {
                            event: r
                        } : void 0),
                        n && (null != (e = this.Ea) && e.interstitialEnded(n),
                        null != (t = this.Ea)) && t.interstitialStarted(n)
                    }
                }
                )), s.playingInterstitialAssetId$.pipe(dn(), xn(s.playingInterstitialId$, e.activeItemById$), ie( ([[e,t],i,r]) => {
                    var n = null != (n = null == r ? void 0 : r.parentItemId) ? n : null == r ? void 0 : r.itemId;
                    if (!n)
                        return X;
                    var a = i ? s.getInterstitialForId(i) : void 0;
                    if (!a)
                        return X;
                    if (null == e && null != t) {
                        const e = s.getInterstitialAssetForId(t);
                        this.Oi.trigger(K.INTERSTITIAL_ASSET_STARTED, e && a ? {
                            asset: e,
                            event: a
                        } : void 0),
                        !n || null != (r = this.Ea) && r.interstitialAssetStarted(n)
                    } else if (null != e && null == t) {
                        const t = s.getInterstitialAssetForId(e);
                        this.Oi.trigger(K.INTERSTITIAL_ASSET_ENDED, t && a ? {
                            asset: t,
                            event: a
                        } : void 0),
                        n && t && null != (i = this.Ea) && i.interstitialAssetEnded(n, t.duration)
                    } else if (null != e && null != t && e !== t) {
                        const i = s.getInterstitialAssetForId(e)
                          , r = s.getInterstitialAssetForId(t);
                        this.Oi.trigger(K.INTERSTITIAL_ASSET_ENDED, i && a ? {
                            asset: i,
                            event: a
                        } : void 0),
                        n && i && null != (e = this.Ea) && e.interstitialAssetEnded(n, i.duration),
                        this.Oi.trigger(K.INTERSTITIAL_ASSET_STARTED, r && a ? {
                            asset: r,
                            event: a
                        } : void 0),
                        !n || null != (t = this.Ea) && t.interstitialAssetStarted(n)
                    }
                }
                ))) : X
            }
            desiredRateChanged(e, t) {
                var i;
                Yc(e) !== Yc(t) ? this.Da = performance.now() : this.Da = NaN,
                null != (i = this.Ea) && i.handleDesiredRateChanged(e, t),
                this.Oi.trigger(K.DESIRED_RATE_CHANGED, {
                    oldRate: e,
                    newRate: t
                })
            }
            qa(e, t, i) {
                var r, n;
                t && t.frag && (r = e.currentTime,
                r = e.getCombinedBufferInfo(r, 0)) && (r = r.len ? r.end : 0,
                n = e.mediaElementDuration,
                e = e.bufferMonitorInfo) && (e = Math.max(e.almostDryWaterLevelSeconds, e.lowWaterLevelSeconds / 2),
                n = n - t.endPTS,
                0 < r && n <= e || t.frag.isLastFragment) && this.Oi.inGaplessMode && !this.Oi.isPreloading && this.Oi.trigger(K.READY_FOR_NEXT_ITEM, {
                    duration: r
                })
            }
            ja() {
                return this.xa.pipe(Pr(sr), ie(e => {
                    this.Oi.trigger(e.eventName, e.payload)
                }
                ))
            }
            handleLevelLoading(e) {
                var {mediaOptionId: e, mediaOptionType: t, url: i} = e
                  , i = {
                    url: f(i),
                    level: e,
                    type: Bs[t]
                };
                this.Oi.trigger(K.LEVEL_LOADING, i)
            }
            handleLevelLoaded(e, t, i) {
                var r, {itemId: e, mediaOptionId: n} = e, n = {
                    mediaOptionId: n,
                    details: t,
                    playlistType: t.type,
                    stats: i = i || {
                        complete: !1,
                        loaded: NaN,
                        tfirst: NaN,
                        tload: NaN,
                        total: NaN,
                        trequest: NaN
                    }
                }, i = this.Oi.itemQueue.getQueueItemForId(e), i = null != (r = null != (r = null == i ? void 0 : i.parentItemId) ? r : null == i ? void 0 : i.itemId) ? r : e;
                if (null != (r = this.Ea) && r.handleLevelLoaded(i, t, n.stats),
                this.Oi.trigger(K.LEVEL_LOADED, n),
                null != t && t.daterangeTags) {
                    const e = {
                        daterangeTags: t.daterangeTags
                    };
                    this.Oi.trigger(K.DATERANGE_UPDATED, e)
                }
            }
            handleLevelUpdated(e) {
                e = {
                    level: e.mediaOptionId,
                    details: e
                };
                this.Oi.trigger(K.LEVEL_UPDATED, e)
            }
            Va(e) {
                this.xa.next(e)
            }
            postSubtitleTrackSwitch(e, t, i) {
                var r = this.Oi.itemQueue.activeItem
                  , n = null != (n = null == r ? void 0 : r.isInterstitial) && n
                  , r = !n && void 0 !== (null == r ? void 0 : r.parentItemId);
                return this.Oi.config.enableInterstitialPlayback && !t && (n || r && e) || ("persistentID"in i ? this.Va({
                    eventName: K.SUBTITLE_TRACK_SWITCH,
                    payload: {
                        track: Object.assign({}, i),
                        hidden: !1,
                        fromInterstitial: n
                    }
                }) : this.Va({
                    eventName: K.SUBTITLE_TRACK_SWITCH,
                    payload: {
                        track: void 0,
                        hidden: !1,
                        fromInterstitial: n
                    }
                })),
                X
            }
            postAudioTrackSwitched(e, t, i) {
                var r, n;
                i && (n = !(r = null != (r = null == (n = this.Oi.itemQueue.activeItem) ? void 0 : n.isInterstitial) && r) && void 0 !== (null == n ? void 0 : n.parentItemId),
                this.Oi.config.enableInterstitialPlayback && !t && (r || n && e) || this.Va({
                    eventName: K.AUDIO_TRACK_SWITCHED,
                    payload: {
                        id: i.id,
                        track: i,
                        fromInterstitial: r
                    }
                }))
            }
            triggerBufferAppended() {
                this.Oi.trigger(K.BUFFER_APPENDED)
            }
            triggerBufferedToInterstitialBoundary(e, t, i, r) {
                this.Oi.trigger(K.BUFFERED_TO_INTERSTITIAL_BOUNDARY, {
                    id: e,
                    type: t,
                    timestamp: i,
                    willResetMediaSource: r
                })
            }
            triggerManifestLoaded(e) {
                var t = e.rootMediaOptionsTuple[se.Variant]
                  , i = t.filter(e => e.iframes)
                  , i = {
                    levels: t,
                    audioTracks: e.rootMediaOptionsTuple[se.AltAudio],
                    subtitleTracks: e.rootMediaOptionsTuple[se.Subtitle],
                    iframeVariants: i,
                    url: e.baseUrl,
                    audioMediaSelectionGroup: e.audioMediaSelectionGroup,
                    subtitleMediaSelectionGroup: e.subtitleMediaSelectionGroup,
                    stats: e.stats,
                    isMediaPlaylist: null != (t = e.isMediaPlaylist) && t
                };
                this.Oi.trigger(K.MANIFEST_LOADED, i)
            }
            triggerManifestParsed(e) {
                var t = {
                    levels: e.mediaOptionListQueries[se.Variant].filteredMediaOptionList,
                    firstLevel: 0,
                    audio: !1,
                    video: !0,
                    altAudio: !1,
                    audioTracks: e.mediaOptionListQueries[se.AltAudio].filteredMediaOptionList,
                    subtitleTracks: e.mediaOptionListQueries[se.Subtitle].filteredMediaOptionList,
                    iframeVariants: null != (t = null == (t = e.rootPlaylistEntity) ? void 0 : t.iframeVariants) ? t : [],
                    audioMediaSelectionGroup: e.audioMediaSelectionGroup,
                    subtitleMediaSelectionGroup: e.subtitleMediaSelectionGroup,
                    stats: e.loadStats
                };
                this.Oi.trigger(K.MANIFEST_PARSED, t),
                null != (e = this.Ea) && e.handleManifestParsed(t)
            }
            triggerFragLoaded(e, t) {
                var i, r = {
                    frag: e,
                    stats: t
                }, n = this.Oi.itemQueue.getQueueItemForId(e.itemId), n = null != (i = null != (i = null == n ? void 0 : n.parentItemId) ? i : null == n ? void 0 : n.itemId) ? i : e.itemId;
                null != (i = this.Ea) && i.handleFragLoaded(n, e, t),
                this.Oi.trigger(K.FRAG_LOADED, r)
            }
            triggerPrefetchNextItem(e) {
                this.Oi.trigger(K.READY_TO_PREFETCH_NEXT_ITEM, {
                    appItemId: e
                })
            }
        }
        class ag extends ja {
            constructor(e) {
                super(e)
            }
            get currentConfig() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.config
            }
            get extendMaxTTFB() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.extendMaxTTFB
            }
            get config$() {
                return this.selectActive(e => null == e ? void 0 : e.config)
            }
            get pendingSeek() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.userSeek
            }
            get pendingSeek$() {
                return this.selectActive(e => null == e ? void 0 : e.userSeek)
            }
            get alternateMatchingInfo() {
                var e;
                return null == (e = this.getActive()) ? void 0 : e.alternateMatchingInfo
            }
            get alternateMatchingInfo$() {
                return this.selectActive(e => null == e ? void 0 : e.alternateMatchingInfo)
            }
        }
        class sg extends Ua {
            constructor() {
                super({}, {
                    name: "hls-store"
                })
            }
        }
        class og {
            constructor(e) {
                this.ce = e,
                this.ri = new ag(e)
            }
            get query() {
                return this.ri
            }
            setHlsEntity(e) {
                const t = e.id;
                ae( () => {
                    this.ce.add(h(e)),
                    this.ce.setActive(t)
                }
                )
            }
            removeEntity(e) {
                this.ce.remove(e)
            }
            setUserSeek(e) {
                this.ce.updateActive({
                    userSeek: e
                })
            }
            setExtendMaxTTFB(e) {
                this.ce.updateActive({
                    extendMaxTTFB: e
                })
            }
            set config(e) {
                this.ce.updateActive({
                    config: e
                })
            }
            setAlternateMatchingInfo(e) {
                this.ce.updateActive({
                    alternateMatchingInfo: e
                })
            }
            setAudioAlternateMatchingInfo(e) {
                var t = this.ri.getActive();
                t && (t = Object.assign(Object.assign({}, t.alternateMatchingInfo), {
                    audioMatchingInfo: e
                }),
                this.ce.updateActive({
                    alternateMatchingInfo: t
                }))
            }
            setSubtitleAlternateMatchingInfo(e) {
                var t = this.ri.getActive();
                t && (t = Object.assign(Object.assign({}, t.alternateMatchingInfo), {
                    subtitleMatchingInfo: e
                }),
                this.ce.updateActive({
                    alternateMatchingInfo: t
                }))
            }
            reset() {
                this.ri.getActive() && this.ce.updateActive({
                    alternateMatchingInfo: void 0,
                    userSeek: void 0,
                    extendMaxTTFB: void 0
                })
            }
            destroy() {
                this.ce.destroy()
            }
        }
        function lg(e, t) {
            var i = e.seekable;
            let r = 0;
            return re(r = 0 < i.length ? i.end(i.length - 1) : r) || (r = e.mediaElementDuration),
            Math.max(0, r - (t.leftMediaTimeToAutoPause || 0))
        }
        (r = void 0 || {}).AlmostDryWaterLevel = "AlmostDryWaterLevel",
        r.LowWaterLevel = "LowWaterLevel",
        r.HighWaterLevel = "HighWaterLevel",
        (e = nf = nf || {})[e.Enter = 0] = "Enter",
        e[e.Exit = 1] = "Exit";
        class dg extends ja {
        }
        function ug(e, t) {
            var {appItemId: i, clientName: r, serviceName: n, platformInfo: a} = e
              , i = {
                appItemId: i,
                clientName: r,
                serviceName: n,
                platformInfo: a
            };
            return t && (i.parentItemId = null != (r = e.parentItemId) ? r : e.itemId),
            i
        }
        class cg {
            constructor(e, t) {
                this.Ka = e,
                this.R = t,
                this.Ha = !0,
                this.za = null,
                this.playing$ = new pn(null),
                this.Qa = new pn(null),
                this.ri = new dg(e)
            }
            static createItem(e, t, i, r, n=!1, a={}) {
                var s, o = new Date, o = `${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.` + o.getMilliseconds(), l = (l = t,
                (l = null == (l = es.parseURL(l)) ? void 0 : l.fragment.substr(1)) && 0 !== l.length && (l = new URLSearchParams(l)).has("t") && re(l = Number(l.get("t"))) ? l : null);
                let d = null != (s = a.initialSeekTime) ? s : NaN;
                return re(d) || (re(l) ? d = l : re(i.startPosition) && (d = i.startPosition)),
                {
                    itemId: e + `_` + o,
                    parentItemId: a.parentItemId,
                    clientName: a.clientName,
                    serviceName: a.serviceName,
                    appItemId: a.appItemId,
                    initialRate: a.initialRate,
                    platformInfo: a.platformInfo,
                    loopCount: a.loopCount,
                    itemStartOffsets: a.itemStartOffsets || [0, 0],
                    seekImmediately: a.seekImmediately,
                    initialSeekTime: d,
                    name: e,
                    url: t,
                    config: {},
                    isInterstitial: n,
                    itemTimelineStartPosition: 0,
                    itemTimelineEndPosition: 1 / 0,
                    replaceItemAction: a.replaceItemAction
                }
            }
            get query() {
                return this.ri
            }
            get activeItemById$() {
                return this.ri.selectActiveId().pipe(W(e => this.ri.getActive()))
            }
            get removedItems$() {
                return this.ri.selectEntityAction(va.Remove).pipe(W(e => e))
            }
            get activeItem() {
                return this.ri.getActive()
            }
            getQueueItemForId(e) {
                return this.ri.getEntity(e)
            }
            get queueItems$() {
                return this.ri.selectAll().pipe(W(e => null != e ? e : []))
            }
            get queueItems() {
                return this.ri.getAll()
            }
            get isFirstItem() {
                return this.Ha
            }
            get playingItem() {
                return this.playing$.getValue()
            }
            get loadingItem() {
                var e, t;
                return null == this.playingItem || (t = (e = this.ri.getAll()).findIndex(e => {
                    return e.itemId === (null == (e = this.playingItem) ? void 0 : e.itemId)
                }
                )) < 0 || t >= e.length - 1 ? null : e[t + 1]
            }
            addQueueItem(e, t, i, r=!1, n={}) {
                let a;
                return this.prefetchItem && n.appItemId && this.prefetchItem.appItemId === n.appItemId ? (a = Object.assign(Object.assign(Object.assign({}, this.prefetchItem), n), {
                    isInterstitial: r
                }),
                this.Qa.next(null)) : a = cg.createItem(e, t, i, this.R, r, n),
                null != this.playingItem && (a.initialSeekTime = void 0),
                null != n && n.itemStartOffsets && (a.itemStartOffsets = n.itemStartOffsets,
                this.Ha = !1,
                this.playing$.next(null != (e = this.activeItem) ? e : null)),
                ae( () => {
                    this.Ka.add(a),
                    this.Ka.setActive(a.itemId)
                }
                ),
                a
            }
            addPrefetchItem(e, t, i, r=!1, n={}) {
                if (null != n.appItemId)
                    return e = cg.createItem(e, t, i, this.R, r, n),
                    null != n && n.itemStartOffsets && (e.itemStartOffsets = n.itemStartOffsets),
                    this.Qa.next(e),
                    e
            }
            get prefetchItem$() {
                return this.Qa.asObservable()
            }
            get prefetchItem() {
                return this.Qa.getValue()
            }
            get primaryItem() {
                var e = null != (e = null == (e = this.playingItem) ? void 0 : e.parentItemId) ? e : null == (e = this.playingItem) ? void 0 : e.itemId;
                if (e)
                    return this.ri.getEntity(e)
            }
            insertQueueItem(e) {
                this.Ka.add(e)
            }
            setPlayingItem(e) {
                this.playing$.next(e)
            }
            getItemTimelineEndPosition(e) {
                e = this.getQueueItemForId(e);
                return null == e ? void 0 : e.itemTimelineEndPosition
            }
            updatePlayingItemId(e=!0) {
                this.playing$.next(this.loadingItem),
                e && this.clearAllButActive()
            }
            resetLoadingItem() {
                ae( () => {
                    this.loadingItem && this.removeQueueItem(this.loadingItem.itemId),
                    this.playingItem && this.Ka.setActive(this.playingItem.itemId)
                }
                )
            }
            getQueueItemForTime(e, t=!1) {
                for (const i of this.queueItems)
                    if (e >= i.itemTimelineStartPosition && e <= i.itemTimelineEndPosition && (!i.isInterstitial || i.isInterstitial && t))
                        return i;
                return null
            }
            Ga(e, t, i, r) {
                const n = Object.assign({}, this.ri.getEntity(e))
                  , a = null != i ? i : n.initialSeekTime;
                this.Ha = !1,
                ae( () => {
                    this.Ka.update(e, {
                        itemStartOffsets: t,
                        initialSeekTime: a,
                        seekImmediately: r
                    }),
                    this.Ka.setActive(e)
                }
                )
            }
            setActiveWithContext(e, t, i, r, n) {
                this.za && this.za.itemId === e && null != e ? (this.za.parentItemId = (null == t ? void 0 : t.parentItemId) || this.za.parentItemId,
                this.za.userSwitchAudioTrack = (null == t ? void 0 : t.userSwitchAudioTrack) || this.za.userSwitchAudioTrack,
                this.za.userSwitchSubtitleTrack = (null == t ? void 0 : t.userSwitchSubtitleTrack) || this.za.userSwitchSubtitleTrack) : this.za = t,
                this.Ga(e, i, r, n)
            }
            reset() {
                ae( () => {
                    this.resetInternal(),
                    this.playing$.next(null)
                }
                )
            }
            resetInternal() {
                this.clearQueue(),
                this.za = null,
                this.Ha = !0
            }
            setActive(e, t, i, r) {
                var n;
                (null == (n = this.za) ? void 0 : n.itemId) !== e && null != e && (this.za = null),
                this.Ga(e, t, i, r)
            }
            getActiveItemContext(e) {
                var t;
                return (null == (t = this.za) ? void 0 : t.itemId) === e && null != e ? this.za : null
            }
            clearActiveItemContext(e) {
                var t;
                (null == (t = this.za) ? void 0 : t.itemId) === e && null != e && (this.za = null)
            }
            updateItemById(e, t) {
                this.Ka.update(e, t)
            }
            isPreloading() {
                return null != this.playingItem && null != this.loadingItem
            }
            setQueueItem(e, t, i, r, n=!1) {
                var a;
                let s;
                this.prefetchItem && r.appItemId && this.prefetchItem.appItemId === r.appItemId ? (s = Object.assign(Object.assign(Object.assign({}, this.prefetchItem), r), {
                    initialSeekTime: null != (a = r.initialSeekTime) ? a : 0
                }),
                this.Qa.next(null)) : s = cg.createItem(e, t, i, this.R, n, r),
                ae( () => {
                    this.Ka.remove(),
                    this.Ka.add(s),
                    this.Ka.setActive(s.itemId)
                }
                ),
                this.playing$.next(null != (a = this.activeItem) ? a : null)
            }
            removeQueueItem(e) {
                this.Ka.remove(e)
            }
            clearQueue() {
                this.Ka.remove()
            }
            clearAllButActive() {
                var e;
                const t = null == (e = this.activeItem) ? void 0 : e.itemId;
                ae( () => {
                    this.ri.getAll().forEach(e => {
                        e.itemId !== t && this.Ka.remove(e.itemId)
                    }
                    )
                }
                )
            }
        }
        class hg {
            constructor(e, t, i, r, n, a, s, o) {
                this.Wa = e,
                this.Xa = t,
                this.Ya = i,
                this.Gt = r,
                this.cs = n,
                this.Ja = a,
                this.Re = s,
                this.activeInterstitialId = null,
                this._primaryQueueItem = null,
                this.Za = NaN,
                this.el = null,
                this.il = -1,
                this.nl = new z,
                this.rl = [],
                this.sl = null,
                this.ol = [null, null],
                this.al = null,
                this.ll = new z,
                this.ul = [!1, !1],
                this.cl = [!1, !1],
                this.hl = {},
                this.R = o.child(hg.loggerName)
            }
            reset() {
                this.el = null,
                this.il = -1,
                this.sl = null,
                this.ol = [null, null],
                this.hl = {},
                this.rl = [],
                this.activeInterstitialId = null,
                this._primaryResumptionTime = void 0,
                this.al = null,
                this.cl = [!1, !1],
                this.ul = [!1, !1]
            }
            set mediaQuery(e) {
                this.Er = e
            }
            get activeInterstitial() {
                return this.activeInterstitialId ? this.Xa.interstitialQuery.getInterstitialForId(this.activeInterstitialId) : null
            }
            cancelInterstitial(e, t, i) {
                this.ll.next({
                    seekTo: e,
                    initialRate: t,
                    seekImmediately: i
                })
            }
            postRollCheck$(t, e) {
                const {config: i, mediaLibraryService: r, rootPlaylistQuery: n} = e;
                return i.enableInterstitialPlayback ? ma([r.query.selectEntity(n.itemId).pipe(W(e => null == e ? void 0 : e.liveOrEvent)), this.Xa.interstitialQuery.playableInterstitials$, t.isBufferedToEnd$(i.maxBufferHole, !1)]).pipe(W( ([e,t,i]) => {
                    var r = this.Wa.playingItem;
                    return e || !i || this.activeInterstitial || null != r && r.isInterstitial ? [] : (this._primaryQueueItem && this._primaryQueueItem.itemId === (null == r ? void 0 : r.itemId) || (this._primaryQueueItem = r),
                    t.filter(e => e.cueType === vo.Postroll))
                }
                ), te(e => this.dl(e, void 0, i)), W(e => (0 < e.length && null != this.sl && (this.sl = null),
                0 !== e.length && (this.el = e,
                this.fl(t, 1 / 0)))), te( () => X)) : X
            }
            fragmentIsInterstitialBoundary(a, e) {
                var t;
                const {config: m, mediaLibraryService: i} = e
                  , r = Y(!1);
                if (a.iframe || a.mediaOptionType === se.Subtitle)
                    return r;
                const f = a.mediaOptionType
                  , n = this.Xa.interstitialQuery
                  , s = m.enableInterstitialPlayback ? n.playableInterstitials : [];
                if (0 === s.length)
                    return r;
                var e = this.Wa.getQueueItemForId(a.itemId);
                if (!e)
                    return r;
                const g = a.start
                  , y = g + a.duration
                  , v = i.getQueryForOption(a).mediaOptionDetails
                  , S = null != (t = null == v ? void 0 : v.fragments) ? t : []
                  , I = null != (t = null == v ? void 0 : v.pdtToMSN) ? t : [];
                if (e.isInterstitial) {
                    if (this.activeInterstitial) {
                        const a = n.getInterstitialForId(this.activeInterstitial.identifier);
                        if (null != a && a.playoutLimit) {
                            const e = P(a.playoutLimit)
                              , t = this.getInterstitialStartTime(a, I, S);
                            g >= t + e && this.ll.next({})
                        }
                    }
                    return r
                }
                this._primaryPlaylistType = null == v ? void 0 : v.type,
                this._primaryQueueItem && this._primaryQueueItem.itemId === e.itemId || (this._primaryQueueItem = e);
                let b = NaN
                  , o = this.sl;
                if (null == o) {
                    let p = NaN;
                    o = s.filter(t => {
                        var e, i;
                        const r = t.cueType === vo.Preroll
                          , n = t.cueType === vo.Midroll
                          , a = null != (e = t.snapOptions) ? e : So.None
                          , s = "VOD" === this._primaryPlaylistType && this._primaryQueueItem ? this._primaryQueueItem.itemStartOffsets : [0, 0]
                          , o = this.getInterstitialStartTime(t, I, S)
                          , l = !re(p) || o === p
                          , d = s[f] + o
                          , u = Math.abs(g - d) <= P(hg.kFragStartTolerance)
                          , c = (u || g <= d) && y > d && n;
                        let h = !1;
                        if (m.enablePartialInterstitialPlaybackForLiveEdge && null != v && v.liveOrEvent && re(t.duration)) {
                            h = d <= g && d + t.duration > g;
                            const p = (null == (i = v.fragments[v.fragments.length - 1]) ? void 0 : i.start) || 0
                              , e = zp(v, m.liveAllowLowLatencyPlayback) - um(v, m)
                              , r = p - d;
                            b = Math.max(0, r - e)
                        }
                        return !(!(r || c || h) || !l || this.activeInterstitial || !(r || u || h) && (this.sl || (p = o,
                        this.sl = []),
                        (0 === this.sl.length || this.sl.findIndex(e => e.identifier === t.identifier) < 0) && this.sl.push(t),
                        this.ol[f] || (this.ol[f] = y - d),
                        a !== So.Out && a !== So.InOut || (d - g < y - d ? (this.sl = null,
                        f === se.Variant && (this.hl[t.identifier] = D(g, 1e3),
                        this.ol[f] = 0),
                        0) : (f === se.Variant && (this.hl[t.identifier] = D(y, 1e3)),
                        1))))
                    }
                    )
                }
                if (null == o || 0 === o.length)
                    return r;
                const l = o[0]
                  , d = l.cueType === vo.Preroll
                  , u = ("VOD" === this._primaryPlaylistType ? this._primaryQueueItem.itemStartOffsets[f] : 0) + this.getInterstitialStartTime(l, I, S)
                  , c = l.snapOptions === So.Out || l.snapOptions === So.InOut
                  , h = g <= u && y > u
                  , p = (d || re(this.ol[f]) || !h || (this.ol[f] = y - u),
                null != (e = null == (t = this.Er) ? void 0 : t.expectedSbCount) ? e : 0);
                return (g >= u || h && c) && (this.cl[f] = !0),
                (this.el && 0 !== this.el.length ? Y(this.el) : this.dl(o, b, m)).pipe(xn(this.Ya), W( ([e,[,t]]) => {
                    if (0 === e.length || !e.some(e => 0 < e.assets.length))
                        return this.reset(),
                        !1;
                    if (this.el = e,
                    !d && !this.cl.every( (e, t) => t >= p || e))
                        return this.cl[f];
                    this.sl = null;
                    var e = e[0].interstitial
                      , i = e.snapOptions
                      , i = i === So.In || i === So.InOut;
                    let r = 0;
                    var n = this.getInterstitialStartTime(e, I, S);
                    if (e.cueType !== vo.Preroll && (r = i ? a.start : n),
                    null != v && v.liveOrEvent) {
                        const e = zp(v, m.liveAllowLowLatencyPlayback);
                        this.Za = e - a.start - r
                    }
                    return this.vl(this.hl),
                    this.hl = {},
                    this.fl(t, r)
                }
                ))
            }
            get playback$() {
                return ne(this.pl(), this.ml(), this.yl())
            }
            fragmentAppended(e) {
                this.nl.next(e)
            }
            getAdjustedSeek(r, n, e, t=!1, a, s, i) {
                var o = this.Xa.interstitialQuery
                  , l = this.Gt.enableInterstitialPlayback ? o.playableInterstitialsForSeek : [];
                let d, u;
                if (n < r && 0 === l.length || r === n)
                    return {
                        adjustedSeek: r
                    };
                var o = o.getInterstitialForId(null != (o = o.playingInterstitialId) ? o : "");
                if (o) {
                    const n = null == i ? void 0 : i.find(e => e.start <= r && e.end >= r);
                    return r = n ? r : Math.min(r, null != (i = o.duration) ? i : 1 / 0),
                    {
                        adjustedSeek: this.gl(r, e)
                    }
                }
                if (n < r) {
                    const e = l.find(e => {
                        var t = e.cueType === vo.Midroll
                          , i = this.getInterstitialStartTime(e, a, s)
                          , e = e.referenceRestrictions === Io.Jump || e.referenceRestrictions === Io.SkipJump;
                        return t && e && n < i && i <= r
                    }
                    );
                    if (e) {
                        const n = this.getInterstitialStartTime(e, a, s)
                          , i = Xc(t ? this.Wa.activeItem : this.Wa.getQueueItemForTime(n));
                        return this.al = r,
                        {
                            adjustedSeek: Math.max(i, i + n - this.Gt.adjustedSeekToleranceMs / 1e3)
                        }
                    }
                    {
                        const n = this.Wa.getQueueItemForTime(r);
                        return {
                            adjustedSeek: r + Xc(n)
                        }
                    }
                }
                {
                    const n = this.Wa.getQueueItemForTime(r)
                      , {itemId: e, itemStartOffsets: t} = null != n ? n : {}
                      , a = null != (o = null == t ? void 0 : t[se.Variant]) ? o : 0;
                    return e && e !== (null == (i = this.Wa.activeItem) ? void 0 : i.itemId) && (d = e,
                    u = a,
                    ae( () => {
                        this.Xa.setActiveInterstitialAssetId(null),
                        this.Xa.setActiveInterstitialId(null)
                    }
                    ),
                    this.activeInterstitialId = null,
                    this.rl = []),
                    this.Xa.removeInterstitialsFromPastEventsFromTime(r),
                    {
                        adjustedSeek: r + a,
                        newItemId: d,
                        startOffset: u
                    }
                }
            }
            dl(t, i, e) {
                return function(u, c, h, p) {
                    const {interstitials: e, startOffset: m} = {
                        interstitials: t,
                        startOffset: i
                    };
                    return Lr(e).pipe($r(d => Lr(d.urls).pipe(_r(e => {
                        var t, i, r, n, a, s, o, l;
                        return -1 === e.indexOf(".m3u") ? (t = new URL(e),
                        re(m) && t.searchParams.append("_HLS_start_offset", m.toString()),
                        t = t.toString(),
                        i = d.identifier,
                        r = t,
                        n = i,
                        a = u,
                        s = c,
                        o = h,
                        l = p,
                        na( () => {
                            var e = eo({
                                url: r
                            }, o)
                              , t = {
                                url: r,
                                xhrSetup: s.xhrSetup,
                                forInterstitialAssetList: !0,
                                interstitialIdentifier: n
                            };
                            let i;
                            if (a.allowInterstitialAssetListDownload)
                                i = Mo(t, e, 0, l);
                            else {
                                const r = Object.assign(Object.assign({}, t), {
                                    method: "GET",
                                    responseType: "text",
                                    extendMaxTTFB: 0
                                });
                                i = l.load(r, e).pipe(Po())
                            }
                            return i.pipe(W( ({responseText: r}) => {
                                {
                                    var n = r;
                                    let t, e, i;
                                    try {
                                        try {
                                            t = JSON.parse(n)
                                        } catch (n) {
                                            throw wo("interstitial asset list JSON format is malformed")
                                        }
                                        if (null == t)
                                            throw wo("interstitial asset list is empty");
                                        if (!Array.isArray(t.ASSETS))
                                            throw wo("invalid interstitial asset list ASSETS data type");
                                        const e = function(e) {
                                            for (const i of e.assets) {
                                                const e = "string" != typeof (t = i).uri ? wo("invalid interstitial asset URI data type") : hs(t.uri) ? "number" != typeof t.duration ? wo("invalid interstitial asset DURATION data type") : void 0 : wo("interstitial asset uri is not absolute " + t.uri);
                                                if (null != e)
                                                    return e
                                            }
                                            var t
                                        }(i = {
                                            assets: t.ASSETS.map(e => ({
                                                uri: e.URI,
                                                duration: e.DURATION
                                            }))
                                        });
                                        if (null != e)
                                            throw e;
                                        return i
                                    } catch (n) {
                                        throw e = n instanceof pe ? n : wo(`unknown exception when parsing interstitial asset list: ` + n)
                                    }
                                }
                            }
                            ))
                        }
                        ).pipe($( () => Y({
                            assets: []
                        })))) : Y({
                            assets: [{
                                uri: e,
                                duration: d.duration
                            }]
                        })
                    }
                    ), Qr( (e, t) => [...e, ...t.assets], []), W(e => ({
                        id: d.identifier,
                        assets: e
                    })))), Qr( (e, t) => (e[t.id] = t.assets,
                    e), {}))
                }(e, e, e.playlistLoadPolicy, this.Re, this.R).pipe(W(r => t.reduce( (e, t) => {
                    var i = r[t.identifier];
                    return i && e.push({
                        interstitial: t,
                        assets: i
                    }),
                    e
                }
                , [])))
            }
            fl(r, n) {
                return !(!this.el || this.il > this.el.length || !this.el.find( () => {
                    var e, t = null == (e = this.el) ? void 0 : e[++this.il];
                    if (t) {
                        const {interstitial: e, assets: i} = t;
                        if (this.bl(e, i, n, r))
                            return !0
                    }
                    return !1
                }
                ))
            }
            gl(e, n) {
                const t = this.Xa.interstitialQuery
                  , i = null != (r = t.playingInterstitialId) ? r : ""
                  , a = t.getInterstitialForId(i);
                if (!a)
                    return e;
                var r = a.assets.map(e => this.Wa.getQueueItemForId(e)).filter(e => null != e);
                if (0 === r.length)
                    return e;
                const s = Xc(r[0]) + e
                  , o = r.reduce( (e, t) => {
                    var i = Xc(t);
                    return i > Xc(e) && i < s ? t : e
                }
                , r[0]);
                return o && (null == (e = this.Wa.playingItem) ? void 0 : e.itemId) !== o.itemId && ae( () => {
                    var e, t, i, r;
                    this.Xa.setActiveInterstitialAssetId(o.itemId),
                    this.Xa.setActiveInterstitialId(a.identifier),
                    this.Xa.removeInterstitialsFromPastEvents([a.identifier]),
                    e = n,
                    t = o.itemId,
                    i = s,
                    r = null != (r = null == (r = e.sourceBufferEntities) ? void 0 : r.filter(e => Boolean(e)).length) ? r : 0,
                    pg(oe.Variant, e, t, i) && (2 !== r || pg(oe.AltAudio, e, t, i)) || this.Wa.setActive(o.itemId, o.itemStartOffsets),
                    this.Wa.playing$.next(o)
                }
                ),
                s
            }
            pl() {
                const r = this.Xa.interstitialQuery;
                return r.activeInterstitialId$.pipe(Pr(sr), Kl(), xn(this.Ya), W( ([e,[,t]]) => {
                    var i, e = r.getInterstitialForId(e);
                    return [null != (i = null == (i = null == e ? void 0 : e.assets) ? void 0 : i.map(e => this.Wa.getQueueItemForId(e)).filter(e => !!e)) ? i : [], t, null != (i = null == e ? void 0 : e.cueType) ? i : vo.Midroll]
                }
                ), te( ([a,s,o]) => {
                    var e;
                    return a.length < 1 ? X : (e = null != (e = Lo(a, null != (e = r.activeInterstitialAssetId) ? e : "").element) ? e : a[0],
                    this.Sl(e, !0, s, o),
                    this.rl = a,
                    e = this.nl.pipe(Kl(), te(i => {
                        const {itemId: e, type: t, isLastFragment: r} = i;
                        if (t !== se.Subtitle && r) {
                            const i = null != (n = null == (n = this.Er) ? void 0 : n.expectedSbCount) ? n : 0
                              , r = this.Wa.getQueueItemForId(e);
                            this.ul[t] = !0;
                            var n = this.ul.every( (e, t) => t >= i || e);
                            if (r && r.isInterstitial && n) {
                                this.cl = [!1, !1],
                                this.ul = [!1, !1];
                                const i = Lo(a, r.itemId).index
                                  , n = a[i + 1];
                                return this.Sl(n, !1, s, o),
                                Y(!0)
                            }
                        }
                        return X
                    }
                    ), Pn(this.ll)),
                    ne(this.ll.pipe(ie(e => {
                        this.al = null,
                        this.Sl(null, !1, s, o, e.seekTo, e.initialRate, e.seekImmediately)
                    }
                    )), e).pipe(te( () => X)))
                }
                ))
            }
            ml() {
                return this.Ya.pipe(Z(e => !!e && !!e[1]), te( ([,e]) => ma([e.timeupdate$, e.bufferedSegmentsByType$(oe.Variant)]).pipe(W( ([t,e]) => null == e ? void 0 : e.find(e => e.startPTS <= t && e.endPTS > t)), Z(e => !!e), Rn(null), dn())), W( ([e,t]) => this.wl(e, t)), J())
            }
            yl() {
                return this.Ya.pipe(Z(e => !!e && !!e[0] && !!e[1]), te( ([e,s]) => e.getInFlightFragByType$(se.Variant).pipe(Z(e => "appending" === (null == e ? void 0 : e.state)), W(e => e), te( ({itemId: e, compatible: t}) => {
                    var i = this.Wa.getQueueItemForId(e);
                    if (i) {
                        var e = s.sourceBufferEntityByType(oe.Variant)
                          , r = i.itemStartOffsets[se.Variant]
                          , n = i.isInterstitial
                          , e = null == e ? void 0 : e.bufferedSegments[(null == e ? void 0 : e.bufferedSegments.length) - 1];
                        if (!e && n) {
                            const e = null != (a = ko(i.itemId)) ? a : "";
                            this.Ja.triggerBufferedToInterstitialBoundary(e, nf.Enter, D(r, 1e3), !t)
                        } else {
                            var e = this.Wa.getQueueItemForId(null != (a = null == e ? void 0 : e.frag.itemId) ? a : "")
                              , a = null != (a = null == e ? void 0 : e.isInterstitial) && a;
                            if (r -= Xc(e),
                            n !== a) {
                                const e = n ? null != (a = ko(i.itemId)) ? a : "" : i.itemId
                                  , s = n ? nf.Enter : nf.Exit;
                                this.Ja.triggerBufferedToInterstitialBoundary(e, s, D(r, 1e3), !t)
                            }
                        }
                    }
                    return X
                }
                ))))
            }
            interstitialIsPlaying() {
                var e = this.Wa.playingItem;
                return e && e.isInterstitial
            }
            itemIdIsInterstitial(e) {
                var e = this.Wa.getQueueItemForId(e);
                return null != (e = null == e ? void 0 : e.isInterstitial) && e
            }
            handleError(r) {
                const e = !(r instanceof b) || r.fatal
                  , n = this.activeInterstitial;
                return e && n ? (this.R.error("Error during interstitial, switching to next available asset or primary content"),
                this.Ya.pipe(tn(1), W( ([,e]) => {
                    var t = null != (t = this.Xa.interstitialQuery.activeInterstitialAssetId) ? t : ""
                      , i = Lo(this.rl, t).index + 1;
                    return this.Wa.removeQueueItem(t),
                    this.Sl(this.rl[i], !1, e, n.cueType),
                    {
                        handled: !0,
                        error: r
                    }
                }
                ))) : Y({
                    handled: !1,
                    error: r
                })
            }
            snapIn(e, t) {
                const i = e["initialSeekTime"];
                if (!re(i))
                    return NaN;
                if (null != t && !t.iframesOnly && t.mediaOptionType !== se.Subtitle) {
                    var t = (null == t ? void 0 : t.fragments) || []
                      , r = Eo.search(t, e => {
                        var t = e.start
                          , e = t + e.duration
                          , t = i - t
                          , e = e - i;
                        return t < e && 0 <= t && 0 <= e ? 0 : t
                    }
                    );
                    if (r) {
                        const t = r.start;
                        return this.Wa.updateItemById(e.itemId, {
                            initialSeekTime: t
                        }),
                        t
                    }
                }
                return i
            }
            getInterstitialStartTime(e, t, i) {
                var r;
                return e.startTime ? P(e.startTime) : ([t,i] = p(r = e.startDate, t, i),
                r = (r - t) / 1e3 + i - Xc(this._primaryQueueItem),
                this.Xa.updateInterstitial(e.identifier, {
                    startTime: {
                        baseTime: r,
                        timescale: 1
                    }
                }),
                r)
            }
            wl(e, t) {
                var i, r;
                let n = !1;
                var a = this.Xa.interstitialQuery.playingInterstitialId;
                if (null == e && null != t) {
                    const e = t.frag
                      , r = this.Wa.getQueueItemForId(e.itemId);
                    if (r)
                        if (r.isInterstitial) {
                            const e = ko(r.itemId);
                            a !== e && (null !== a && (this.cs.interstitialPlayTime(null != (i = r.parentItemId) ? i : r.itemId),
                            this.Xa.interstitialQuery.getInterstitialForId(a)),
                            this.Xa.interstitialQuery.getInterstitialForId(null != e ? e : ""),
                            this.Xa.setPlayingInterstitialId(e),
                            this.Xa.setPlayingInterstitialAssetId(r.itemId),
                            n = !a)
                        } else
                            a && (this.Xa.setPlayingInterstitialAssetId(null),
                            this.Xa.setPlayingInterstitialId(null),
                            n = !0)
                } else if (null != e && null != t) {
                    const i = e.frag
                      , s = t.frag
                      , o = this.Wa.getQueueItemForId(i.itemId)
                      , l = this.Wa.getQueueItemForId(s.itemId);
                    if (o && l && o.itemId !== l.itemId) {
                        this.cs.interstitialPlayTime(null != (r = o.parentItemId) ? r : o.itemId);
                        const e = ko(o.itemId)
                          , t = ko(l.itemId);
                        !o.isInterstitial && l.isInterstitial ? a !== t && (this.Xa.interstitialQuery.getInterstitialForId(null != t ? t : ""),
                        this.Xa.setPlayingInterstitialId(t),
                        this.Xa.setPlayingInterstitialAssetId(l.itemId),
                        n = !0) : o.isInterstitial && l.isInterstitial ? (e && t && e !== t && (this.Xa.interstitialQuery.getInterstitialForId(e),
                        this.Xa.interstitialQuery.getInterstitialForId(t),
                        this.Xa.setPlayingInterstitialId(t)),
                        this.Xa.setPlayingInterstitialAssetId(s.itemId)) : o.isInterstitial && !l.isInterstitial && (this.Xa.interstitialQuery.getInterstitialForId(null != e ? e : ""),
                        this.Xa.setPlayingInterstitialAssetId(null),
                        this.Xa.setPlayingInterstitialId(null),
                        n = !0)
                    }
                }
                return n
            }
            Sl(r, n, e, a, t, i, s) {
                var o;
                let l = a === vo.Postroll ? [e.mediaElementDuration, e.mediaElementDuration] : this.Tl(e, a);
                var [d,u] = l;
                !re(u) && re(d) && (l = [d, d]);
                const c = this.Xa.interstitialQuery;
                let h = null != t ? t : 0;
                var u = null != (u = this.activeInterstitial) ? u : c.getInterstitialForId(null != (d = c.playingInterstitialId) ? d : "")
                  , d = null != (d = null == u ? void 0 : u.duration) ? d : 0;
                u && !t && (h = Co(u));
                let p = l[se.Variant] + h;
                if ("VOD" === this._primaryPlaylistType)
                    switch (a) {
                    case vo.Preroll:
                        0 !== h || t || (p = NaN);
                        break;
                    case vo.Midroll:
                        p += !re(t) && null != (o = this._primaryResumptionTime) ? o : 0;
                        break;
                    case vo.Postroll:
                        p = -.5
                    }
                else
                    p = t ? p : -(null != (m = this.Za) ? m : 0) - (h - d);
                var m = this.al ? this.al + h + l[se.Variant] : null;
                let f;
                if (u) {
                    const r = u.cueType === vo.Preroll ? 0 : P(u.startTime);
                    f = r + h
                } else
                    f = 1 / 0;
                if (r)
                    ae( () => {
                        var e = r.itemStartOffsets.find(re) ? r.itemStartOffsets : l
                          , t = ko(null != (t = c.activeInterstitialAssetId) ? t : "")
                          , i = ko(r.itemId)
                          , t = (i && t !== i && this.Xa.updateRealCurrentTimeOffsetMap(i, e),
                        n && this.Wa.updateItemById(null != (i = null == (t = this._primaryQueueItem) ? void 0 : t.itemId) ? i : "", {
                            itemTimelineEndPosition: f
                        }),
                        a === vo.Preroll ? 0 : void 0)
                          , i = !!re(t) || void 0;
                        this.Wa.setActive(r.itemId, e, t, i),
                        this.Xa.setActiveInterstitialAssetId(r.itemId)
                    }
                    );
                else if (!this.fl(e)) {
                    const r = this._primaryQueueItem
                      , n = cg.createItem(r.name, r.url, this.Gt, this.R, !1, Object.assign(Object.assign({}, ug(r, !0)), {
                        initialSeekTime: null != t ? t : this._primaryResumptionTime,
                        initialRate: i,
                        itemTimelineEndPosition: r.itemTimelineEndPosition,
                        seekImmediately: s
                    }))
                      , a = (n.itemStartOffsets = l,
                    n.initialSeekTime = re(m) ? m : p,
                    n.itemTimelineStartPosition = f,
                    null != (d = null == u ? void 0 : u.snapOptions) ? d : So.None);
                    n.snapIn = a === So.In || a === So.InOut,
                    ae( () => {
                        var e;
                        this.Wa.insertQueueItem(n),
                        this.Wa.setActive(n.itemId, n.itemStartOffsets, n.initialSeekTime, s),
                        null != (e = this.el) && e.forEach( ({interstitial: e}) => {
                            this.Xa.updateInterstitial(e.identifier, {
                                hasPlayed: !0
                            }),
                            this.Xa.addInterstitialToPastEvents(e.identifier)
                        }
                        ),
                        this.Xa.setActiveInterstitialAssetId(null),
                        this.Xa.setActiveInterstitialId(null)
                    }
                    ),
                    this.reset()
                }
            }
            Tl(e, t) {
                const i = e.currentTime
                  , r = e.getBufferInfo(i, this.Gt.maxBufferHole)
                  , n = t === vo.Preroll || 0 === i ? 0 : Number.POSITIVE_INFINITY
                  , a = [n, n];
                return _s.forEach(e => {
                    var t = null == (t = r[e]) ? void 0 : t.bufferedSegments;
                    t && 0 < t.length && (a[e] = null != (e = null == (t = r[e]) ? void 0 : t.buffered.end) ? e : n)
                }
                ),
                a
            }
            bl(s, t, e, o) {
                const l = this._primaryQueueItem;
                if (l && s && 0 < t.length) {
                    const d = []
                      , u = [];
                    let a = 0;
                    return ae( () => {
                        t.forEach( (e, t) => {
                            var i = `interstitial:${s.identifier}:asset_` + (t + 1)
                              , r = ug(l, !0)
                              , i = cg.createItem(i, e.uri, this.Gt, this.R, !0, r)
                              , r = s.cueType === vo.Preroll ? 0 : Number.POSITIVE_INFINITY;
                            let n = [r, r];
                            re(this.ol[0]) && 0 === this.il && 0 === t && (n = this.Tl(o, s.cueType).map( (e, t) => {
                                t = null != (t = this.ol[t]) ? t : 0;
                                return Math.max(0, e - t)
                            }
                            )),
                            i.itemStartOffsets = n,
                            this.Xa.addInterstitialAsset({
                                parentIdentifier: s.identifier,
                                identifier: i.itemId,
                                url: e.uri,
                                duration: e.duration
                            }),
                            this.Wa.insertQueueItem(i),
                            u.push(i.itemId),
                            d.push(e.uri),
                            a += e.duration || 0
                        }
                        );
                        var e = Math.max(a, s.duration || 0);
                        this.Xa.updateInterstitial(s.identifier, {
                            urls: d,
                            assets: u,
                            duration: e
                        }),
                        this.Xa.setActiveInterstitialId(s.identifier)
                    }
                    ),
                    !this._primaryResumptionTime && re(e) && (this._primaryResumptionTime = e),
                    this.activeInterstitialId = s.identifier,
                    s
                }
                return s && this.Xa.removeInterstitials([s.identifier]),
                null
            }
            Il(i) {
                var e;
                let r;
                null != (e = this.el) && e.find( ({interstitial: e}, t) => {
                    if (e.identifier === i.identifier)
                        return r = t,
                        !0
                }
                ),
                re(r) && (this.il = r)
            }
            Ol(i, e) {
                return e.filter(e => {
                    var t = i.startTime
                      , e = e.startTime;
                    return t && e && P(t) === P(e)
                }
                )
            }
            reloadPlayingItem(t, i, e, r) {
                var n, a;
                const s = this.Wa.playingItem;
                if (s) {
                    if (s.isInterstitial) {
                        const o = this.Xa.interstitialQuery
                          , l = o.playingInterstitialId
                          , d = o.getInterstitialForId(null != l ? l : "");
                        if (d) {
                            const l = s.itemId
                              , a = null != (n = d.duration) ? n : 0
                              , u = Xc(s) + a;
                            return r.removeLaterCues(u),
                            void e.flushAndCallback(Math.max(u - 1, 0), 1 / 0, () => {
                                ae( () => {
                                    var e = o.playableInterstitials;
                                    this.Ol(d, e),
                                    this.Il(d),
                                    this.Xa.setActiveInterstitialAssetId(l),
                                    this.Xa.setActiveInterstitialId(d.identifier),
                                    this.Xa.removeInterstitialsFromPastEvents([d.identifier]),
                                    this.Wa.setActiveWithContext(l, i, s.itemStartOffsets, t)
                                }
                                )
                            }
                            )
                        }
                    }
                    const o = this.Wa.activeItem
                      , l = (null != o && o.isInterstitial && (ae( () => {
                        var e;
                        this.Xa.removeInterstitialsFromPastEvents([null != (e = ko(o.itemId)) ? e : ""]),
                        this.Xa.setActiveInterstitialId(null),
                        this.Xa.setActiveInterstitialAssetId(null)
                    }
                    ),
                    this.il = -1,
                    this.reset()),
                    this.Wa.getItemTimelineEndPosition(s.itemId))
                      , d = (a = s,
                    Object.assign(Object.assign({}, a), {
                        url: f(a.url)
                    }));
                    re(l) ? e.flushAndCallback(Math.max(l - 1, 0), 1 / 0, () => {
                        this.Wa.setActiveWithContext(s.itemId, i, s.itemStartOffsets, t)
                    }
                    ) : (this.R.error(`flushTime unknown: failed to flush before loading primary item ` + JSON.stringify(d)),
                    this.Wa.setActiveWithContext(s.itemId, i, s.itemStartOffsets, t))
                }
            }
            vl(i) {
                ae( () => {
                    for (var [e,t] of Object.entries(i))
                        this.Xa.updateInterstitial(e, {
                            startTime: t
                        })
                }
                )
            }
        }
        function pg(e, t, i, r) {
            var e = t.getBufferedSegmentsByType(e).filter(e => e.frag.itemId === i).sort( (e, t) => e.startPTS - t.startPTS)
              , n = 0 < e.length ? e[e.length - 1] : null;
            if (n && n.frag.isLastFragment) {
                const e = t.getCombinedBufferInfo(r, .5);
                if (e)
                    return e.end > n.startPTS
            }
            return !1
        }
        hg.loggerName = {
            name: "Interstitials"
        },
        hg.kFragStartTolerance = {
            baseTime: 10,
            timescale: 100
        };
        class mg extends pn {
            constructor(e) {
                super(e),
                this.pipe = super.pipe,
                this.next = super.next
            }
            get first() {
                return null == this.value || this.value.length ? null : this.value[0]
            }
            takeUntil(e) {
                return Pn(this.pipe(Z(e)))
            }
        }
        var fg, gg, yg = {
            findFragmentBySNAndBuffer: function(e, t, i=0, r=0, n=0) {
                let a;
                e = e ? t[e.mediaSeqNum - t[0].mediaSeqNum + 1] : null;
                return a = i < r ? (r - n < i && (n = 0),
                e && !this.fragmentWithinToleranceTest(i, n, e) ? e : yo.search(t, this.fragmentWithinToleranceTest.bind(null, i, n))) : t[t.length - 1]
            },
            fragmentWithinToleranceTest: function(e, t, i) {
                t = Math.min(t, i.duration);
                return i.start + i.duration - t <= e ? 1 : i.start - t > e && i.start ? -1 : 0
            }
        };
        const vg = {
            name: "seek"
        };
        function Sg(e, t, i) {
            var i = i.getTime()
              , [e,t] = p(i, e, t)
              , t = t + (i - e) / 1e3;
            return re(t) ? Math.max(0, t) : 0
        }
        function Ig(e, t, i, r, n, a, s) {
            var o = Mp(i)
              , l = i[se.Variant]
              , d = l.totalduration
              , u = n.itemStartPosition
              , c = n.startTimeOffset
              , n = n.itemId
              , h = null == a ? void 0 : a.getActiveItemContext(n)
              , p = r["liveEdgeForZeroStartPositon"];
            if (t && h && (null != a && a.clearActiveItemContext(n),
            h.userSwitchAudioTrack || h.userSwitchSubtitleTrack))
                return null;
            if (o)
                return re(e) ? 0 <= e ? e = e > zp(l) ? Math.max(l.fragments[0].start, zp(l) - l.targetduration) : e : u + (d + e) : u + bg(l, c);
            {
                const n = !re(e) || e < 0;
                if (t && (n || 0 === e && p && "LIVE" === l.type)) {
                    if (e = 1 / 0,
                    re(l.startTimeOffset) || re(c)) {
                        const t = bg(l, c);
                        e = Math.max(0, null == (a = l.fragments[0]) ? void 0 : a.start) + t
                    }
                } else
                    n && (e = 1 / 0);
                return s ? e : pm(e, i, r)
            }
        }
        function bg(e, t=NaN) {
            let i = 0;
            if (re(e.startTimeOffset))
                i = e.startTimeOffset;
            else {
                if (!re(t))
                    return i;
                i = t
            }
            t = e.totalduration;
            let r = (i = Math.abs(i) > t ? 0 <= i ? t : -1 * t : i) < 0 ? t - Math.abs(i) : i;
            return r = e.liveOrEvent ? Math.min(r, t - 3 * e.targetduration) : r
        }
        function Tg(e, t, i) {
            var r = i.rootPlaylistQuery.itemId
              , n = e.getQueueItemForId(r)
              , a = (null == (a = e.playingItem) ? void 0 : a.itemId) === r
              , s = a || null != n && n.seekImmediately ? null == n ? void 0 : n.initialSeekTime : null
              , a = (i.logger.child(vg),
            (a || null != n && n.seekImmediately) && e.updateItemById(r, {
                initialSeekTime: void 0,
                seekImmediately: void 0
            }),
            t.query);
            return null != s && null == a.pendingSeek && t.setUserSeek(s),
            a.pendingSeek$.pipe(function(v) {
                const {config: S, mediaSink: I, rootPlaylistQuery: b, mediaLibraryService: T, itemQueue: E} = i;
                return i.logger.child(vg),
                e => e.pipe(te( (e, i) => {
                    var t, r, n, a, s, o, l, d, u, c, h, p, m, f, g, y;
                    return null == e ? X : (t = I.mediaQuery.seekTo$.pipe(On(1), Kl(), W( () => {}
                    )),
                    e = e,
                    r = 0 === i,
                    n = S,
                    a = b,
                    s = T,
                    o = I.mediaQuery,
                    l = E,
                    Sn([e instanceof Date ? (f = e,
                    g = r,
                    y = n,
                    Uf(a, s).pipe(W(e => {
                        var t = e[se.Variant]
                          , i = Mp(e);
                        let r = Sg(t.pdtToMSN, t.fragments, f)
                          , n = NaN;
                        return i || (r = pm(r, e, y)),
                        g && (n = i ? zp(t) : hm(e, y).end),
                        {
                            seekTo: r,
                            playlistEnd: n
                        }
                    }
                    ), tn(1))) : (d = e,
                    u = r,
                    c = n,
                    p = o,
                    m = l,
                    Uf(h = a, s).pipe(Z(e => null != e[se.Variant]), Z(e => {
                        return t = e[se.Variant],
                        !(c.liveAllowLowLatencyPlayback && t.liveOrEvent && t.parts && 0 < t.parts.length && (!re(d) || d < 0 || 0 === d && c.liveEdgeForZeroStartPositon) && sf(e[se.Variant]));
                        var t
                    }
                    ), tn(1), W(e => {
                        var t = null != p.liveSeekableRange
                          , i = Mp(e);
                        let r = NaN;
                        return {
                            seekTo: Ig(d, u, e, c, h, m, t),
                            playlistEnd: r = u ? i ? zp(e[se.Variant]) : hm(e, c).end : r
                        }
                    }
                    ))), t]).pipe(tn(1), W(e => {
                        var t;
                        if (e)
                            return {seekTo: e, playlistEnd: t} = e,
                            re(t) && 0 === i && (I.msDuration = t),
                            I.seekWithOptions(null != e ? e : NaN, void 0, !0),
                            null != e ? e : void 0
                    }
                    ), ee( () => {
                        v.setUserSeek(void 0)
                    }
                    )))
                }
                ))
            }(t))
        }
        function Eg(t, i) {
            return e => e.pipe(In({
                delay: e => {
                    if (t.error(`Got error in ${i} ${e.message} fatal:${null == e ? void 0 : e.fatal} handled:` + (null == e ? void 0 : e.handled)),
                    e instanceof b && !e.fatal)
                        return e.handled ? ue : X;
                    throw e
                }
            }))
        }
        function Ag(t, i, n) {
            return new G(function(e) {
                const r = {};
                var c;
                r.enabledMediaOptionSwitchInfo$ = new pn(void 0),
                n.pipe((c = (e, t, i) => e.execute(e, t, i, r),
                u => new G(t => {
                    {
                        var n = u
                          , a = t
                          , s = c;
                        const o = new mg([]);
                        let i = 0
                          , r = 0
                          , e = !1;
                        const l = () => {
                            !e || o.value.length || i || a.complete()
                        }
                          , d = e => {
                            i++;
                            let t = !1;
                            a.add(Lr(s(e, r++, o)).pipe(ie({
                                next(e) {
                                    a.next(e)
                                },
                                error(e) {
                                    a.error(e)
                                },
                                complete() {
                                    t = !0
                                }
                            }), ee( () => {
                                if (t)
                                    try {
                                        for (i--; o.value.length && i < 1; ) {
                                            var e = o.value[0];
                                            o.next(o.value.slice(1)),
                                            d(e)
                                        }
                                        l()
                                    } catch (e) {
                                        a.error(e)
                                    }
                            }
                            )).subscribe())
                        }
                        ;
                        a.add(n.pipe(ie({
                            next: e => i < 1 ? d(e) : o.next([...o.value, e]),
                            error(e) {
                                a.error(e)
                            },
                            complete() {
                                e = !0,
                                l()
                            }
                        })).subscribe())
                    }
                }
                )), te( () => X)).subscribe(e),
                e.add(i.enabledMediaOptionsSwitchInfo$(t).subscribe(r.enabledMediaOptionSwitchInfo$))
            }
            )
        }
        function Og(e, t, i) {
            let r = e.currentTime - t;
            e = null == (t = e.getCombinedBufferInfo(e.currentTime, i)) ? void 0 : t.start;
            return r = re(e) && e > r ? e : r
        }
        function Rg(i, r=!1) {
            return e => {
                return e.pipe((t = i,
                e => e.pipe(Ff(t), te(e => e ? e.mediaOptionDetailsEntity$.pipe(Kl()) : Y(null)))), Z(e => null == e || null != e.mediaOptionDetails), J( (e, t) => {
                    var e = null == e ? void 0 : e.mediaOptionDetails
                      , t = null == t ? void 0 : t.mediaOptionDetails
                      , i = (null == e ? void 0 : e.endSN) === (null == t ? void 0 : t.endSN) && (null == e ? void 0 : e.ptsKnown) === (null == t ? void 0 : t.ptsKnown) && (null == e ? void 0 : e.liveOrEvent) === (null == t ? void 0 : t.liveOrEvent)
                      , e = !r || (null == e ? void 0 : e.partEndSN) === (null == t ? void 0 : t.partEndSN) && (null == e ? void 0 : e.partEndIndex) === (null == t ? void 0 : t.partEndIndex);
                    return i && e
                }
                ));
                var t
            }
        }
        const wg = (e, t) => {
            let i, r = "";
            return i = e.videoCodec && e.audioCodec ? (r = e.videoCodec + `, ` + e.audioCodec,
            t = null != t ? t : "video/mp4",
            "audiovideo") : e.videoCodec ? (r = `` + e.videoCodec,
            t = null != t ? t : "video/mp4",
            "video") : (r = `` + (null != (e = e.audioCodec) ? e : ""),
            t = null != t ? t : "audio/mp4",
            "audio"),
            {
                mimeType: t + `;codecs=` + r,
                codec: r,
                container: t,
                type: i
            }
        }
        ;
        class Pg {
            constructor(e, t, i) {
                this.Gt = e,
                this.R = t,
                this.kl = i,
                this.te = [],
                this.Ml = [],
                this.El = []
            }
            parseInitSegment(l) {
                return new G(e => {
                    const t = l["frag"]
                      , {keyTagInfo: i, mediaOptionType: r} = t;
                    let n;
                    if (this.Ml[r] = t,
                    yt.probeInitSegment(l.initSegment)) {
                        const e = ht.remuxInitSegment(l.initSegment, this.R, i)
                          , t = yt.parseInitSegment(e, this.R)
                          , {mimeType: r, type: a, codec: s, container: o} = wg(t, null);
                        n = {
                            moovData: t,
                            mimeType: r,
                            track: {
                                type: a,
                                codec: s,
                                initSegment: e,
                                container: o
                            }
                        }
                    } else
                        n = {
                            moovData: null,
                            mimeType: null,
                            track: {
                                type: null,
                                codec: null,
                                initSegment: l.initSegment,
                                container: null
                            }
                        };
                    e.next(n),
                    e.complete()
                }
                )
            }
            parseSegment(T, e) {
                return this.Al(T, this.El, e, this.kl).pipe(te( ({demuxer: e, contiguous: t, trackSwitch: i, discontinuity: r, accurateTimeOffset: n}) => {
                    const {frag: S, defaultInitPTS: a} = T
                      , {keyTagInfo: s, start: o, duration: I, mediaOptionType: l} = S;
                    let b;
                    this.El[l] = S;
                    var d = dl(e.observer);
                    return Y(d.event(E.FRAG_PARSING_INIT_SEGMENT).pipe(te(e => {
                        var t;
                        return e.track.initSegment.byteLength !== (null == (t = T.initSegment) ? void 0 : t.byteLength) && (b = this.Nl(e)),
                        X
                    }
                    )), d.event(E.FRAG_PARSING_DATA).pipe(W(i => {
                        var {startPTS: e, startDTS: t, firstKeyframePts: r, framesWithoutIDR: n, largestVideoSampleSize: a, dropped: s, data1: o, data2: l, captionData: d, id3Samples: u, audioTrackInfo: c} = i;
                        let {endPTS: h, endDTS: p} = i;
                        if (re(h.baseTime) || (i.endPTS = h = Object.assign(Object.assign({}, e), {
                            baseTime: e.baseTime + D(I, e.timescale).baseTime
                        })),
                        re(p.baseTime) || (i.endDTS = p = Object.assign(Object.assign({}, t), {
                            baseTime: t.baseTime + D(I, t.timescale).baseTime
                        })),
                        !re(T.iframeMediaStart)) {
                            var m = S
                              , f = T.iframeMediaStart
                              , g = this.Gt.audioPrimingDelay;
                            let e = NaN
                              , t = NaN;
                            re(f) && (t = f,
                            e = .01,
                            re(t)) && re(g) && (t += g);
                            var y, {startPTS: f, startDTS: g, endPTS: i, endDTS: v} = i;
                            if (!(void 0 !== f && void 0 !== g && 0 <= f.baseTime && 0 <= g.baseTime && 0 < m.duration && (null == i || 0 < x(i, f)) && (null == v || 0 < x(v, g))) || re(e) && re(t) && !(Math.abs(P(g) - t) <= e))
                                throw new A(!1,H.FailedDemuxerSanityCheck,`Failed demuxer sanity check frag=${function(e) {
                                    if (!e)
                                        return "";
                                    let t = ["mediaOptionId", "mediaSeqNum", "discoSeqNum", "start", "duration"];
                                    return null != e && e.part && (t = [...t, "part", "partIndex"]),
                                    JSON.stringify(e, t)
                                }(m)} parsed=${JSON.stringify({
                                    startPTS: f,
                                    endPTS: i,
                                    startDTS: g,
                                    endDTS: v
                                })} ` + (m = {
                                    expectedStartDTS: t,
                                    fudge: e
                                },
                                y = 3,
                                JSON.stringify(m, (e, t) => !isNaN(t) && null != t && t.toFixed ? Number(null == t ? void 0 : t.toFixed(y)) : t)))
                        }
                        return S.mediaOptionType === se.Variant && (this.ut = c),
                        {
                            startPTS: e,
                            endPTS: h,
                            startDTS: t,
                            endDTS: p,
                            firstKeyframePts: r,
                            framesWithoutIDR: n,
                            largestVideoSampleSize: a,
                            dropped: s,
                            data1: o,
                            data2: l,
                            captionData: d,
                            id3Samples: u,
                            parsedInitSegment: b
                        }
                    }
                    )), d.event(L.INTERNAL_ERROR).pipe(te(this.Rl)), e.push(T.segment, s, T.initSegment, o, r, i, t, T.totalDuration, n, a, T.iframeMediaStart, T.iframeDuration, this.ut).pipe(te( () => X))).pipe(Gr(), tn(1))
                }
                ))
            }
            reset(e=void 0) {
                var t;
                null == e ? (this.te.forEach(e => {
                    e && e.destroy()
                }
                ),
                this.te = []) : (null != (t = this.te[e]) && t.destroy(),
                delete this.te[e])
            }
            willBeTrackSwitch(e, t) {
                var {mediaOptionType: e, mediaOptionId: i} = e
                  , t = (t || this.El)[e];
                return !(t && t.mediaOptionId === i)
            }
            Al(e, r, t, i) {
                const {frag: n, ptsKnown: a, seeking: s, live: o} = e
                  , {discoSeqNum: l, mediaSeqNum: d, mediaOptionType: u} = n;
                return na( () => {
                    const e = this.te[u];
                    if (e)
                        return Y(e);
                    if (!Pg.typeSupported) {
                        const e = Qu();
                        Pg.typeSupported = {
                            mp4: e.isTypeSupported("video/mp4"),
                            mpeg: e.isTypeSupported("audio/mpeg"),
                            mp3: e.isTypeSupported('audio/mp4; codecs="mp3"'),
                            ac3: e.isTypeSupported('audio/mp4; codecs="ac-3"'),
                            ec3: e.isTypeSupported('audio/mp4; codecs="ec-3"')
                        }
                    }
                    return i.init(Pg.typeSupported, this.Gt, t).pipe(ie(e => this.te[u] = e))
                }
                ).pipe(W(e => {
                    var t = r[u]
                      , i = this.willBeTrackSwitch(n, r);
                    return {
                        demuxer: e,
                        trackSwitch: i,
                        discontinuity: !(t && l === t.discoSeqNum),
                        contiguous: !!t && !i && t.mediaSeqNum + 1 === d,
                        accurateTimeOffset: !s && (a || !o)
                    }
                }
                ))
            }
            Nl(e) {
                var e = e["track"]
                  , t = e["initSegment"]
                  , i = yt.parseInitSegment(t, this.R)
                  , {mimeType: r, type: n, codec: a, container: s} = wg(i, e.container);
                return {
                    moovData: i,
                    mimeType: r,
                    track: Object.assign(Object.assign({}, e), {
                        type: n,
                        codec: a,
                        initSegment: t,
                        container: s
                    })
                }
            }
            Rl(e) {
                return R(e)
            }
        }
        function Mg(e, t, i, r, n) {
            const a = t.responseURL
              , s = (a || (t.responseURL = e),
            r)["keySystemPreference"]
              , {responseText: o, responseURL: l, stats: d} = t
              , {itemId: u, appItemId: c, itemStartOffsets: h, isInterstitial: p, parentItemId: m} = i
              , f = Ls(i)
              , g = Object.assign(Object.assign({}, d), {
                tparsed: {
                    tbegin: NaN,
                    tend: NaN
                },
                tfiltered: NaN
            });
            if (af.isMediaPlaylist(o)) {
                const t = "media-pl-" + Ga()
                  , i = performance.now()
                  , d = af.parseMediaOptionPlaylist(o, a, s || void 0, {}, u, t, se.Variant, n, h[se.Variant])
                  , p = performance.now();
                r = Lh(d.mediaOptionDetails, u, r),
                e = (ao(d.mediaOptionDetails),
                {
                    itemId: u,
                    mediaOptionId: t,
                    mediaOptionType: se.Variant,
                    url: e,
                    relativeUrl: e,
                    bandwidth: 0,
                    bitrate: 0,
                    iframes: d.mediaOptionDetails.iframesOnly,
                    pathwayID: "."
                });
                return g.tparsed = {
                    tbegin: i,
                    tend: p
                },
                {
                    parentItemId: m,
                    itemId: u,
                    statsId: f,
                    appItemId: c,
                    itemStartOffsets: h,
                    rootMediaOptionsTuple: [[e], [], []],
                    stats: g,
                    interstitials: r,
                    baseUrl: l,
                    initialDetails: d.mediaOptionDetails,
                    isMediaPlaylist: !0,
                    variantIdToAlternateGroupIdTuple: new Map
                }
            }
            {
                const e = performance.now()
                  , t = af.parseSessionData(o, l, n)
                  , i = af.parseSessionKeys(o, l, null != s ? s : void 0)
                  , r = af.parseRootPlaylistWithAlternates(u, o, l, p)
                  , a = performance.now()
                  , {variantMediaOptions: d, contentSteeringOption: y, masterVariableList: v, startTimeOffset: S, variantIdToAlternateGroupIdTuple: I} = r
                  , {audioAlternateOptions: b, subtitleAlternateOptions: T, audioMediaSelectionGroup: E, subtitleMediaSelectionGroup: A} = r.alternateMediaInfo;
                return g.tparsed = {
                    tbegin: e,
                    tend: a
                },
                {
                    parentItemId: m,
                    itemId: u,
                    statsId: f,
                    appItemId: c,
                    itemStartOffsets: h,
                    interstitials: [],
                    rootMediaOptionsTuple: [d.reverse(), null != b ? b : [], null != T ? T : []],
                    stats: g,
                    baseUrl: l,
                    audioMediaSelectionGroup: E,
                    subtitleMediaSelectionGroup: A,
                    contentSteeringOption: null != y ? y : void 0,
                    sessionData: t,
                    sessionKeys: i,
                    masterVariableList: v,
                    startTimeOffset: S,
                    variantIdToAlternateGroupIdTuple: I
                }
            }
        }
        function Cg(e, t, i, r) {
            if (200 === t && r && 10 < r.length) {
                if (af.isValidPlaylist(r))
                    return !0;
                {
                    const t = new pe(he.NETWORK_ERROR,Q.MANIFEST_PARSING_ERROR,!0,H.PlaylistErrorMissingEXTM3U);
                    throw t.url = e,
                    t
                }
            }
            return !1
        }
        function kg(e) {
            return !e.iframes || !e.width || !e.height || e.width * e.height <= 2488320
        }
        function Lg(n, d, a, s, o) {
            if (0 === n.length)
                return Y({
                    hdrMediaOptions: [],
                    sdrMediaOptions: [],
                    imageIframeVariants: []
                });
            const i = (null == a ? void 0 : a.maxHdcpLevel) || void 0
              , u = null == a ? void 0 : a.maxSecurityLevel
              , c = null == s ? void 0 : s.keySystemPreference
              , e = e => !0;
            let t = e
              , r = ((0 < s.disableVideoCodecList.size || 0 < s.disableAudioCodecList.size) && (t = t => {
                {
                    var i = s.disableVideoCodecList
                      , r = s.disableAudioCodecList;
                    let e = !0;
                    return e = (e = t.videoCodec ? t.videoCodecList.every(e => {
                        e = gc(e);
                        return !i.has(e)
                    }
                    ) : e) && !t.iframes && t.audioCodec ? t.audioCodecList.every(e => {
                        e = vc(e);
                        return !r.has(e)
                    }
                    ) : e
                }
            }
            ),
            e)
              , l = (i && Cu(i) && (r = e => {
                var t = i;
                return t = ku(t),
                !(e = e.hdcpLevel) || ku(e) <= t
            }
            ),
            e);
            u && c && qu(u, c) && (l = t => {
                {
                    var i = u
                      , r = c;
                    function n(e) {
                        return qu(e, r) ? a[e] : -1
                    }
                    const a = Bl.getKeySystemSecurityLevel(r)
                      , s = Bl.getKeySystemFormat(r)
                      , o = n(i)
                      , l = t.allowedCPCMap;
                    if (!l)
                        return !0;
                    let e = !0;
                    for (const i of null != (t = l[s]) ? t : [])
                        if (e = n(i) <= o,
                        !e)
                            break;
                    return e
                }
            }
            );
            var h = Lr(n).pipe(Z(e => t(e) && r(e) && l(e)));
            let p;
            if (null != s && s.useMediaKeySystemAccessFilter && c && navigator && "function" == typeof navigator.requestMediaKeySystemAccess) {
                const n = new Map;
                p = h.pipe(_r(t => {
                    if (t.iframes && t.imageCodec)
                        return Y(t);
                    var e = tl(t.videoCodecList, t.audioCodecList)
                      , i = JSON.stringify(e);
                    let r = n.get(i);
                    return r || (r = Bl.requestKeySystemAccess(c, e, void 0, o, null).pipe(W( () => !0), $(e => Y(!1)), An({
                        bufferSize: 1,
                        refCount: !0
                    })),
                    n.set(i, r)),
                    r.pipe(W(e => e ? t : null))
                }
                ), Kl(), Hr())
            } else
                p = h.pipe(Hr());
            return p.pipe(te(e => {
                if (0 === e.length || Wu(e))
                    throw new pe(he.MEDIA_ERROR,Q.MANIFEST_INCOMPATIBLE_CODECS_ERROR,!0,H.UnsupportedKeySystemAccess);
                const i = e.filter(e => e.iframes && e.imageCodec)
                  , t = navigator && navigator.mediaCapabilities
                  , n = !(null == s || !s.useMediaCapabilities) && t && "function" == typeof t.decodingInfo;
                let r;
                if (n)
                    r = function(e) {
                        const r = Hu()
                          , n = function() {
                            const d = new Map
                              , u = navigator && navigator.mediaCapabilities;
                            return (i, e, t, r) => {
                                var n, a, s = {
                                    type: "media-source"
                                }, o = (t ? s.video = function(e) {
                                    var t = {
                                        contentType: `video/mp4;codecs=` + e,
                                        width: i.width,
                                        height: i.height,
                                        bitrate: i.bandwidth || i.avgBandwidth,
                                        framerate: i.iframes ? 8 : i.frameRate
                                    };
                                    if (i.videoRange)
                                        switch (i.videoRange) {
                                        case "PQ":
                                            q.isDolby(e) ? (t.hdrMetadataType = fg.DoVi,
                                            t.colorGamut = "rec2020") : (q.isHEVC(e) || q.isVP09(e) || q.isAV1(e)) && (t.hdrMetadataType = fg.HDR10,
                                            t.colorGamut = "rec2020"),
                                            t.transferFunction = "pq";
                                            break;
                                        case "HLG":
                                            t.colorGamut = "rec2020",
                                            t.transferFunction = "hlg"
                                        }
                                    return t
                                }(e) : s.audio = (n = i,
                                a = {
                                    contentType: `audio/mp4;codecs=` + (e = e)
                                },
                                n = Gm.getAlternateWithRichestChannelLayoutForGroupId(n.audioAlternates),
                                (o = null == n ? void 0 : n.channels) && (a.channels = q.getChannelCount(o).toString(),
                                a.spatialRendering = q.isDolbyAtmos(e, o)),
                                (e = null == n ? void 0 : n.sampleRate) && (a.samplerate = e),
                                a),
                                JSON.stringify(s));
                                let l;
                                return d.has(o) ? l = d.get(o) : (l = Lr(u && "function" == typeof u.decodingInfo ? u.decodingInfo(s) : [void 0]).pipe(W(e => !e || e.supported && (!t || e.powerEfficient))),
                                d.set(o, l)),
                                [...r, l]
                            }
                        }();
                        let a = {};
                        return Lr(e).pipe(_r(t => {
                            var e;
                            if (!r(t))
                                return a = {
                                    audioCodecList: t.audioCodecList,
                                    videoCodecList: t.videoCodecList
                                },
                                Y(null);
                            let i = [Y(!0)];
                            if (null != (e = t.videoCodecList) && e.forEach(e => {
                                i = n(t, e, !0, i)
                            }
                            ),
                            0 < (null == (e = t.audioCodecList) ? void 0 : e.length)) {
                                const e = Gm.getRichestAudioCodec(t.audioCodecList);
                                i = n(t, e, !1, i),
                                a.richestAudioCodec = e
                            }
                            return ne(...i).pipe(Qr( (e, t) => e && t, !0), $(e => Y(!1)), W(e => e ? t : null))
                        }
                        ), Kl())
                    }(e);
                else {
                    const d = Hu()
                      , a = e => d(e)
                      , s = function() {
                        const s = new Set
                          , o = new Set
                          , l = Qu()
                          , d = !l.isTypeSupported('audio/mp4; codecs="mp4a.40.2"; channels="-1"')
                          , u = d && !l.isTypeSupported('audio/mp4; codecs="mp4a.40.2"; channels="2"; features="INVALID"');
                        let r;
                        return e => {
                            let t = !1;
                            var i;
                            return e.audioCodecList && e.audioAlternates && (i = null == (i = Gm.getAlternateWithRichestChannelLayoutForGroupId(e.audioAlternates)) ? void 0 : i.channels,
                            0 < e.audioCodecList.length) && i && (e = Gm.getRichestAudioCodec(e.audioCodecList),
                            t = ( (e, t) => {
                                var i, r, n, a = q.isDolbyAtmos(e, t);
                                if (u || d && !a) {
                                    n = (i = e) + `/` + (r = t),
                                    s.has(n) || o.has(n) || (( (e, t) => {
                                        var i = t.split("/")
                                          , r = parseInt(i[0]);
                                        let n, a;
                                        if (1 < i.length) {
                                            const t = i[1].split(",")[0];
                                            n = `audio/mp4;codecs="${e}";channels="${r}";features="${t}"`,
                                            a = `audio/mp4;codecs="${e}";channels="8";features="${t}"`
                                        } else
                                            n = `audio/mp4;codecs="${e}";channels="${r}"`;
                                        let s = l.isTypeSupported(n);
                                        return s = !s && a ? l.isTypeSupported(a) : s
                                    }
                                    )(i, r) ? s : o).add(n);
                                    const d = e + `/` + t;
                                    return o.has(d)
                                }
                                return !!a
                            }
                            )(e, i)) && (r = {
                                richestCodec: e,
                                channels: i
                            }),
                            !t
                        }
                    }();
                    r = Lr(e).pipe(Z(e => a(e) && s(e)))
                }
                return r.pipe(Z(e => kg(e) && function(e, t) {
                    var i = 0 < (null == d ? void 0 : d.length)
                      , e = e ? (a = null != (a = t.videoCodec) ? a : "",
                    n = t.videoRange,
                    r = e.videoDynamicRangeFormats,
                    e = e.videoCodecs,
                    a = function(e, t, i, r) {
                        if (!r && !i)
                            return {};
                        i = i ? ju(i, t) : {},
                        t = r ? ju(r, e) : {};
                        let n, a;
                        a = e === qe.SDR ? (n = i,
                        t) : (n = t,
                        i);
                        var s = Object.assign({}, n)
                          , o = a
                          , l = {}
                          , r = Object.entries(s);
                        for (const [s,o] of r)
                            !re(o) && "object" != typeof o || (l[s] = o);
                        return Object.assign(Object.assign({}, o), l)
                    }(q.getDynamicRangeType(n, a), n = q.getCompressionType(a), e, r),
                    n !== Ge.VP09 && (a.highestPlayablePeakBitRateForClearContent = void 0),
                    a) : {
                        highestPlayableAverageBitRate: void 0,
                        highestPlayablePeakBitRate: void 0,
                        highestPlayableWidth: void 0,
                        highestPlayableHeight: void 0,
                        highestPlayableFrameRate: void 0
                    }
                      , {highestPlayablePeakBitRateForClearContent: r, highestPlayablePeakBitRate: n, highestPlayableAverageBitRate: a} = e
                      , s = t.frameRate
                      , o = $u(a, s)
                      , l = $u(n, s)
                      , s = $u(r, s)
                      , i = t.allowedCPCMap || i
                      , l = Gu(t.bandwidth, l);
                    return (i || !r ? l : l || Gu(t.bandwidth, s)) && Gu(t.avgBandwidth, o) && Gu(t.width, e.highestPlayableWidth) && Gu(t.height, e.highestPlayableHeight) && Gu(t.frameRate, e.highestPlayableFrameRate)
                }(a, e)), Hr(), te(e => {
                    if (0 === e.length || Wu(e))
                        throw new pe(he.MEDIA_ERROR,Q.MANIFEST_INCOMPATIBLE_CODECS_ERROR,!0,H.UnsupportedMediaCodec);
                    var t = Lr(i).pipe(Z(kg), Hr());
                    return aa([Y(e), t]).pipe(W( ([e,t]) => {
                        if (0 === e.length || Wu(e))
                            throw new pe(he.MEDIA_ERROR,Q.MANIFEST_INCOMPATIBLE_CODECS_ERROR,!0,H.FilterOutBasedOnCaps);
                        let i = (null == a ? void 0 : a.videoDynamicRangeFormats) || [];
                        var {hdrMediaOptions: e, sdrMediaOptions: r} = function(e, i) {
                            var t, {doViSupported: r, hdr10Supported: n, hlgSupported: a} = function() {
                                var e = {
                                    doViSupported: !1,
                                    hdr10Supported: !1,
                                    hlgSupported: !1
                                };
                                for (const t of i)
                                    switch (t.type) {
                                    case qe.DolbyVision:
                                        e.doViSupported = !0;
                                        break;
                                    case qe.HDR10:
                                        e.hdr10Supported = !0;
                                        break;
                                    case qe.HLG:
                                        e.hlgSupported = !0
                                    }
                                return e
                            }(), s = {
                                hdrMediaOptions: new Array,
                                sdrMediaOptions: new Array
                            };
                            for (const i of e)
                                switch (q.getDynamicRangeType(i.videoRange, null != (t = i.videoCodec) ? t : "")) {
                                case qe.HDR:
                                case qe.HDR10:
                                    n && s.hdrMediaOptions.push(i);
                                    break;
                                case qe.DolbyVision:
                                    r && s.hdrMediaOptions.push(i);
                                    break;
                                case qe.HLG:
                                    a && s.hdrMediaOptions.push(i);
                                    break;
                                default:
                                    "SDR" !== i.videoRange && null != i.videoRange || s.sdrMediaOptions.push(i)
                                }
                            return s
                        }(e, i = n && 0 === i.length ? [{
                            type: qe.SDR
                        }, {
                            type: qe.HDR
                        }, {
                            type: qe.HDR10
                        }, {
                            type: qe.DolbyVision
                        }, {
                            type: qe.HLG
                        }] : i);
                        if (0 === e.length && 0 === r.length || Wu(e) && Wu(r))
                            throw new pe(he.MEDIA_ERROR,Q.MANIFEST_INCOMPATIBLE_VIDEO_RANGE_ERROR,!0,H.UnsupportedVideoDynamicRange);
                        return {
                            hdrMediaOptions: e,
                            sdrMediaOptions: r,
                            imageIframeVariants: t
                        }
                    }
                    ))
                }
                ), $(e => {
                    throw e instanceof pe && (e.fatal = !0,
                    e.response = H.IncompatibleAsset),
                    e
                }
                ))
            }
            ))
        }
        (rd = fg = fg || {}).HDR10 = "smpteSt2086",
        rd.DoVi = "smpteSt2094-10",
        rd.HDR10Plus = "smpteSt2094-40";
        class Ng extends gm {
            constructor(e, t, i, r, n) {
                super(e, t, i),
                this.Pl = r,
                this.R = n
            }
            static makeFilters() {
                return fm()
            }
            _initFilters() {
                return Ng.kAllowFilters
            }
            get Cl() {
                return this.mediaOptionType
            }
            get mediaOptionListInfo() {
                var e;
                return null != (e = null == (e = this.getEntity(this.itemId)) ? void 0 : e.mediaOptionListTuple[this.Cl]) ? e : null
            }
            get mediaOptionListInfo$() {
                return this.selectEntity(this.itemId, e => e && e.mediaOptionListTuple ? e.mediaOptionListTuple[this.Cl] : null).pipe(Kl())
            }
            getMatchingAlternateWithPersistentId(e, i, t, r, n) {
                if (!t)
                    return null;
                var a = this.Cl
                  , s = Nu(a === se.AltAudio ? t.audioAlternates : t.subtitleAlternates, Ng.kAllowFilters, this.mediaOptionListInfo);
                if (a === se.Subtitle || n)
                    return null != (a = s.find( (e, t) => !(0 < (null == r ? void 0 : r.length) && r.includes(e.mediaOptionId) || re(i) && e.persistentID !== i))) ? a : null;
                const o = q.getStickyAtmosStatus(this.Pl.useStickyAtmosFilter, t.audioCodec, null == e ? void 0 : e.channels);
                let l = null;
                a = null != (n = s.find( (e, t) => !(0 < (null == r ? void 0 : r.length) && r.includes(e.mediaOptionId) || re(i) && e.persistentID !== i || (l = l || e,
                null != o && o !== q.isJOCChannels(e.channels))))) ? n : null;
                return !a && o ? l : a
            }
            getMatchingAlternate(e, t) {
                e = this.mediaOptionFromId(e);
                return this.getMatchingAlternateWithPersistentId(e, null == e ? void 0 : e.persistentID, t, [], !1)
            }
            packageAlternateMediaOption(e, t) {
                var i = null != (i = null == (i = this.getEntity(this.itemId)) ? void 0 : i.mediaOptionListTuple[se.Subtitle]) ? i : null
                  , e = Nu(null != (e = null == e ? void 0 : e.subtitleAlternates) ? e : [], Ng.kAllowFilters, i);
                return t.mediaType === O.CLOSEDCAPTION ? this.Dl(e, t) : t
            }
            Dl(e, t) {
                e = this.xl(t, e);
                return e ? Object.assign(Object.assign({}, t), {
                    url: e.url,
                    relativeUrl: e.relativeUrl,
                    backingMediaOptionId: e.mediaOptionId
                }) : t
            }
            xl(e, t) {
                let i;
                return i = e && e.mediaType === O.CLOSEDCAPTION ? Ng.pairForcedSubtitleMediaOptionWithClosedCaptionInList(e, t, this.R) : i
            }
            static pairForcedSubtitleMediaOptionWithClosedCaptionInList(t, e, i) {
                return e.find(function(e) {
                    return e.mediaType === O.SUBTITLE && e.lang === t.lang && e.forced && e.autoselect
                })
            }
        }
        Ng.kAllowFilters = Ng.makeFilters();
        class Dg extends Ic {
            constructor(e) {
                super(),
                this.pathwayPriority = e,
                this.name = "PathwayFilter",
                this.initFn = e => ({
                    pathwayRanking: Yu(this.pathwayPriority)
                }),
                this.firstPassFn = (e, t, i, r) => {
                    var n = r.pathwayRanking(e.pathwayID);
                    (null == r.selectedPathwayRanking || n > r.selectedPathwayRanking) && (r.selectedPathway = e.pathwayID,
                    r.selectedPathwayRanking = n)
                }
                ,
                this.filterFn = (e, t, i, r) => e.pathwayID === r.selectedPathway
            }
            get id() {
                return le.PathwayFilter
            }
            get desc() {
                return `pathwayPriority: ` + JSON.stringify(this.pathwayPriority)
            }
        }
        class xg extends ja {
            constructor(e, t, i, r) {
                super(e),
                this.Ll = e,
                this.itemId = t,
                this.logger = r,
                this.mediaOptionListQueries = [new vm(e,this.itemId), new Ng(e,this.itemId,se.AltAudio,i,this.logger), new Ng(e,this.itemId,se.Subtitle,i,this.logger)]
            }
            get rootPlaylistEntity() {
                return this.getEntity(this.itemId)
            }
            get parentItemId() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.parentItemId
            }
            get statsId() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.statsId
            }
            get appItemId() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.appItemId
            }
            get rootMediaOptionsTuple() {
                var e = null == (e = this.rootPlaylistEntity) ? void 0 : e.mediaOptionListTuple;
                return e ? [e[0].mediaOptions, e[1].mediaOptions, e[2].mediaOptions] : [[], [], []]
            }
            get itemStartOffsets() {
                var e;
                return null != (e = this.rootPlaylistEntity) && e.itemStartOffsets ? this.rootPlaylistEntity.itemStartOffsets.map(e => re(e) ? e : 0) : [0, 0]
            }
            get itemStartPosition() {
                return this.itemStartOffsets[0]
            }
            get startTimeOffset() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.startTimeOffset
            }
            get highestVideoCodec() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.highestVideoCodec
            }
            get baseUrl() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.baseUrl
            }
            get avAnchor() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.avAnchor
            }
            get audioMediaSelectionGroup() {
                var e;
                return null != (e = null == (e = this.rootPlaylistEntity) ? void 0 : e.audioMediaSelectionGroup) ? e : null
            }
            get subtitleMediaSelectionGroup() {
                var e;
                return null != (e = null == (e = this.rootPlaylistEntity) ? void 0 : e.subtitleMediaSelectionGroup) ? e : null
            }
            get audioMediaSelectionOptions() {
                var e;
                return null != (e = null == (e = null == (e = this.rootPlaylistEntity) ? void 0 : e.audioMediaSelectionGroup) ? void 0 : e.MediaSelectionGroupOptions) ? e : []
            }
            get subtitleMediaSelectionOptions() {
                var e;
                return null != (e = null == (e = null == (e = this.rootPlaylistEntity) ? void 0 : e.subtitleMediaSelectionGroup) ? void 0 : e.MediaSelectionGroupOptions) ? e : []
            }
            get contentSteeringOption() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.contentSteeringOption
            }
            get masterVariableList() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.masterVariableList
            }
            get loadStats() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.loadStats
            }
            get isMediaPlaylist() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.isMediaPlaylist
            }
            getInitPTS(e) {
                var t;
                return null == (t = this.rootPlaylistEntity) ? void 0 : t.initPtsRecord[e]
            }
            get abrStatus$() {
                return this.selectEntity(this.itemId, e => null == e ? void 0 : e.abrStatus)
            }
            get abrStatus() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.abrStatus
            }
            get nextMaxAutoOptionId() {
                var e;
                return null == (e = null == (e = this.rootPlaylistEntity) ? void 0 : e.abrStatus) ? void 0 : e.nextMaxAutoOptionId
            }
            get nextMinAutoOptionId() {
                var e;
                return null == (e = null == (e = this.rootPlaylistEntity) ? void 0 : e.abrStatus) ? void 0 : e.nextMinAutoOptionId
            }
            initPTS$(t) {
                return this.selectEntity(this.itemId, ({initPtsRecord: e}) => e[t])
            }
            get rootPlaylistEntity$() {
                return this.selectEntity(this.itemId).pipe(Z(e => Boolean(e)), W(e => e))
            }
            get rootPlaylistEntityAdded$() {
                return this.selectEntityAction(va.Add).pipe(W(e => e.map(e => this.getEntity(e))))
            }
            get rootMediaOptionsTuple$() {
                return this.selectEntity(this.itemId, e => [e.mediaOptionListTuple[0].mediaOptions, e.mediaOptionListTuple[1].mediaOptions, e.mediaOptionListTuple[2].mediaOptions])
            }
            get sessionData() {
                var e;
                return null == (e = this.rootPlaylistEntity) ? void 0 : e.sessionData
            }
            get sessionData$() {
                return this.selectEntity(this.itemId, ({sessionData: e}) => e).pipe(Kl())
            }
            get avAnchor$() {
                return this.selectEntity(this.itemId, "avAnchor")
            }
            get enabledMediaOptionKeys$() {
                return this.selectEntity(this.itemId, "enabledMediaOptionKeys").pipe(Z(e => Boolean(e)))
            }
            get enabledMediaOptionKeys() {
                var e;
                return null != (e = null == (e = this.getEntity(this.itemId)) ? void 0 : e.enabledMediaOptionKeys) ? e : [de, de, de]
            }
            get enabledMediaOptionSwitchContexts() {
                var e;
                return null != (e = null == (e = this.getEntity(this.itemId)) ? void 0 : e.mediaOptionSwitchContexts) ? e : [null, null, null]
            }
            get enabledMediaOptions$() {
                return Fr([this.enabledMediaOptionByType$(se.Variant), this.enabledMediaOptionByType$(se.AltAudio), this.enabledMediaOptionByType$(se.Subtitle)])
            }
            _l(t) {
                return this.selectEntity(this.itemId, e => null == e ? void 0 : e.enabledMediaOptionKeys[t]).pipe(Kl(), W(e => {
                    return Ds(e) && (e = this.enabledMediaOptionKeys[t]["mediaOptionId"],
                    null != (e = this.mediaOptionListQueries[t].mediaOptionFromId(e))) ? e : de
                }
                ))
            }
            enabledMediaOptionByType$(e) {
                return this._l(e).pipe(J( (e, t) => e.mediaOptionId === t.mediaOptionId && e.relativeUrl === t.relativeUrl))
            }
            enabledMediaOptionSwitchForType$(r) {
                return this._l(r).pipe(Rn(null), dn(), W( ([e,t]) => {
                    var i = null == (i = this.enabledMediaOptionSwitchContexts) ? void 0 : i[r];
                    return {
                        fromId: null == e ? void 0 : e.mediaOptionId,
                        toId: null == t ? void 0 : t.mediaOptionId,
                        switchContext: i
                    }
                }
                ), J( (e, t) => e.fromId === t.fromId && e.toId === t.toId))
            }
            enabledMediaOptionsSwitchInfo$(e) {
                const t = this.hasAlternateWithUrl(se.AltAudio)
                  , i = Fr(_s.map(e => e !== se.AltAudio || t ? this.enabledMediaOptionSwitchForType$(e).pipe() : Y({
                    fromId: void 0,
                    toId: Ns.mediaOptionId,
                    switchContext: void 0
                })));
                return t ? i.pipe(vr(0)) : i
            }
            enabledMediaOptionIdByType(e) {
                return this.getEntity(this.itemId).enabledMediaOptionKeys[e].mediaOptionId
            }
            get enabledMediaOptionsBeforeTrickplay() {
                return this.getEntity(this.itemId).enabledMediaOptionsBeforeTrickplay
            }
            variantMediaOptionById(e) {
                return this.mediaOptionListQueries[se.Variant].mediaOptionFromId(e)
            }
            alternateMediaOptionById(e, t) {
                return this.mediaOptionListQueries[e].mediaOptionFromId(t)
            }
            enabledAlternateMediaOptionByType(e) {
                var t = this.enabledMediaOptionIdByType(e);
                return this.alternateMediaOptionById(e, t)
            }
            get enabledVariantMediaOption() {
                var e = this.enabledMediaOptionIdByType(se.Variant);
                return this.variantMediaOptionById(e)
            }
            get enabledVariantMediaOption$() {
                return this.enabledMediaOptionKeys$.pipe(W(e => {
                    var e = e[se.Variant];
                    return Ds(e) && null != (e = this.mediaOptionListQueries[se.Variant].mediaOptionFromId(e.mediaOptionId)) ? e : de
                }
                ))
            }
            lastLoadedMediaOptionByType(e) {
                var t;
                return null == (t = this.getEntity(this.itemId).lastLoadedMediaOptionKeys) ? void 0 : t[e]
            }
            lastLoadedMediaOptionByType$(t) {
                return this.selectEntity(this.itemId).pipe(Kl(), W(e => e.lastLoadedMediaOptionKeys), Kl(), W(e => e[t]))
            }
            get filteredMediaOptions$() {
                return Fr([this.mediaOptionListQueries[0].getFilteredMediaOptionList$(), this.mediaOptionListQueries[1].getFilteredMediaOptionList$(), this.mediaOptionListQueries[2].getFilteredMediaOptionList$()])
            }
            getDisabledMediaOption(e) {
                return {
                    itemId: this.itemId,
                    mediaOptionType: e,
                    mediaOptionId: "Nah",
                    relativeUrl: void 0
                }
            }
            getEnabledMediaOptionMask() {
                return this.enabledMediaOptionKeys.map(e => Ds(e))
            }
            get isInterstitial() {
                var e;
                return null != (e = null == (e = this.getEntity(this.itemId)) ? void 0 : e.isInterstitial) && e
            }
            altMediaOptionHasValidUrl(e, t) {
                return xs(this.alternateMediaOptionById(e, t))
            }
            hasAlternateWithUrl(e) {
                return this.mediaOptionListQueries[e].hasOptionWithUrl
            }
            hasClosedCaption() {
                return !!this.rootMediaOptionsTuple[se.Subtitle].some(e => e.mediaType === O.CLOSEDCAPTION)
            }
            get hdrMode$() {
                return this.mediaOptionListQueries[se.Variant].hdrMode$
            }
            get pathwayPenaltyBox$() {
                return this.mediaOptionListQueries[se.Variant].pathwayPenaltyBoxChanged$
            }
            get viewportInfo$() {
                return this.mediaOptionListQueries[se.Variant].viewportInfo$
            }
            get variantRemoved$() {
                return this.mediaOptionListQueries[se.Variant].removedListChanged$
            }
            get variantCompatibleIds$() {
                return this.mediaOptionListQueries[se.Variant].compatibleIdsListChanged$
            }
            get variantPenaltyBox$() {
                return this.mediaOptionListQueries[se.Variant].penaltyBoxChanged$
            }
            get combinedVariantFilterChange$() {
                return this.mediaOptionListQueries[se.Variant].commonFilterParamChanges$
            }
            get combinedAltAudioFilterChange$() {
                return this.mediaOptionListQueries[se.AltAudio].commonFilterParamChanges$
            }
            get combinedSubtitleFilterChange$() {
                return this.mediaOptionListQueries[se.Subtitle].commonFilterParamChanges$
            }
            get maxHdcpLevel$() {
                return this.mediaOptionListQueries[se.Variant].maxHdcpLevel$
            }
            get currentPathwayID() {
                var e;
                return null == (e = this.enabledVariantMediaOption) ? void 0 : e.pathwayID
            }
            get currentPathwayID$() {
                return this.enabledVariantMediaOption$.pipe((i = "pathwayID",
                J(function(e, t) {
                    return e[i] === t[i]
                })), W(e => e.pathwayID));
                var i
            }
            getErrorInfoByType(e) {
                var t;
                return null == (t = null == (t = this.rootPlaylistEntity) ? void 0 : t.errorsByType) ? void 0 : t[e]
            }
            getInFlightFrags() {
                return [this.Ll.inFlightFragTuple[0].value, this.Ll.inFlightFragTuple[1].value]
            }
            getInFlightFragByType(e) {
                return e !== se.Subtitle && null != (e = this.getInFlightFrags()[e]) ? e : null
            }
            getInFlightFragByType$(e) {
                return e === se.Subtitle ? nl : this.Ll.inFlightFragTuple[e]
            }
            matchAlternates(e, t, i, r) {
                var n = this.enabledAlternateMediaOptionByType(se.AltAudio)
                  , a = (null == n ? void 0 : n.persistentID) !== t
                  , n = re(t) ? this.mediaOptionListQueries[se.AltAudio].getMatchingAlternateWithPersistentId(n, t, e, r, a) : void 0
                  , t = this.enabledAlternateMediaOptionByType(se.Subtitle)
                  , a = re(i) ? this.mediaOptionListQueries[se.Subtitle].getMatchingAlternateWithPersistentId(t, i, e, r, !1) : void 0;
                return [n || de, a || de]
            }
            getLegacyMatchingAlternateWithPersistentId(e, t, i) {
                var r = this.enabledAlternateMediaOptionByType(e)
                  , n = e === se.AltAudio && (null == r ? void 0 : r.persistentID) !== t;
                let a = this.mediaOptionListQueries[e].getMatchingAlternateWithPersistentId(r, t, i, [], n);
                return a = a || this.mediaOptionListQueries[e].getMatchingAlternateWithPersistentId(r, t, void 0, [], n)
            }
            isValidMediaOptionTuple(i, e=void 0) {
                const r = e || this.getEnabledMediaOptionMask();
                return [se.Variant, se.AltAudio, se.Subtitle].reduce( (e, t) => e && r[t] === Ds(i[t]), !0)
            }
            matchGroup(t, i, r, n) {
                {
                    var a = t
                      , s = i
                      , o = r
                      , l = n;
                    let e = !1;
                    switch (a.type) {
                    case "CLOSED-CAPTIONS":
                        e = !l || a.groupId === l;
                        break;
                    case "SUBTITLES":
                        e = !o || a.groupId === o;
                        break;
                    case "AUDIO":
                        e = !s || a.groupId === s
                    }
                    return e
                }
            }
            get preferHDR() {
                return this.mediaOptionListQueries[se.Variant].mediaOptionListInfo.preferHDR
            }
            get hasHdrLevels() {
                return this.mediaOptionListQueries[se.Variant].mediaOptionListInfo.hasHdrLevels
            }
        }
        class Fg extends Ua {
            constructor() {
                super({}, {
                    name: "root-playlist-store",
                    idKey: "itemId"
                }),
                this.inFlightFragTuple = [new pn(void 0), new pn(void 0)]
            }
            setInFlightFrag(e, t) {
                this.inFlightFragTuple[e].next(t)
            }
        }
        function Bg(e, t) {
            return null == e.url && null != e.relativeUrl ? (t = ps(e.relativeUrl, t),
            Object.assign(Object.assign({}, e), {
                url: t,
                relativeUrl: t
            })) : e
        }
        (sd = gg = gg || {})[sd.NoMatch = 0] = "NoMatch",
        sd[sd.BaseNameMatch = 1] = "BaseNameMatch",
        sd[sd.LanguageTagMatch = 2] = "LanguageTagMatch";
        class Ug {
            constructor(e, t, i, r, n, a, s) {
                this.ce = e,
                this.hlsService = t,
                this.logger = i,
                this.Gt = r,
                this.rtcService = n,
                this.Fl = a,
                this.jl = s,
                this.Ho = new Map,
                this.ri = new ja(e)
            }
            isContentSteeringEnabled() {
                return this.Gt.enableContentSteering
            }
            get query() {
                return this.ri
            }
            getQueryForId(e) {
                let t = this.Ho.get(e);
                return t || (t = new xg(this.ce,e,this.Gt,this.logger),
                this.Ho.set(e, t)),
                t
            }
            removeItems(e) {
                this.ce.remove(e);
                Array.isArray(e) ? e.forEach(e => {
                    this.Ho.get(e) && this.Ho.delete(e)
                }
                ) : this.Ho.get(e) && this.Ho.delete(e);
                for (const e of [])
                    e.dispose()
            }
            removeAll() {
                this.ce.remove(),
                this.Ho.forEach(e => {
                    e.mediaOptionListQueries.forEach(e => e.dispose())
                }
                ),
                this.Ho.clear()
            }
            setRootPlaylistEntity(e, t) {
                ae( () => {
                    this.query.hasEntity(e) ? this.ce.replace(e, t) : this.ce.add(t),
                    this.ce.setActive(e)
                }
                )
            }
            setActive(e) {
                this.ce.setActive(e)
            }
            setSessionData(e, t) {
                this.ce.update(e, {
                    sessionData: t
                })
            }
            setAVAnchor(e, t) {
                this.ce.update(e, {
                    avAnchor: t
                })
            }
            setEnabledMediaOptionSwitchContextByType(e, t, i, r) {
                var n = this.getQueryForId(e);
                n.enabledMediaOptionKeys[t].mediaOptionId === i && (i = null == (i = n.enabledMediaOptionSwitchContexts) ? void 0 : i[t],
                null != r || null != i) && ((i = null != (n = null == (i = n.rootPlaylistEntity) ? void 0 : i.mediaOptionSwitchContexts) ? n : [null, null, null])[t] = null != r ? r : null,
                this.ce.update(e, {
                    mediaOptionSwitchContexts: i
                }))
            }
            clearMediaOptionSwitchContextByType(e, t) {
                var i = null == (i = this.ri.getEntity(e)) ? void 0 : i.mediaOptionSwitchContexts;
                null != (null == i ? void 0 : i[t]) && ((i = i.slice())[t] = null,
                this.ce.update(e, {
                    mediaOptionSwitchContexts: i
                }))
            }
            saveEnabledOptionsForTrickplay(e, t) {
                t = t ? this.getQueryForId(e).enabledMediaOptionKeys : null;
                this.ce.update(e, {
                    enabledMediaOptionsBeforeTrickplay: t
                })
            }
            setEnabledMediaOptionByType(e, t, i, r=!1, n=void 0) {
                i = i || {
                    itemId: e,
                    mediaOptionId: "Nah"
                };
                var a = this.getQueryForId(e).rootPlaylistEntity;
                if (a) {
                    var [s,o,l] = null != (s = a.enabledMediaOptionKeys) ? s : [Ns, Ns, Ns]
                      , s = [s, o, l]
                      , o = (s[t] = {
                        itemId: e,
                        mediaOptionId: i.mediaOptionId
                    },
                    this.Ul(a, s));
                    if (r) {
                        const e = null != (i = null == (l = a.mediaOptionSwitchContexts) ? void 0 : l.slice()) ? i : [null, null, null];
                        e[t] = null != n ? n : null,
                        o.mediaOptionSwitchContexts = e
                    }
                    this.ce.update(e, o)
                }
            }
            Bl(e, t, i, r) {
                if ((null == i ? void 0 : i.mediaType) === O.CLOSEDCAPTION) {
                    t = r.variantMediaOptionById(t),
                    r = r.mediaOptionListQueries[se.Subtitle].packageAlternateMediaOption(t, i);
                    if (r.relativeUrl !== i.relativeUrl)
                        return Wg(t, r, e, this.logger)
                }
                return null
            }
            Ul(i, e) {
                var r, n, a, s, o;
                const l = {
                    abrStatus: Object.assign({}, i.abrStatus),
                    mediaOptionListTuple: [...i.mediaOptionListTuple],
                    enabledMediaOptionKeys: null != (n = null == (r = i.enabledMediaOptionKeys) ? void 0 : r.slice()) ? n : [Ns, Ns, Ns]
                }
                  , d = l.enabledMediaOptionKeys;
                let u;
                for (let t = 0; t < e.length; ++t) {
                    const n = e[t]
                      , h = d[t].mediaOptionId !== n.mediaOptionId;
                    h && (d[t] = n,
                    l.mediaOptionListTuple = _g(l.mediaOptionListTuple, t, {}, e => e.mediaOptionId === n.mediaOptionId ? Bg(e, i.baseUrl) : e));
                    var c = this.getQueryForId(n.itemId);
                    if (t === se.Variant) {
                        const i = l.mediaOptionListTuple[se.Variant].mediaOptions.find(e => e.mediaOptionId === d[t].mediaOptionId)
                          , e = (this.Gt.enableBoss && this.jl.setTransformer(n.itemId, le.HostRankFilter, new Pc(null != (a = i.url) ? a : i.relativeUrl,c.baseUrl)),
                        c.mediaOptionListQueries[t].mediaOptionList);
                        if (h) {
                            const r = l.mediaOptionListTuple[se.Variant]
                              , {mediaOptions: a, hasScore: d, pathwayPriority: u} = r;
                            a.sort(Zu(a.length, {
                                hasScore: d,
                                pivotVariant: i,
                                pathwayPriority: u,
                                enableSteering: this.Gt.enableContentSteering,
                                preferHostOverQuality: !0,
                                preferCloseToPivotQuality: !1
                            })),
                            l.abrStatus = (s = n.mediaOptionId,
                            o = e,
                            s = km(s, o),
                            {
                                fragDownloadSlow: !1,
                                fragDownloadTooSlow: !1,
                                nextMinAutoOptionId: de.mediaOptionId,
                                nextMaxAutoOptionId: de.mediaOptionId,
                                highBWTrigger: s
                            })
                        } else
                            l.abrStatus.highBWTrigger = km(n.mediaOptionId, e);
                        u = n
                    } else if (t === se.Subtitle && Ds(n)) {
                        const i = c.alternateMediaOptionById(t, n.mediaOptionId)
                          , e = this.Bl(l.mediaOptionListTuple[t].mediaOptions, u.mediaOptionId, i, c);
                        e && (l.mediaOptionListTuple[t] = Object.assign(Object.assign({}, l.mediaOptionListTuple[t]), {
                            mediaOptions: e
                        }))
                    }
                }
                return l
            }
            setManualMode(e, t) {
                this.ce.update(e, {
                    manualMode: t
                })
            }
            setEnabledMediaOptions(e, t) {
                var i = this.getQueryForId(e).rootPlaylistEntity;
                i && (t = t.map( ({mediaOptionId: e, itemId: t}) => ({
                    mediaOptionId: e,
                    itemId: t
                })),
                i = this.Ul(i, t),
                this.ce.update(e, i))
            }
            setEnabledMediaOptionsAndSwitchContexts(e, t, i) {
                var r = this.getQueryForId(e).rootPlaylistEntity;
                r && (t = t.map( ({mediaOptionId: e, itemId: t}) => ({
                    mediaOptionId: e,
                    itemId: t
                })),
                (r = this.Ul(r, t)).mediaOptionSwitchContexts = i,
                this.ce.update(e, r))
            }
            setLastLoadedMediaOptionByType(e, t, i) {
                i = i || {
                    itemId: e,
                    mediaOptionId: "Nah"
                };
                var r, n, a = this.getQueryForId(e).rootPlaylistEntity;
                a && ([a,r,n] = null != (a = a.enabledMediaOptionKeys) ? a : [Ns, Ns, Ns],
                (a = [a, r, n])[t] = {
                    itemId: e,
                    mediaOptionId: i.mediaOptionId
                },
                this.ce.update(e, {
                    lastLoadedMediaOptionKeys: a
                }))
            }
            setViewportInfo(e, t) {
                var i = this.getQueryForId(e).rootPlaylistEntity;
                i && (i = _g(i.mediaOptionListTuple, se.Variant, {
                    viewportInfo: t
                }),
                this.ce.update(e, {
                    mediaOptionListTuple: i
                }))
            }
            static doUpdateRootHDRSwitch(e, t, i, r, n, a, s, o, l) {
                a = _g(e.mediaOptionListTuple, se.Variant, {
                    preferHDR: a,
                    hasHdrLevels: s
                }),
                s = t.query.getEntity(e.itemId),
                t = i.getQueryForId(e.statsId).getCombinedEstimate(l, null == s ? void 0 : s.serviceName),
                i = {
                    targetDuration: (null == t ? void 0 : t.maxDurationSec) || l.defaultTargetDuration,
                    targetStartupMs: null == l ? void 0 : l.targetStartupMs,
                    enableBoss: l.enableBoss,
                    enableContentSteering: l.enableContentSteering
                };
                return Xg(null, zg(Object.assign(Object.assign({}, e), {
                    mediaOptionListTuple: a
                })), r, n, o, l, i, t)
            }
            switchToSDROnly(e, t) {
                if (this.Gt.enableBoss) {
                    const t = new Map([[le.HDRFilter, new Oc(!1,!1)], [le.CompatibleIdsFilter, new Tc(null)]]);
                    null != (i = this.jl) && i.setMultipleTransformers(e, t)
                }
                var i = this.getQueryForId(e).rootPlaylistEntity
                  , i = Ug.doUpdateRootHDRSwitch(i, t, this.Fl, this.jl, this.hlsService, !1, !1, this.logger, this.Gt)["mediaOptionListTuple"];
                this.ce.update(e, {
                    mediaOptionListTuple: i
                })
            }
            doPathwaySwitch(e, t, i) {
                var r, e = this.getQueryForId(e), n = e.rootPlaylistEntity;
                n && (t = t || n.mediaOptionListTuple[se.Variant].pathwayPriority) && 0 < t.length && (r = this.Fl.getQueryForId(n.statsId),
                n = zg(n, t),
                t = r.getCombinedEstimate(),
                r = Xg(null, n, this.jl, this.hlsService, this.logger, this.Gt, {
                    targetStartupMs: this.Gt.targetStartupMs,
                    targetDuration: (null == t ? void 0 : t.maxDurationSec) || 0,
                    enableBoss: this.Gt.enableBoss,
                    enableContentSteering: this.Gt.enableContentSteering
                }, t, i),
                this.setRootPlaylistEntity(e.itemId, r))
            }
            setHDRPreference(e, t, i, r) {
                var n, a, s = this.getQueryForId(e).rootPlaylistEntity, o = null == (o = null == s ? void 0 : s.mediaOptionListTuple) ? void 0 : o[se.Variant];
                (null == o ? void 0 : o.preferHDR) === i || i && !o.hasHdrLevels || (o = s.mediaOptionListTuple[se.Variant],
                n = new Oc(o.hasHdrLevels,i),
                null != (a = this.jl) && a.setTransformer(e, le.HDRFilter, n),
                a = Ug.doUpdateRootHDRSwitch(s, t, this.Fl, this.jl, this.hlsService, i, o.hasHdrLevels, this.logger, this.Gt),
                this.ce.update(e, a))
            }
            setPathwayPriority(e, t) {
                var i = this.getQueryForId(e).rootPlaylistEntity;
                i && (i = _g(i.mediaOptionListTuple, se.Variant, {
                    pathwayPriority: t
                }),
                this.ce.update(e, {
                    mediaOptionListTuple: i
                }))
            }
            setInitPTS(e, t, i, r, n, a) {
                var s = this.getQueryForId(e).rootPlaylistEntity;
                s && ((s = Object.assign({}, s.initPtsRecord))[t] = {
                    variantDTS: i,
                    timelineOffset: r,
                    offsetTimestamp: n,
                    iframeMode: a
                },
                this.ce.update(e, {
                    initPtsRecord: s
                }))
            }
            static prunePenaltyBox(e, t) {
                return e ? e.filter(e => e && !(e.expiry <= t)) : []
            }
            static addToPenaltyBox(e, t, i, r=12e4) {
                i = {
                    id: i,
                    expiry: t + r
                };
                return null == e ? [i] : e.push(i)
            }
            addToPenaltyBox(e, t, i) {
                var r = this.getQueryForId(e).rootPlaylistEntity;
                if (r) {
                    var n = r.mediaOptionListTuple[t].penaltyBoxQueue
                      , a = performance.now()
                      , n = Ug.prunePenaltyBox(n, a)
                      , a = (Ug.addToPenaltyBox(n, a, i),
                    _g(r.mediaOptionListTuple, t, {
                        penaltyBoxQueue: n
                    }));
                    if (this.ce.update(e, {
                        mediaOptionListTuple: a
                    }),
                    this.Gt.enableBoss) {
                        const i = new Ec([...this.getQueryForId(e).mediaOptionListQueries[t].mediaOptionListInfo.penaltyBoxQueue]);
                        null != (r = this.jl) && r.setTransformer(e, le.PenaltyBoxFilter, i)
                    }
                }
            }
            addToPathwayPenaltyBox(e, t) {
                var i = this.getQueryForId(e).rootPlaylistEntity;
                if (i) {
                    var r = performance.now()
                      , n = i.mediaOptionListTuple[se.Variant].pathwayPenaltyBox.slice()
                      , r = (Ug.addToPenaltyBox(n, r, t.pathwayID, 3e5),
                    _g(i.mediaOptionListTuple, se.Variant, {
                        pathwayPenaltyBox: n
                    }))
                      , t = (this.ce.update(e, {
                        mediaOptionListTuple: r
                    }),
                    this.Gt.enableBoss)
                      , i = this.Gt.enableContentSteering;
                    if (t && i) {
                        const t = new Ac(this.getQueryForId(e).mediaOptionListQueries[se.Variant].mediaOptionListInfo.pathwayPenaltyBox);
                        null != (n = this.jl) && n.setTransformer(e, le.PathwayPenaltyBoxFilter, t)
                    }
                }
            }
            prunePathwayPenaltyBox(e) {
                var t, i, r = this.getQueryForId(e).rootPlaylistEntity;
                r && (i = performance.now(),
                t = r.mediaOptionListTuple[se.Variant].pathwayPenaltyBox) && 0 !== t.length && (t = Ug.prunePenaltyBox(t.slice(), i),
                i = _g(r.mediaOptionListTuple, se.Variant, {
                    pathwayPenaltyBox: t
                }),
                this.ce.update(e, {
                    mediaOptionListTuple: i
                }))
            }
            prunePenaltyBox(e, i=null) {
                var r = this.getQueryForId(e).rootPlaylistEntity;
                if (r) {
                    let t = r.mediaOptionListTuple;
                    var n = performance.now();
                    if (i) {
                        const e = t[i];
                        t = _g(t, i, {
                            penaltyBoxQueue: Ug.prunePenaltyBox(e.penaltyBoxQueue, n)
                        })
                    } else
                        for (let e = 0; e < t.length; e++) {
                            const i = t[e];
                            t = _g(t, e, {
                                penaltyBoxQueue: Ug.prunePenaltyBox(i.penaltyBoxQueue, n)
                            })
                        }
                    this.ce.update(e, {
                        mediaOptionListTuple: t
                    })
                }
            }
            removePermanently(e, t, i) {
                var r = this.getQueryForId(e).rootPlaylistEntity;
                if (r) {
                    var n = r.mediaOptionListTuple
                      , n = new Set(n[t].removed)
                      , i = (n.add(i),
                    _g(r.mediaOptionListTuple, t, {
                        removed: Array.from(n)
                    }));
                    if (this.ce.update(e, {
                        mediaOptionListTuple: i
                    }),
                    this.Gt.enableBoss) {
                        const i = new bc([...this.getQueryForId(e).mediaOptionListQueries[t].mediaOptionListInfo.removed]);
                        null != (r = this.jl) && r.setTransformer(e, le.PermanentRemovalFilter, i)
                    }
                }
            }
            moveAllWithMatchingHosts(e, t, i, r) {
                const n = this.getQueryForId(e).rootPlaylistEntity;
                if (n) {
                    var a = n.mediaOptionListTuple[t]
                      , s = a.mediaOptions.filter(e => vs(i, e)).map(e => e.mediaOptionId)
                      , o = {
                        removed: a.removed,
                        penaltyBoxQueue: null != (a = a.penaltyBoxQueue) ? a : []
                    };
                    if (r) {
                        const e = new Set([...o.removed, ...s]);
                        o.removed = Array.from(e)
                    } else {
                        const e = performance.now()
                          , t = o.penaltyBoxQueue.slice();
                        o.penaltyBoxQueue = Ug.prunePenaltyBox(t, e);
                        for (const t of s)
                            Ug.addToPenaltyBox(o.penaltyBoxQueue, e, t)
                    }
                    a = _g(n.mediaOptionListTuple, t, o, e => Bg(e, n.baseUrl));
                    if (this.ce.update(e, {
                        mediaOptionListTuple: a
                    }),
                    this.Gt.enableBoss) {
                        const i = new Ec([...this.getQueryForId(e).mediaOptionListQueries[t].mediaOptionListInfo.penaltyBoxQueue]);
                        null != (r = this.jl) && r.setTransformer(e, le.PenaltyBoxFilter, i)
                    }
                }
            }
            setMaxHdcpLevel(e, t, i=!1) {
                var r = this.getQueryForId(e).rootPlaylistEntity;
                if (r) {
                    if (i || ku(t) < ku(r.mediaOptionListTuple[se.Variant].maxHdcpLevel)) {
                        const i = _g(r.mediaOptionListTuple, se.Variant, {
                            maxHdcpLevel: t
                        });
                        this.ce.update(e, {
                            mediaOptionListTuple: i
                        })
                    }
                    !this.Gt.enableBoss || null != (i = this.jl) && i.setTransformer(e, le.HDCPFilter, new wc(t))
                }
            }
            updateConsecutiveTimeouts(e, t, i, r) {
                var n = this.getQueryForId(e)
                  , a = null == (a = null == (a = n.getErrorInfoByType(t)) ? void 0 : a.timeouts) ? void 0 : a[r];
                (i || 0 !== a && null != a) && (a = h(n.rootPlaylistEntity.errorsByType) || [{
                    timeouts: {
                        load: 0,
                        append: 0,
                        key: 0
                    }
                }, {
                    timeouts: {
                        load: 0,
                        append: 0,
                        key: 0
                    }
                }, {
                    timeouts: {
                        load: 0,
                        append: 0,
                        key: 0
                    }
                }],
                i ? ++a[t].timeouts[r] : a[t].timeouts[r] = 0,
                this.ce.update(e, {
                    errorsByType: a
                }))
            }
            updateInflightFrag(t, i, r, n, a, s) {
                if (!(i === se.Subtitle || r && r.itemId !== t)) {
                    var o = this.ce.inFlightFragTuple[i].value;
                    if (o || r) {
                        if (a && null != o && o.bwSample) {
                            let e = Object.keys(a).length !== Object.keys(o.bwSample).length;
                            if (!e)
                                for (const [i,r] of Object.entries(o.bwSample))
                                    if (a[i] !== r) {
                                        e = !0;
                                        break
                                    }
                            if (!e)
                                return
                        }
                        if (r) {
                            var {start: r, duration: l, mediaOptionId: d, mediaSeqNum: u, discoSeqNum: c, iframe: h, isLastFragment: p, mediaOptionType: m} = r;
                            let e = null == o ? void 0 : o.tstart;
                            t = {
                                itemId: t,
                                mediaOptionId: d,
                                mediaOptionType: m,
                                mediaSeqNum: u,
                                discoSeqNum: c,
                                start: r,
                                duration: l,
                                tstart: e = n !== (null == o ? void 0 : o.state) ? performance.now() : e,
                                state: n,
                                iframe: h,
                                isLastFragment: p,
                                compatible: s,
                                bwSample: a ? Object.assign({}, a) : null
                            };
                            this.ce.setInFlightFrag(i, t)
                        } else
                            this.ce.setInFlightFrag(i, void 0)
                    }
                }
            }
            setNextMaxAutoOptionId(e, t) {
                t = Object.assign(Object.assign({}, this.getQueryForId(e).abrStatus), {
                    nextMaxAutoOptionId: t
                });
                this.ce.update(e, {
                    abrStatus: t
                })
            }
            setNextMinAutoOptionId(e, t) {
                t = Object.assign(Object.assign({}, this.getQueryForId(e).abrStatus), {
                    nextMinAutoOptionId: t
                });
                this.ce.update(e, {
                    abrStatus: t
                })
            }
            setHighBWTrigger(e, t) {
                t = Object.assign(Object.assign({}, this.getQueryForId(e).abrStatus), {
                    highBWTrigger: t
                });
                this.ce.update(e, {
                    abrStatus: t
                })
            }
            setFragLoadSlow(e, t) {
                var i, r = this.getQueryForId(e);
                null != r && (i = r.abrStatus,
                (null == t ? void 0 : t.fragDownloadSlow) !== (null == i ? void 0 : i.fragDownloadSlow) || (null == t ? void 0 : t.fragDownloadTooSlow) !== (null == i ? void 0 : i.fragDownloadTooSlow)) && (i = Object.assign(Object.assign({}, r.abrStatus), t),
                this.ce.update(e, {
                    abrStatus: i
                }))
            }
            pickMediaOptionTupleByAlternateMatchingInfo(e, t, i, r=!1, n=!1) {
                var a = e.enabledMediaOptionIdByType(se.Variant)
                  , a = e.variantMediaOptionById(a)
                  , i = t === se.AltAudio ? null == (l = i.audioMatchingInfo) ? void 0 : l.persistentId : null == (l = i.subtitleMatchingInfo) ? void 0 : l.persistentId;
                let s, o;
                if (t === se.AltAudio) {
                    const t = e.enabledAlternateMediaOptionByType(se.Subtitle);
                    o = null == t ? void 0 : t.persistentID,
                    s = i
                } else {
                    const t = e.enabledAlternateMediaOptionByType(se.AltAudio);
                    s = null == t ? void 0 : t.persistentID,
                    o = i
                }
                var l = e.getEnabledMediaOptionMask();
                return l[t] = !!(re(i) && 0 <= i),
                a ? this.getBestMediaOptionTupleFromVariantAndPersistentId(e, a, s, o, l, void 0, void 0, r, n, !1, !0) : [de, de, de]
            }
            getFallbackMediaOptionTupleFromMediaOptionId(e, t, i, r, n=!1, a=!1, s=!1, o=!1) {
                var r = r ? [r] : [i]
                  , l = e.enabledMediaOptionIdByType(se.Variant)
                  , l = e.variantMediaOptionById(l)
                  , d = t === se.AltAudio ? e.alternateMediaOptionById(se.AltAudio, i) : e.enabledAlternateMediaOptionByType(se.AltAudio)
                  , d = null == d ? void 0 : d.persistentID
                  , i = t === se.Subtitle ? e.alternateMediaOptionById(se.Subtitle, i) : e.enabledAlternateMediaOptionByType(se.Subtitle)
                  , i = null == i ? void 0 : i.persistentID;
                return l ? this.getBestMediaOptionTupleFromVariantAndPersistentId(e, l, d, i, void 0, r, t, n, a, s, o) : [de, de, de]
            }
            hasFallbackMediaOptionTuple(e, t, i, r) {
                var n = e.mediaOptionListQueries[t].mediaOptionFromId(i);
                return e.isValidMediaOptionTuple(this.getFallbackMediaOptionTupleFromMediaOptionId(e, t, i, n.backingMediaOptionId, !1, r))
            }
            $l(e, t, i, r, n=void 0) {
                var a = e.enabledMediaOptionIdByType(se.Variant)
                  , a = e.variantMediaOptionById(a)
                  , e = e.getLegacyMatchingAlternateWithPersistentId(i, r, a);
                e && this.setEnabledMediaOptionByType(t, i, e, !0, n)
            }
            setEnabledMediaOptionTupleWithMatchedGroups(t, i, e, r, n=void 0) {
                const a = r.getQueryForId(t)
                  , s = i === se.AltAudio ? null == (r = e.audioMatchingInfo) ? void 0 : r.persistentId : null == (r = e.subtitleMatchingInfo) ? void 0 : r.persistentId
                  , o = this.pickMediaOptionTupleByAlternateMatchingInfo(a, i, e);
                if (!a.isValidMediaOptionTuple(o))
                    return this.$l(a, t, i, s, n);
                ae( () => {
                    this.setEnabledMediaOptionByType(t, i, o[i], !0, n);
                    var e = o[se.Variant]
                      , e = (this.setEnabledMediaOptionByType(t, se.Variant, e),
                    i === se.AltAudio ? se.Subtitle : se.AltAudio);
                    o[e].mediaOptionId !== a.enabledMediaOptionIdByType(e) && this.setEnabledMediaOptionByType(t, e, o[e], !1)
                }
                )
            }
            canSwitchToSDR(e, t, i, r=!1) {
                var n = e.mediaOptionListQueries[se.Variant].mediaOptionFromId(t);
                return !!n && !!ym(n) && (t = this.getFallbackMediaOptionTupleFromMediaOptionId(e, se.Variant, t, n.backingMediaOptionId, !0, i, r),
                e.isValidMediaOptionTuple(t))
            }
            getBestMediaOptionTupleFromVariantAndPersistentId(t, i, r, n, a, s, o, l, d, u, c) {
                let h;
                const p = this.Gt
                  , m = t.mediaOptionListQueries[se.Variant];
                if (p.enableBoss) {
                    const o = null == (f = this.jl) ? void 0 : f.getQuery(t.itemId, this.logger)
                      , c = {
                        hasScore: t.mediaOptionListQueries[se.Variant].mediaOptionListInfo.hasScore,
                        pivotVariant: i,
                        pathwayPriority: t.mediaOptionListQueries[se.Variant].mediaOptionListInfo.pathwayPriority,
                        enableSteering: p.enableContentSteering,
                        preferHostOverQuality: !1,
                        preferCloseToPivotQuality: !0
                    }
                      , m = new Map([[le.ValidFallbackFilter, new Mc(i,d,u,s)], [le.FallbackSelector, new xc(c)]])
                      , g = t.enabledMediaOptionKeys[se.AltAudio]
                      , y = Ds(g) ? t.alternateMediaOptionById(se.AltAudio, g.mediaOptionId) : null
                      , v = q.getStickyAtmosStatus(p.useStickyAtmosFilter, i.audioCodec, null == y ? void 0 : y.channels)
                      , S = [t.mediaOptionListQueries[se.AltAudio].mediaOptionListInfo.penaltyBoxQueue, t.mediaOptionListQueries[se.AltAudio].mediaOptionListInfo.removed, t.mediaOptionListQueries[se.AltAudio].mediaOptionListInfo.compatibleIds]
                      , I = [t.mediaOptionListQueries[se.Subtitle].mediaOptionListInfo.penaltyBoxQueue, t.mediaOptionListQueries[se.Subtitle].mediaOptionListInfo.removed, t.mediaOptionListQueries[se.Subtitle].mediaOptionListInfo.compatibleIds]
                      , b = (null == y ? void 0 : y.persistentID) !== r
                      , T = new Fc(v,S,I,r,n,a || t.getEnabledMediaOptionMask(),s,b);
                    m.set(le.ErrorHandlingValidAlternatesFilter, T),
                    m.set(le.ValidAlternatesFilter, T),
                    null != (f = this.jl) && f.setMultipleTransformers(t.itemId, m);
                    let e = [de, de, de];
                    var f = l ? o.variantFor(os.ErrorHandlingSdrOnly) : o.variantFor(os.ErrorHandling);
                    return f && (h = t.matchAlternates(f, r, n, s),
                    e = [f, ...h]),
                    e
                }
                const g = m.listFallbackVariants(i.mediaOptionId, l, d, u, this.Gt.enableContentSteering, s);
                let y = [de, de, de];
                for (let e = g.length; 0 < e--; ) {
                    const o = g[e]
                      , l = (h = t.matchAlternates(o, r, n, s),
                    Vg(t, o, r, n, a, s));
                    if (l) {
                        y = l;
                        break
                    }
                }
                return y = c && !t.isValidMediaOptionTuple(y, a) ? function(e, t, i, r, n, a, s) {
                    let o = Number.POSITIVE_INFINITY;
                    const l = t.filteredMediaOptionList;
                    let d = [de, de, de];
                    for (const t of l) {
                        const l = Vg(i, t, r, n, a, s)
                          , u = Math.abs(t.bitrate - e.bitrate);
                        l && u < o && (d = l,
                        o = u)
                    }
                    return d
                }(i, m, t, r, n, a, s) : y
            }
            getAlternatesForVariant(e, t, i, r) {
                var n = e.variantMediaOptionById(t)
                  , a = this.Gt;
                if (a.enableBoss) {
                    const t = {
                        hasScore: e.mediaOptionListQueries[se.Variant].mediaOptionListInfo.hasScore,
                        pivotVariant: n,
                        pathwayPriority: e.mediaOptionListQueries[se.Variant].mediaOptionListInfo.pathwayPriority,
                        enableSteering: a.enableContentSteering,
                        preferHostOverQuality: !1,
                        preferCloseToPivotQuality: !0
                    }
                      , s = new Map([[le.ValidFallbackFilter, new Mc(n,!1,!1,[])], [le.FallbackSelector, new xc(t)]])
                      , o = e.enabledMediaOptionKeys[se.AltAudio]
                      , l = Ds(o) ? e.alternateMediaOptionById(se.AltAudio, o.mediaOptionId) : null
                      , d = q.getStickyAtmosStatus(a.useStickyAtmosFilter, n.audioCodec, null == l ? void 0 : l.channels)
                      , u = [e.mediaOptionListQueries[se.AltAudio].mediaOptionListInfo.penaltyBoxQueue, e.mediaOptionListQueries[se.AltAudio].mediaOptionListInfo.removed, e.mediaOptionListQueries[se.AltAudio].mediaOptionListInfo.compatibleIds]
                      , c = [e.mediaOptionListQueries[se.Subtitle].mediaOptionListInfo.penaltyBoxQueue, e.mediaOptionListQueries[se.Subtitle].mediaOptionListInfo.removed, e.mediaOptionListQueries[se.Subtitle].mediaOptionListInfo.compatibleIds]
                      , h = (null == l ? void 0 : l.persistentID) !== i
                      , p = new Fc(d,u,c,i,r,e.getEnabledMediaOptionMask(),[],h);
                    s.set(le.ErrorHandlingValidAlternatesFilter, p),
                    s.set(le.ValidAlternatesFilter, p),
                    null != (a = this.jl) && a.setMultipleTransformers(e.itemId, s)
                }
                return [n, ...e.matchAlternates(n, i, r, [])]
            }
            getEnabledAlternatesForVariant(e, t) {
                var i = e.enabledAlternateMediaOptionByType(se.AltAudio)
                  , i = null != (i = null == i ? void 0 : i.persistentID) ? i : void 0
                  , r = e.enabledAlternateMediaOptionByType(se.Subtitle)
                  , r = null != (r = null == r ? void 0 : r.persistentID) ? r : void 0;
                return this.getAlternatesForVariant(e, t, i, r)
            }
            setLoading(e) {
                this.ce.setLoading(e)
            }
        }
        function _g(e, t, i, r) {
            var [n,a,s] = e
              , o = r ? e => e.map(r) : e => e;
            switch (t) {
            case se.Variant:
                return [Object.assign(Object.assign(Object.assign({}, n), i), {
                    mediaOptions: o(n.mediaOptions)
                }), a, s];
            case se.AltAudio:
                return [n, Object.assign(Object.assign(Object.assign({}, a), i), {
                    mediaOptions: o(a.mediaOptions)
                }), s];
            case se.Subtitle:
                return [n, a, Object.assign(Object.assign(Object.assign({}, s), i), {
                    mediaOptions: o(s.mediaOptions)
                })];
            default:
                return e
            }
        }
        function Vg(e, t, i, r, n, a) {
            i = e.matchAlternates(t, i, r, a);
            return e.isValidMediaOptionTuple([t, ...i], n) ? [t, ...i] : null
        }
        function Qg(e, t, n, i, r) {
            let a;
            return t = t,
            s = n,
            a = (a = t && re(null == s ? void 0 : s.persistentId) && (t = No(t.itemId),
            s = No(s.itemId),
            t) && s ? i.find(function(e) {
                var t, i, r;
                return e.MediaSelectionOptionsPersistentID === n.persistentId && (!n.language || ({baseName: t, lang: i, region: r} = Tp.toLocale(n.language),
                Boolean(Hg({
                    baseName: t,
                    lang: i,
                    region: r
                }, e))))
            }) : a) || (r && n ? function(t, i, r=!1) {
                let n = null;
                const {baseName: a, lang: s, region: o} = Tp.toLocale(t.language)
                  , l = [!0, !1];
                for (let e = 0; e < l.length; ++e) {
                    const d = l[e];
                    for (let e = 0; e < i.length; e++) {
                        const l = i[e];
                        if (!(l.MediaSelectionOptionsIsAutoSelect !== d || r && l.MediaSelectionOptionsDisplaysNonForcedSubtitles)) {
                            const t = Hg({
                                baseName: a,
                                lang: s,
                                region: o
                            }, l);
                            if ((null == t ? void 0 : t.matchType) === gg.BaseNameMatch) {
                                n = t.option;
                                break
                            }
                            (null == t ? void 0 : t.matchType) === gg.LanguageTagMatch && (n = t.option)
                        }
                    }
                    if (n)
                        break
                }
                return n
            }(n, i) : i.find(function(e) {
                return e.MediaSelectionOptionsIsDefault
            }));
            var s
        }
        const Kg = (e, i, r, n, t, a) => {
            if (r) {
                let t = Qg(0, e, i, r.MediaSelectionGroupOptions, a.enableInterstitialPlayback);
                return t = t || r.MediaSelectionGroupOptions[0],
                n.find(e => e.persistentID === (null == t ? void 0 : t.MediaSelectionOptionsPersistentID))
            }
        }
        ;
        function Hg(e, t) {
            var i = Tp.toLocale(t.MediaSelectionOptionsExtendedLanguageTag);
            return i.baseName && e.baseName && i.baseName === e.baseName ? {
                matchType: gg.BaseNameMatch,
                option: t
            } : i.lang === e.lang ? {
                matchType: gg.LanguageTagMatch,
                option: t
            } : null
        }
        const jg = (e, t, i, r) => {
            e = e["rootMediaOptionsTuple"];
            let n = Array.from(e[se.Variant])
              , a = !1
              , s = !1;
            return (n = n.filter(e => {
                if (e.audioCodecList && e.audioAlternates) {
                    var t = e.audioAlternates && 0 < e.audioAlternates.length ? e.audioAlternates[0] : void 0
                      , t = null == t ? void 0 : t.channels;
                    if (t) {
                        var i = q.getImmersiveAudioType(t);
                        if (!q.isCompatibleImmersiveAudioType(i))
                            return !1;
                        e.audioChannelCount = parseInt(t)
                    }
                }
                return e
            }
            )).forEach(e => {
                a = a || Boolean(e.videoCodec),
                s = s || Boolean(e.audioCodec) || Boolean(e.audioAlternates)
            }
            ),
            {
                variantMediaOptions: n = a && s ? n.filter( ({videoCodec: e}) => Boolean(e)) : n
            }
        }
          , qg = (E, e, A, O, R, w, t, i) => Lg(t, E.sessionKeys, e, O, i).pipe(W( ({hdrMediaOptions: e, sdrMediaOptions: t, imageIframeVariants: i}) => {
            var t = e.concat(t)
              , e = 0 < e.length
              , r = t.concat(i);
            O.enableBoss && null != A && A.setVariants(E.itemId, r);
            {
                var n = E
                  , a = t;
                r = e,
                t = R,
                e = w;
                const {parentItemId: h, itemId: p, statsId: m, itemStartOffsets: f, rootMediaOptionsTuple: g, audioMediaSelectionGroup: y, subtitleMediaSelectionGroup: v, startTimeOffset: S=NaN, appItemId: I, variantIdToAlternateGroupIdTuple: b} = n
                  , T = [new Set, new Set];
                for (const n of a) {
                    const a = b.get(n.mediaOptionId);
                    if (a && (T[tp.Audio].add(a[tp.Audio]),
                    T[tp.Subtitle].add(a[tp.Subtitle])),
                    n.audioAlternates)
                        for (const a of n.audioAlternates)
                            T[tp.Audio].add(a.groupId);
                    if (n.subtitleAlternates)
                        for (const a of n.subtitleAlternates)
                            T[tp.Subtitle].add(a.groupId)
                }
                var s = g[se.AltAudio].filter(e => T[tp.Audio].has(e.groupId))
                  , o = g[se.Subtitle].filter(e => T[tp.Subtitle].has(e.groupId))
                  , l = a.every(e => re(e.score))
                  , d = n.baseUrl
                  , u = null == (u = n.contentSteeringOption) ? void 0 : u.initPathwayPriority
                  , c = n.sessionData;
                return {
                    parentItemId: h,
                    itemId: p,
                    statsId: m,
                    appItemId: I,
                    baseUrl: d,
                    mediaOptionListTuple: [{
                        mediaOptions: a,
                        hasHdrLevels: r,
                        hasScore: l,
                        preferHDR: t,
                        compatibleIds: null,
                        penaltyBoxQueue: [],
                        removed: [],
                        pathwayPriority: u,
                        pathwayPenaltyBox: []
                    }, {
                        mediaOptions: s,
                        compatibleIds: null,
                        penaltyBoxQueue: [],
                        removed: []
                    }, {
                        mediaOptions: o,
                        penaltyBoxQueue: [],
                        removed: []
                    }],
                    audioMediaSelectionGroup: y,
                    subtitleMediaSelectionGroup: v,
                    enabledMediaOptionKeys: [de, de, de],
                    mediaOptionSwitchContexts: [null, null, null],
                    avAnchor: null,
                    itemStartOffsets: f,
                    startTimeOffset: S,
                    initPtsRecord: {},
                    contentSteeringOption: n.contentSteeringOption,
                    masterVariableList: n.masterVariableList,
                    loadStats: n.stats,
                    isMediaPlaylist: n.isMediaPlaylist,
                    isInterstitial: e,
                    iframeVariants: i,
                    abrStatus: {
                        fragDownloadSlow: !1,
                        fragDownloadTooSlow: !1,
                        nextMinAutoOptionId: de.mediaOptionId,
                        nextMaxAutoOptionId: de.mediaOptionId,
                        highBWTrigger: NaN
                    },
                    sessionData: c
                }
            }
        }
        ))
          , Gg = (t, i, r, n, a, s, o) => {
            if (n) {
                const s = Qg(0, t, i, n.MediaSelectionGroupOptions, o.enableInterstitialPlayback);
                let e;
                return e = s ? a.find(e => e.mediaType === O.CLOSEDCAPTION ? (!r || e.groupId === r) && e.persistentID === s.MediaSelectionOptionsPersistentID : e.mediaType === O.SUBTITLE ? e.persistentID === s.MediaSelectionOptionsPersistentID : void 0) : e
            }
        }
        ;
        function $g(e, t, i, r, n) {
            var a = e.mediaOptionListTuple[se.Variant];
            let s;
            var o = e.itemId;
            if (i.enableBoss && r) {
                const e = new Map([[le.PermanentRemovalFilter, new bc(a.removed)], [le.CompatibleIdsFilter, new Tc(null)], [le.PenaltyBoxFilter, new Ec(a.penaltyBoxQueue)], [le.HDRFilter, new Oc(a.hasHdrLevels,a.preferHDR)], [le.ViewportFilter, new Rc(a.viewportInfo)], [le.HDCPFilter, new wc(a.maxHdcpLevel)]]);
                i.enableContentSteering && e.set(le.PathwayFilter, new Dg(a.pathwayPriority)),
                r.setMultipleTransformers(o, e),
                s = r.getQuery(o, t).variantsFor(os.FirstSelection)
            } else {
                const t = [...vm.kAllowFilters];
                e.contentSteeringOption && i.enableContentSteering && t.push(new Lu({
                    name: "Content Steering Pathway Filter",
                    priority: 5,
                    initFn: (e, t={}) => {
                        var i = Yu(t.pathwayPriority);
                        return Object.assign(Object.assign({}, t), {
                            pathwayRanking: i
                        })
                    }
                    ,
                    firstPassFn(e, t, i, r) {
                        var n = i.pathwayRanking(e.pathwayID);
                        (null == i.selectedPathwayRanking || n > i.selectedPathwayRanking) && (i.selectedPathway = e.pathwayID,
                        i.selectedPathwayRanking = n)
                    },
                    filterFn: (e, t, i) => e.pathwayID === i.selectedPathway
                })),
                s = Nu(a.mediaOptions, t, Object.assign(Object.assign({}, a), {
                    compatibleIds: null
                }))
            }
            return {
                firstVariant: function(e, t, i, r, n, a, s, o) {
                    var l, d, u, c, h, p, m, f, g, y, v;
                    if (!(!e || e.length < 1 || e.every(e => e.iframes)))
                        return (i ? (m = r,
                        f = n,
                        g = a,
                        y = s,
                        v = o,
                        e.reduceRight( (e, t) => {
                            if (t.iframes)
                                return e;
                            let i = e;
                            r = t.score,
                            n = m && f && g && y && !Ku(t, m, f, g, y, v) ? ns.INVALID : ns.VALID;
                            var r, n = new Sc(n,r);
                            return i = !e || n.isGreaterThan(e.bestRank) || n.isEqualTo(e.bestRank) && t.bandwidth < e.selected.bandwidth ? {
                                selected: t,
                                bestRank: n
                            } : i
                        }
                        , null)) : (l = t,
                        d = r,
                        u = n,
                        c = a,
                        h = s,
                        p = o,
                        e.reduceRight( (e, t) => {
                            if (t.iframes)
                                return e;
                            let i = e;
                            var r = function(e, t, i, r, n, a, s) {
                                o = e.bitrate,
                                l = e.height;
                                var o = (d = (e, t, i) => (e - t) * (e - i) <= 0)(o, t.minValidBitrate, t.maxValidBitrate) && d(l, t.minValidHeight, t.maxValidHeight) ? ns.VALID : ns.INVALID
                                  , l = "PQ" === (d = e.videoRange) ? is.PQ : "HLG" === d ? is.HLG : "SDR" === d ? is.SDR : is.UNKNOWN
                                  , {videoCodecRank: d, audioCodecRank: u} = {
                                    videoCodecRank: gc((d = e).videoCodec),
                                    audioCodecRank: vc(d.audioCodec)
                                }
                                  , t = e.bitrate < t.maxPreferredBitrate ? ns.VALID : ns.INVALID
                                  , c = e.audioChannelCount || 1
                                  , i = i && r && n && a && !Ku(e, i, r, n, a, s) ? ns.INVALID : ns.VALID;
                                return new Sc(o,l,d,c,u,i,t,e.height)
                            }(t, l, d, u, c, h, p);
                            return i = !e || r.isGreaterThan(e.bestRank) || r.isEqualTo(e.bestRank) && t.bitrate > e.selected.bitrate ? {
                                selected: t,
                                bestRank: r
                            } : i
                        }
                        , null))).selected
                }(s, am, a.hasScore, n, i, n, n, n),
                filteredVariants: s
            }
        }
        function Wg(e, t, i, r) {
            if ((null == t ? void 0 : t.mediaType) === O.CLOSEDCAPTION) {
                e = Ng.pairForcedSubtitleMediaOptionWithClosedCaptionInList(t, null != (e = e.subtitleAlternates) ? e : [], r);
                if (e)
                    return t = Object.assign(Object.assign({}, t), {
                        url: e.url,
                        relativeUrl: e.relativeUrl,
                        backingMediaOptionId: e.mediaOptionId
                    }),
                    i.map(e => e.mediaOptionId === t.mediaOptionId ? t : e)
            }
            return null
        }
        function zg(e, t) {
            var [i,r,n] = e.mediaOptionListTuple
              , t = Object.assign(Object.assign({}, e), {
                mediaOptionListTuple: [Object.assign(Object.assign({}, i), {
                    mediaOptions: [...i.mediaOptions],
                    pathwayPriority: null != t ? t : i.pathwayPriority
                }), Object.assign(Object.assign({}, r), {
                    compatibleIds: null
                }), Object.assign({}, n)]
            })
              , i = e.audioMediaSelectionGroup
              , r = null == i ? void 0 : i.MediaSelectionGroupOptions;
            return r && (t.audioMediaSelectionGroup = Object.assign(Object.assign({}, i), {
                MediaSelectionGroupOptions: [...r]
            })),
            t
        }
        function Xg(e, t, i, r, n, a, s, o, l) {
            var d = t.itemId
              , [u,c,h] = t.mediaOptionListTuple
              , p = (null == l ? void 0 : l.size) || 0
              , {firstVariant: o, filteredVariants: m} = function(e, t, i, r, n) {
                var a = e.mediaOptionListTuple[se.Variant];
                let {firstVariant: s, filteredVariants: o} = $g(e, t, i, r, n);
                if (!s) {
                    const H = a.preferHDR;
                    a.preferHDR = !H && a.hasHdrLevels,
                    a.preferHDR !== H && ({firstVariant: s, filteredVariants: o} = $g(e, t, i, r, n))
                }
                if (s)
                    return {
                        firstVariant: s,
                        filteredVariants: o
                    };
                throw new j(!0,0 === o.length ? H.NoValidAlternates : H.NoValidFirstAlternate)
            }(t, n, s, i, o)
              , f = {
                itemId: d,
                mediaOptionId: o.mediaOptionId
            }
              , p = ((null == l ? void 0 : l.size) || 0) - p;
            if (p) {
                var g = l;
                l = p,
                p = t;
                const T = new Map
                  , E = new Map
                  , A = p.mediaOptionListTuple[se.Variant]
                  , O = Array.from(g.values());
                let e = g.size - l;
                for (; e < g.size; e++) {
                    const g = O[e];
                    A.mediaOptions = A.mediaOptions.concat(g),
                    g.forEach(e => {
                        var t;
                        null != (t = e.audioAlternates) && t.forEach(e => {
                            var t = e.groupId + `_` + e.persistentID;
                            T.has(t) || T.set(t, e)
                        }
                        ),
                        null != (t = e.subtitleAlternates) && t.forEach(e => {
                            var t = e.groupId + `_` + e.persistentID;
                            E.has(t) || E.set(t, e)
                        }
                        )
                    }
                    )
                }
                var l = p.mediaOptionListTuple[se.AltAudio]
                  , y = Array.from(T.values())
                  , l = (l.mediaOptions = l.mediaOptions.concat(y),
                p.mediaOptionListTuple[se.Subtitle])
                  , y = Array.from(E.values());
                l.mediaOptions = l.mediaOptions.concat(y)
            }
            var p = r.query.alternateMatchingInfo
              , {firstAudio: l, firstSubtitle: y} = function(e, t, i, r, n, a, s, o, l) {
                t = e.audioAlternates ? Nu(e.audioAlternates, Ng.kAllowFilters, t) : [],
                i = t.length ? Kg(a, null == s ? void 0 : s.audioMatchingInfo, i, t, l, o) : null,
                t = e.subtitleAlternates ? Nu(e.subtitleAlternates, Ng.kAllowFilters, r) : [];
                return {
                    firstAudio: i,
                    firstSubtitle: t.length ? Gg(a, null == s ? void 0 : s.subtitleMatchingInfo, e.closedcaption, n, t, l, o) : null
                }
            }(o, c, t.audioMediaSelectionGroup, h, t.subtitleMediaSelectionGroup, e, p, a, n)
              , v = null == l ? void 0 : l.mediaOptionId
              , v = v ? {
                itemId: d,
                mediaOptionId: v
            } : de
              , S = y ? y.mediaOptionId : null
              , S = S ? {
                itemId: d,
                mediaOptionId: S,
                mediaOptionType: se.Subtitle
            } : de
              , {mediaOptions: m, audioGroups: I} = s.enableBoss ? (null == i ? void 0 : i.getQuery(d, n)).getCompatibleOptionBasedOnFirstMediaOptions(o) : Au(m, o)
              , m = (u.compatibleIds = m.map(e => e.mediaOptionId),
            u.mediaOptions);
            for (const e of m)
                null == e.url && null != e.relativeUrl && (e.url = ps(e.relativeUrl, t.baseUrl));
            m.sort(Zu(m.length, {
                hasScore: u.hasScore,
                pivotVariant: o,
                pathwayPriority: u.pathwayPriority,
                enableSteering: s.enableContentSteering,
                preferHostOverQuality: !0,
                preferCloseToPivotQuality: !1
            }));
            const b = function(e, t) {
                var i = {
                    filteredAudioMediaOptions: new Array,
                    compatibleIds: new Array,
                    persistentIds: new Set,
                    altAudio: !1
                };
                for (const r of e)
                    t.has(r.groupId) && (i.persistentIds.add(r.persistentID),
                    i.compatibleIds.push(r.mediaOptionId),
                    i.filteredAudioMediaOptions.push(r),
                    i.altAudio || (i.altAudio = !!r.relativeUrl));
                return i
            }(c.mediaOptions, I);
            c.compatibleIds = b.compatibleIds;
            var u = t.audioMediaSelectionGroup
              , I = null == u ? void 0 : u.MediaSelectionGroupOptions
              , c = (I && (u.MediaSelectionGroupOptions = I.filter(e => b.persistentIds.has(e.MediaSelectionOptionsPersistentID))),
            Wg(o, y, h.mediaOptions, n))
              , u = (c && (h.mediaOptions = c),
            a.useHighestVideoCodecPrivate ? function(t) {
                const i = new Map
                  , r = t.length
                  , n = e => {
                    var t = yc(e)
                      , t = i.get(t);
                    return q.isHigherCodecByFamily(t, e) ? 1 : 0
                }
                ;
                for (let e = 0; e < r; e++) {
                    const r = t[e].videoCodecList;
                    if (r) {
                        const t = B(r, n);
                        i.set(yc(t), t)
                    }
                }
                return i
            }(m) : new Map);
            if (t.highestVideoCodec = u,
            !p && No(d)) {
                const {firstMatchingInfo: i, mediaOptionSwitchContexts: n} = function(e, t, i, r) {
                    var n = {};
                    let a = [null, null, null];
                    return t && (n.audioMatchingInfo = {
                        itemId: e,
                        persistentId: t.persistentID,
                        language: t.lang,
                        name: t.name
                    }),
                    i && (n.subtitleMatchingInfo = {
                        itemId: e,
                        persistentId: i.persistentID,
                        language: i.lang,
                        name: i.name,
                        forced: i.forced
                    }),
                    r ? a = [null, r.userSwitchAudioTrack && t ? {
                        userInitiated: !0,
                        triggerEvent: !0
                    } : null, r.userSwitchSubtitleTrack && i ? {
                        userInitiated: !0
                    } : null] : No(e) && !r && (a = [null, t ? {
                        triggerEvent: !0
                    } : null, null]),
                    {
                        firstMatchingInfo: n,
                        mediaOptionSwitchContexts: a
                    }
                }(d, l, y, e);
                r.setAlternateMatchingInfo(i),
                t.mediaOptionSwitchContexts = n
            } else
                t.mediaOptionSwitchContexts = [null, null, null];
            return t.abrStatus = {
                fragDownloadSlow: !1,
                fragDownloadTooSlow: !1,
                nextMinAutoOptionId: de.mediaOptionId,
                nextMaxAutoOptionId: de.mediaOptionId,
                highBWTrigger: km(f.mediaOptionId, m)
            },
            t.enabledMediaOptionKeys = [f, v, S],
            s.enableBoss && (i.setTransformer(o.itemId, le.HostRankFilter, new Pc(null != (I = o.url) ? I : o.relativeUrl,t.baseUrl)),
            null != i && i.setTransformer(o.itemId, le.MatchingPathwayFilter, new Uc(o.pathwayID))),
            t
        }
        function Yg(e, t, i, r, n, a, s, o, l) {
            a = performance.now() - a,
            a = s.targetStartupMs > a ? s.targetStartupMs - a : s.targetStartupMs;
            return Xg(t, i, n, r, l, s, s.enableAdaptiveStartup ? {
                targetDuration: (null == o ? void 0 : o.maxDurationSec) || s.defaultTargetDuration,
                targetStartupMs: a,
                enableBoss: s.enableBoss,
                enableContentSteering: s.enableContentSteering
            } : void 0, o)
        }
        function Jg(e, t) {
            const {mediaSink: i, itemQueue: r} = e
              , n = i["mediaQuery"];
            return ce(ma([n.desiredRate$, n.waterLevelChangedForType$(oe.Variant)]).pipe(W( ([e,t]) => !(Yc(e) || re(t) && t < nu.HighWater || r.isPreloading()))), e => e).pipe(te( () => t))
        }
        function Zg(n, a, s, o) {
            const {config: l, mediaLibraryService: d} = n;
            return e => e.pipe(In({
                delay: (e, t) => {
                    if (e instanceof j || !(e instanceof b))
                        return e.handled = !0,
                        e.fatal = !1,
                        d.setPrefetchErrored(a, o),
                        R( () => e);
                    let i;
                    switch (o) {
                    case rf.Manifest:
                        i = eo({
                            url: s
                        }, l.manifestLoadPolicy);
                        break;
                    case rf.Playlist:
                        i = eo({
                            url: s
                        }, l.playlistLoadPolicy);
                        break;
                    case rf.Segment:
                        i = eo({
                            url: s
                        }, l.fragLoadPolicy);
                        break;
                    default:
                        return R( () => e)
                    }
                    i.maxLoadTimeMs = F(i.maxLoadTimeMs, 2e4);
                    var r = to(e, i);
                    return Bp(e, t - 1, r, 0, !1, null).pipe(te( () => Jg(n, Y(tf.IN_PROGRESS)).pipe(W( () => 0))))
                }
            }))
        }
        const ey = "prefetch";
        class ty {
            constructor(e, t, i, r) {
                this.Oi = e,
                this.Nr = t,
                this.Gt = i,
                this.R = r,
                this._i = new z,
                this.Vl(),
                this.ql()
            }
            destroy() {
                this.Nr.destroy(),
                this._i.next(),
                this.Oi = void 0
            }
            ql() {
                var e = dl(this.Oi, this)
                  , t = [e.event(L.KEY_REQUEST_STARTED, this.Kl, this), e.event(L.KEY_LOADED, this.Hl, this)];
                try {
                    "object" == typeof window && window.BeforeUnloadEvent && t.push(da(window, "beforeunload").pipe(ie(this.zl.bind(this))))
                } catch (e) {} finally {
                    ne(...t).pipe(Pn(this._i)).subscribe()
                }
            }
            Vl() {
                this.Oi.mediaElementQuery$.pipe(te(e => this.Ql(e)), Pn(this._i)).subscribe(),
                this.Oi.itemQueue.activeItemById$.pipe(ie(t => {
                    if (t && !t.parentItemId) {
                        let e = !1;
                        if (this.Oi.userInfo ? this.Oi.userInfo.internalBuild ? e = !0 : this.Oi.userInfo.diagnosticsAndUsage && (e = this.Gt.enableRtcReporting) : e = this.Gt.enableRtcReporting,
                        e) {
                            const t = this.Oi.reportingAgent;
                            t && this.Nr.rtcComponent.setReportingAgent(t)
                        } else
                            this.Nr.rtcComponent.setReportingAgent(null);
                        this.Nr.serverInfoInstance = {};
                        var i = t.itemId
                          , t = !!t.loopCount && 0 < t.loopCount;
                        this.Nr.rtcStore.createEntity(i, this.Nr.hlsjsVersion, this.Gt.enableInterstitialPlayback, t, this.Gt.testGroupId),
                        !this.Oi.isFirstItem && this.Oi.inGaplessMode || this.Nr.setPeriodic(i)
                    }
                }
                ), Pn(this._i)).subscribe()
            }
            Ql(e) {
                return e.gotPlaying$.pipe(ie(e => {
                    var t;
                    if (e) {
                        const e = this.Nr.oldRate
                          , i = this.Nr.newRate || 1;
                        1 < Math.abs(e) && 1 < Math.abs(i) || (this.Nr.rtcStore.updateCanPlay(null != (t = this.Nr.rtcEventItemId(!0)) ? t : "", {
                            mediaDur: this.Oi.bufferedDuration,
                            oldRate: e,
                            newRate: i,
                            forInterstitial: this.Oi.interstitialActive,
                            playStartTime: this.Oi.realCurrentTime
                        }),
                        this.Nr.sendAndFinalize(this.Nr.rtcEventItemId(!0), o.PlayLikelyToKeepUp),
                        this.Nr.rtcStore.updateRateChanged(this.Nr.rtcEventItemId(!0), {
                            rate: i,
                            latency: re(this.Nr.playStart) ? performance.now() - this.Nr.playStart : 0,
                            mediaDur: this.Oi.bufferedDuration,
                            currentTime: this.Oi.realCurrentTime,
                            url: null != (t = this.Nr.levelSwitchingUrl) ? t : "",
                            forInterstitial: this.Oi.interstitialActive
                        }),
                        this.Nr.sendAndFinalize(this.Nr.rtcEventItemId(!0), o.PlayRateChanged))
                    }
                }
                ))
            }
            Kl(e) {
                this.Nr.keyRequestStarted(e, this.Oi.interstitialActive)
            }
            Hl(e) {
                var t;
                e.method = null == (t = e.decryptdata) ? void 0 : t.method,
                this.Nr.keyLoaded(e, this.Oi.interstitialActive)
            }
            zl() {
                this.Nr.detachMedia()
            }
        }
        function iy(n, a, s) {
            return e => {
                var t, i, r;
                return t = n,
                i = a,
                r = s,
                Fr([e.pipe(te(e => {
                    return e ? ne(e = new Wd(e,t,i,r), Y(e)) : Y(null)
                }
                )), e]).pipe(W( ([e,t]) => ({
                    legibleSystemAdapter: e,
                    mediaSink: t
                })))
            }
        }
        ty.loggerName = {
            name: "rtc-service"
        };
        ol;
        class ry {
            constructor(e) {
                this.Ma = e
            }
            destroy() {
                this.Ma = void 0
            }
            get inGaplessMode() {
                return Boolean(this.Ma && this.Ma.inGaplessMode)
            }
            get isFirstItem() {
                return Boolean(this.Ma && this.Ma.isFirstItem)
            }
            get isPreloading() {
                return Boolean(this.Ma && this.Ma.isPreloading)
            }
            get loadingItem() {
                return this.Ma && this.Ma.loadingItem
            }
            get playingItem() {
                return this.Ma && this.Ma.playingItem
            }
            dequeueSource(e) {
                var t;
                null != (t = this.Ma) && t.dequeueSource(e)
            }
            queueSource(e, t) {
                var i;
                null != (i = this.Ma) && i.queueSource(e, t)
            }
            endSource() {
                var e;
                null != (e = this.Ma) && e.endSource()
            }
        }
        return class cy extends ol {
            constructor(e={}, x, t, i, r=Ga()) {
                var n, a, s, o, l;
                if (super(),
                this.sessionID = r,
                this._i = new z,
                this.Gl = new pn(null),
                this.Ra = new pn(null),
                this.Pa = new pn(null),
                this.Ca = new pn(null),
                this.Wl = null,
                this.rs = null,
                this.Xl = null,
                this.aa = new og(new sg),
                this.Yl = (L = this.aa,
                new wf(new Ef,L)),
                this.Jl = new Ph(new wh),
                this.Xa = new Ro(new Oo),
                this.Zl = null,
                this.tu = null,
                this.eu = new qs,
                this.iu = !0,
                this.Lr = new th,
                this.nu = !1,
                this.ru = new pn(void 0),
                this.su = new z,
                this.ou = [],
                this.au = new z,
                this.lu = new pn(!0),
                this.uu = new ry(this),
                this.cu = new pn(null),
                this.hu = new tg(this),
                e.liveSyncDurationCount && e.liveSyncDuration)
                    throw new j(!0,H.MixedLiveSyncDurationConfig);
                let d = "silent";
                e.debug && (d = e.debugLevel),
                this.du = new Hs(null != (L = e.rtcLogHistoryNumLines) ? L : ks.rtcLogHistoryNumLines),
                this.logger = null != (L = this.logger) ? L : ([L,s={},o] = [r, (a = {
                    allowed: e.allowedLogs,
                    buildType: e.buildType,
                    consoleOverride: "boolean" != typeof e.debug ? e.debug : void 0,
                    disallowed: e.disallowedLogs,
                    level: "log" === d ? "debug" : d,
                    sendLogs: e.sendLogs || null,
                    storeLogs: this.du.recordLogs.bind(this.du)
                },
                L = a["consoleOverride"],
                s = new Set(a.allowed),
                o = new Set(a.disallowed),
                Object.assign({
                    name: "hls",
                    timestamp: a.sendLogs ? su.stdTimeFunctions.epochTime : su.stdTimeFunctions.isoTime,
                    browser: {
                        asObject: !0,
                        serialize: !0,
                        transmit: {
                            send: (e, t) => {
                                var i;
                                null != (i = a.storeLogs) && i.call(a, t)
                            }
                        },
                        write: {
                            debug: Iu.bind(null, Su(L || console, "debug"), "debug", s, o),
                            info: Iu.bind(null, Su(L || console, "info"), "info", s, o),
                            warn: Iu.bind(null, Su(L || console, "warn"), "warn", s, o),
                            error: Iu.bind(null, Su(L || console, "error"), "error", s, o),
                            fatal: Iu.bind(null, Su(L || console, "error"), "fatal", s, o)
                        }
                    }
                }, a)), this.lu],
                (l = su(([l={}] = [s],
                Object.assign(Object.assign({}, l), {
                    customLevels: Object.assign(Object.assign({}, l.customLevels || {}), {
                        qe: 35,
                        timing: 35
                    })
                }))).child({
                    sessionId: L,
                    name: "hls",
                    isEnabled: o
                })).qe = function(t, e=[], i=[]) {
                    const r = new Set(e)
                      , n = new Set(i);
                    return e => {
                        r.size && !r.has(e.name) || n.has(e.name) || t.info(e)
                    }
                }(l, s.allowed, s.disallowed),
                (n = l).perf = function(e) {
                    var t;
                    null != (t = e) && "object" == typeof t && "critical"in t && "name"in t && "data"in t ? (e.data.tnow = performance.now(),
                    n.info(e)) : n.info({
                        name: "timing"
                    }, "string" == typeof e ? e : JSON.stringify(e))
                }
                ,
                l.sessionId = L,
                "function" != typeof l.isLevelEnabled && (l.isLevelEnabled = function(e) {
                    return this.levels.values[e] >= this.levelVal || this.levelVal <= 35 && ("qe" === e || "perf" === e)
                }
                .bind(l)),
                l),
                this.itemQueue = (o = this.logger,
                s = new Ua({},{
                    name: "item-queue",
                    idKey: "itemId",
                    resettable: !0
                }),
                new cg(s,o));
                const B = function(i, e, t, r) {
                    if (r.child({
                        name: "remote-config"
                    }),
                    !(i && t && (r = i,
                    o = Cs,
                    null != r) && r.BagDict && r.ConfigurationDict && (r = r.Version) && o && (r = r.split("."),
                    o = o.supportedStorebagVersion.split("."),
                    r[0] === o[0])))
                        return {};
                    const n = i.ConfigurationDict;
                    let a = {};
                    var s, o = (r = i.BagDict[t.clientName]) ? r[t.serviceName] : null;
                    if (function(t, i) {
                        if (!t || !i)
                            return !1;
                        const r = t.VersionRange;
                        if (!r)
                            return !1;
                        const n = r[0]
                          , e = r[1];
                        if (!(n && e && Jd(n, e)))
                            return !1;
                        var a = t.SamplingThreshold;
                        if (!(re(a) && a <= 1 && 0 <= a))
                            return !1;
                        if (!(a = t.Configurations))
                            return !1;
                        let s = 0;
                        for (const t of a) {
                            if (!t)
                                return !1;
                            const l = t[0]
                              , r = t[1]
                              , n = l ? i[l] : null;
                            let e = !1;
                            if (!(e = n ? null != n.GroupId && "string" == typeof n.GroupId && n.GroupId.length < 20 : e))
                                return !1;
                            if (!(l && n && n.Patch && re(r)))
                                return !1;
                            s += r
                        }
                        var o = Math.abs(1 - s) <= Number.EPSILON;
                        return a && 0 < a.length && o && (a = new Date(t.ExpirationDate)) && a.getTime() > Date.now()
                    }(o, n) && o) {
                        const i = Math.max(0, Math.min(o.SamplingThreshold, 1))
                          , t = 0 === Zd([i, 1 - i]);
                        if (r = e,
                        e = o.VersionRange,
                        s = e[0],
                        e = e[1],
                        (null == s || Jd(r, s)) && (null == e || Jd(e, r)) && t) {
                            s = o.Configurations.map(e => [n[e[0]], e[1]]),
                            r = Zd(s.map( ([,e]) => e));
                            const i = s[r][0]
                              , e = Object.keys(i.Patch).filter(e => e in ks && !Yd.has(e)).reduce( (e, t) => (Object.prototype.hasOwnProperty.call(i.Patch, t) && (e[t] = i.Patch[t]),
                            e), {});
                            a.testGroupId = i.GroupId,
                            a = Object.assign(a, e)
                        }
                    }
                    return a
                }(i, cy.version, t, this.logger)
                  , F = Object.assign(Object.assign(Object.assign({}, ks), e), B);
                if (F.maxRequiredStartDuration < F.minRequiredStartDuration || F.minRequiredStartDuration < 0 || F.minRequiredStartDuration < F.minRequiredStartDurationLLHLS)
                    throw new j(!0,H.InvalidRequiredStartDuration);
                this.fu = F,
                this.Fl = (L = this.logger,
                l = this.fu,
                new cp(new up,L,l)),
                i = F.buildType,
                me = "production" === i,
                Oa = !1,
                Ta && (delete window.$$stores,
                delete window.$$queries),
                this.fu.audioPrimingDelay = 0,
                this.vu = new Hh(this,r,this.logger),
                this.Nr = new Wh(this,F,cy.version,this.vu,this.logger,this.du.getLogs.bind(this.du)),
                this.mu = new ty(this,this.Nr,F,this.logger),
                F.enableBoss && (this.yu = new Vc(new Pu)),
                this.Aa = this.Aa = (t = this.aa,
                e = this.logger,
                L = F,
                i = this.Nr,
                N = this.Fl,
                D = this.yu,
                new Ug(new Fg,t,e,L,i,N,D)),
                this.Re = new zd(this.logger),
                this.gu = new Xd(po,this.Re.load,this.logger);
                const u = this.aa;
                u.setHlsEntity({
                    id: r,
                    config: F
                });
                var c, h, p, m, f, g, y, v, S, I, b, T, E, A, O, R, w, P, M, C, U, _, k, V, t = this.Jl.query, e = new ql(new jl), L = this.Xa.interstitialQuery, i = (this.Ca.next(L),
                this.Ja = new ng(this,this.logger,this.Nr,this.Re,this.Aa,this.Yl),
                this.Su = new hg(this.itemQueue,this.Xa,Fr([this.Ra, this.Pa, this.Ca]),F,this.Nr.rtcQuery,this.Ja,this.Re,this.logger),
                this.Ja.setInterstitialQuery(L),
                w = this.Jl,
                ( () => {
                    if ("function" == typeof matchMedia) {
                        var e = matchMedia("(dynamic-range: high)")
                          , t = matchMedia("bad query");
                        if (e.media !== t.media)
                            return t = "function" == typeof e.addEventListener ? da(e, "change") : "function" == typeof e.addListener ? ca(e.addListener.bind(e), e.removeListener.bind(e)) : X,
                            ne(Y(e.matches), t.pipe(W(Oh)))
                    }
                    return Y(!0)
                }
                )().pipe(ie(e => {
                    w.updateSupportsHdr(e)
                }
                )).pipe(wn(X))), N = this.Gl.pipe((b = F,
                E = (T = this).hu,
                A = this.logger,
                O = this.Lr,
                R = this.Nr,
                e => e.pipe(te(e => e ? ((e = new Th(e,new zc,b,T,E,A,O,R)).openMediaSource(),
                ne(e, Y(e))) : Y(null)))), ie(e => {
                    e = null != (e = null == e ? void 0 : e.mediaQuery) ? e : null,
                    this.Ja.setMediaElementQuery(e),
                    this.Pa.next(e)
                }
                ), ee( () => {
                    this.Ja.setInterstitialQuery(null),
                    this.Pa.next(null)
                }
                ), Tn()), D = (c = e,
                h = N,
                p = this.Lr,
                m = F,
                f = t,
                y = (g = this).Nr,
                v = this.Re,
                S = this.logger,
                P = F.keyLoadPolicy,
                M = this.Aa,
                C = e.query,
                U = this.itemQueue,
                I = e => e.pipe(Fa(e => {
                    const t = M.query.getActiveId()
                      , i = C.getKeyInfo(e.uri);
                    i && i.mediaOptionKeys.some( ({itemId: e}) => e === t) && ig(i, !1, M.getQueryForId(t), M)
                }
                ), In({
                    delay: (e, t) => {
                        if (e instanceof Fo || e instanceof Bo)
                            return rg(e, t - 1, to(e, eo({
                                url: e.keyuri
                            }, P)), M, C, U);
                        throw e
                    }
                })),
                new G(e => {
                    const t = new Ql(c,h,m,f,g,y,v,S,I);
                    return e.next(t),
                    function() {
                        p.wrap(t.destroy()).subscribe()
                    }
                }
                ).pipe(ie(e => this.Zl = e))), L = (this.rs = ( () => {
                    let e = null;
                    return null != F.createRPCService && (e = Qh(F.createRPCService, Uh)),
                    (e = null == (e = F.enableWorker && null == e ? Kh : e) ? Uh : e)(this.logger)
                }
                )(),
                this.Xl = (r = this.rs,
                {
                    crypto: new Dh(r),
                    mux: new xh(r)
                }),
                this.itemQueue.activeItemById$.pipe(te(e => Fr([this.wu(e, this.itemQueue, this.Wl, this.logger), this.Tu(e, this.itemQueue.isPreloading(), F)]).pipe(W( ([,e]) => e))), In({
                    delay: this.Iu.bind(this)
                }))), t = this.itemQueue.activeItemById$.pipe(W(e => e ? Ls(e) : void 0), Kl(), J(), (_ = F,
                k = this.Fl,
                V = this.logger,
                e => e.pipe(J(), te(r => new G( () => {
                    var e, t;
                    t = r,
                    (e = k).getQueryForId(t).hasEntity(t) ? e.setActive(t) : e.addEmptyEntity(t);
                    const i = k.getQueryForId(r);
                    return () => {
                        ip.setCombinedEstimate(_, Object.assign({}, i.getCombinedEstimate()), V, r),
                        k.remove(r)
                    }
                }
                ))))), e = Fr([L, N.pipe(iy(F, this, this.logger), ie( ({legibleSystemAdapter: e, mediaSink: t}) => {
                    this.tu = e,
                    this.Su.mediaQuery = null == t ? void 0 : t.mediaQuery,
                    this.Wl = t
                }
                ))]).pipe(ie( ([e,t]) => {
                    var i, r, {legibleSystemAdapter: t, mediaSink: n} = t;
                    e && this.Zl && t && n ? ({rootPlaylistQuery: e, mediaParser: i, config: r} = e,
                    this.ru.next({
                        logger: this.logger,
                        config: r,
                        hlsService: this.aa,
                        platformService: this.Jl,
                        statsService: this.Fl,
                        rtcService: this.Nr,
                        rpcClients: this.Xl,
                        hlsQuery: this.aa.query,
                        rootPlaylistService: this.Aa,
                        rootPlaylistQuery: e,
                        mediaLibraryService: this.Yl,
                        keySystemAdapter: this.Zl,
                        legibleSystemAdapter: t,
                        mediaSink: n,
                        mediaParser: i,
                        iframeClock: this.eu,
                        playerEvents: this.Ja,
                        mediaSelectionBossService: this.yu,
                        interstitialService: this.Xa,
                        interstitialController: this.Su,
                        customUrlLoader: this.Re,
                        gaplessInstance: this.uu,
                        itemQueue: this.itemQueue,
                        errorRecovery: this.hu,
                        operationQueue$: this.su
                    })) : this.ru.next(void 0)
                }
                )), r = this.ru.pipe(Pr(Zn), te(u => {
                    if (!u)
                        return X;
                    if (u.rootPlaylistQuery.itemId !== (null == (N = this.itemQueue.activeItem) ? void 0 : N.itemId))
                        return X;
                    const {rootPlaylistQuery: a, mediaSink: s, itemQueue: e, logger: t, config: o} = u
                      , l = s.mediaQuery
                      , i = a.mediaOptionListQueries[se.Variant].hasIframes
                      , r = function(r) {
                        if (!r)
                            return X;
                        const {logger: e, config: t, platformService: i, rootPlaylistService: n, rootPlaylistQuery: a, keySystemAdapter: s, mediaSink: o, mediaParser: l, gaplessInstance: d, operationQueue$: u, itemQueue: c} = r
                          , h = a["itemId"]
                          , p = [Ag(e, a, u)]
                          , m = s.keyStatusChange$.pipe((f = r,
                        e => e.pipe(_r( (e, t) => {
                            var {decryptdata: e, status: i, error: r} = e
                              , n = f["itemQueue"];
                            if ("needs-renewal" === i)
                                return xf(f, e, void 0);
                            if ("error" !== i || !(r instanceof Bo || r instanceof Fo) || r.handled)
                                return X;
                            {
                                const {rootPlaylistService: e, keySystemAdapter: t} = f;
                                return rg(r, 0, null, e, t.ksQuery, n)
                            }
                        }
                        ), te( () => X))));
                        var f, g = i.query, y = a.mediaOptionListQueries[se.Variant], v = y.filteredMediaOptionList, S = y.mediaOptionListInfo.hasHdrLevels;
                        return p.push(S ? g.displaySupportsHdr$.pipe(J(), te(e => (e = function(s, o, l) {
                            const {config: d, logger: e, mediaLibraryService: u, mediaSink: t, rootPlaylistQuery: c, rootPlaylistService: h, itemQueue: p} = s
                              , m = t["mediaQuery"];
                            return {
                                operation: Yh.RendererSwitch,
                                priority: Xh.Normal,
                                execute: (t, e, i, r) => {
                                    var n = na( () => (h.setHDRPreference(o, p, l, !0),
                                    ue)).pipe(te(e => Zf(s, t, 0, r).pipe(Pn(eg(t, i, c, u, m, d)))))
                                      , a = na( () => ue);
                                    return ha( () => !1, na( () => ue), en(n, a))
                                }
                                ,
                                logger: e
                            }
                        }(r, h, e),
                        u.next(e),
                        X))) : na( () => {
                            var e = function(n) {
                                const {logger: e, rootPlaylistQuery: a, mediaLibraryService: s, mediaSink: t, config: o} = n
                                  , l = t.mediaQuery;
                                return {
                                    operation: Yh.VariantSwitch,
                                    priority: Xh.Normal,
                                    execute: (e, t, i, r) => Zf(n, e, 0, r).pipe(Pn(eg(e, i, a, s, l, o))),
                                    logger: e
                                }
                            }(r);
                            return u.next(e),
                            X
                        }
                        )),
                        p.push(kr(m, sr).pipe(Eg(e, "keyStatusChange")), function(u) {
                            const {rootPlaylistQuery: c, mediaSink: h, mediaLibraryService: e, config: p, itemQueue: m} = u
                              , {livePlaylistUpdateStaleness: a, liveAllowLowLatencyPlayback: f} = p
                              , g = h.mediaQuery
                              , t = Fr([c.enabledMediaOptionByType$(se.Variant).pipe(Rg(e, f)), c.hasAlternateWithUrl(se.AltAudio) ? c.enabledMediaOptionByType$(se.AltAudio).pipe(Rg(e, f)) : nl]);
                            return Fr([t, g.msReadyState$, g.desiredRate$]).pipe(te( ([e,t]) => "open" !== t || !e[se.Variant] || e.some(e => {
                                return null != e && !0 === e.mediaOptionDetails.liveOrEvent && ([e,t,i=!1] = [e, a, f],
                                !((n = null == e ? void 0 : e.mediaOptionDetails) && (r = performance.now(),
                                e = e.lastUpdateMillis || r,
                                i && Pp(n) ? r - e < t * n.partTargetDuration * 1e3 : r - e < t * n.targetduration * 1e3)));
                                var t, i, r, n
                            }
                            ) ? X : ce(g.updating$, e => !e).pipe(rn(e), Fa( ([e,t]) => {
                                var i, r;
                                const n = g.bufferedRangeTuple
                                  , a = [e.mediaOptionDetails, null == t ? void 0 : t.mediaOptionDetails]
                                  , s = !Mp(a)
                                  , o = Cp(a);
                                let l = !0
                                  , d = NaN;
                                if (s) {
                                    const u = h.liveSeekableRange;
                                    if (o) {
                                        const u = hm(a, p)
                                          , m = Math.max(e.lastUpdateMillis, null != (r = null == t ? void 0 : t.lastUpdateMillis) ? r : -1 / 0);
                                        h.updateLiveSeekableRange(u.start, u.end, u.edge, u.boundary, m),
                                        function(e, s, o, l) {
                                            if (1 !== l.desiredRate)
                                                return !1;
                                            const t = l.desiredPos
                                              , d = o.maxSeekHole
                                              , u = {
                                                avgPlaylistLoadTimeMs: 0,
                                                avgPlaylistParseTimeMs: 0
                                            }
                                              , c = l.getBufferInfo(t, d);
                                            return e.map(e => e && e.mediaOptionDetails ? cm(e.mediaOptionDetails, o) : null),
                                            !e.every( (e, t) => {
                                                var i, r, n, a = null == e ? void 0 : e.mediaOptionDetails;
                                                return !(null != a && !l.canContinuePlaybackWithoutGap(a, null != (e = null == e ? void 0 : e.lastUpdateMillis) ? e : 0, u, d)) || (e = s[t],
                                                t = null == (t = c[t]) ? void 0 : t.buffered,
                                                !(!e || !t) && a.itemId === e.itemId && a.mediaOptionId === e.mediaOptionId && ({part: r, mediaSeqNum: i, partIndex: n} = e,
                                                r ? i >= a.partStartSN && (i < a.partEndSN || i === a.partEndSN && n <= a.partEndIndex) : i >= a.startSN && i <= a.endSN) && (r = {
                                                    start: e.start,
                                                    end: e.start + e.duration
                                                },
                                                n = cm(a, o),
                                                mm(r, t, d) && mm(r, n, d)))
                                            }
                                            )
                                        }([e, t], c.getInFlightFrags(), p, g) && (d = p.liveResumeAtWindowStart ? 0 : 1 / 0)
                                    } else {
                                        if (6e4 < performance.now() - (null == u ? void 0 : u.tupdate)) {
                                            const {start: c, end: e, edge: p, boundary: t, tupdate: m} = u
                                              , i = performance.now() - m
                                              , f = i / 1e3;
                                            h.updateLiveSeekableRange(c + f, e + f, p + f, t + f, m + i),
                                            h.msDuration += f,
                                            d = p + f
                                        }
                                        l = !1
                                    }
                                } else
                                    h.clearLiveSeekableRange();
                                if (l) {
                                    const u = n[oe.Variant]
                                      , c = n[oe.AltAudio]
                                      , e = null != (r = null == (i = null == u ? void 0 : u[u.length - 1]) ? void 0 : i.end) ? r : 0
                                      , p = null != (i = null == (i = null == c ? void 0 : c[c.length - 1]) ? void 0 : i.end) ? i : 0
                                      , t = Math.max(e, p)
                                      , g = isNaN(h.msDuration) ? 0 : h.msDuration
                                      , s = Math.max(zp(a[se.Variant], f), a[se.AltAudio] ? zp(a[se.AltAudio], f) : 0)
                                      , o = (h.msDuration = Math.max(g, s, t),
                                    Xc(m.getQueueItemForId(a[se.Variant].itemId)) || 0);
                                    h.primaryContentDuration = s - o
                                }
                                return isNaN(d) || u.interstitialController.interstitialIsPlaying() || h.seekWithOptions(d, void 0, !0),
                                X
                            }
                            ))))
                        }(r), function() {
                            const {mediaSink: e, interstitialController: u, statsService: c} = r
                              , t = e.mediaQuery;
                            return Fr([Y(r), t.desiredRate$.pipe(dn())]).pipe(te( ([e,[t,i]]) => {
                                const {rootPlaylistQuery: n, rootPlaylistService: r, config: a, mediaSink: s, mediaLibraryService: o, itemQueue: l} = e
                                  , d = s.mediaQuery;
                                if (0 === t && 1 === i) {
                                    const e = _s.every(e => {
                                        var t, e = n.enabledMediaOptionKeys[e], e = o.getQueryForOption(e), i = c.getQueryForId(null != (i = n.statsId) ? i : ""), r = l.getQueueItemForId(n.itemId), e = e.mediaOptionDetailsEntity;
                                        return !(null != (t = null == e ? void 0 : e.mediaOptionDetails) && t.ptsKnown) || d.canContinuePlaybackWithoutGap(e.mediaOptionDetails, null != (t = e.lastUpdateMillis) ? t : 0, i.getPlaylistEstimate(a, null == r ? void 0 : r.serviceName), a.maxBufferHole)
                                    }
                                    );
                                    if (!e && !u.interstitialIsPlaying())
                                        return s.pause(),
                                        _s.forEach(e => {
                                            r.updateInflightFrag(n.itemId, e, null, null, null, null)
                                        }
                                        ),
                                        s.flushAll(0, 1 / 0, !0)
                                }
                                return X
                            }
                            ), te( () => X))
                        }()),
                        t.useViewportSizeForLevelCap && v.some(e => re(e.width) && re(e.height)) && p.push(g.viewportInfo$.pipe(J( (e, t) => e && t && e.width === t.width && e.height === t.height), ie(e => {
                            n.setViewportInfo(h, e)
                        }
                        ))),
                        (S || v.some(e => null != e.hdcpLevel)) && p.push(Fr([a.hdrMode$.pipe(J()), a.maxHdcpLevel$.pipe(J())]).pipe(On(1), te( ([]) => ((null == c ? void 0 : c.playingItem.itemId) !== h || d.inGaplessMode || 0 !== a.itemStartPosition || (o.resetMediaSource(),
                        l.reset()),
                        X)))),
                        y.hasIframes && p.push(function() {
                            const {rootPlaylistQuery: a, mediaSelectionBossService: s, mediaSink: e} = r
                              , t = e.mediaQuery
                              , i = a.enabledVariantMediaOption$;
                            return Fr([Y(r), t.desiredRate$.pipe(dn())]).pipe(J( (e, t) => e[1] === t[1]), xn(i), te( ([[e,[t,i]],r]) => {
                                var n, t = Yc(t), i = Yc(i);
                                return t !== i && ({rootPlaylistService: t, logger: n} = e,
                                i) && a.nextMaxAutoOptionId === de.mediaOptionId && (t.setNextMaxAutoOptionId(a.itemId, r.mediaOptionId),
                                null != s) && s.setTransformer(a.itemId, le.BitrateFilter, new Nc(0,r.bitrate)),
                                X
                            }
                            ))
                        }()),
                        ne(...p).pipe(te( () => X))
                    }(u).pipe(In({
                        delay: this.Iu.bind(this)
                    }))
                      , n = e.activeItem;
                    Yc(n.initialRate) && this.Ou(this.desiredRate, n.initialRate, n.initialSeekTime),
                    a.isInterstitial || this.nu || this.ku(t),
                    this.Wl.addAirPlaySource(n.url);
                    var d, c, h, p, m, f, g, y, v, S, I, b, T, E, A, O, R, w, P, M, C, k, L, N = l.gotFirstAppend$(sr).pipe(te( () => {
                        var e = [function(e) {
                            const t = e.mediaSink.mediaQuery
                              , i = e.rootPlaylistQuery.statsId;
                            return i ? kr(ne(t.seekTo$.pipe(Z(e => re(null == e ? void 0 : e.pos))), t.flushing$.pipe(dn(), Z( ([e,t]) => !0 === e && !1 === t))), sr).pipe(ie( () => nm(e.config, e.logger, e.rootPlaylistQuery, e.mediaSink, e.mediaLibraryService, e.statsService.getQueryForId(i)))) : X
                        }(u), function(n) {
                            const {rootPlaylistQuery: a, mediaLibraryService: r, mediaSink: s, config: o} = n;
                            return ce(a.lastLoadedMediaOptionByType$(se.Variant), e => !!e).pipe(te(e => {
                                if (!(e = r.getQueryForOption(e).mediaOptionDetails))
                                    return X;
                                s.startMonitors(),
                                s.bufferMonitorTargetDuration = e.targetduration;
                                const t = performance.now()
                                  , i = [];
                                return Us.forEach(e => {
                                    e !== se.Variant && !a.hasAlternateWithUrl(e) || i.push(a.enabledMediaOptionByType$(e).pipe(Ff(r), te(e => e ? e.mediaOptionDetailsEntity$ : X), J( (e, t) => (null == e ? void 0 : e.lastUpdateMillis) === (null == t ? void 0 : t.lastUpdateMillis)), Z(e => !1 === (null == e ? void 0 : e.detailsLoading) && e.lastUpdateMillis > t)))
                                }
                                ),
                                ne(...i).pipe(Pr(sr), ie(e => {
                                    var t = s.mediaQuery
                                      , i = n.legibleSystemAdapter
                                      , r = e.mediaOptionDetails
                                      , e = e.lastUpdateMillis;
                                    if (r.liveOrEvent && i && t.readyState >= HTMLMediaElement.HAVE_METADATA)
                                        if (r.mediaOptionType !== se.Variant || Ds(a.enabledMediaOptionKeys[se.Subtitle])) {
                                            if (r.mediaOptionType === se.Subtitle) {
                                                const n = Og(t, o.liveOldCueRemovalOffsetSec, o.maxBufferHole);
                                                i.removeEarlierCues(n)
                                            }
                                        } else {
                                            const n = Og(t, o.liveOldCueRemovalOffsetSec, o.maxBufferHole);
                                            i.removeEarlierId3Cues(n)
                                        }
                                    if (function(e, t, i, r, l) {
                                        return t = function(e, t, i, r, n) {
                                            if (!t.ptsKnown)
                                                return 0;
                                            var a = t.targetduration
                                              , s = cm(t, l).start
                                              , n = n.canContinuePlaybackWithoutGap(t, i, {
                                                avgPlaylistLoadTimeMs: 0,
                                                avgPlaylistParseTimeMs: 0
                                            }, r);
                                            let o = Math.max(0, e - a);
                                            return o = e < s && !n ? s : o
                                        }(r.desiredPos, e, t, i, r),
                                        i = cm(e, l).end,
                                        {
                                            expired: e.liveOrEvent && e.ptsKnown && i < t,
                                            windowEnd: i,
                                            minPosition: t
                                        }
                                    }(r, e, o.maxBufferHole, t, o).expired)
                                        throw new zs(!1,H.LivePlaylistTooFar,!1,r.mediaOptionType,r.mediaOptionId,r.url)
                                }
                                ))
                            }
                            ))
                        }(u).pipe(Eg(t, "enabledOptions")), l.ended$.pipe(te(e => e ? X : ce(ma([l.gotPlaying$, l.readyState$]), ([e,t]) => !0 === e || t >= HTMLMediaElement.HAVE_METADATA).pipe(te( () => yr(0, 1e3)), ie( () => {
                            this.Mu(F, l)
                        }
                        ))))];
                        return this.inGaplessMode || e.push(function() {
                            const {config: e, mediaSink: t, rootPlaylistQuery: i, mediaLibraryService: r, gaplessInstance: n} = u
                              , a = t["mediaQuery"];
                            return Fr([Uf(i, r), a.msReadyState$, a.updating$, a.isIframeRate$, a.isBufferedToEnd$(e.maxBufferHole, !n.inGaplessMode)]).pipe(Z( ([,e,t,i,r]) => "open" === e && !1 === t && !i && r), ie( ([e]) => {
                                null != e[0] && e.every(e => null == e || !1 === e.liveOrEvent && !1 === e.iframesOnly) && !n.inGaplessMode && t.endStream()
                            }
                            ), wn(X))
                        }()),
                        i && o.enableIFramePreloading && e.push((a => {
                            const {config: e, logger: n, mediaLibraryService: s, rootPlaylistQuery: o} = a;
                            var t;
                            return e.enableIFramePreloading ? (t = o.enabledMediaOptionByType$(se.Variant).pipe(te(e => {
                                return t = s.getQueryForOption(e),
                                i = o,
                                r = i.mediaOptionListQueries[se.Variant].hasIframes,
                                t = null != (i = null == (t = t.getEntity(i.itemId)) ? void 0 : t.liveOrEvent) && i,
                                r && !t ? function(e, t) {
                                    var {rootPlaylistQuery: i, logger: r, config: n, mediaSink: a, statsService: s, mediaLibraryService: o, mediaSelectionBossService: l} = t
                                      , a = a["mediaQuery"]
                                      , s = s.getQueryForId(null != (s = i.statsId) ? s : "")
                                      , n = Om(!0, n, i, o.getQueryForOption(e), a, s, l, r);
                                    return (e = i.variantMediaOptionById(n.variantMediaOption)) ? o.retrieveMediaOptionDetails(t, e, !0, !1) : X
                                }(e, a).pipe(tn(1), sn(e => {
                                    var t = a
                                      , {mediaSink: i, mediaLibraryService: r, rootPlaylistQuery: n} = t;
                                    if (null != (i = Hp(i = (i = i["mediaQuery"]).currentTime, null != (i = Qp(e, i)) ? i : -1, e)) && i.mediaFragment)
                                        return aa([(e = i.mediaFragment).keyTagInfo ? xf(t, e.keyTagInfo, {
                                            itemId: e.itemId,
                                            mediaOptionId: e.mediaOptionId,
                                            appItemId: n.appItemId
                                        }) : X, r.retrieveInitSegmentCacheEntity(t, e, e.discoSeqNum)]).pipe(W( () => tf.SUCCESS));
                                    throw new j(!1,H.NoIframeFragmentToPrefetch)
                                }
                                ), $(e => (n.error(ey, `got error ${e.message} in prefetch`),
                                Y(tf.ERRORED)))) : Y(tf.DISABLED);
                                var t, i, r
                            }
                            )),
                            Jg(a, t).pipe(tn(1), ee( () => {}
                            ))) : Y(tf.DISABLED)
                        }
                        )(u)),
                        o.enableItemPreloading && this.inGaplessMode && (this.Yl.clearPrefetchCache(),
                        this.Ja.triggerPrefetchNextItem(this.itemQueue.activeItem.appItemId),
                        e.push((e => {
                            const {config: t, logger: i, mediaLibraryService: r, itemQueue: n} = e
                              , a = i.child({
                                name: ey
                            })
                              , s = Object.assign(Object.assign({}, e), {
                                logger: a
                            });
                            return t.enableItemPreloading ? n.prefetchItem$.pipe(Kl(), J( (e, t) => t.appItemId === e.appItemId)).pipe(te(t => {
                                var e, i = null == t ? void 0 : t.url;
                                return i && t.appItemId ? (r.addPrefetchItem(null != (e = t.appItemId) ? e : "", i, a),
                                Jg(s, function(e, t) {
                                    var i;
                                    const {logger: r, mediaLibraryService: n, hlsService: a, config: s} = t
                                      , o = e.url
                                      , l = null != (i = e.appItemId) ? i : "";
                                    return function(n, e, t, a, s, i) {
                                        const r = eo({
                                            url: n.url
                                        }, e)
                                          , {mediaSelectionBossService: o, statsService: l, hlsService: d, platformService: u, customUrlLoader: c} = t;
                                        return Mo({
                                            url: n.url,
                                            xhrSetup: s.xhrSetup
                                        }, r, i, c).pipe(W(e => Mg(n.url, e, n, s, a)), te(e => {
                                            var t = u.query
                                              , i = t.displaySupportsHdr
                                              , r = jg(e)["variantMediaOptions"];
                                            return qg(e, t.platformInfo, o, s, i, n.isInterstitial, r, a)
                                        }
                                        ), W(e => {
                                            var t = l.getQueryForId(null != (t = n.serviceName) ? t : "")
                                              , t = s.enableAdaptiveStartup ? t.getCombinedEstimate(s, n.serviceName) : null;
                                            return e.loadStats && !Object.isFrozen(e.loadStats) && (e.loadStats.tfiltered = performance.now()),
                                            Yg(0, null, e, d, o, performance.now(), s, t, a)
                                        }
                                        ), io(!1))
                                    }(e, s.manifestLoadPolicy, t, r, s, a.query.extendMaxTTFB).pipe(Zg(t, l, o, rf.Manifest), W(t => (n.cachePrefetchRootEntity(l, t),
                                    t.mediaOptionListTuple[se.Variant].mediaOptions.find(e => e.mediaOptionId === t.enabledMediaOptionKeys[se.Variant].mediaOptionId))), function(i, r, n, a) {
                                        const {config: s, mediaLibraryService: o} = r;
                                        return function() {
                                            for (var e = [], t = 0; t < arguments.length; t++)
                                                e[t] = arguments[t];
                                            return Fi(e)
                                        }(te(e => {
                                            var t;
                                            if (void 0 !== e && e.url)
                                                return t = e.mediaOptionId,
                                                function(a, s, e, t, o) {
                                                    const {logger: l, hlsService: i, customUrlLoader: r} = e
                                                      , {playlistLoadPolicy: n, keySystemPreference: d} = t
                                                      , u = eo({
                                                        url: o
                                                    }, n)
                                                      , c = i.query.extendMaxTTFB;
                                                    return Mo({
                                                        url: o,
                                                        xhrSetup: t.xhrSetup
                                                    }, u, c, r).pipe(W( ({responseText: e, responseURL: t, stats: i}) => {
                                                        t = t || o;
                                                        var r = performance.now()
                                                          , e = ef.parseMediaOptionPlaylist(e, null != t ? t : o, d, {}, a, s, se.Variant, l, 0, !1)
                                                          , t = performance.now()
                                                          , n = e["mediaOptionDetails"]
                                                          , r = {
                                                            playlistLoadTimeMs: i.tload - i.trequest,
                                                            playlistParseTimeMs: t - r,
                                                            tparsed: {
                                                                tbegin: r,
                                                                tend: t
                                                            }
                                                        };
                                                        return {
                                                            mediaOptionDetails: n,
                                                            isDeltaPlaylist: e.isDeltaPlaylist,
                                                            interstitials: [],
                                                            bwSample: i,
                                                            playlistSample: r
                                                        }
                                                    }
                                                    ), ro(se.Variant, s, !1, o))
                                                }(i.itemId, t, r, s, e.url).pipe(Zg(r, n, null != (t = e.url) ? t : "", rf.Playlist), te(e => {
                                                    var e = e["mediaOptionDetails"]
                                                      , t = (o.cachePrefetchDetails(n, e),
                                                    e.fragments[0])
                                                      , i = null != (i = e.url) ? i : ps(null != (i = e.relativeUrl) ? i : "", null != (i = us.getBaseURL(a)) ? i : "");
                                                    return (e = o.cachePrefetchSegment(r, n, e, t)) ? e.pipe(Zg(r, n, i, rf.Segment)) : X
                                                }
                                                ));
                                            throw new j(!1,H.NoVariantMediaOptionToPrefetch)
                                        }
                                        ))
                                    }(e, t, l, o))
                                }(t, s)).pipe($(e => (a.error(`Caught unhandled error in item prefetch path: ` + JSON.stringify(e)),
                                r.setPrefetchErrored(null != (e = t.appItemId) ? e : ""),
                                Y(tf.ERRORED))))) : Y(tf.DISABLED)
                            }
                            ), tn(1), ee( () => {}
                            )) : Y(tf.DISABLED)
                        }
                        )(u))),
                        a.sessionData && e.push(kr(ce(l.gotPlaying$, e => e), sr).pipe(te( () => Fr([a.sessionData$, this.aa.query.config$])), tn(1), te( ([e,t]) => this.gu.loadSessionData(e, t)), ie(e => {
                            this.Aa.setSessionData(a.itemId, e)
                        }
                        ), $(e => (this.logger.error(`SessionData err:` + e.message),
                        X)))),
                        ne(...e)
                    }
                    )), D = [Tg(this.itemQueue, this.aa, u), r], x = (null != a.contentSteeringOption && D.push(Y(u).pipe((k = o,
                    L = o.steeringManifestLoadPolicy,
                    e => e.pipe(te(i => {
                        const {logger: t, operationQueue$: r, rootPlaylistQuery: e, statsService: n, itemQueue: a, customUrlLoader: h, hlsService: s} = i
                          , o = e["itemId"]
                          , l = e["rootPlaylistEntity"]
                          , d = l["contentSteeringOption"]
                          , p = new Map;
                        if (null == d || !i.config.enableContentSteering)
                            return pa;
                        const m = n.getQueryForId(e.statsId)
                          , f = a.getQueueItemForId(o)
                          , u = new pn(3e5);
                        let g = d["serverURI"]
                          , y = l["baseUrl"];
                        const v = s.query.extendMaxTTFB;
                        return ue.pipe(te( () => {
                            return i = g,
                            r = y,
                            n = k,
                            a = L,
                            s = h,
                            o = e.currentPathwayID,
                            l = new Set([...p.keys()]),
                            d = m.getBandwidthEstimate(k, null == f ? void 0 : f.serviceName),
                            u = v,
                            c = t,
                            na( () => {
                                var e, t = el(i);
                                return null != t ? Y({
                                    responseText: Ee.utf8arrayToStr(t),
                                    responseURL: i
                                }) : (t = [],
                                (e = es.parseURL(i)) && "" !== e.query && "?" !== e.query && t.push(e.query.substr(1)),
                                null != o && t.push(`_HLS_pathway=` + encodeURIComponent(o)),
                                null != d && re(d.avgBandwidth) && t.push(`_HLS_throughput=` + Math.round(d.avgBandwidth)),
                                0 < t.length && e && (e.query = "?" + t.join("&"),
                                i = es.buildURLFromParts(e)),
                                t = eo({
                                    url: i
                                }, a),
                                Mo({
                                    url: i,
                                    xhrSetup: n.xhrSetup
                                }, t, u, s))
                            }
                            ).pipe(W( ({responseText: e, responseURL: t}) => ({
                                steeringManifest: wp(e, r, l, c),
                                responseURL: t
                            })));
                            var i, r, n, a, s, o, l, d, u, c
                        }
                        ), ie( ({steeringManifest: e, responseURL: t}) => {
                            y = t,
                            null != e.reloadURI && (g = e.reloadURI),
                            u.next(1e3 * e.ttl),
                            t = function(s, o, l) {
                                const {config: d, logger: e, mediaLibraryService: u, mediaSink: t, rootPlaylistQuery: c, rootPlaylistService: h, mediaSelectionBossService: p} = s
                                  , m = t["mediaQuery"];
                                return {
                                    operation: Yh.ContentSteering,
                                    priority: Xh.Low,
                                    execute: (t, e, i, r) => {
                                        var n = na( () => (ae( () => {
                                            var e, t = o["pathwayPriority"], i = (i = c["rootPlaylistEntity"]).mediaOptionListTuple[se.Variant], r = null != (r = o.pathwayClones) ? r : [];
                                            (!function(t=[], i=[]) {
                                                if (t.length !== i.length)
                                                    return !1;
                                                for (let e = 0; e < t.length; e++)
                                                    if (t[e] !== i[e])
                                                        return !1;
                                                return !0
                                            }(i.pathwayPriority, t) || r.length) && (i = d.enableBoss,
                                            e = d.enableContentSteering,
                                            i && e && null != p && p.setTransformer(c.itemId, le.ContentSteeringPathwayCloner, new _c(r,c.baseUrl,l)),
                                            h.doPathwaySwitch(c.itemId, t, l))
                                        }
                                        ),
                                        ue)).pipe(te(e => Zf(s, t, 0, r).pipe(Pn(eg(t, i, c, u, m, d)))))
                                          , a = na( () => ue);
                                        return ha( () => !1, na( () => ue), en(n, a))
                                    }
                                    ,
                                    logger: e
                                }
                            }(i, e, p),
                            r.next(t)
                        }
                        ), $(e => (t.error("error in Content Steering epic:", e),
                        ue)), (c = () => u.pipe(Mn(e => 0 < e), te(e => yr(e))),
                        Ht(function(t, i) {
                            var r, n, a = !1, s = !1, o = !1, l = function() {
                                return o && s && (i.complete(),
                                !0)
                            }, d = function e() {
                                o = !1,
                                r = t.subscribe(Wi(i, void 0, function() {
                                    o = !0,
                                    l() || (n || (n = new z,
                                    c().subscribe(Wi(i, function() {
                                        r ? d() : a = !0
                                    }, function() {
                                        s = !0,
                                        l()
                                    }))),
                                    n.next())
                                })),
                                a && (r.unsubscribe(),
                                r = null,
                                a = !1,
                                e())
                            };
                            d()
                        })));
                        var c
                    }
                    ), wn(pa))))),
                    F.enableBoss && this.yu && D.push((d = a,
                    c = this.yu,
                    d.hdrMode$.pipe(te(e => {
                        var t = new Oc(d.hasHdrLevels,d.preferHDR);
                        return null != c && c.setTransformer(d.itemId, le.HDRFilter, t),
                        X
                    }
                    ))), (M = a,
                    C = this.yu,
                    M.maxHdcpLevel$.pipe(te(e => (e = new wc(e),
                    null != C && C.setTransformer(M.itemId, le.HDCPFilter, e),
                    X)))), (R = this.Aa,
                    w = a,
                    P = this.yu,
                    w.pathwayPenaltyBox$.pipe(te(e => {
                        var t;
                        return null != R && R.isContentSteeringEnabled() && (t = new Ac(e),
                        null != P && P.setTransformer(w.itemId, le.PathwayPenaltyBoxFilter, t),
                        function(e, i) {
                            if (e.rootPlaylistEntity) {
                                const t = e.rootPlaylistEntity.mediaOptionListTuple[se.Variant].pathwayPriority;
                                if (t && t.find(t => !i.find(e => e.id === t)) !== e.currentPathwayID)
                                    return !0
                            }
                            return !1
                        }(w, e)) && R.doPathwaySwitch(w.itemId),
                        X
                    }
                    ))), (A = a,
                    O = this.yu,
                    A.viewportInfo$.pipe(te(e => (e = new Rc(e),
                    null != O && O.setTransformer(A.itemId, le.ViewportFilter, e),
                    X)))), (T = a,
                    E = this.yu,
                    T.variantRemoved$.pipe(te(e => (e = new bc(e),
                    null != E && E.setTransformer(T.itemId, le.PermanentRemovalFilter, e),
                    X)))), (I = a,
                    b = this.yu,
                    I.variantCompatibleIds$.pipe(te(e => (e = new Tc(e),
                    null != b && b.setTransformer(I.itemId, le.CompatibleIdsFilter, e),
                    X)))), (v = a,
                    S = this.yu,
                    v.variantPenaltyBox$.pipe(te(e => (e = new Ec(e),
                    null != S && S.setTransformer(v.itemId, le.PenaltyBoxFilter, e),
                    X)))), (f = a,
                    g = this.yu,
                    y = this.fu,
                    x = f.enabledMediaOptionKeys$.pipe(J( (e, t) => e[se.AltAudio].mediaOptionId === t[se.AltAudio].mediaOptionId && e[se.Subtitle].mediaOptionId === t[se.Subtitle].mediaOptionId)),
                    ma([f.combinedAltAudioFilterChange$, f.combinedSubtitleFilterChange$, x]).pipe(te( ([e,t,i]) => {
                        var r = f.mediaOptionListQueries
                          , n = f.getEnabledMediaOptionMask()
                          , a = f.enabledVariantMediaOption
                          , s = f.enabledMediaOptionKeys[se.AltAudio]
                          , s = Ds(s) ? f.alternateMediaOptionById(se.AltAudio, s.mediaOptionId) : null
                          , a = q.getStickyAtmosStatus(y.useStickyAtmosFilter, a.audioCodec, null == s ? void 0 : s.channels)
                          , s = r[se.AltAudio].mediaOptionFromId(i[se.AltAudio].mediaOptionId)
                          , r = r[se.Subtitle].mediaOptionFromId(i[se.Subtitle].mediaOptionId)
                          , i = new Fc(a,e,t,null == s ? void 0 : s.persistentID,null == r ? void 0 : r.persistentID,n,[null == r ? void 0 : r.backingMediaOptionId],!1)
                          , a = new Map([[le.ValidAlternatesFilter, i], [le.ErrorHandlingValidAlternatesFilter, i]]);
                        return null != g && g.setMultipleTransformers(f.itemId, a),
                        X
                    }
                    ))), (h = this.Aa,
                    p = a,
                    m = this.yu,
                    p.currentPathwayID$.pipe(te(e => (null != h && h.isContentSteeringEnabled() && null != m && m.setTransformer(p.itemId, le.MatchingPathwayFilter, new Uc(e)),
                    X))))),
                    o.enableInterstitialPlayback && D.push(this.Su.postRollCheck$(l, u)),
                    (this.inGaplessMode || o.enableInterstitialPlayback) && D.push(this.itemQueue.playing$.pipe(Kl(), J( (e, t) => e.itemId === t.itemId), te(n => {
                        const a = this.Eu(n.itemId);
                        return ce(a.rootPlaylistEntity$, e => !!e).pipe(te(e => {
                            if (o.enableInterstitialPlayback) {
                                const e = this.Xa.interstitialQuery.playingInterstitialId
                                  , i = Xc(n)
                                  , r = a.enabledAlternateMediaOptionByType(se.Subtitle);
                                this.tu.handlePlayingItemChanged({
                                    playingInterstitialId: e,
                                    startTime: i,
                                    subtitleMediaOption: r
                                });
                                var t = {
                                    itemId: n.itemId,
                                    isInterstitial: n.isInterstitial
                                };
                                this.trigger(K.ITEM_PLAYING, t)
                            }
                            return this.inGaplessMode && No(n.itemId) && !n.parentItemId ? Y(n) : X
                        }
                        ))
                    }
                    ), dn(), ie( ([e,t]) => {
                        var e = e.itemId
                          , i = t.itemId
                          , t = Xc(t)
                          , r = {
                            prevItemId: e,
                            nextItemId: i,
                            nextStartTime: t,
                            nextDuration: l.msDuration - t
                        };
                        this.trigger(K.ITEM_TRANSITIONED, r),
                        this.Nr.itemTransitioned(e, i),
                        this.tu.removeEarlierCues(t)
                    }
                    ), wn(X))),
                    i && D.push(function(s) {
                        const {config: o, iframeClock: l, mediaSink: e} = u
                          , d = e["mediaQuery"];
                        return d.desiredRate$.pipe(te(a => Yc(a) ? yr(0, Math.abs(1e3 / a)).pipe(W( () => {
                            let t;
                            var i = d.seekable;
                            if (l.isStarted && !(i.length < 1)) {
                                var r = null == (r = l.getCurrentTime()) ? void 0 : r.seconds;
                                if (re(r)) {
                                    var n = null != (n = Xc(s.getQueueItemForTime(r))) ? n : 0;
                                    let e = i.start(0);
                                    re(e) || (e = 0),
                                    i = lg(d, o),
                                    1 < a && i <= r ? (t = {
                                        newRate: 0,
                                        postFlushSeek: i
                                    },
                                    l.pause()) : a < 0 && r - n - e < a / -2 && (t = {
                                        newRate: 1,
                                        postFlushSeek: e
                                    })
                                }
                            }
                            return t
                        }
                        ), Kl(), tn(1)) : X))
                    }(this.itemQueue).pipe(ie( ({newRate: e, postFlushSeek: t}) => {
                        this.Ou(this.desiredRate, e, t)
                    }
                    ))),
                    this.inGaplessMode && this.isPreloading && D.push(l.timeupdate$.pipe(te(e => {
                        if (this.inGaplessMode && this.isPreloading) {
                            var t = this.itemQueue.playingItem
                              , i = this.itemQueue.loadingItem
                              , r = this.itemQueue.activeItem
                              , n = Xc(i);
                            if (re(n) && n <= e && t !== r)
                                return this.itemQueue.updatePlayingItemId(!o.enableInterstitialPlayback),
                                this.Au(i, this.Su, a, s)
                        }
                        return X
                    }
                    ))),
                    n.loopCount);
                    return re(x) && 0 < x && D.push(l.isBufferedToEnd$(o.maxBufferHole).pipe(Z(e => e), W(e => {
                        const t = this.itemQueue.activeItem
                          , i = Xc(t)
                          , r = l.minSBDuration - i;
                        if (Math.abs(r) < o.maxBufferHole)
                            return null;
                        var n = null == t ? void 0 : t.loopCount;
                        if (re(n) && 0 < n || n === 1 / 0) {
                            const e = l.getBufferInfo(l.currentTime, F.maxBufferHole)
                              , o = [null != (n = null == (n = e[se.Variant]) ? void 0 : n.buffered.end) ? n : 0, null != (n = null == (n = e[se.AltAudio]) ? void 0 : n.buffered.end) ? n : 0]
                              , i = Object.assign(Object.assign({}, ug(t, !1)), {
                                itemStartOffsets: o,
                                initialSeekTime: re(t.initialSeekTime) ? t.initialSeekTime - Xc(t) + o[se.Variant] : NaN,
                                parentItemId: null != (n = t.parentItemId) ? n : t.itemId,
                                loopCount: t.loopCount - 1,
                                seekImmediately: !1
                            });
                            return {
                                activeItem: t,
                                nextItem: cg.createItem(t.name, t.url, this.fu, this.logger, !1, i)
                            }
                        }
                    }
                    ), Kl(), te( ({nextItem: e}) => (ae( () => {
                        this.itemQueue.insertQueueItem(e),
                        this.itemQueue.setActive(e.itemId, e.itemStartOffsets, e.initialSeekTime)
                    }
                    ),
                    X)))),
                    F.attemptErrorRecovery && D.push(a.variantPenaltyBox$.pipe(te(e => {
                        const t = this.cu.value;
                        return t && !e.find(e => e.id === t) && this.cu.next(null),
                        X
                    }
                    ))),
                    ne(...D, N)
                }
                )), L = this.itemQueue.removedItems$.pipe(_r(t => {
                    const i = [];
                    return ae( () => {
                        var e;
                        this.Yl.remove(t),
                        this.Aa.removeItems(t),
                        this.Nr.removeItemList(t),
                        i.push(this.Zl.removeItemsAndKeys(t, !1)),
                        F.enableBoss && null != (e = this.yu) && e.destroyItems(t)
                    }
                    ),
                    i
                }
                )), Q = [];
                F.enableInterstitialPlayback && Q.push(this.Su.playback$.pipe(ie(e => {
                    e && F.forcePauseOnInterstitialBoundary && this.setRate(0)
                }
                ))),
                ne(this.au.pipe($r( () => 0 === this.ou.length ? X : this.ou.shift())).pipe($(e => X)), N.pipe($(e => X)), D.pipe($(this.Iu.bind(this))), ne(i, L, e, r, ...Q, t, this.Lr).pipe($(e => this.Iu(e)))).pipe(ee( () => {
                    var e, t, i, r;
                    try {
                        this.detachMedia(),
                        this.trigger(K.DESTROYING),
                        this.uu.destroy(),
                        this.hu.destroy(),
                        this.Ja.destroy(),
                        null != (e = this.vu) && e.destroy(),
                        null != (t = this.mu) && t.destroy(),
                        F.enableBoss && null != (i = this.yu) && i.destroy(),
                        this.Yl.clear(),
                        this.Aa.removeAll(),
                        this.Fl.destroy(),
                        this.itemQueue.clearQueue(),
                        u.removeEntity(this.sessionID),
                        this.Xa.reset(),
                        this.Su.reset(),
                        this.ou = [],
                        this.Ra.next(null),
                        this.Pa.next(null),
                        this.Ca.next(null),
                        null != (r = this.Nu) && r.reset(),
                        this.fu.xhrSetup = void 0,
                        this.vu.reset()
                    } catch (e) {
                        this.logger.error(`Got error in finalize ` + e.message)
                    }
                }
                ), Pn(Sn(this._i))).subscribe()
            }
            get rootPlaylistQuery$() {
                return kr(this.Ra.pipe(Va), sr)
            }
            get mediaElementQuery$() {
                return kr(this.Pa.pipe(Va), sr)
            }
            get interstitialQuery$() {
                return kr(this.Ca.pipe(Va), sr)
            }
            get activeRootPlaylistQuery() {
                return this.Ra.value
            }
            Eu(e) {
                return this.Aa.getQueryForId(e)
            }
            get Ru() {
                return this.Pa.value
            }
            static get version() {
                return "2.610.3"
            }
            static get Events() {
                return K
            }
            static get ErrorTypes() {
                return he
            }
            static get ErrorDetails() {
                return Q
            }
            get Events() {
                return cy.Events
            }
            get ErrorTypes() {
                return cy.ErrorTypes
            }
            get ErrorDetails() {
                return cy.ErrorDetails
            }
            static get DefaultConfig() {
                return h(ks)
            }
            get DefaultConfig() {
                return cy.DefaultConfig
            }
            static isSupported() {
                try {
                    var e = Qu()
                      , t = window.SourceBuffer || window.WebKitSourceBuffer
                      , i = e && "function" == typeof e.isTypeSupported && e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')
                      , r = !t || t.prototype && "function" == typeof t.prototype.appendBuffer && "function" == typeof t.prototype.remove;
                    return !!i && !!r
                } catch (e) {
                    return !1
                }
            }
            static loadRemoteConfigurations(e, t, i) {
                var r, n, a, s = {
                    maxNumRetry: 0,
                    maxRetryDelayMs: 0,
                    retryDelayMs: 0
                };
                return r = e,
                n = {
                    xhrSetup: i
                },
                a = Object.assign(Object.assign({}, t), {
                    autoRetry: !1,
                    timeoutRetry: s,
                    errorRetry: s
                }),
                na( () => po({
                    url: r,
                    xhrSetup: n.xhrSetup,
                    method: "GET",
                    responseType: "text",
                    extendMaxTTFB: 0
                }, a).pipe(W( ([e]) => JSON.parse(e.responseText))))
            }
            wu(e, t, i, r) {
                var n;
                return i && e ? (n = i.mediaQuery.combinedBuffer.length) && e.replaceItemAction == as.RESET_MEDIASOURCE ? (t.updateItemById(e.itemId, {
                    replaceItemAction: as.DO_NOTHING
                }),
                i.resetMediaSource(0),
                ue) : n && e.replaceItemAction == as.FLUSH_ALL ? (t.updateItemById(e.itemId, {
                    replaceItemAction: as.DO_NOTHING
                }),
                i.flushAll(0, 1 / 0).pipe(te( () => ce(this.Wl.mediaQuery.updating$, e => !e)), W( () => {
                    this.Wl.msDuration = 0
                }
                ))) : ue : ue
            }
            Au(t, i, e, r) {
                let n = t.initialSeekTime;
                const a = r.mediaQuery
                  , s = a.getBufferedSegmentsByType(oe.Variant).find(e => e.frag.itemId === t.itemId);
                return ce(null != s && s.frag ? Y(s.frag) : e.lastLoadedMediaOptionByType$(se.Variant), e => !!e).pipe(te(e => {
                    if (null != (e = null == (e = this.Yl.getQueryForOption(e)) ? void 0 : e.mediaOptionDetails) && e.liveOrEvent) {
                        const t = um(e, this.fu);
                        n = Math.min(t, n)
                    }
                    return this.fu.enableInterstitialPlayback && t.snapIn && i && (n = i.snapIn(t, e)),
                    ce(a.mediaElementDuration$, e => (!re(n) || e > n) && 0 < e).pipe(W(e => n < 0 ? Math.max(Xc(t), e + n) : n), W(e => this.Pu(Xc(t), e, a)), ie(e => {
                        re(e) && e >= a.currentTime - this.fu.maxSeekHole && r.seekWithOptions(e, void 0, !0, !1)
                    }
                    ), wn(X))
                }
                ))
            }
            Pu(e, t, i) {
                const r = re(t) ? t : e
                  , n = i.getCombinedBufferInfo(r, 0).nextStart;
                if (re(n)) {
                    const e = i.getBufferedSegmentsByType(oe.Variant).find(e => e.startPTS <= r && e.endPTS > r);
                    e && e.startPTS <= n && e.endPTS > n && (t = n)
                }
                return t
            }
            ku(e) {
                re(t = null == (t = null == (t = this.aa.query.alternateMatchingInfo) ? void 0 : t.audioMatchingInfo) ? void 0 : t.persistentId) && (this.audioSelectedPersistentID = t);
                var t = null == (t = null == (t = this.aa.query.alternateMatchingInfo) ? void 0 : t.subtitleMatchingInfo) ? void 0 : t.persistentId;
                re(t) && (this.subtitleSelectedPersistentID = t),
                this.nu = !0
            }
            Cu(t) {
                var e = this.Ru.getBufferedSegmentsByType(oe.Variant).find(e => e.startPTS <= t && t < e.endPTS);
                if (e)
                    return e.frag.mediaOptionId
            }
            recoverFromFatalError() {
                var e = this.playingItem.itemId
                  , t = this.Cu(this.realCurrentTime);
                t && (this.Aa.addToPenaltyBox(e, se.Variant, t),
                this.reloadPlayingItem({
                    parentItemId: this.playingItem.parentItemId,
                    itemId: this.playingItem.itemId
                }),
                this.Wl.resetMediaSource())
            }
            shouldAttemptErrorRecovery(e) {
                if (!this.config.attemptErrorRecovery)
                    return !1;
                if (0 !== this.desiredRate && 1 !== this.desiredRate)
                    return !1;
                let i = null;
                var t, r, n = null == (n = this.activeRootPlaylistQuery) ? void 0 : n.mediaOptionListQueries[se.Variant].filteredMediaOptionList.reduce( (e, t) => t.iframes ? e : (i = t.mediaOptionId,
                e + 1), 0), a = null == (a = this.activeRootPlaylistQuery) ? void 0 : a.enabledMediaOptionIdByType(se.Variant);
                return !(0 === n || 1 === n && i && i === a || !e.fatal || !(e.type === he.MEDIA_ERROR && e.details === Q.BUFFER_STALLED_ERROR || e.type === he.OTHER_ERROR && e.details === Q.INTERNAL_EXCEPTION && e.response === H.InternalError) || (n = this.cu.value,
                t = this.itemQueue.playingItem.itemId,
                r = this.itemQueue.playingItem.url,
                n ? (null != (n = this.Nr) && n.handleErrorRecovery(e, !1, t, a, r),
                1) : (null != (n = this.Nr) && n.handleErrorRecovery(e, !0, t, a, r),
                this.cu.next(a),
                0)))
            }
            Iu(e) {
                try {
                    var t = e.message;
                    const i = e instanceof b ? e : new j(!0,H.InternalError,e.message,e.stack);
                    if (this.logger.error(`Got unhandled or fatal error: ${t}, fatal: ${i.fatal}, isHlsError: ${einstanceof b}, isInterstitial: ` + this.interstitialActive),
                    this.shouldAttemptErrorRecovery(i))
                        return this.recoverFromFatalError(),
                        X;
                    if (i.fatal && this.isPreloading && !this.fu.enableInterstitialPlayback && this.dequeueSource("FatalErrorWhileLoading"),
                    i.fatal)
                        return this.Su.handleError(i).pipe(ie( ({handled: e, error: t}) => {
                            e && (null != (e = this.Nr) && e.handleNonFatalError(i, this.interstitialActive),
                            this.trigger(K.ERROR, Object.assign(Object.assign({}, t), {
                                fatal: !1,
                                interstitial: !0,
                                message: t.message
                            })))
                        }
                        ), Z( ({handled: e, error: t}) => !e && t.fatal), _r( ({error: e}) => this.Wl && this.Wl.mediaQuery.gotPlaying ? ce(this.Wl.mediaQuery.stallInfo$, e => null != e).pipe(rn(e)) : Y(e)), _r(e => {
                            var t;
                            return null != (t = this.Nr) && t.handleFatalError(i, this.interstitialActive, this.itemQueue.playingItem.url),
                            this.trigger(K.ERROR, e),
                            X
                        }
                        ));
                    this.trigger(K.ERROR, i)
                } catch (e) {
                    throw this.logger.error(`Error thrown inside _handleError ` + e.message),
                    e
                }
                return X
            }
            Mu(r, n) {
                var a, s = this.Gl.getValue();
                if (s) {
                    let e = NaN;
                    if (n.isPlayingAtLive) {
                        const r = n.liveSeekableRange
                          , a = r.edge;
                        e = (o = F(a + (performance.now() - r.tupdate) / 1e3, a) - n.currentTime,
                        l = Math.pow(10, 3),
                        Math.round(o * l) / l)
                    }
                    var o = s.readyState >= s.HAVE_FUTURE_DATA
                      , l = {
                        readyToPlay: o,
                        playbackLikelyToKeepUp: n.haveEnough && o,
                        rate: s.playbackRate,
                        paused: s.paused,
                        position: s.currentTime,
                        duration: s.duration,
                        seekableTimeRanges: this.seekableTimeRanges.map(e => [e.start, e.end]),
                        loadedTimeRanges: Ep.timeRangeToArray(s.buffered),
                        interstitialActive: this.interstitialActive,
                        liveEdgeDistance: e
                    };
                    let t = 0
                      , i = 0;
                    if (Ep.isHtmlVideoElement(s)) {
                        const r = s.getVideoPlaybackQuality;
                        if (r && typeof r == typeof Function) {
                            const r = s.getVideoPlaybackQuality();
                            t = l.droppedVideoFrames = r.droppedVideoFrames,
                            l.corruptedVideoFrames = r.corruptedVideoFrames,
                            l.totalVideoFrames = r.totalVideoFrames,
                            i = l.totalVideoFrames - t
                        }
                    } else
                        Ep.isWebkitMediaElement(s) && (t = l.droppedVideoFrames = s.webkitDroppedFrameCount,
                        i = l.decodedFrameCount = s.webkitDecodedFrameCount);
                    r.enablePerformanceLogging && n.getCombinedMediaSourceBufferInfo(r.maxBufferHole),
                    null != (a = this.Nr) && a.handlePlaybackInfo(t, i, e, n.bufferedRangeTuple)
                }
            }
            get currentItem() {
                return this.isPreloading ? this.playingItem : this.itemQueue.activeItem
            }
            get realCurrentTime() {
                var e, t;
                const i = this.Ru;
                if (!i) {
                    const t = this.itemQueue.activeItem;
                    return null != (e = null == t ? void 0 : t.initialSeekTime) ? e : NaN
                }
                if (this.eu.isStarted) {
                    const e = i.seekable
                      , t = 0 < e.length ? F(e.start(0), 0) : 0
                      , r = lg(i, this.fu)
                      , n = this.eu.getCurrentTime().seconds;
                    return Math.max(t, Math.min(r, n))
                }
                let r = i.desiredPos;
                const n = Xc(this.playingItem);
                if (re(r) && re(n))
                    if (this.fu.enableInterstitialPlayback)
                        if (this.interstitialActive) {
                            const e = this.Xa.interstitialQuery
                              , i = e.playingInterstitialId;
                            r -= (null != (t = e.realCurrentTimeOffsetMap[i]) ? t : [0, 0])[se.Variant]
                        } else
                            r -= n;
                    else
                        r -= n;
                return Math.max(0, r)
            }
            set realCurrentTime(e) {
                var t = Xc(this.playingItem);
                !this.fu.enableInterstitialPlayback && re(t) && (e += t),
                this.seekTo = e
            }
            get realDuration() {
                return this.Ru ? this.Ru.primaryContentMediaElementDuration : 1 / 0
            }
            get bufferedDuration() {
                var e = this.Ru;
                return null != (e = null == e ? void 0 : e.getBufferedDuration()) ? e : 0
            }
            get sessionData() {
                var e = this.activeRootPlaylistQuery;
                return null == e ? void 0 : e.sessionData
            }
            get supportedFrameRates() {
                var e = this.fu.trickPlaybackConfig["enabled"]
                  , t = this.fu["liveAllowTrickplay"]
                  , i = [0, 1]
                  , r = this.activeRootPlaylistQuery
                  , n = this.Yl.query;
                return e && r && n.getEntity(r.itemId) && (n.getEntity(r.itemId).liveOrEvent && !t || i.push(8, 24, 48, 96)),
                i
            }
            loadSource(e, i, t) {
                i && Object.keys(i).filter(e => 0 <= ["itemId", "streamID"].indexOf(e)).reduce( (e, t) => t in i ? Object.assign(e, {
                    [t]: i[t]
                }) : e, {}),
                this.ou = [na(this.Du.bind(this, {
                    url: e,
                    itemOptions: i,
                    initialSeekTime: t
                }))],
                this.au.next()
            }
            xu(e) {
                return null != e ? e : Ga()
            }
            Lu(e, t={}, i) {
                var r, n, a, s;
                if ("playready" === this.fu.keySystemPreference && !this.fu.enablePlayReadyKeySystem)
                    throw new j(!0,H.UnsupportedKeySystemError);
                if (!e || !e.trim().length)
                    throw new j(!0,H.EmptyLoadSourceError);
                if (e = us.buildAbsoluteURL(window.location.href, e, {
                    alwaysNormalize: !0
                }),
                null != (r = null == t ? void 0 : t.appData) && r.reportingAgent && (this.reportingAgent = t.appData.reportingAgent),
                null != t && t.userInfo && (this.userInfo = t.userInfo),
                null != (r = this.vu) && r.setupReporter(null == t ? void 0 : t.appData),
                null != t && t.platformInfo && this.Jl.updatePlatformInfo(t.platformInfo),
                function(e, t) {
                    if (t) {
                        const t = ms(e);
                        return void 0 !== fs.find(e => new RegExp(e).exec(null != t ? t : ""))
                    }
                    return !1
                }(e, this.fu.enableQueryParamsForITunes)) {
                    const i = {
                        language: t.language,
                        dsid: t.dsid,
                        subs: t.subs
                    };
                    r = e,
                    n = null == t ? void 0 : t.platformInfo,
                    l = i,
                    s = n.model,
                    o = n.manufacturer,
                    s && o && (s = r,
                    o = n.model,
                    n = n.manufacturer,
                    a = -1 !== s.indexOf("?"),
                    o = encodeURIComponent(null != o ? o : ""),
                    n = encodeURIComponent(null != n ? n : ""),
                    r = (s = a ? s : s + "?") + gs.deviceName + n + gs.deviceModel + o),
                    e = r = function(e, t) {
                        var i;
                        let r;
                        for (r in e = -1 !== e.indexOf("?") ? e : e + "?",
                        t)
                            t[r] && (e += gs[r] + ("subs" === r ? encodeURIComponent(null != (i = t[r]) ? i : "") : t[r]));
                        return e
                    }(r, l)
                }
                this.nu = !1;
                var o = {
                    initialSeekTime: i,
                    platformInfo: null == t ? void 0 : t.platformInfo,
                    clientName: null == (a = null == t ? void 0 : t.appData) ? void 0 : a.clientName,
                    serviceName: null == (s = null == t ? void 0 : t.appData) ? void 0 : s.serviceName,
                    appItemId: null == t ? void 0 : t.itemId,
                    appName: null == (n = null == t ? void 0 : t.appData) ? void 0 : n.appName,
                    loopCount: null == t ? void 0 : t.loopCount,
                    replaceItemAction: null == t ? void 0 : t.replaceItemAction
                }
                  , l = this.xu(null == t ? void 0 : t.itemId);
                this.itemQueue.setQueueItem(l, e, this.fu, o, !1)
            }
            prefetchSource(e, t, i) {
                var r;
                return !(null == t || !t.itemId || (r = this.xu(null == t ? void 0 : t.itemId),
                i = {
                    itemStartOffsets: [0, 0],
                    initialSeekTime: i,
                    platformInfo: null == t ? void 0 : t.platformInfo,
                    clientName: null == (i = null == t ? void 0 : t.appData) ? void 0 : i.clientName,
                    serviceName: null == (i = null == t ? void 0 : t.appData) ? void 0 : i.serviceName,
                    appItemId: null == t ? void 0 : t.itemId,
                    appName: null == (i = null == t ? void 0 : t.appData) ? void 0 : i.appName,
                    loopCount: null == t ? void 0 : t.loopCount
                },
                this.itemQueue.addPrefetchItem(r, e, this.fu, !1, i),
                0))
            }
            queueSource(e, t, i) {
                var r;
                null != t && t.userInfo && (this.userInfo = t.userInfo);
                const n = null == (r = this.Ru) ? void 0 : r.getBufferInfo(null == (r = this.Ru) ? void 0 : r.currentTime, 0)
                  , a = _s.map(e => null != (e = null == (e = n[e]) ? void 0 : e.buffered.end) ? e : 0)
                  , s = {
                    itemStartOffsets: a,
                    initialSeekTime: i,
                    platformInfo: null == t ? void 0 : t.platformInfo,
                    clientName: null == (r = null == t ? void 0 : t.appData) ? void 0 : r.clientName,
                    serviceName: null == (i = null == t ? void 0 : t.appData) ? void 0 : i.serviceName,
                    appItemId: null == t ? void 0 : t.itemId,
                    appName: null == (r = null == t ? void 0 : t.appData) ? void 0 : r.appName,
                    loopCount: null == t ? void 0 : t.loopCount
                }
                  , o = this.xu(null == t ? void 0 : t.itemId);
                this.itemQueue.addQueueItem(o, e, this.fu, !1, s)
            }
            dequeueSource(e="ApplicationInitiated") {
                if (!this.fu.enableInterstitialPlayback)
                    return this.fu.supportGaplessVideo || this.isPreloading || "InvalidFormat" !== e || !this.isFirstItem ? void (this.isPreloading && (this.ou.push(this._dequeueSource(e)),
                    this.au.next())) : (this.logger.error("First item has invalid format for gapless. Probably video. Disabling gapless."),
                    void (this.iu = !1))
            }
            _dequeueSource(e="ApplicationInitiated") {
                const t = this.loadingItem.url
                  , i = this.loadingItem.itemId
                  , r = Xc(this.loadingItem);
                return this.Wl.flushAll(r, 1 / 0).pipe(ie( () => {
                    this.Wl.msDuration = r,
                    this.tu.removeLaterCues(this.Wl.msDuration),
                    this.itemQueue.resetLoadingItem(),
                    "InvalidFormat" !== e && "FatalErrorWhileLoading" !== e || (this.iu = !1),
                    this._u({
                        url: t,
                        itemId: i
                    }, e)
                }
                ))
            }
            _u(e, t) {
                null === e ? this.logger.error("dequeueSource called with no playing or loading item") : (t = {
                    url: e.url,
                    evictedItemId: e.itemId,
                    reason: t
                },
                Object.assign(Object.assign({}, t), {
                    url: f(e.url)
                }),
                this.trigger(K.ITEM_EVICTED, t))
            }
            endSource() {
                if (this.iu = !1,
                this.isPreloading) {
                    const e = Xc(this.loadingItem);
                    this.Wl.flushAndCallback(e, 1 / 0, () => {
                        this.Wl.msDuration = e,
                        this.tu.removeLaterCues(this.Wl.msDuration),
                        this.itemQueue.resetLoadingItem()
                    }
                    )
                }
            }
            get inGaplessMode() {
                return this.fu.gapless && this.iu
            }
            get isPreloading() {
                return this.itemQueue.isPreloading()
            }
            get isFirstItem() {
                return this.itemQueue.isFirstItem
            }
            get loadingItem() {
                return this.itemQueue.loadingItem
            }
            get playingItem() {
                return this.itemQueue.playingItem
            }
            get Fu() {
                let e = this.playingItem.itemId;
                var t;
                return e = this.fu.enableInterstitialPlayback && this.playingItem.isInterstitial && (this.currentItem.isInterstitial || (e = this.currentItem.itemId),
                t = this.itemQueue.primaryItem) ? t.itemId : e
            }
            get url() {
                return this.playingItem ? this.playingItem.url : this.loadingItem ? this.loadingItem.url : void 0
            }
            destroy() {
                const t = this["logger"];
                return this.ru.next(void 0),
                this.ru.next(void 0),
                this._i.next(),
                null != this.rs && (this.Lr.add(),
                this.rs.teardown(e => {
                    e && t.error("RPCService teardown error:", e),
                    this.Lr.done()
                }
                ),
                this.rs = null),
                this.toggleLogging(!1),
                this.eu.stop(),
                this.Lr.toPromise()
            }
            attachMedia(e) {
                this.trigger(K.MEDIA_ATTACHING, {
                    media: e
                }),
                this.Gl.next(e),
                this.trigger(K.MEDIA_ATTACHED, {
                    media: e
                })
            }
            detachMedia() {
                var e;
                this.Gl.getValue() && (this.ru.next(void 0),
                this.trigger(K.MEDIA_DETACHING),
                null != (e = this.Nr) && e.detachMedia(),
                this.eu.stop(),
                this.Gl.next(null),
                this.trigger(K.MEDIA_DETACHED))
            }
            handleResolvedUri(e, t) {
                this.Re.setCustomUrlResponse(e, {
                    uri: t.uri,
                    response: t
                })
            }
            get levels() {
                var e;
                return null != (e = null == (e = this.activeRootPlaylistQuery) ? void 0 : e.mediaOptionListQueries[se.Variant].filteredMediaOptionList) ? e : []
            }
            get audioTracks() {
                var e;
                return null != (e = null == (e = this.activeRootPlaylistQuery) ? void 0 : e.mediaOptionListQueries[se.AltAudio].filteredMediaOptionList) ? e : []
            }
            get audioMediaOptions() {
                var e;
                return null != (e = null == (e = this.activeRootPlaylistQuery) ? void 0 : e.audioMediaSelectionOptions) ? e : []
            }
            get subtitleMediaOptions() {
                var e;
                return null != (e = null == (e = this.activeRootPlaylistQuery) ? void 0 : e.subtitleMediaSelectionOptions) ? e : []
            }
            getAudioMediaOptionsForItem(e) {
                return null != (e = this.Eu(e).audioMediaSelectionOptions) ? e : []
            }
            getSubtitleMediaOptionsForItem(e) {
                return null != (e = this.Eu(e).subtitleMediaSelectionOptions) ? e : []
            }
            get playbackLikelyToKeepUp() {
                var e;
                return null != (e = null == (e = this.Ru) ? void 0 : e.playbackLikelyToKeepUp) && e
            }
            bufferedRangesForPlayerType(e) {
                if (!this.Ru)
                    return [];
                const o = e === ss.Interstitial
                  , t = this.Ru.getBufferedSegmentsByType(oe.Variant).reduce( (e, t) => {
                    var i = this.itemQueue.getQueueItemForId(t.frag.itemId);
                    if (i.isInterstitial === o) {
                        const o = Xc(i)
                          , r = re(i.initialSeekTime) ? i.initialSeekTime : 0
                          , n = Math.max(0, r - o)
                          , a = null != (i = t.appendStart) ? i : 0
                          , s = null != (i = t.appendEnd) ? i : 0;
                        e.push({
                            start: Math.max(0, a - o + n),
                            end: Math.max(0, s - o + n)
                        })
                    }
                    return e
                }
                , []);
                return Qc.getBufferedTimeRanges(t, this.fu.maxBufferHole)
            }
            seekableTimeRangesForPlayerType(e) {
                var t, i;
                if (e !== ss.Interstitial)
                    return 0 === this.Ru.getBufferedSegmentsByType(oe.Variant).filter(e => !(null != (e = this.itemQueue.getQueueItemForId(e.frag.itemId)) && e.isInterstitial)).length ? [{
                        start: 0,
                        end: this.realDuration
                    }] : this.seekableTimeRanges.map(e => {
                        var t = this.itemQueue.getQueueItemForTime((e.end - e.start) / 2);
                        return t ? (t = Xc(t),
                        {
                            start: Math.max(0, e.start - t),
                            end: e.end - t
                        }) : e
                    }
                    );
                {
                    const e = this.Xa.interstitialQuery
                      , r = []
                      , n = null != (t = e.playingInterstitialId) ? t : e.activeInterstitialId;
                    if (n) {
                        const t = e.getInterstitialForId(n);
                        t && r.push({
                            start: 0,
                            end: null != (i = t.duration) ? i : 0
                        })
                    }
                    return r
                }
            }
            set desiredRate(e) {
                null != e && this.setRate(e)
            }
            get desiredRate() {
                var e;
                return null != (e = null == (e = this.Ru) ? void 0 : e.desiredRate) ? e : 0
            }
            get effectiveRate() {
                var e;
                return null != (e = null == (e = this.Ru) ? void 0 : e.effectiveRate) ? e : 0
            }
            get iframeMode() {
                var e;
                return null != (e = null == (e = this.Ru) ? void 0 : e.isIframeRate) && e
            }
            get accessLog() {
                var e, t, i;
                return this.vu && this.activeRootPlaylistQuery && (t = this.activeRootPlaylistQuery.itemId,
                i = null != (e = null != (e = null == (i = this.itemQueue.getQueueItemForId(t)) ? void 0 : i.parentItemId) ? e : null == i ? void 0 : i.itemId) ? e : t,
                this.vu) && this.activeRootPlaylistQuery ? this.vu.getAccessLog(i) : []
            }
            get errorLog() {
                return this.vu ? this.vu.errorLog : []
            }
            setRate(e) {
                this.logger.child({
                    name: "iframes"
                });
                const t = this.desiredRate;
                if (e === t)
                    return -2;
                if (!this.Wl || isNaN(e))
                    return -1;
                e = Number(e);
                const i = Math.abs(e);
                if (!this.supportedFrameRates.some(e => e === i))
                    return -3;
                if (Yc(e)) {
                    if (this.interstitialActive)
                        return -1;
                    if (this.playingItem && this.playingItem.itemId !== this.itemQueue.activeItem.itemId) {
                        const t = this.Aa.getQueryForId(this.playingItem.itemId);
                        if (null == t || !t.mediaOptionListQueries[se.Variant].hasIframes)
                            return -1;
                        if (this.loadingItem && this.loadingItem.isInterstitial)
                            return this.Su.cancelInterstitial(this.realCurrentTime, e, !0),
                            0
                    }
                    const t = this.activeRootPlaylistQuery;
                    if (null == t || !t.mediaOptionListQueries[se.Variant].hasIframes)
                        return -1
                }
                return this.Ou(t, e),
                0
            }
            Ou(e, t, i) {
                const r = Yc(e)
                  , n = Yc(t)
                  , a = this.Wl;
                if (n ? this.eu.start({
                    rootTimeSeconds: null != i ? i : this.realCurrentTime,
                    rate: t
                }) : this.eu.stop(),
                n || r !== n) {
                    const r = this.ru.value;
                    r && this.su.next(this.ju(r, e, t, i))
                } else
                    a.desiredRate = t
            }
            toggleLogging(e) {
                this.lu.next(e)
            }
            ju(l, d, u, c) {
                return {
                    operation: Yh.RateChange,
                    priority: Xh.High,
                    execute: (e, t, i, r) => na( () => {
                        const {mediaSink: e, config: t, rootPlaylistQuery: i} = l
                          , r = e.mediaQuery
                          , n = Yc(d)
                          , a = Yc(u);
                        let s, o = NaN;
                        if (a !== n) {
                            const l = e.mediaQuery;
                            if (o = a ? l.getBufferInfo(0, 0)[se.Variant].buffered.end : F(c, this.eu.getCurrentTime().seconds),
                            t.enableInterstitialPlayback && re(o)) {
                                const l = a ? 1 / 0 : 0
                                  , d = this.Uu;
                                o = this.Su.getAdjustedSeek(o, l, e.mediaQuery, !a, null == d ? void 0 : d.pdtToMSN, null == d ? void 0 : d.fragments).adjustedSeek
                            }
                            s = na( () => (e.haveEnough = !1,
                            e.pause(),
                            e.flushAll(0, 1 / 0)))
                        } else if (a) {
                            const l = 1 / this.config.trickPlaybackConfig.minIframeDuration;
                            s = e.flushData(oe.Variant, r.currentTime + l, 1 / 0)
                        }
                        if (e.desiredRate = u,
                        a !== n && (_m(ds.IframeModeChange, i.enabledVariantMediaOption, l),
                        e.toggleTrickPlaybackMode(a)),
                        null == s)
                            return re(o) && (this.Wl.seekTo = o),
                            ue;
                        {
                            const l = [s];
                            return re(o) && l.push(na( () => r.flushing ? (e.seekTo = o,
                            ue) : Sn([ce(r.seekTo$.pipe(On(1)), e => re(null == e ? void 0 : e.pos)), ce(r.updating$, e => !e).pipe(ie( () => this.Wl.seekTo = o))]))),
                            aa(l)
                        }
                    }
                    ).pipe(te( () => Zf(l, e, 0, r).pipe(Pn(eg(e, i, l.rootPlaylistQuery, l.mediaLibraryService, l.mediaSink.mediaQuery, l.config))))),
                    logger: l.logger
                }
            }
            set skip(e) {
                this.Ru && (this.eu.isStarted && this.eu.start({
                    rootTimeSeconds: this.realCurrentTime + e,
                    rate: this.desiredRate
                }),
                this.realCurrentTime = Math.max(0, this.realCurrentTime + e))
            }
            Bu(e) {
                const t = Xc(this.playingItem);
                if (re(t) && e < t && (e = t),
                this.isPreloading) {
                    e > Xc(this.loadingItem) && (e = Xc(this.loadingItem));
                    const t = this.Ru.getBufferInfo(this.Ru.currentTime, this.fu.maxBufferHole)[se.Variant];
                    t && e < t.buffered.start && this.dequeueSource("SeekToUnbufferedTimeRanges")
                }
                this.aa.setUserSeek(e)
            }
            $u(e) {
                var t, i, r, n = this.itemQueue.activeItem;
                if (!n)
                    return e;
                const a = n.isInterstitial ? ss.Interstitial : ss.Primary
                  , s = this.realCurrentTime
                  , o = this.Uu
                  , {adjustedSeek: l, newItemId: d, startOffset: u} = this.Su.getAdjustedSeek(e, s, this.Ru, !1, null == o ? void 0 : o.pdtToMSN, null == o ? void 0 : o.fragments, this.seekableTimeRangesForPlayerType(a));
                if (e < s || 0 === l) {
                    const e = (null != (r = null == (i = this.Ru) ? void 0 : i.getBufferedSegmentsByType(oe.Variant)) ? r : []).find(e => {
                        var t = this.itemQueue.getQueueItemForId(e.frag.itemId)
                          , i = null != (i = null == t ? void 0 : t.isInterstitial) && i
                          , t = t.itemId !== (null == (t = this.itemQueue.playingItem) ? void 0 : t.itemId);
                        return i && t && l < e.appendStart && this.Ru.currentTime > e.appendStart
                    }
                    );
                    if (e || d)
                        return this.Su.reset(),
                        void this.Wl.flushAndCallback(Math.max(l - 1, 0), 1 / 0, () => {
                            d && (this.itemQueue.updateItemById(d, {
                                itemTimelineEndPosition: 1 / 0
                            }),
                            this.itemQueue.setActive(d, [u, u], l, !0),
                            this.itemQueue.updatePlayingItemId(!this.config.enableInterstitialPlayback))
                        }
                        )
                } else if ((null == (t = this.playingItem) ? void 0 : t.itemId) !== n.itemId && (null == (i = this.playingItem) || !i.isInterstitial) && l >= e) {
                    const i = ko(n.itemId) || ko(null == (r = this.itemQueue.loadingItem) ? void 0 : r.itemId);
                    if (i) {
                        const r = this.Xa.interstitialQuery.getInterstitialForId(i)
                          , t = this.Su.getInterstitialStartTime(r, null == o ? void 0 : o.pdtToMSN, null == o ? void 0 : o.fragments);
                        if (l > t)
                            return void this.Su.cancelInterstitial(e, null, !0)
                    }
                }
                this.aa.setUserSeek(l)
            }
            set seekTo(e) {
                var t = Number(e);
                re(t) ? this.fu.enableInterstitialPlayback ? this.$u(t) : this.inGaplessMode ? this.Bu(t) : (this.eu.isStarted && this.eu.start({
                    rootTimeSeconds: t,
                    rate: this.desiredRate
                }),
                this.aa.setUserSeek(t)) : this.logger.error(`[seek] got invalid seek value ` + e)
            }
            seekToDate(e) {
                this.aa.setUserSeek(e)
            }
            get availableProgramDateTime() {
                return new Map(this.Vu)
            }
            get Vu() {
                var e, t = this.Uu;
                if (!t)
                    return [];
                const i = this.Fu
                  , r = this.itemQueue.getQueueItemForId(i)
                  , n = null != (e = null == t ? void 0 : t.pdtToMSN) ? e : []
                  , a = this.fu.enableInterstitialPlayback ? Xc(r) : 0
                  , s = null != (e = null == t ? void 0 : t.fragments) ? e : []
                  , o = null == t ? void 0 : t.startSN;
                return 0 === n.length || 0 === s.length ? [] : n.map( ([e,t]) => [e, (null == (e = s[t - o]) ? void 0 : e.start) - a])
            }
            get Uu() {
                var e;
                if (this.activeRootPlaylistQuery && this.playingItem)
                    return e = this.Fu,
                    this.itemQueue.getQueueItemForId(e),
                    (e = this.Aa.getQueryForId(e).lastLoadedMediaOptionByType(se.Variant)) && Ds(e) ? this.Yl.getQueryForOption(e).mediaOptionDetails : void 0
            }
            get playingDate() {
                if (n = this.Uu) {
                    var t, i, e = this.Fu, e = this.itemQueue.getQueueItemForId(e), e = this.fu.enableInterstitialPlayback ? Xc(e) : 0, r = n.pdtToMSN, n = n.fragments, e = this.realCurrentTime + e;
                    if (r && 0 !== r.length)
                        return [n,r] = (t = e,
                        i = n,
                        Array.isArray(r) && Array.isArray(i) && r.length && i.length && ([n,r] = null != (n = m(r, ([,e]) => i[e - i[0].mediaSeqNum].start <= t)) ? n : r[0],
                        re(r = null != (r = null == (r = i[r - i[0].mediaSeqNum]) ? void 0 : r.start) ? r : NaN)) ? [n, r] : []),
                        re(n += 1e3 * (e - r)) ? new Date(n) : void 0
                }
            }
            get seekableTimeRanges() {
                var e;
                return null != (e = null == (e = this.Ru) ? void 0 : e.seekableTimeRanges) ? e : []
            }
            get isLive() {
                var e;
                return !!this.playingItem && (e = this.playingItem.isInterstitial ? this.playingItem.parentItemId : this.playingItem.itemId,
                null != (e = null == (e = this.Yl.query.getEntity(e)) ? void 0 : e.liveOrEvent)) && e
            }
            get isPlayingAtLive() {
                var e;
                return null != (e = null == (e = this.Ru) ? void 0 : e.isPlayingAtLive) && e
            }
            set variantId(e) {}
            selectPersistentID(t, e, i) {
                var r;
                const n = this.activeRootPlaylistQuery
                  , a = null == (r = this.playingItem) ? void 0 : r.itemId;
                if (!n || No(a)) {
                    const r = null == n ? void 0 : n.itemId;
                    !n || No(r) ? t === se.AltAudio ? this.primaryAudioSelectedPersistentID = e : this.primarySubtitleSelectedPersistentID = e : (this.logger.error(`[${Bs[t]}] reloading playingItem ${a} to load persistentID ` + e),
                    ae( () => {
                        this.Ku(a, i);
                        var e = {
                            parentItemId: this.playingItem.parentItemId,
                            itemId: this.playingItem.itemId
                        };
                        t === se.AltAudio ? e.userSwitchAudioTrack = !0 : e.userSwitchSubtitleTrack = !0,
                        this.reloadPlayingItem(e)
                    }
                    ))
                } else
                    this.logger.error(`[${Bs[t]}] attempting to set persistentID ${e} when playing interstitial ` + a)
            }
            get audioSelectedPersistentID() {
                var e;
                return null == (e = null == (e = this.aa.query.alternateMatchingInfo) ? void 0 : e.audioMatchingInfo) ? void 0 : e.persistentId
            }
            set audioSelectedPersistentID(e) {
                var t = [{
                    MediaSelectionGroupMediaType: O.AUDIO,
                    MediaSelectionOptionsPersistentID: e
                }];
                this.selectPersistentID(se.AltAudio, e, t)
            }
            set primaryAudioSelectedPersistentID(t) {
                var e, i = this.activeRootPlaylistQuery, r = null == i ? void 0 : i.mediaOptionListQueries[se.AltAudio].filteredMediaOptionList, n = null == i ? void 0 : i.itemId;
                if (r)
                    t !== (null == (e = i.enabledAlternateMediaOptionByType(se.AltAudio)) ? void 0 : e.persistentID) && (e = {
                        itemId: n,
                        language: null == (i = r.find(e => e.persistentID === t)) ? void 0 : i.lang,
                        name: null == i ? void 0 : i.name,
                        persistentId: t
                    },
                    this.aa.setAudioAlternateMatchingInfo(e),
                    r = this.aa.query.alternateMatchingInfo,
                    this.Aa.setEnabledMediaOptionTupleWithMatchedGroups(n, se.AltAudio, r, this.Aa, {
                        userInitiated: !0,
                        triggerEvent: !0
                    }));
                else if (re(t) && !(t < 0)) {
                    const e = {
                        itemId: n,
                        language: void 0,
                        name: void 0,
                        persistentId: t
                    };
                    this.aa.setAudioAlternateMatchingInfo(e)
                }
            }
            get subtitleSelectedPersistentID() {
                var e;
                return null == (e = null == (e = this.aa.query.alternateMatchingInfo) ? void 0 : e.subtitleMatchingInfo) ? void 0 : e.persistentId
            }
            set subtitleSelectedPersistentID(e) {
                var t = [{
                    MediaSelectionGroupMediaType: O.SUBTITLE,
                    MediaSelectionOptionsPersistentID: e,
                    MediaSelectionOptionsDisplaysNonForcedSubtitles: ls.YES
                }];
                this.selectPersistentID(se.Subtitle, e, t)
            }
            set primarySubtitleSelectedPersistentID(t) {
                var e;
                const i = this.activeRootPlaylistQuery
                  , r = null == i ? void 0 : i.mediaOptionListQueries[se.Subtitle].filteredMediaOptionList;
                if (r) {
                    if (t !== (null == (e = i.enabledAlternateMediaOptionByType(se.Subtitle)) ? void 0 : e.persistentID)) {
                        var n = i.itemId;
                        if (0 !== r.length || re(t) && !(t < 0))
                            if (re(t) && -1 !== t) {
                                const e = r.find(e => e.persistentID === t)
                                  , i = {
                                    itemId: n,
                                    language: null == e ? void 0 : e.lang,
                                    name: null == e ? void 0 : e.name,
                                    forced: null == e ? void 0 : e.forced,
                                    persistentId: t
                                };
                                this.aa.setSubtitleAlternateMatchingInfo(i);
                                var a = this.aa.query.alternateMatchingInfo;
                                this.Aa.setEnabledMediaOptionTupleWithMatchedGroups(n, se.Subtitle, a, this.Aa, {
                                    userInitiated: !0
                                })
                            } else
                                this.aa.setSubtitleAlternateMatchingInfo(null),
                                this.Aa.setEnabledMediaOptionByType(n, se.Subtitle, de)
                    }
                } else if (re(t) && !(t < 0)) {
                    const e = {
                        language: void 0,
                        name: void 0,
                        forced: void 0,
                        persistentId: t
                    };
                    this.aa.setSubtitleAlternateMatchingInfo(e)
                }
            }
            get iframeVariants() {
                var e = this.activeRootPlaylistQuery;
                return e ? this.config.enableBoss ? this.yu.getQuery(e.itemId, this.logger).variantsFor(os.ImageVariant) : e.rootPlaylistEntity.iframeVariants : []
            }
            loadImageIframeData$(d, u) {
                const c = this.activeRootPlaylistQuery;
                if (!c)
                    return R( () => new j(!1,H.InvalidLoadImageIframe));
                const n = function(e, t) {
                    if (!e.length)
                        throw new TypeError("Expected variant array");
                    var i = t ? e.find(e => e.mediaOptionId === t) : e[0];
                    if (i)
                        return i;
                    throw new j(!1,H.IFrameVariantNotFound,`Could not find image I-frame variant "${t}" of ${e.length} avaiable variants`)
                }(this.iframeVariants, null == u ? void 0 : u.variantId)
                  , e = function(a, s, o, l, d, u, c, h, p, m) {
                    var e = a["itemId"]
                      , t = l.getQueryForOption(a);
                    t.hasEntity(e) || l.createMediaLibraryEntity(e);
                    const f = t.mediaOptionDetails;
                    return f && ("VOD" === f.type || f.liveOrEvent && !Km(f, t.mediaOptionDetailsEntity.lastUpdateMillis)) ? (l.setLastAccessed(a),
                    Y(f)) : null !== (e = l.inFlightDetails) && Fs(e.mediaOption, a) ? e.request : (t = na( () => {
                        var {playlistLoadPolicy: e, keySystemPreference: t} = h
                          , i = s.masterVariableList
                          , r = c.query.extendMaxTTFB
                          , n = a.mediaOptionType;
                        return l.setDetailsLoading(a),
                        of(a, s.baseUrl, s.itemStartOffsets[n], h, h, e, p, m, t, i, r, f).pipe(W(Pf(a, s, o, l, d, u, h, m)), $(e => {
                            if (f)
                                return Y(f);
                            throw e
                        }
                        ), ee( () => {
                            l.inFlightDetails = null,
                            l.setDetailsLoading(a, !1)
                        }
                        ))
                    }
                    ).pipe(Tn()),
                    l.inFlightDetails = {
                        mediaOption: a,
                        request: t
                    },
                    t)
                }(n, c, this.Aa, this.Yl, this.Xa, this.Fl, this.aa, this.fu, this.Re, this.logger).pipe(tn(1), te(e => {
                    {
                        var [e,r,t,n,a=0] = [d, e, this.fu, this.Re, (this.logger,
                        c.itemStartPosition)];
                        const s = r.fragments
                          , o = e + (a || 0)
                          , l = Math.min(1, Math.max(0, (null == u ? void 0 : u.snapToNextFrameFactor) || 0));
                        let i = Eo.search(s, function(e, t, i) {
                            var r = i.start
                              , i = i.duration;
                            return r <= (e += i * t) && e < r + i ? 0 : e - r
                        }
                        .bind(null, o, l));
                        if (!i) {
                            let e = NaN
                              , t = NaN;
                            if (s.length) {
                                const r = s[s.length - 1];
                                e = s[0].start,
                                t = r.start + r.duration,
                                o < t && o + 1 > e ? i = s[0] : o > e && o - 1 < t && (i = s[s.length - 1])
                            }
                            if (!i)
                                return R( () => new j(!1,H.NoFragmentFoundAtSearchPositionInPlaylist,`Could not find fragment at pos ${o} in playlist "${r.mediaOptionId}" [${e}-${t}]`))
                        }
                        return go(i, r.url || "", t, t.fragLoadPolicy, n).pipe(W( ({mediaFragment: e, loadedData: t, bwSample: i}) => a ? [Object.assign(Object.assign({}, e), {
                            start: e.start - a
                        }), t, i] : [e, t, i]))
                    }
                }
                ), Nn((null == u ? void 0 : u.timeoutMs) || 5e3), W(e => {
                    var [[e,t,i],r] = [e, n];
                    if ((t = k.findBox(new Uint8Array(t), ["mdat"])).length)
                        return {
                            fragment: e,
                            data: t[0],
                            stats: i,
                            variant: r
                        };
                    throw new j(!1,H.MdatNotFound)
                }
                ));
                return Sn([e, this._i]).pipe(W(e => {
                    if (e)
                        return e;
                    throw new j(!1,H.InvalidLoadImageIframe)
                }
                ))
            }
            get selectedMediaArray() {
                return this.activeRootPlaylistQuery ? this.Hu() : []
            }
            set selectedMediaArray(e) {
                this.activeRootPlaylistQuery && e.forEach(e => {
                    e.MediaSelectionGroupMediaType === O.AUDIO || e.MediaSelectionOptionsMediaType === O.AUDIO ? this.audioSelectedPersistentID = e.MediaSelectionOptionsPersistentID : e.MediaSelectionGroupMediaType !== O.SUBTITLE && e.MediaSelectionOptionsMediaType !== O.SUBTITLE && e.MediaSelectionOptionsMediaType !== O.CLOSEDCAPTION || (this.subtitleSelectedPersistentID = e.MediaSelectionOptionsPersistentID)
                }
                )
            }
            getHTMLTextTrack(e) {
                return this.tu.getExistingHTMLTextTrackWithSubtitleTrackId(e)
            }
            get keysystems() {
                return this.Zl.availableKeySystems
            }
            setProtectionData(e) {
                this.Zl.initialize(e, this.aa.query.currentConfig.certLoadPolicy)
            }
            generateKeyRequest(e, t) {
                this.Zl.generateRequest(e, t) && this.Nr.licenseChallengeReceived({
                    keyuri: e
                })
            }
            setLicenseResponse(e, t) {
                this.Zl.setLicenseResponse(e, t)
            }
            get interstitialActive() {
                return !!this.Xa.interstitialQuery.playingInterstitialId
            }
            removeInterstitials(e) {
                this.Xa.removeInterstitials(e)
            }
            cancelInterstitial(e, t) {
                if (i = this.Xa.interstitialQuery.getInterstitialForId(e)) {
                    var t = null != t ? t : P(i.startTime) + Co(i)
                      , i = ko(this.itemQueue.playingItem.itemId)
                      , r = this.itemQueue.activeItem;
                    if (r.isInterstitial && i === e)
                        this.Su.cancelInterstitial(t, null, !0);
                    else {
                        const e = r.itemStartOffsets[se.Variant] + t;
                        this.itemQueue.updateItemById(r.itemId, {
                            initialSeekTime: e
                        }),
                        this.aa.setUserSeek(e)
                    }
                }
            }
            createInterstitials(e) {
                e = e.filter(e => Mh(e)),
                this.Xa.addInterstitials(e)
            }
            updateInterstitial(e, t) {
                this.Xa.updateInterstitial(e, t)
            }
            redoPlatformCapabilities() {
                return this.reloadPlayingItem({
                    parentItemId: this.playingItem.parentItemId,
                    itemId: this.playingItem.itemId
                })
            }
            Hu(e=null) {
                var t = []
                  , i = null == (r = this.aa.query.alternateMatchingInfo) ? void 0 : r.audioMatchingInfo
                  , r = null == r ? void 0 : r.subtitleMatchingInfo;
                if (e && !No(e))
                    return this.logger.error("attempt to query non-primary item's selectedMediaArray"),
                    [];
                if (i && !No(i.itemId))
                    return this.logger.error(`audio matching info set by non-primary items: ` + (null == i ? void 0 : i.itemId)),
                    [];
                if (r && !No(r.itemId))
                    return this.logger.error(`subtitle matching info set by non-primary items: ` + (null == r ? void 0 : r.itemId)),
                    [];
                if (i) {
                    const e = {
                        MediaSelectionGroupMediaType: O.AUDIO,
                        MediaSelectionOptionsPersistentID: i.persistentId
                    };
                    t.push(e)
                }
                if (r) {
                    const e = {
                        MediaSelectionGroupMediaType: O.SUBTITLE,
                        MediaSelectionOptionsPersistentID: r.persistentId,
                        MediaSelectionOptionsForced: r.forced
                    };
                    t.push(e)
                }
                return t
            }
            Ku(r, e) {
                var n, a = this.itemQueue.getQueueItemForId(r);
                if (a = this.Aa.getQueryForId(null == a ? void 0 : a.itemId)) {
                    const s = e.find(e => e.MediaSelectionGroupMediaType === O.AUDIO);
                    let t;
                    if (s) {
                        let e = s.MediaSelectionOptionsExtendedLanguageTag;
                        if (!e) {
                            const r = (null != (n = a.audioMediaSelectionOptions) ? n : []).find(e => e.MediaSelectionOptionsPersistentID === s.MediaSelectionOptionsPersistentID);
                            e = null == r ? void 0 : r.MediaSelectionOptionsExtendedLanguageTag
                        }
                        t = {
                            itemId: r,
                            language: e,
                            name: s.MediaSelectionOptionsName,
                            persistentId: s.MediaSelectionOptionsPersistentID
                        }
                    }
                    const o = e.find(e => e.MediaSelectionGroupMediaType === O.SUBTITLE);
                    let i;
                    if (o) {
                        let e = o.MediaSelectionOptionsExtendedLanguageTag;
                        if (!e) {
                            const r = (null != (n = a.subtitleMediaSelectionOptions) ? n : []).find(e => e.MediaSelectionOptionsPersistentID === o.MediaSelectionOptionsPersistentID);
                            e = null == r ? void 0 : r.MediaSelectionOptionsExtendedLanguageTag
                        }
                        i = {
                            itemId: r,
                            language: e,
                            name: o.MediaSelectionOptionsName,
                            persistentId: o.MediaSelectionOptionsPersistentID,
                            forced: !o.MediaSelectionOptionsDisplaysNonForcedSubtitles
                        }
                    }
                    ae( () => {
                        s && this.aa.setAudioAlternateMatchingInfo(t),
                        o && this.aa.setSubtitleAlternateMatchingInfo(i)
                    }
                    )
                }
            }
            changeTracks(e, t=!0) {
                const i = (this.playingItem || this.loadingItem).itemId
                  , r = this.itemQueue.primaryItem.itemId
                  , n = t ? r : i
                  , a = Tp.toLocale(e).baseName;
                let s = [];
                e && (s = [{
                    MediaSelectionGroupMediaType: O.AUDIO,
                    MediaSelectionOptionsExtendedLanguageTag: a
                }, {
                    MediaSelectionGroupMediaType: O.SUBTITLE,
                    MediaSelectionOptionsExtendedLanguageTag: a,
                    MediaSelectionOptionsDisplaysNonForcedSubtitles: ls.YES
                }]),
                ae( () => {
                    this.Ku(n, s),
                    this.reloadPlayingItem({
                        parentItemId: this.playingItem.parentItemId,
                        itemId: this.playingItem.itemId,
                        userSwitchAudioTrack: !0,
                        userSwitchSubtitleTrack: !0
                    })
                }
                )
            }
            reloadPlayingItem(e=null) {
                var t, i, r;
                this.Ru ? (i = null == (t = this.itemQueue.activeItem) ? void 0 : t.itemId,
                r = this.Ru.currentTime,
                this.fu.enableInterstitialPlayback ? this.Su.reloadPlayingItem(r, e, this.Wl, this.tu) : (this.itemQueue.setActive(null, t.itemStartOffsets),
                this.itemQueue.setActiveWithContext(i, e, t.itemStartOffsets, r, !0))) : this.logger.error("mediaSink not ready yet")
            }
            endItem() {
                this.ou = [na(this.Du.bind(this, void 0))],
                this.au.next()
            }
            Du(n) {
                var e;
                const a = null == (e = this.itemQueue.activeItem) ? void 0 : e.itemId
                  , s = !!n
                  , o = !!this.Yl.getSegmentRecord(null == (e = null == n ? void 0 : n.itemOptions) ? void 0 : e.itemId)
                  , l = [];
                return ae( () => {
                    var e, t;
                    if (a) {
                        const n = this.aa.query.currentConfig
                          , t = this.realCurrentTime
                          , r = this.interstitialActive;
                        this.ru.next(void 0);
                        var i = !this.fu.enableItemPreloading || !o;
                        if (this.Yl.clear(i),
                        this.Aa.removeAll(),
                        this.aa.reset(),
                        n.enableInterstitialPlayback && (null != (e = this.Xa) && e.reset(),
                        null != (i = this.Su)) && i.reset(),
                        null != (e = this.tu) && e.reset(),
                        null != (i = this.Wl) && i.reset(),
                        this.itemQueue.resetInternal(),
                        n.enableBoss && null != (e = this.yu) && e.destroyItem(a),
                        l.push(na( () => (this.Nr.endItem(a, t, r),
                        ue))),
                        this.Wl) {
                            const n = this.Wl.mediaQuery;
                            if (n.combinedBuffer.length) {
                                let e;
                                this.Wl.haveEnough = !1,
                                n.paused || this.Wl.pause(),
                                s ? this.fu.replaceItemAction === as.DO_NOTHING && (e = this.Wl.flushAll(0, 1 / 0)) : e = this.Wl.flushAll(0, 1 / 0).pipe(te( () => ce(this.Wl.mediaQuery.updating$, e => !e)), W( () => {
                                    this.Wl.msDuration = 0
                                }
                                )),
                                e && l.unshift(e)
                            }
                        }
                    }
                    if (s) {
                        const e = null != (t = n.itemOptions) ? t : {};
                        a && this.fu.replaceItemAction && (e.replaceItemAction = this.fu.replaceItemAction),
                        this.Lu(n.url, e, n.initialSeekTime)
                    }
                }
                ),
                0 < l.length ? aa(l).pipe(W( () => {}
                )) : ue
            }
            levelWithPersistentId(e) {}
            startLoad(e) {
                re(e) && (this.seekTo = e)
            }
            stopLoad() {}
            get config() {
                return this.fu
            }
            get media() {
                return null != this.Gl.value
            }
            set subtitleDisplay(e) {}
            Tu(l, e, t) {
                var i;
                if (this.Ja.setRootPlaylistQuery(null),
                this.Ra.next(null),
                null != (i = this.Nu) && i.reset(),
                !l)
                    return Y(null);
                const r = Object.assign({}, t);
                if (null != l && l.isInterstitial)
                    for (const l of Is) {
                        const e = t[l].interstitial
                          , i = t[l];
                        r[l] = Object.assign(Object.assign({}, i), {
                            default: e,
                            customURL: e
                        })
                    }
                return Fr([function(i, r, n, a, s, e, o, l, d, u, c, t, h, p) {
                    const {itemId: m, platformInfo: f, isInterstitial: g, serviceName: y} = i
                      , v = Ls(i)
                      , S = n.getQueryForId(m)
                      , I = n["logger"]
                      , b = p.getActiveItemContext(m);
                    if (S.hasEntity(m)) {
                        n.setActive(m);
                        const i = c.alternateMatchingInfo;
                        if (b && i) {
                            const r = [null, null != b && b.userSwitchAudioTrack ? {
                                userInitiated: !0,
                                triggerEvent: !0
                            } : null, null != b && b.userSwitchSubtitleTrack ? {
                                userInitiated: !0
                            } : null];
                            {
                                var T = m
                                  , E = (c = i,
                                r)
                                  , A = b
                                  , O = S
                                  , R = n
                                  , w = d
                                  , P = [!0, Boolean(c.audioMatchingInfo), Boolean(c.subtitleMatchingInfo)]
                                  , M = O.preferHDR
                                  , C = O.enabledVariantMediaOption
                                  , k = c.audioMatchingInfo
                                  , L = c.subtitleMatchingInfo;
                                let e = null == k ? void 0 : k.persistentId
                                  , t = null == L ? void 0 : L.persistentId;
                                if (!re(e)) {
                                    const T = Qg(0, A, c.audioMatchingInfo, O.audioMediaSelectionGroup.MediaSelectionGroupOptions, w.enableInterstitialPlayback);
                                    e = null == T ? void 0 : T.MediaSelectionOptionsPersistentID
                                }
                                if (!re(t)) {
                                    const T = Qg(0, A, c.subtitleMatchingInfo, O.subtitleMediaSelectionGroup.MediaSelectionGroupOptions, w.enableInterstitialPlayback);
                                    t = null == T ? void 0 : T.MediaSelectionOptionsPersistentID
                                }
                                k = R.getBestMediaOptionTupleFromVariantAndPersistentId(O, C, e, t, P, [], null, !M, !1, !1, !1),
                                Ds(k[se.Variant]) && R.setEnabledMediaOptionsAndSwitchContexts(T, k, E)
                            }
                        }
                        return Y(S)
                    }
                    n.setLoading(!0),
                    A = d.enableItemPreloading && null != (L = a.getPrefetchCache(i.appItemId)) ? L.rootEntity : void 0;
                    let N;
                    if (A)
                        N = Y(A).pipe(W(e => ((e = Object.assign({}, e)).itemStartOffsets = i.itemStartOffsets,
                        e)));
                    else {
                        a.clearPrefetchCache();
                        const c = performance.now();
                        N = function(t, e, i, r, n, a) {
                            const s = t["url"]
                              , o = eo(t, e);
                            return Mo({
                                url: s,
                                onProgress: {
                                    getData: !0,
                                    cb: Cg
                                },
                                xhrSetup: n.xhrSetup
                            }, o, a, i).pipe(W(e => Mg(s, e, t, n, r)), io(!1))
                        }(i, r, e, I, d, l.query.extendMaxTTFB).pipe(yf(m, p, null, eo(i, r), 0, !1, S, n, t), te(e => {
                            h.triggerManifestLoaded(e);
                            var {initialDetails: t, stats: i, interstitials: r} = e
                              , t = (t && (a.archiveMediaOptionDetails(n, t, Object.assign({}, i), !0, d.liveAllowLowLatencyPlayback),
                            d.enableInterstitialPlayback) && 0 < r.length && s.addInterstitials(r),
                            u.displaySupportsHdr)
                              , i = jg(e)["variantMediaOptions"];
                            return qg(e, f, o, d, t, g, i, I)
                        }
                        ), W(e => {
                            var t = d.enableAdaptiveStartup ? D.getCombinedEstimate(d, y) : null;
                            return Object.isFrozen(e.loadStats) || (e.loadStats.tfiltered = performance.now()),
                            Yg(0, b, e, l, o, c, d, t, I)
                        }
                        ))
                    }
                    const D = t.getQueryForId(v);
                    return N.pipe(W(e => (n.setRootPlaylistEntity(m, e),
                    S)), ee( () => {
                        n.setLoading(!1)
                    }
                    ))
                }(l, t.manifestLoadPolicy, this.Aa, this.Yl, this.Xa, this.Re, this.yu, this.aa, t, this.Jl.query, this.aa.query, this.Fl, this.Ja, this.itemQueue).pipe(te(e => (this.Ja.setRootPlaylistQuery(e),
                this.Ra.next(e),
                this.Ja.triggerManifestParsed(e),
                ne(function(e, t, i, r, n, a, s, o, l, d, u, c, h) {
                    const p = t["canUseNetworkResourcesForLiveStreamingWhilePaused"]
                      , m = {
                        rootPlaylistQuery: r,
                        rootPlaylistService: i,
                        statsService: a,
                        rtcService: s,
                        logger: e,
                        config: t,
                        interstitialService: o,
                        customUrlLoader: u,
                        itemQueue: c,
                        hlsService: l,
                        playerEvents: h
                    }
                      , f = [];
                    return Us.forEach(e => {
                        e !== se.Variant && !r.hasAlternateWithUrl(e) || f.push(r.enabledMediaOptionByType$(e).pipe(te(e => xs(e) && Ds(e) ? n.retrieveMediaOptionDetails(m, e, !1, !1).pipe(on(t => function(e) {
                            if (!e)
                                return X;
                            var {mediaOptionDetails: e, lastUpdateMillis: t, unchangedCount: i} = e;
                            if (null == e || !e.liveOrEvent)
                                return X;
                            if (Km(e, null != t ? t : 0))
                                return yr(0).pipe();
                            let r = Qm(e);
                            return 0 < i && (r /= 2,
                            r = Math.max(r, 5e3)),
                            r = r - (performance.now() - (null != t ? t : 0)) + 0,
                            yr(r = Math.max(1e3, Math.round(r))).pipe()
                        }(n.getQueryForOption(t).mediaOptionDetailsEntity).pipe(te( () => p ? Y(!0) : d.pipe(te(e => e ? e.desiredRate$ : Y(0))).pipe(W(e => 0 !== e), J())), te(e => e ? n.retrieveMediaOptionDetails(m, t, !1, !0, !0) : X), tn(1)), 1)) : X)))
                    }
                    ),
                    ne(...f).pipe(Eg(e, "loadMediaOptions"))
                }(this.logger, r, this.Aa, e, this.Yl, this.Fl, this.Nr, this.Xa, this.aa, this.mediaElementQuery$, this.Re, this.itemQueue, this.Ja).pipe(te( () => X)), Y(e))))), na( () => (null == this.Nu && (this.Nu = new Pg(t,this.logger,this.Xl.mux)),
                Y(this.Nu))), Y(r)]).pipe(te(e => {
                    var t, i, r, [e,n,a] = e, s = {
                        logger: this.logger,
                        config: a,
                        statsService: this.Fl,
                        rootPlaylistQuery: e,
                        rootPlaylistService: this.Aa,
                        interstitialService: this.Xa,
                        mediaParser: n,
                        gaplessInstance: this.uu,
                        keySystemAdapter: this.Zl,
                        rpcClients: this.Xl,
                        rtcService: this.Nr,
                        customUrlLoader: this.Re,
                        itemQueue: this.itemQueue,
                        hlsService: this.aa,
                        playerEvents: this.Ja
                    }, o = null == (o = this.itemQueue.getQueueItemForId(e.itemId)) ? void 0 : o.name;
                    return (o = s.config.enableItemPreloading ? this.Yl.getPrefetchCache(o) : void 0) && o.fragRequest ? Y({
                        rootPlaylistQuery: e,
                        mediaParser: n,
                        config: a
                    }) : ne((o = this.Yl,
                    t = this.Zl,
                    i = this.aa.query,
                    r = s["rootPlaylistQuery"],
                    o = function(a, s, o, l, d) {
                        const u = o.rootPlaylistQuery.appItemId;
                        return e => e.pipe(Bf(a, 1), te( (i, r) => {
                            if (i && 0 === r) {
                                const r = Object.values(i.initSegments);
                                let e, t = NaN;
                                if (i.liveOrEvent)
                                    1 === r.length && (t = r[0].discoSeqNum);
                                else {
                                    const a = l.pendingSeek;
                                    n = a instanceof Date ? Sg(i.pdtToMSN, i.fragments, a) : Ig(null != (n = null != a ? a : d) ? n : 0, !0, [i, null], o.config, o.rootPlaylistQuery, void 0, !1),
                                    e = yg.findFragmentBySNAndBuffer(void 0, i.fragments, n, zp(i)),
                                    t = F(null == e ? void 0 : e.discoSeqNum, NaN)
                                }
                                var n = new Array;
                                if (e ? n.push(a.cacheFrag(o, e)) : re(t) && n.push(a.retrieveInitSegmentCacheEntity(o, i, t)),
                                null != e && e.keyTagInfo && s) {
                                    const a = e.keyTagInfo;
                                    n.push(s.getKeyFromDecryptData(a, {
                                        itemId: e.itemId,
                                        mediaOptionId: e.mediaOptionId,
                                        appItemId: u
                                    }, o.config.keyLoadPolicy))
                                }
                                if (0 < n.length)
                                    return aa(n)
                            }
                            return ue
                        }
                        ), tn(1), te( () => X), $(e => (o.logger.error(`prefetchFirstSegAndKey: err=` + e.message),
                        X)))
                    }(o, t, s, i, l.initialSeekTime),
                    t = [r.enabledMediaOptionByType$(se.Variant).pipe(o)],
                    r.hasAlternateWithUrl(se.AltAudio) && t.push(r.enabledMediaOptionByType$(se.AltAudio).pipe(o)),
                    ne(...t)), Y({
                        rootPlaylistQuery: e,
                        mediaParser: n,
                        config: a
                    }))
                }
                ))
            }
        }
    }
    ,
    "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = "undefined" != typeof globalThis ? globalThis : e || my).Hls = t()
}(!1);
//# sourceMappingURL=hls.js.map
