hls-parser
Advanced tools
Comparing version 0.10.7 to 0.10.8
/*! For license information please see hls-parser.min.js.LICENSE.txt */ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HLS=t():e.HLS=t()}(self,(()=>(()=>{"use strict";var e={492:function(e,t,s){var i=this&&this.__createBinding||(Object.create?function(e,t,s,i){void 0===i&&(i=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,i,n)}:function(e,t,s,i){void 0===i&&(i=s),e[i]=t[s]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&i(t,e,s);return n(t,e),t},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setOptions=t.getOptions=t.types=t.stringify=t.parse=void 0;const o=s(591);Object.defineProperty(t,"getOptions",{enumerable:!0,get:function(){return o.getOptions}}),Object.defineProperty(t,"setOptions",{enumerable:!0,get:function(){return o.setOptions}});const T=r(s(749));t.parse=T.default;const u=r(s(186));t.stringify=u.default;const E=a(s(676));t.types=E},749:function(e,t,s){var i=this&&this.__createBinding||(Object.create?function(e,t,s,i){void 0===i&&(i=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,i,n)}:function(e,t,s,i){void 0===i&&(i=s),e[i]=t[s]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&i(t,e,s);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});const r=a(s(591)),o=s(676);function T(e){return r.trim(e,'"')}function u(e){const t=r.splitAt(e,",");return{duration:r.toNumber(t[0]),title:decodeURIComponent(escape(t[1]))}}function E(e){const t=r.splitAt(e,"@");return{length:r.toNumber(t[0]),offset:t[1]?r.toNumber(t[1]):-1}}function c(e){const t=r.splitAt(e,"x");return{width:r.toNumber(t[0]),height:r.toNumber(t[1])}}function l(e){const t="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",s=e.split(",");0===s.length&&r.INVALIDPLAYLIST(t);const i=[];for(const e of s){const[s,n]=r.splitAt(e,":");s&&n?i.push({format:s,cpcList:n.split("/")}):r.INVALIDPLAYLIST(t)}return i}function I(e){const t=r.hexToByteSequence(e);return 16!==t.length&&r.INVALIDPLAYLIST("IV must be a 128-bit unsigned integer"),t}function A(e,t){t.IV&&e.compatibleVersion<2&&(e.compatibleVersion=2),(t.KEYFORMAT||t.KEYFORMATVERSIONS)&&e.compatibleVersion<5&&(e.compatibleVersion=5)}function h(e){const t={};for(const i of r.splitByCommaWithPreservingQuotes(e)){const[e,n]=r.splitAt(i,"="),a=T(n);switch(e){case"URI":t[e]=a;break;case"START-DATE":case"END-DATE":t[e]=new Date(a);break;case"IV":t[e]=I(a);break;case"BYTERANGE":t[e]=E(a);break;case"RESOLUTION":t[e]=c(a);break;case"ALLOWED-CPC":t[e]=l(a);break;case"END-ON-NEXT":case"DEFAULT":case"AUTOSELECT":case"FORCED":case"PRECISE":case"CAN-BLOCK-RELOAD":case"INDEPENDENT":case"GAP":t[e]="YES"===a;break;case"DURATION":case"PLANNED-DURATION":case"BANDWIDTH":case"AVERAGE-BANDWIDTH":case"FRAME-RATE":case"TIME-OFFSET":case"CAN-SKIP-UNTIL":case"HOLD-BACK":case"PART-HOLD-BACK":case"PART-TARGET":case"BYTERANGE-START":case"BYTERANGE-LENGTH":case"LAST-MSN":case"LAST-PART":case"SKIPPED-SEGMENTS":case"SCORE":case"PROGRAM-ID":t[e]=r.toNumber(a);break;default:e.startsWith("SCTE35-")?t[e]=r.hexToByteSequence(a):e.startsWith("X-")?t[e]=(s=n).startsWith('"')?T(s):s.startsWith("0x")||s.startsWith("0X")?r.hexToByteSequence(s):r.toNumber(s):("VIDEO-RANGE"===e&&"SDR"!==a&&"HLG"!==a&&"PQ"!==a&&r.INVALIDPLAYLIST(`VIDEO-RANGE: unknown value "${a}"`),t[e]=a)}}var s;return t}function N(){r.INVALIDPLAYLIST("The file contains both media and master playlist tags.")}function f(e,t,s){const i=function({attributes:e}){return new o.Rendition({type:e.TYPE,uri:e.URI,groupId:e["GROUP-ID"],language:e.LANGUAGE,assocLanguage:e["ASSOC-LANGUAGE"],name:e.NAME,isDefault:e.DEFAULT,autoselect:e.AUTOSELECT,forced:e.FORCED,instreamId:e["INSTREAM-ID"],characteristics:e.CHARACTERISTICS,channels:e.CHANNELS})}(t),n=e[r.camelify(s)],a=function(e,t){let s=!1;for(const i of e){if(i.name===t.name)return"All EXT-X-MEDIA tags in the same Group MUST have different NAME attributes.";i.isDefault&&(s=!0)}return s&&t.isDefault?"EXT-X-MEDIA A Group MUST NOT have more than one member with a DEFAULT attribute of YES.":""}(n,i);a&&r.INVALIDPLAYLIST(a),n.push(i),i.isDefault&&(e.currentRenditions[r.camelify(s)]=n.length-1)}function S(e,t,s,i,n){const a=new o.Variant({uri:s,bandwidth:t.BANDWIDTH,averageBandwidth:t["AVERAGE-BANDWIDTH"],score:t.SCORE,codecs:t.CODECS,resolution:t.RESOLUTION,frameRate:t["FRAME-RATE"],hdcpLevel:t["HDCP-LEVEL"],allowedCpc:t["ALLOWED-CPC"],videoRange:t["VIDEO-RANGE"],stableVariantId:t["STABLE-VARIANT-ID"],programId:t["PROGRAM-ID"]});for(const s of e)if("EXT-X-MEDIA"===s.name){const e=s.attributes,i=e.TYPE;if(i&&e["GROUP-ID"]||r.INVALIDPLAYLIST("EXT-X-MEDIA TYPE attribute is REQUIRED."),t[i]===e["GROUP-ID"]&&(f(a,s,i),"CLOSED-CAPTIONS"===i))for(const{instreamId:e}of a.closedCaptions)if(e&&e.startsWith("SERVICE")&&n.compatibleVersion<7){n.compatibleVersion=7;break}}return function(e,t,s){for(const i of["AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS"])"CLOSED-CAPTIONS"===i&&"NONE"===e[i]?(s.isClosedCaptionsNone=!0,t.closedCaptions=[]):e[i]&&!t[r.camelify(i)].some((t=>t.groupId===e[i]))&&r.INVALIDPLAYLIST(`${i} attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ${i}.`)}(t,a,n),a.isIFrameOnly=i,a}function p(e,t){if(e.method!==t.method)return!1;if(e.uri!==t.uri)return!1;if(e.iv){if(!t.iv)return!1;if(e.iv.length!==t.iv.length)return!1;for(let s=0;s<e.iv.length;s++)if(e.iv[s]!==t.iv[s])return!1}else if(t.iv)return!1;return e.format===t.format&&e.formatVersion===t.formatVersion}function d(e,t,s,i,n,a,T){const u=new o.Segment({uri:t,mediaSequenceNumber:n,discontinuitySequence:a});let E=!1,c=!1;for(let t=s;t<=i;t++){const{name:s,value:i,attributes:n}=e[t];if("EXTINF"===s)!Number.isInteger(i.duration)&&T.compatibleVersion<3&&(T.compatibleVersion=3),Math.round(i.duration)>T.targetDuration&&r.INVALIDPLAYLIST("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration"),u.duration=i.duration,u.title=i.title;else if("EXT-X-BYTERANGE"===s)T.compatibleVersion<4&&(T.compatibleVersion=4),u.byterange=i;else if("EXT-X-DISCONTINUITY"===s)u.parts.length>0&&r.INVALIDPLAYLIST("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment."),u.discontinuity=!0;else if("EXT-X-KEY"===s)u.parts.length>0&&r.INVALIDPLAYLIST("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment."),A(T,n),u.key=new o.Key({method:n.METHOD,uri:n.URI,iv:n.IV,format:n.KEYFORMAT,formatVersion:n.KEYFORMATVERSIONS});else if("EXT-X-MAP"===s)u.parts.length>0&&r.INVALIDPLAYLIST("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment."),T.compatibleVersion<5&&(T.compatibleVersion=5),T.hasMap=!0,u.map=new o.MediaInitializationSection({uri:n.URI,byterange:n.BYTERANGE});else if("EXT-X-PROGRAM-DATE-TIME"===s)u.programDateTime=i;else if("EXT-X-DATERANGE"===s){const e={};for(const t of Object.keys(n))(t.startsWith("SCTE35-")||t.startsWith("X-"))&&(e[t]=n[t]);u.dateRange=new o.DateRange({id:n.ID,classId:n.CLASS,start:n["START-DATE"],end:n["END-DATE"],duration:n.DURATION,plannedDuration:n["PLANNED-DURATION"],endOnNext:n["END-ON-NEXT"],attributes:e})}else if("EXT-X-CUE-OUT"===s)u.markers.push(new o.SpliceInfo({type:"OUT",duration:n&&n.DURATION||i}));else if("EXT-X-CUE-IN"===s)u.markers.push(new o.SpliceInfo({type:"IN"}));else if("EXT-X-CUE-OUT-CONT"===s||"EXT-X-CUE"===s||"EXT-OATCLS-SCTE35"===s||"EXT-X-ASSET"===s||"EXT-X-SCTE35"===s)u.markers.push(new o.SpliceInfo({type:"RAW",tagName:s,value:i}));else if("EXT-X-PRELOAD-HINT"!==s||n.TYPE)if("EXT-X-PRELOAD-HINT"===s&&"PART"===n.TYPE&&c)r.INVALIDPLAYLIST("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.");else if("EXT-X-PART"!==s&&"EXT-X-PRELOAD-HINT"!==s||n.URI){if("EXT-X-PRELOAD-HINT"===s&&"MAP"===n.TYPE)E&&r.INVALIDPLAYLIST("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist."),E=!0,T.hasMap=!0,u.map=new o.MediaInitializationSection({hint:!0,uri:n.URI,byterange:{length:n["BYTERANGE-LENGTH"],offset:n["BYTERANGE-START"]||0}});else if("EXT-X-PART"===s||"EXT-X-PRELOAD-HINT"===s&&"PART"===n.TYPE){"EXT-X-PART"!==s||n.DURATION||r.INVALIDPLAYLIST("EXT-X-PART: DURATION attribute is mandatory"),"EXT-X-PRELOAD-HINT"===s&&(c=!0);const e=new o.PartialSegment({hint:"EXT-X-PRELOAD-HINT"===s,uri:n.URI,byterange:"EXT-X-PART"===s?n.BYTERANGE:{length:n["BYTERANGE-LENGTH"],offset:n["BYTERANGE-START"]||0},duration:n.DURATION,independent:n.INDEPENDENT,gap:n.GAP});u.parts.push(e)}}else r.INVALIDPLAYLIST("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory");else r.INVALIDPLAYLIST("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory")}return u}function X(e,t,s,i,n,a,T){const u=new o.PrefetchSegment({uri:t,mediaSequenceNumber:n,discontinuitySequence:a});for(let t=s;t<=i;t++){const{name:s,attributes:i}=e[t];"EXTINF"===s?r.INVALIDPLAYLIST("A prefetch segment must not be advertised with an EXTINF tag."):"EXT-X-DISCONTINUITY"===s?r.INVALIDPLAYLIST("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag."):"EXT-X-PREFETCH-DISCONTINUITY"===s?u.discontinuity=!0:"EXT-X-KEY"===s?(A(T,i),u.key=new o.Key({method:i.METHOD,uri:i.URI,iv:i.IV,format:i.KEYFORMAT,formatVersion:i.KEYFORMATVERSIONS})):"EXT-X-MAP"===s&&r.INVALIDPLAYLIST("Prefetch segments must not be advertised with an EXT-X-MAP tag.")}return u}function R(e,t){const s=new o.MediaPlaylist;let i=-1,n=0,a=!1,T=!1,u=0,E=null,c=null,l=!1;for(const[I,A]of e.entries()){const{name:h,value:N,attributes:f,category:S}=A;if("Segment"!==S){if("EXT-X-VERSION"===h)void 0===s.version?s.version=N:r.INVALIDPLAYLIST("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.");else if("EXT-X-TARGETDURATION"===h)s.targetDuration=t.targetDuration=N;else if("EXT-X-MEDIA-SEQUENCE"===h)s.segments.length>0&&r.INVALIDPLAYLIST("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist."),s.mediaSequenceBase=n=N;else if("EXT-X-DISCONTINUITY-SEQUENCE"===h)s.segments.length>0&&r.INVALIDPLAYLIST("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist."),a&&r.INVALIDPLAYLIST("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag."),s.discontinuitySequenceBase=u=N;else if("EXT-X-ENDLIST"===h)s.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===h)s.playlistType=N;else if("EXT-X-I-FRAMES-ONLY"===h)t.compatibleVersion<4&&(t.compatibleVersion=4),s.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===h)s.independentSegments&&r.INVALIDPLAYLIST("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist"),s.independentSegments=!0;else if("EXT-X-START"===h)s.start&&r.INVALIDPLAYLIST("EXT-X-START tag MUST NOT appear more than once in a Playlist"),"number"!=typeof f["TIME-OFFSET"]&&r.INVALIDPLAYLIST("EXT-X-START: TIME-OFFSET attribute is REQUIRED"),s.start={offset:f["TIME-OFFSET"],precise:f.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===h)f["CAN-BLOCK-RELOAD"]||r.INVALIDPLAYLIST("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS"),s.lowLatencyCompatibility={canBlockReload:f["CAN-BLOCK-RELOAD"],canSkipUntil:f["CAN-SKIP-UNTIL"],holdBack:f["HOLD-BACK"],partHoldBack:f["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===h)f["PART-TARGET"]||r.INVALIDPLAYLIST("EXT-X-PART-INF: PART-TARGET attribute is mandatory"),s.partTargetDuration=f["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===h)f.URI||r.INVALIDPLAYLIST("EXT-X-RENDITION-REPORT: URI attribute is mandatory"),0===f.URI.search(/^[a-z]+:/)&&r.INVALIDPLAYLIST("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri"),s.renditionReports.push(new o.RenditionReport({uri:f.URI,lastMSN:f["LAST-MSN"],lastPart:f["LAST-PART"]}));else if("EXT-X-SKIP"===h)f["SKIPPED-SEGMENTS"]||r.INVALIDPLAYLIST("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory"),t.compatibleVersion<9&&(t.compatibleVersion=9),s.skip=f["SKIPPED-SEGMENTS"],n+=s.skip;else if("EXT-X-PREFETCH"===h){const a=X(e,N,-1===i?I:i,I-1,n++,u,t);a&&(a.discontinuity&&(a.discontinuitySequence++,u=a.discontinuitySequence),a.key?E=a.key:a.key=E,s.prefetchSegments.push(a)),T=!0,i=-1}else if("string"==typeof A){-1===i&&r.INVALIDPLAYLIST("A URI line is not preceded by any segment tags"),s.targetDuration||r.INVALIDPLAYLIST("The EXT-X-TARGETDURATION tag is REQUIRED"),T&&r.INVALIDPLAYLIST("These segments must appear after all complete segments.");const a=d(e,A,i,I-1,n++,u,t);a&&([u,E,c]=D(s,a,u,E,c),!l&&a.parts.length>0&&(l=!0)),i=-1}}else-1===i&&(i=I),"EXT-X-DISCONTINUITY"===h&&(a=!0)}if(-1!==i){const a=d(e,"",i,e.length-1,n++,u,t);if(a){const{parts:e}=a;e.length>0&&!s.endlist&&!e.at(-1)?.hint&&r.INVALIDPLAYLIST("If the Playlist contains EXT-X-PART tags and does not contain an EXT-X-ENDLIST tag, the Playlist must contain an EXT-X-PRELOAD-HINT tag with a TYPE=PART attribute"),D(s,a,E,c),!l&&a.parts.length>0&&(l=!0)}}return function(e){const t=new Map,s=new Map;let i=!1,n=!1;for(let a=e.length-1;a>=0;a--){const{programDateTime:o,dateRange:T}=e[a];if(o&&(n=!0),T&&T.start){i=!0,T.endOnNext&&(T.end||T.duration)&&r.INVALIDPLAYLIST("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.");const e=T.start.getTime(),n=T.duration||0;T.end&&T.duration&&e+1e3*n!==T.end.getTime()&&r.INVALIDPLAYLIST("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION"),T.endOnNext&&(T.end=t.get(T.classId)),t.set(T.classId,T.start);const a=T.end?T.end.getTime():T.start.getTime()+1e3*(T.duration||0),o=s.get(T.classId);if(o){for(const t of o)(t.start<=e&&t.end>e||t.start>=e&&t.start<a)&&r.INVALIDPLAYLIST("DATERANGE tags with the same CLASS should not overlap");o.push({start:e,end:a})}else s.set(T.classId,[{start:e,end:a}])}}i&&!n&&r.INVALIDPLAYLIST("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.")}(s.segments),s.lowLatencyCompatibility&&function({lowLatencyCompatibility:e,targetDuration:t,partTargetDuration:s,segments:i,renditionReports:n},a){const{canSkipUntil:o,holdBack:T,partHoldBack:u}=e;o<6*t&&r.INVALIDPLAYLIST("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.");T<3*t&&r.INVALIDPLAYLIST("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.");if(a){void 0===s&&r.INVALIDPLAYLIST("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags"),void 0===u&&r.INVALIDPLAYLIST("EXT-X-PART: PART-HOLD-BACK attribute is mandatory"),u<s&&r.INVALIDPLAYLIST("PART-HOLD-BACK must be at least PART-TARGET");for(const[e,{parts:t}]of i.entries()){t.length>0&&e<i.length-3&&r.INVALIDPLAYLIST("Remove EXT-X-PART tags from the Playlist after they are greater than three target durations from the end of the Playlist.");for(const[e,{duration:i}]of t.entries())void 0!==i&&(i>s&&r.INVALIDPLAYLIST("PART-TARGET is the maximum duration of any Partial Segment"),e<t.length-1&&i<.85*s&&r.INVALIDPLAYLIST("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET"))}}for(const e of n){const t=i.at(-1);null!==e.lastMSN&&void 0!==e.lastMSN||(e.lastMSN=t.mediaSequenceNumber),(null===e.lastPart||void 0===e.lastPart)&&t.parts.length>0&&(e.lastPart=t.parts.length-1)}}(s,l),s}function D(e,t,s,i,n){const{discontinuity:a,key:o,map:T,byterange:u,uri:E}=t;if(a&&(t.discontinuitySequence=s+1),o||(t.key=i),T||(t.map=n),u&&-1===u.offset){const{segments:t}=e;if(t.length>0){const e=t.at(-1);e.byterange&&e.uri===E?u.offset=e.byterange.offset+e.byterange.length:r.INVALIDPLAYLIST("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource")}else r.INVALIDPLAYLIST("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file")}return e.segments.push(t),[t.discontinuitySequence,t.key,t.map]}function L(e,t){const[s,i]=function(e){const t=e.indexOf(":");return-1===t?[e.slice(1).trim(),null]:[e.slice(1,t).trim(),e.slice(t+1).trim()]}(e),n=function(e){switch(e){case"EXTM3U":case"EXT-X-VERSION":return"Basic";case"EXTINF":case"EXT-X-BYTERANGE":case"EXT-X-DISCONTINUITY":case"EXT-X-PREFETCH-DISCONTINUITY":case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-PROGRAM-DATE-TIME":case"EXT-X-DATERANGE":case"EXT-X-CUE-OUT":case"EXT-X-CUE-IN":case"EXT-X-CUE-OUT-CONT":case"EXT-X-CUE":case"EXT-OATCLS-SCTE35":case"EXT-X-ASSET":case"EXT-X-SCTE35":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":return"Segment";case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":case"EXT-X-ENDLIST":case"EXT-X-PLAYLIST-TYPE":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PREFETCH":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return"MediaPlaylist";case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":return"MasterPlaylist";case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-START":return"MediaorMasterPlaylist";default:return"Unknown"}}(s);if(function(e,t){if("Segment"===e||"MediaPlaylist"===e)return void 0===t.isMasterPlaylist?void(t.isMasterPlaylist=!1):void(t.isMasterPlaylist&&N());if("MasterPlaylist"===e){if(void 0===t.isMasterPlaylist)return void(t.isMasterPlaylist=!0);!1===t.isMasterPlaylist&&N()}}(n,t),"Unknown"===n)return null;"MediaPlaylist"===n&&"EXT-X-RENDITION-REPORT"!==s&&"EXT-X-PREFETCH"!==s&&(t.hash[s]&&r.INVALIDPLAYLIST("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist"),t.hash[s]=!0);const[a,o]=function(e,t){switch(e){case"EXTM3U":case"EXT-X-DISCONTINUITY":case"EXT-X-ENDLIST":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-CUE-IN":return[null,null];case"EXT-X-VERSION":case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":return[r.toNumber(t),null];case"EXT-X-CUE-OUT":return Number.isNaN(Number(t))?[null,h(t)]:[r.toNumber(t),null];case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-DATERANGE":case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":case"EXT-X-START":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return[null,h(t)];case"EXTINF":return[u(t),null];case"EXT-X-BYTERANGE":return[E(t),null];case"EXT-X-PROGRAM-DATE-TIME":return[new Date(t),null];default:return[t,null]}}(s,i);return{name:s,category:n,value:a,attributes:o}}function m(e,t){let s;return t.isMasterPlaylist?s=function(e,t){const s=new o.MasterPlaylist;let i=!1;for(const[n,{name:a,value:T,attributes:u}]of e.entries())if("EXT-X-VERSION"===a)s.version=T;else if("EXT-X-STREAM-INF"===a){const a=e[n+1];("string"!=typeof a||a.startsWith("#EXT"))&&r.INVALIDPLAYLIST("EXT-X-STREAM-INF must be followed by a URI line");const o=S(e,u,a,!1,t);o&&("number"==typeof o.score&&(i=!0,o.score<0&&r.INVALIDPLAYLIST("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.")),s.variants.push(o))}else if("EXT-X-I-FRAME-STREAM-INF"===a){const i=S(e,u,u.URI,!0,t);i&&s.variants.push(i)}else if("EXT-X-SESSION-DATA"===a){const e=new o.SessionData({id:u["DATA-ID"],value:u.VALUE,uri:u.URI,language:u.LANGUAGE});s.sessionDataList.some((t=>t.id===e.id&&t.language===e.language))&&r.INVALIDPLAYLIST("A Playlist MUST NOT contain more than one EXT-X-SESSION-DATA tag with the same DATA-ID attribute and the same LANGUAGE attribute."),s.sessionDataList.push(e)}else if("EXT-X-SESSION-KEY"===a){"NONE"===u.METHOD&&r.INVALIDPLAYLIST("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE");const e=new o.Key({method:u.METHOD,uri:u.URI,iv:u.IV,format:u.KEYFORMAT,formatVersion:u.KEYFORMATVERSIONS});s.sessionKeyList.some((t=>p(t,e)))&&r.INVALIDPLAYLIST("A Master Playlist MUST NOT contain more than one EXT-X-SESSION-KEY tag with the same METHOD, URI, IV, KEYFORMAT, and KEYFORMATVERSIONS attribute values."),A(t,u),s.sessionKeyList.push(e)}else"EXT-X-INDEPENDENT-SEGMENTS"===a?(s.independentSegments&&r.INVALIDPLAYLIST("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist"),s.independentSegments=!0):"EXT-X-START"===a&&(s.start&&r.INVALIDPLAYLIST("EXT-X-START tag MUST NOT appear more than once in a Playlist"),"number"!=typeof u["TIME-OFFSET"]&&r.INVALIDPLAYLIST("EXT-X-START: TIME-OFFSET attribute is REQUIRED"),s.start={offset:u["TIME-OFFSET"],precise:u.PRECISE||!1});if(i)for(const e of s.variants)"number"!=typeof e.score&&r.INVALIDPLAYLIST("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute");if(t.isClosedCaptionsNone)for(const e of s.variants)e.closedCaptions.length>0&&r.INVALIDPLAYLIST("If there is a variant with CLOSED-CAPTIONS attribute of NONE, all EXT-X-STREAM-INF tags MUST have this attribute with a value of NONE");return s}(e,t):(s=R(e,t),!s.isIFrame&&t.hasMap&&t.compatibleVersion<6&&(t.compatibleVersion=6)),t.compatibleVersion>1&&(!s.version||s.version<t.compatibleVersion)&&r.INVALIDPLAYLIST(`EXT-X-VERSION needs to be ${t.compatibleVersion} or higher.`),s}t.default=function(e){const t={version:void 0,isMasterPlaylist:void 0,hasMap:!1,targetDuration:0,compatibleVersion:1,isClosedCaptionsNone:!1,hash:{}},s=m(function(e,t){const s=[];for(const i of e.split("\n")){const e=Buffer.from(i.trim()).toString();if(e)if(e.startsWith("#")){if(e.startsWith("#EXT")){const i=L(e,t);i&&s.push(i)}}else s.push(e)}return 0!==s.length&&"EXTM3U"===s[0].name||r.INVALIDPLAYLIST("The EXTM3U tag MUST be the first line."),s}(e,t),t);return s.source=e,s}},186:function(e,t,s){var i=this&&this.__createBinding||(Object.create?function(e,t,s,i){void 0===i&&(i=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,i,n)}:function(e,t,s,i){void 0===i&&(i=s),e[i]=t[s]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&i(t,e,s);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});const r=a(s(591)),o=["#EXTINF","#EXT-X-BYTERANGE","#EXT-X-DISCONTINUITY","#EXT-X-STREAM-INF","#EXT-X-CUE-OUT","#EXT-X-CUE-IN","#EXT-X-KEY","#EXT-X-MAP"],T=["#EXT-X-MEDIA"];class u extends Array{constructor(e){super(),this.baseUri=e}push(...e){for(const t of e)if(t.startsWith("#"))if(o.some((e=>t.startsWith(e))))super.push(t);else{if(this.includes(t)){if(T.some((e=>t.startsWith(e))))continue;r.INVALIDPLAYLIST(`Redundant item (${t})`)}super.push(t)}else super.push(t);return this.length}}function E(e,t){let s=1e3;t&&(s=10**t);const i=Math.round(e*s)/s;return t?i.toFixed(t):i}function c(e){const t=[`DATA-ID="${e.id}"`];return e.language&&t.push(`LANGUAGE="${e.language}"`),e.value?t.push(`VALUE="${e.value}"`):e.uri&&t.push(`URI="${e.uri}"`),`#EXT-X-SESSION-DATA:${t.join(",")}`}function l(e,t){const s=t?"#EXT-X-SESSION-KEY":"#EXT-X-KEY",i=[`METHOD=${e.method}`];return e.uri&&i.push(`URI="${e.uri}"`),e.iv&&(16!==e.iv.length&&r.INVALIDPLAYLIST("IV must be a 128-bit unsigned integer"),i.push(`IV=${r.byteSequenceToHex(e.iv)}`)),e.format&&i.push(`KEYFORMAT="${e.format}"`),e.formatVersion&&i.push(`KEYFORMATVERSIONS="${e.formatVersion}"`),`${s}:${i.join(",")}`}function I(e,t){const s=t.isIFrameOnly?"#EXT-X-I-FRAME-STREAM-INF":"#EXT-X-STREAM-INF",i=[`BANDWIDTH=${t.bandwidth}`];if(t.averageBandwidth&&i.push(`AVERAGE-BANDWIDTH=${t.averageBandwidth}`),t.isIFrameOnly&&i.push(`URI="${t.uri}"`),t.codecs&&i.push(`CODECS="${t.codecs}"`),t.resolution&&i.push(`RESOLUTION=${t.resolution.width}x${t.resolution.height}`),t.frameRate&&i.push(`FRAME-RATE=${E(t.frameRate,3)}`),t.hdcpLevel&&i.push(`HDCP-LEVEL=${t.hdcpLevel}`),t.audio.length>0){i.push(`AUDIO="${t.audio[0].groupId}"`);for(const s of t.audio)e.push(A(s))}if(t.video.length>0){i.push(`VIDEO="${t.video[0].groupId}"`);for(const s of t.video)e.push(A(s))}if(t.subtitles.length>0){i.push(`SUBTITLES="${t.subtitles[0].groupId}"`);for(const s of t.subtitles)e.push(A(s))}if(r.getOptions().allowClosedCaptionsNone&&0===t.closedCaptions.length)i.push("CLOSED-CAPTIONS=NONE");else if(t.closedCaptions.length>0){i.push(`CLOSED-CAPTIONS="${t.closedCaptions[0].groupId}"`);for(const s of t.closedCaptions)e.push(A(s))}if(t.score&&i.push(`SCORE=${t.score}`),t.allowedCpc){const e=[];for(const{format:s,cpcList:i}of t.allowedCpc)e.push(`${s}:${i.join("/")}`);i.push(`ALLOWED-CPC="${e.join(",")}"`)}t.videoRange&&i.push(`VIDEO-RANGE=${t.videoRange}`),t.stableVariantId&&i.push(`STABLE-VARIANT-ID="${t.stableVariantId}"`),t.programId&&i.push(`PROGRAM-ID=${t.programId}`),e.push(`${s}:${i.join(",")}`),t.isIFrameOnly||e.push(`${t.uri}`)}function A(e){const t=[`TYPE=${e.type}`,`GROUP-ID="${e.groupId}"`,`NAME="${e.name}"`];return void 0!==e.isDefault&&t.push("DEFAULT="+(e.isDefault?"YES":"NO")),void 0!==e.autoselect&&t.push("AUTOSELECT="+(e.autoselect?"YES":"NO")),void 0!==e.forced&&t.push("FORCED="+(e.forced?"YES":"NO")),e.language&&t.push(`LANGUAGE="${e.language}"`),e.assocLanguage&&t.push(`ASSOC-LANGUAGE="${e.assocLanguage}"`),e.instreamId&&t.push(`INSTREAM-ID="${e.instreamId}"`),e.characteristics&&t.push(`CHARACTERISTICS="${e.characteristics}"`),e.channels&&t.push(`CHANNELS="${e.channels}"`),e.uri&&t.push(`URI="${e.uri}"`),`#EXT-X-MEDIA:${t.join(",")}`}function h(e,t,s,i,n=1){let a=!1,o="";if(t.discontinuity&&e.push("#EXT-X-DISCONTINUITY"),t.key){const i=l(t.key);i!==s&&(e.push(i),s=i)}if(t.map){const s=function(e){const t=[`URI="${e.uri}"`];e.byterange&&t.push(`BYTERANGE="${N(e.byterange)}"`);return`#EXT-X-MAP:${t.join(",")}`}(t.map);s!==i&&(e.push(s),i=s)}if(t.programDateTime&&e.push(`#EXT-X-PROGRAM-DATE-TIME:${r.formatDate(t.programDateTime)}`),t.dateRange&&e.push(function(e){const t=[`ID="${e.id}"`];e.start&&t.push(`START-DATE="${r.formatDate(e.start)}"`);e.end&&t.push(`END-DATE="${e.end}"`);e.duration&&t.push(`DURATION=${e.duration}`);e.plannedDuration&&t.push(`PLANNED-DURATION=${e.plannedDuration}`);e.classId&&t.push(`CLASS="${e.classId}"`);e.endOnNext&&t.push("END-ON-NEXT=YES");for(const s of Object.keys(e.attributes))s.startsWith("X-")?"number"==typeof e.attributes[s]?t.push(`${s}=${e.attributes[s]}`):t.push(`${s}="${e.attributes[s]}"`):s.startsWith("SCTE35-")&&t.push(`${s}=${r.byteSequenceToHex(e.attributes[s])}`);return`#EXT-X-DATERANGE:${t.join(",")}`}(t.dateRange)),t.markers.length>0&&(o=function(e,t){let s="";for(const i of t)if("OUT"===i.type)s="OUT",e.push(`#EXT-X-CUE-OUT:DURATION=${i.duration}`);else if("IN"===i.type)s="IN",e.push("#EXT-X-CUE-IN");else if("RAW"===i.type){const t=i.value?`:${i.value}`:"";e.push(`#${i.tagName}${t}`)}return s}(e,t.markers)),t.parts.length>0&&(a=function(e,t){let s=!1;for(const i of t)if(i.hint){const t=[];if(t.push("TYPE=PART",`URI="${i.uri}"`),i.byterange){const{offset:e,length:s}=i.byterange;t.push(`BYTERANGE-START=${e}`),s&&t.push(`BYTERANGE-LENGTH=${s}`)}e.push(`#EXT-X-PRELOAD-HINT:${t.join(",")}`),s=!0}else{const t=[];t.push(`DURATION=${i.duration}`,`URI="${i.uri}"`),i.byterange&&t.push(`BYTERANGE=${N(i.byterange)}`),i.independent&&t.push("INDEPENDENT=YES"),i.gap&&t.push("GAP=YES"),e.push(`#EXT-X-PART:${t.join(",")}`)}return s}(e,t.parts)),a)return[s,i];const T=n<3?Math.round(t.duration):E(t.duration,function(e){const t=e.toString(10),s=t.indexOf(".");return-1===s?0:t.length-s-1}(t.duration));return e.push(`#EXTINF:${T},${unescape(encodeURIComponent(t.title||""))}`),t.byterange&&e.push(`#EXT-X-BYTERANGE:${N(t.byterange)}`),Array.prototype.push.call(e,`${t.uri}`),[s,i,o]}function N({offset:e,length:t}){return`${t}@${e}`}t.default=function(e){r.PARAMCHECK(e),r.ASSERT("Not a playlist","playlist"===e.type);const t=new u(e.uri);return t.push("#EXTM3U"),e.version&&t.push(`#EXT-X-VERSION:${e.version}`),e.independentSegments&&t.push("#EXT-X-INDEPENDENT-SEGMENTS"),e.start&&t.push(`#EXT-X-START:TIME-OFFSET=${E(e.start.offset)}${e.start.precise?",PRECISE=YES":""}`),e.isMasterPlaylist?function(e,t){for(const s of t.sessionDataList)e.push(c(s));for(const s of t.sessionKeyList)e.push(l(s,!0));for(const s of t.variants)I(e,s)}(t,e):function(e,t){let s="",i="",n=!1;if(t.targetDuration&&e.push(`#EXT-X-TARGETDURATION:${t.targetDuration}`),t.lowLatencyCompatibility){const{canBlockReload:s,canSkipUntil:i,holdBack:n,partHoldBack:a}=t.lowLatencyCompatibility,r=[];r.push("CAN-BLOCK-RELOAD="+(s?"YES":"NO")),void 0!==i&&r.push(`CAN-SKIP-UNTIL=${i}`),void 0!==n&&r.push(`HOLD-BACK=${n}`),void 0!==a&&r.push(`PART-HOLD-BACK=${a}`),e.push(`#EXT-X-SERVER-CONTROL:${r.join(",")}`)}t.partTargetDuration&&e.push(`#EXT-X-PART-INF:PART-TARGET=${t.partTargetDuration}`),t.mediaSequenceBase&&e.push(`#EXT-X-MEDIA-SEQUENCE:${t.mediaSequenceBase}`),t.discontinuitySequenceBase&&e.push(`#EXT-X-DISCONTINUITY-SEQUENCE:${t.discontinuitySequenceBase}`),t.playlistType&&e.push(`#EXT-X-PLAYLIST-TYPE:${t.playlistType}`),t.isIFrame&&e.push("#EXT-X-I-FRAMES-ONLY"),t.skip>0&&e.push(`#EXT-X-SKIP:SKIPPED-SEGMENTS=${t.skip}`);for(const a of t.segments){let r="";[s,i,r]=h(e,a,s,i,t.version),"OUT"===r?n=!0:"IN"===r&&n&&(n=!1)}"VOD"===t.playlistType&&n&&e.push("#EXT-X-CUE-IN"),t.prefetchSegments.length>2&&r.INVALIDPLAYLIST("The server must deliver no more than two prefetch segments");for(const s of t.prefetchSegments)s.discontinuity&&e.push("#EXT-X-PREFETCH-DISCONTINUITY"),e.push(`#EXT-X-PREFETCH:${s.uri}`);t.endlist&&e.push("#EXT-X-ENDLIST");for(const s of t.renditionReports){const t=[];t.push(`URI="${s.uri}"`,`LAST-MSN=${s.lastMSN}`),void 0!==s.lastPart&&t.push(`LAST-PART=${s.lastPart}`),e.push(`#EXT-X-RENDITION-REPORT:${t.join(",")}`)}}(t,e),t.join("\n")}},676:function(e,t,s){var i=this&&this.__createBinding||(Object.create?function(e,t,s,i){void 0===i&&(i=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,i,n)}:function(e,t,s,i){void 0===i&&(i=s),e[i]=t[s]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&i(t,e,s);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.RenditionReport=t.PrefetchSegment=t.PartialSegment=t.Segment=t.MediaPlaylist=t.MasterPlaylist=t.Playlist=t.SpliceInfo=t.DateRange=t.MediaInitializationSection=t.Key=t.SessionData=t.Variant=t.Rendition=void 0;const r=a(s(591));t.Rendition=class{constructor({type:e,uri:t,groupId:s,language:i,assocLanguage:n,name:a,isDefault:o,autoselect:T,forced:u,instreamId:E,characteristics:c,channels:l}){r.PARAMCHECK(e,s,a),r.CONDITIONALASSERT(["SUBTITLES"===e,t],["CLOSED-CAPTIONS"===e,E],["CLOSED-CAPTIONS"===e,!t],[u,"SUBTITLES"===e]),this.type=e,this.uri=t,this.groupId=s,this.language=i,this.assocLanguage=n,this.name=a,this.isDefault=o,this.autoselect=T,this.forced=u,this.instreamId=E,this.characteristics=c,this.channels=l}};t.Variant=class{constructor({uri:e,isIFrameOnly:t=!1,bandwidth:s,averageBandwidth:i,score:n,codecs:a,resolution:o,frameRate:T,hdcpLevel:u,allowedCpc:E,videoRange:c,stableVariantId:l,programId:I,audio:A=[],video:h=[],subtitles:N=[],closedCaptions:f=[],currentRenditions:S={audio:0,video:0,subtitles:0,closedCaptions:0}}){r.PARAMCHECK(e,s),this.uri=e,this.isIFrameOnly=t,this.bandwidth=s,this.averageBandwidth=i,this.score=n,this.codecs=a,this.resolution=o,this.frameRate=T,this.hdcpLevel=u,this.allowedCpc=E,this.videoRange=c,this.stableVariantId=l,this.programId=I,this.audio=A,this.video=h,this.subtitles=N,this.closedCaptions=f,this.currentRenditions=S}};t.SessionData=class{constructor({id:e,value:t,uri:s,language:i}){r.PARAMCHECK(e,t||s),r.ASSERT("SessionData cannot have both value and uri, shoud be either.",!(t&&s)),this.id=e,this.value=t,this.uri=s,this.language=i}};t.Key=class{constructor({method:e,uri:t,iv:s,format:i,formatVersion:n}){r.PARAMCHECK(e),r.CONDITIONALPARAMCHECK(["NONE"!==e,t]),r.CONDITIONALASSERT(["NONE"===e,!(t||s||i||n)]),this.method=e,this.uri=t,this.iv=s,this.format=i,this.formatVersion=n}};t.MediaInitializationSection=class{constructor({hint:e=!1,uri:t,mimeType:s,byterange:i}){r.PARAMCHECK(t),this.hint=e,this.uri=t,this.mimeType=s,this.byterange=i}};t.DateRange=class{constructor({id:e,classId:t,start:s,end:i,duration:n,plannedDuration:a,endOnNext:o,attributes:T={}}){r.PARAMCHECK(e),r.CONDITIONALPARAMCHECK([!0===o,t]),r.CONDITIONALASSERT([i,s],[i,s<=i],[n,n>=0],[a,a>=0]),this.id=e,this.classId=t,this.start=s,this.end=i,this.duration=n,this.plannedDuration=a,this.endOnNext=o,this.attributes=T}};t.SpliceInfo=class{constructor({type:e,duration:t,tagName:s,value:i}){r.PARAMCHECK(e),r.CONDITIONALPARAMCHECK(["OUT"===e,t]),r.CONDITIONALPARAMCHECK(["RAW"===e,s]),this.type=e,this.duration=t,this.tagName=s,this.value=i}};class o{constructor(e){r.PARAMCHECK(e),this.type=e}}class T extends o{constructor({isMasterPlaylist:e,uri:t,version:s,independentSegments:i=!1,start:n,source:a}){super("playlist"),r.PARAMCHECK(e),this.isMasterPlaylist=e,this.uri=t,this.version=s,this.independentSegments=i,this.start=n,this.source=a}}t.Playlist=T;t.MasterPlaylist=class extends T{constructor(e={}){super({...e,isMasterPlaylist:!0});const{variants:t=[],currentVariant:s,sessionDataList:i=[],sessionKeyList:n=[]}=e;this.variants=t,this.currentVariant=s,this.sessionDataList=i,this.sessionKeyList=n}};t.MediaPlaylist=class extends T{constructor(e={}){super({...e,isMasterPlaylist:!1});const{targetDuration:t,mediaSequenceBase:s=0,discontinuitySequenceBase:i=0,endlist:n=!1,playlistType:a,isIFrame:r,segments:o=[],prefetchSegments:T=[],lowLatencyCompatibility:u,partTargetDuration:E,renditionReports:c=[],skip:l=0,hash:I}=e;this.targetDuration=t,this.mediaSequenceBase=s,this.discontinuitySequenceBase=i,this.endlist=n,this.playlistType=a,this.isIFrame=r,this.segments=o,this.prefetchSegments=T,this.lowLatencyCompatibility=u,this.partTargetDuration=E,this.renditionReports=c,this.skip=l,this.hash=I}};t.Segment=class extends o{constructor({uri:e,mimeType:t,data:s,duration:i,title:n,byterange:a,discontinuity:r,mediaSequenceNumber:o=0,discontinuitySequence:T=0,key:u,map:E,programDateTime:c,dateRange:l,markers:I=[],parts:A=[]}){super("segment"),this.uri=e,this.mimeType=t,this.data=s,this.duration=i,this.title=n,this.byterange=a,this.discontinuity=r,this.mediaSequenceNumber=o,this.discontinuitySequence=T,this.key=u,this.map=E,this.programDateTime=c,this.dateRange=l,this.markers=I,this.parts=A}};t.PartialSegment=class extends o{constructor({hint:e=!1,uri:t,duration:s,independent:i,byterange:n,gap:a}){super("part"),r.PARAMCHECK(t),this.hint=e,this.uri=t,this.duration=s,this.independent=i,this.duration=s,this.byterange=n,this.gap=a}};t.PrefetchSegment=class extends o{constructor({uri:e,discontinuity:t,mediaSequenceNumber:s=0,discontinuitySequence:i=0,key:n}){super("prefetch"),r.PARAMCHECK(e),this.uri=e,this.discontinuity=t,this.mediaSequenceNumber=s,this.discontinuitySequence=i,this.key=n}};t.RenditionReport=class{constructor({uri:e,lastMSN:t,lastPart:s}){r.PARAMCHECK(e),this.uri=e,this.lastMSN=t,this.lastPart=s}}},591:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getOptions=t.setOptions=t.hasOwnProp=t.formatDate=t.camelify=t.splitByCommaWithPreservingQuotes=t.trim=t.splitAt=t.tryCatch=t.byteSequenceToHex=t.hexToByteSequence=t.toNumber=t.INVALIDPLAYLIST=t.CONDITIONALPARAMCHECK=t.PARAMCHECK=t.CONDITIONALASSERT=t.ASSERT=t.THROW=void 0;let s={};function i(e){if(s.strictMode)throw e;s.silent||console.error(e.message)}function n(e,t=10){if("number"==typeof e)return e;const s=10===t?Number.parseFloat(e):Number.parseInt(e,t);return Number.isNaN(s)?0:s}t.THROW=i,t.ASSERT=function(e,...t){for(const[s,n]of t.entries())n||i(new Error(`${e} : Failed at [${s}]`))},t.CONDITIONALASSERT=function(...e){for(const[t,[s,n]]of e.entries())s&&(n||i(new Error(`Conditional Assert : Failed at [${t}]`)))},t.PARAMCHECK=function(...e){for(const[t,s]of e.entries())void 0===s&&i(new Error(`Param Check : Failed at [${t}]`))},t.CONDITIONALPARAMCHECK=function(...e){for(const[t,[s,n]]of e.entries())s&&void 0===n&&i(new Error(`Conditional Param Check : Failed at [${t}]`))},t.INVALIDPLAYLIST=function(e){i(new Error(`Invalid Playlist : ${e}`))},t.toNumber=n,t.hexToByteSequence=function(e){(e.startsWith("0x")||e.startsWith("0X"))&&(e=e.slice(2));const t=[];for(let s=0;s<e.length;s+=2)t.push(n(e.slice(s,s+2),16));return Buffer.from(t)},t.byteSequenceToHex=function(e,t=0,s=e.length){s<=t&&i(new Error(`end must be larger than start : start=${t}, end=${s}`));const n=[];for(let i=t;i<s;i++)n.push(`0${(255&e[i]).toString(16).toUpperCase()}`.slice(-2));return`0x${n.join("")}`},t.tryCatch=function(e,t){try{return e()}catch(e){return t(e)}},t.splitAt=function(e,t,s=0){let i=-1;for(let n=0,a=0;n<e.length;n++)if(e[n]===t){if(a++===s)return[e.slice(0,n),e.slice(n+1)];i=n}return-1!==i?[e.slice(0,i),e.slice(i+1)]:[e]},t.trim=function(e,t=" "){return e?(e=e.trim()," "===t||(e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1))),e):e},t.splitByCommaWithPreservingQuotes=function(e){const t=[];let s=!0,i=0;const n=[];for(let a=0;a<e.length;a++){const r=e[a];s&&","===r?(t.push(e.slice(i,a).trim()),i=a+1):'"'!==r&&"'"!==r||(s?(n.push(r),s=!1):r===n.at(-1)?(n.pop(),s=!0):n.push(r))}return t.push(e.slice(i).trim()),t},t.camelify=function(e){const t=[];let s=!1;for(const i of e)"-"!==i&&"_"!==i?s?(t.push(i.toUpperCase()),s=!1):t.push(i.toLowerCase()):s=!0;return t.join("")},t.formatDate=function(e){return`${e.getUTCFullYear()}-${("0"+(e.getUTCMonth()+1)).slice(-2)}-${("0"+e.getUTCDate()).slice(-2)}T${("0"+e.getUTCHours()).slice(-2)}:${("0"+e.getUTCMinutes()).slice(-2)}:${("0"+e.getUTCSeconds()).slice(-2)}.${("00"+e.getUTCMilliseconds()).slice(-3)}Z`},t.hasOwnProp=function(e,t){return Object.hasOwnProperty.call(e,t)},t.setOptions=function(e={}){s=Object.assign(s,e)},t.getOptions=function(){return Object.assign({},s)}}},t={};var s=function s(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,s),a.exports}(492);return s})())); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.HLS=e():t.HLS=e()}(self,(()=>(()=>{"use strict";var t={463:function(t,e,n){function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,i,o,s=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);c=!0);}catch(t){u=!0,a=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=i(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){c=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(c)throw o}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var s=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(e,n);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,a)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),c=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),u=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&s(e,t,n);return c(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});var l=u(n(771)),T=n(890);function f(t){return l.trim(t,'"')}function E(t){var e=l.splitAt(t,",");return{duration:l.toNumber(e[0]),title:decodeURIComponent(escape(e[1]))}}function h(t){var e=l.splitAt(t,"@");return{length:l.toNumber(e[0]),offset:e[1]?l.toNumber(e[1]):-1}}function p(t){var e=l.splitAt(t,"x");return{width:l.toNumber(e[0]),height:l.toNumber(e[1])}}function I(t){var e="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",n=t.split(",");0===n.length&&l.INVALIDPLAYLIST(e);var i,o=[],s=a(n);try{for(s.s();!(i=s.n()).done;){var c=i.value,u=r(l.splitAt(c,":"),2),T=u[0],f=u[1];T&&f?o.push({format:T,cpcList:f.split("/")}):l.INVALIDPLAYLIST(e)}}catch(t){s.e(t)}finally{s.f()}return o}function d(t){return t.startsWith('"')?f(t):t.startsWith("0x")||t.startsWith("0X")?l.hexToByteSequence(t):l.toNumber(t)}function A(t,e){e.IV&&t.compatibleVersion<2&&(t.compatibleVersion=2),(e.KEYFORMAT||e.KEYFORMATVERSIONS)&&t.compatibleVersion<5&&(t.compatibleVersion=5)}function y(t){var e,n,i,o={},s=a(l.splitByCommaWithPreservingQuotes(t));try{for(s.s();!(e=s.n()).done;){var c=e.value,u=r(l.splitAt(c,"="),2),T=u[0],E=u[1],A=f(E);switch(T){case"URI":o[T]=A;break;case"START-DATE":case"END-DATE":o[T]=new Date(A);break;case"IV":o[T]=(n=A,i=void 0,16!==(i=l.hexToByteSequence(n)).length&&l.INVALIDPLAYLIST("IV must be a 128-bit unsigned integer"),i);break;case"BYTERANGE":o[T]=h(A);break;case"RESOLUTION":o[T]=p(A);break;case"ALLOWED-CPC":o[T]=I(A);break;case"END-ON-NEXT":case"DEFAULT":case"AUTOSELECT":case"FORCED":case"PRECISE":case"CAN-BLOCK-RELOAD":case"INDEPENDENT":case"GAP":o[T]="YES"===A;break;case"DURATION":case"PLANNED-DURATION":case"BANDWIDTH":case"AVERAGE-BANDWIDTH":case"FRAME-RATE":case"TIME-OFFSET":case"CAN-SKIP-UNTIL":case"HOLD-BACK":case"PART-HOLD-BACK":case"PART-TARGET":case"BYTERANGE-START":case"BYTERANGE-LENGTH":case"LAST-MSN":case"LAST-PART":case"SKIPPED-SEGMENTS":case"SCORE":case"PROGRAM-ID":o[T]=l.toNumber(A);break;default:T.startsWith("SCTE35-")?o[T]=l.hexToByteSequence(A):T.startsWith("X-")?o[T]=d(E):("VIDEO-RANGE"===T&&"SDR"!==A&&"HLG"!==A&&"PQ"!==A&&l.INVALIDPLAYLIST('VIDEO-RANGE: unknown value "'.concat(A,'"')),o[T]=A)}}}catch(t){s.e(t)}finally{s.f()}return o}function S(){l.INVALIDPLAYLIST("The file contains both media and master playlist tags.")}function v(t,e,n){var r,i=(r=e.attributes,new T.Rendition({type:r.TYPE,uri:r.URI,groupId:r["GROUP-ID"],language:r.LANGUAGE,assocLanguage:r["ASSOC-LANGUAGE"],name:r.NAME,isDefault:r.DEFAULT,autoselect:r.AUTOSELECT,forced:r.FORCED,instreamId:r["INSTREAM-ID"],characteristics:r.CHARACTERISTICS,channels:r.CHANNELS})),o=t[l.camelify(n)],s=function(t,e){var n,r=!1,i=a(t);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(o.name===e.name)return"All EXT-X-MEDIA tags in the same Group MUST have different NAME attributes.";o.isDefault&&(r=!0)}}catch(t){i.e(t)}finally{i.f()}return r&&e.isDefault?"EXT-X-MEDIA A Group MUST NOT have more than one member with a DEFAULT attribute of YES.":""}(o,i);s&&l.INVALIDPLAYLIST(s),o.push(i),i.isDefault&&(t.currentRenditions[l.camelify(n)]=o.length-1)}function N(t,e,n,r,i){var o,s=new T.Variant({uri:n,bandwidth:e.BANDWIDTH,averageBandwidth:e["AVERAGE-BANDWIDTH"],score:e.SCORE,codecs:e.CODECS,resolution:e.RESOLUTION,frameRate:e["FRAME-RATE"],hdcpLevel:e["HDCP-LEVEL"],allowedCpc:e["ALLOWED-CPC"],videoRange:e["VIDEO-RANGE"],stableVariantId:e["STABLE-VARIANT-ID"],programId:e["PROGRAM-ID"]}),c=a(t);try{for(c.s();!(o=c.n()).done;){var u=o.value;if("EXT-X-MEDIA"===u.name){var f=u.attributes,E=f.TYPE;if(E&&f["GROUP-ID"]||l.INVALIDPLAYLIST("EXT-X-MEDIA TYPE attribute is REQUIRED."),e[E]===f["GROUP-ID"]&&(v(s,u,E),"CLOSED-CAPTIONS"===E)){var h,p=a(s.closedCaptions);try{for(p.s();!(h=p.n()).done;){var I=h.value.instreamId;if(I&&I.startsWith("SERVICE")&&i.compatibleVersion<7){i.compatibleVersion=7;break}}}catch(t){p.e(t)}finally{p.f()}}}}}catch(t){c.e(t)}finally{c.f()}return function(t,e,n){for(var r=function(){var r=i[a];"CLOSED-CAPTIONS"===r&&"NONE"===t[r]?(n.isClosedCaptionsNone=!0,e.closedCaptions=[]):t[r]&&!e[l.camelify(r)].some((function(e){return e.groupId===t[r]}))&&l.INVALIDPLAYLIST("".concat(r," attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ").concat(r,"."))},a=0,i=["AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS"];a<i.length;a++)r()}(e,s,i),s.isIFrameOnly=r,s}function m(t,e,n,r,a,i,o){for(var s=new T.Segment({uri:e,mediaSequenceNumber:a,discontinuitySequence:i}),c=!1,u=!1,f=n;f<=r;f++){var E=t[f],h=E.name,p=E.value,I=E.attributes;if("EXTINF"===h)!Number.isInteger(p.duration)&&o.compatibleVersion<3&&(o.compatibleVersion=3),Math.round(p.duration)>o.targetDuration&&l.INVALIDPLAYLIST("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration"),s.duration=p.duration,s.title=p.title;else if("EXT-X-BYTERANGE"===h)o.compatibleVersion<4&&(o.compatibleVersion=4),s.byterange=p;else if("EXT-X-DISCONTINUITY"===h)s.parts.length>0&&l.INVALIDPLAYLIST("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment."),s.discontinuity=!0;else if("EXT-X-KEY"===h)s.parts.length>0&&l.INVALIDPLAYLIST("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment."),A(o,I),s.key=new T.Key({method:I.METHOD,uri:I.URI,iv:I.IV,format:I.KEYFORMAT,formatVersion:I.KEYFORMATVERSIONS});else if("EXT-X-MAP"===h)s.parts.length>0&&l.INVALIDPLAYLIST("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment."),o.compatibleVersion<5&&(o.compatibleVersion=5),o.hasMap=!0,s.map=new T.MediaInitializationSection({uri:I.URI,byterange:I.BYTERANGE});else if("EXT-X-PROGRAM-DATE-TIME"===h)s.programDateTime=p;else if("EXT-X-DATERANGE"===h){for(var d={},y=0,S=Object.keys(I);y<S.length;y++){var v=S[y];(v.startsWith("SCTE35-")||v.startsWith("X-"))&&(d[v]=I[v])}s.dateRange=new T.DateRange({id:I.ID,classId:I.CLASS,start:I["START-DATE"],end:I["END-DATE"],duration:I.DURATION,plannedDuration:I["PLANNED-DURATION"],endOnNext:I["END-ON-NEXT"],attributes:d})}else if("EXT-X-CUE-OUT"===h)s.markers.push(new T.SpliceInfo({type:"OUT",duration:I&&I.DURATION||p}));else if("EXT-X-CUE-IN"===h)s.markers.push(new T.SpliceInfo({type:"IN"}));else if("EXT-X-CUE-OUT-CONT"===h||"EXT-X-CUE"===h||"EXT-OATCLS-SCTE35"===h||"EXT-X-ASSET"===h||"EXT-X-SCTE35"===h)s.markers.push(new T.SpliceInfo({type:"RAW",tagName:h,value:p}));else if("EXT-X-PRELOAD-HINT"!==h||I.TYPE)if("EXT-X-PRELOAD-HINT"===h&&"PART"===I.TYPE&&u)l.INVALIDPLAYLIST("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.");else if("EXT-X-PART"!==h&&"EXT-X-PRELOAD-HINT"!==h||I.URI){if("EXT-X-PRELOAD-HINT"===h&&"MAP"===I.TYPE)c&&l.INVALIDPLAYLIST("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist."),c=!0,o.hasMap=!0,s.map=new T.MediaInitializationSection({hint:!0,uri:I.URI,byterange:{length:I["BYTERANGE-LENGTH"],offset:I["BYTERANGE-START"]||0}});else if("EXT-X-PART"===h||"EXT-X-PRELOAD-HINT"===h&&"PART"===I.TYPE){"EXT-X-PART"!==h||I.DURATION||l.INVALIDPLAYLIST("EXT-X-PART: DURATION attribute is mandatory"),"EXT-X-PRELOAD-HINT"===h&&(u=!0);var N=new T.PartialSegment({hint:"EXT-X-PRELOAD-HINT"===h,uri:I.URI,byterange:"EXT-X-PART"===h?I.BYTERANGE:{length:I["BYTERANGE-LENGTH"],offset:I["BYTERANGE-START"]||0},duration:I.DURATION,independent:I.INDEPENDENT,gap:I.GAP});s.parts.push(N)}}else l.INVALIDPLAYLIST("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory");else l.INVALIDPLAYLIST("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory")}return s}function X(t,e,n,r,a,i,o){for(var s=new T.PrefetchSegment({uri:e,mediaSequenceNumber:a,discontinuitySequence:i}),c=n;c<=r;c++){var u=t[c],f=u.name,E=u.attributes;"EXTINF"===f?l.INVALIDPLAYLIST("A prefetch segment must not be advertised with an EXTINF tag."):"EXT-X-DISCONTINUITY"===f?l.INVALIDPLAYLIST("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag."):"EXT-X-PREFETCH-DISCONTINUITY"===f?s.discontinuity=!0:"EXT-X-KEY"===f?(A(o,E),s.key=new T.Key({method:E.METHOD,uri:E.URI,iv:E.IV,format:E.KEYFORMAT,formatVersion:E.KEYFORMATVERSIONS})):"EXT-X-MAP"===f&&l.INVALIDPLAYLIST("Prefetch segments must not be advertised with an EXT-X-MAP tag.")}return s}function O(t,e){var n,i=new T.MediaPlaylist,o=-1,s=0,c=!1,u=!1,f=0,E=null,h=null,p=!1,I=a(t.entries());try{for(I.s();!(n=I.n()).done;){var d=r(n.value,2),A=d[0],y=d[1],S=y.name,v=y.value,N=y.attributes;if("Segment"!==y.category){if("EXT-X-VERSION"===S)void 0===i.version?i.version=v:l.INVALIDPLAYLIST("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.");else if("EXT-X-TARGETDURATION"===S)i.targetDuration=e.targetDuration=v;else if("EXT-X-MEDIA-SEQUENCE"===S)i.segments.length>0&&l.INVALIDPLAYLIST("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist."),i.mediaSequenceBase=s=v;else if("EXT-X-DISCONTINUITY-SEQUENCE"===S)i.segments.length>0&&l.INVALIDPLAYLIST("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist."),c&&l.INVALIDPLAYLIST("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag."),i.discontinuitySequenceBase=f=v;else if("EXT-X-ENDLIST"===S)i.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===S)i.playlistType=v;else if("EXT-X-I-FRAMES-ONLY"===S)e.compatibleVersion<4&&(e.compatibleVersion=4),i.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===S)i.independentSegments&&l.INVALIDPLAYLIST("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist"),i.independentSegments=!0;else if("EXT-X-START"===S)i.start&&l.INVALIDPLAYLIST("EXT-X-START tag MUST NOT appear more than once in a Playlist"),"number"!=typeof N["TIME-OFFSET"]&&l.INVALIDPLAYLIST("EXT-X-START: TIME-OFFSET attribute is REQUIRED"),i.start={offset:N["TIME-OFFSET"],precise:N.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===S)N["CAN-BLOCK-RELOAD"]||l.INVALIDPLAYLIST("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS"),i.lowLatencyCompatibility={canBlockReload:N["CAN-BLOCK-RELOAD"],canSkipUntil:N["CAN-SKIP-UNTIL"],holdBack:N["HOLD-BACK"],partHoldBack:N["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===S)N["PART-TARGET"]||l.INVALIDPLAYLIST("EXT-X-PART-INF: PART-TARGET attribute is mandatory"),i.partTargetDuration=N["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===S)N.URI||l.INVALIDPLAYLIST("EXT-X-RENDITION-REPORT: URI attribute is mandatory"),0===N.URI.search(/^[a-z]+:/)&&l.INVALIDPLAYLIST("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri"),i.renditionReports.push(new T.RenditionReport({uri:N.URI,lastMSN:N["LAST-MSN"],lastPart:N["LAST-PART"]}));else if("EXT-X-SKIP"===S)N["SKIPPED-SEGMENTS"]||l.INVALIDPLAYLIST("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory"),e.compatibleVersion<9&&(e.compatibleVersion=9),i.skip=N["SKIPPED-SEGMENTS"],s+=i.skip;else if("EXT-X-PREFETCH"===S){var O=X(t,v,-1===o?A:o,A-1,s++,f,e);O&&(O.discontinuity&&(O.discontinuitySequence++,f=O.discontinuitySequence),O.key?E=O.key:O.key=E,i.prefetchSegments.push(O)),u=!0,o=-1}else if("string"==typeof y){-1===o&&l.INVALIDPLAYLIST("A URI line is not preceded by any segment tags"),i.targetDuration||l.INVALIDPLAYLIST("The EXT-X-TARGETDURATION tag is REQUIRED"),u&&l.INVALIDPLAYLIST("These segments must appear after all complete segments.");var b=m(t,y,o,A-1,s++,f,e);if(b){var g=r(R(i,b,f,E,h),3);f=g[0],E=g[1],h=g[2],!p&&b.parts.length>0&&(p=!0)}o=-1}}else-1===o&&(o=A),"EXT-X-DISCONTINUITY"===S&&(c=!0)}}catch(t){I.e(t)}finally{I.f()}if(-1!==o){var P=m(t,"",o,t.length-1,s++,f,e);if(P){var D,L=P.parts;!(L.length>0)||i.endlist||null!==(D=L.at(-1))&&void 0!==D&&D.hint||l.INVALIDPLAYLIST("If the Playlist contains EXT-X-PART tags and does not contain an EXT-X-ENDLIST tag, the Playlist must contain an EXT-X-PRELOAD-HINT tag with a TYPE=PART attribute"),R(i,P,E,h),!p&&P.parts.length>0&&(p=!0)}}return function(t){for(var e=new Map,n=new Map,r=!1,i=!1,o=t.length-1;o>=0;o--){var s=t[o],c=s.programDateTime,u=s.dateRange;if(c&&(i=!0),u&&u.start){r=!0,u.endOnNext&&(u.end||u.duration)&&l.INVALIDPLAYLIST("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.");var T=u.start.getTime(),f=u.duration||0;u.end&&u.duration&&T+1e3*f!==u.end.getTime()&&l.INVALIDPLAYLIST("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION"),u.endOnNext&&(u.end=e.get(u.classId)),e.set(u.classId,u.start);var E=u.end?u.end.getTime():u.start.getTime()+1e3*(u.duration||0),h=n.get(u.classId);if(console.log("GET dateRange.classId = ".concat(u.classId)),h){var p,I=a(h);try{for(I.s();!(p=I.n()).done;){var d=p.value;(d.start<=T&&d.end>T||d.start>=T&&d.start<E)&&l.INVALIDPLAYLIST("DATERANGE tags with the same CLASS should not overlap. entry.start=".concat(d.start,", entry.end=").concat(d.end,", start=").concat(T,", end=").concat(E))}}catch(t){I.e(t)}finally{I.f()}h.push({start:T,end:E})}else u.classId&&(console.log("SET dateRange.classId = ".concat(u.classId)),n.set(u.classId,[{start:T,end:E}]))}}r&&!i&&l.INVALIDPLAYLIST("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.")}(i.segments),i.lowLatencyCompatibility&&function(t,e){var n=t.lowLatencyCompatibility,i=t.targetDuration,o=t.partTargetDuration,s=t.segments,c=t.renditionReports,u=n.canSkipUntil,T=n.holdBack,f=n.partHoldBack;u<6*i&&l.INVALIDPLAYLIST("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.");T<3*i&&l.INVALIDPLAYLIST("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.");if(e){void 0===o&&l.INVALIDPLAYLIST("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags"),void 0===f&&l.INVALIDPLAYLIST("EXT-X-PART: PART-HOLD-BACK attribute is mandatory"),f<o&&l.INVALIDPLAYLIST("PART-HOLD-BACK must be at least PART-TARGET");var E,h=a(s.entries());try{for(h.s();!(E=h.n()).done;){var p=r(E.value,2),I=p[0],d=p[1].parts;d.length>0&&I<s.length-3&&l.INVALIDPLAYLIST("Remove EXT-X-PART tags from the Playlist after they are greater than three target durations from the end of the Playlist.");var A,y=a(d.entries());try{for(y.s();!(A=y.n()).done;){var S=r(A.value,2),v=S[0],N=S[1].duration;void 0!==N&&(N>o&&l.INVALIDPLAYLIST("PART-TARGET is the maximum duration of any Partial Segment"),v<d.length-1&&N<.85*o&&l.INVALIDPLAYLIST("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET"))}}catch(t){y.e(t)}finally{y.f()}}}catch(t){h.e(t)}finally{h.f()}}var m,X=a(c);try{for(X.s();!(m=X.n()).done;){var O=m.value,R=s.at(-1);null!==O.lastMSN&&void 0!==O.lastMSN||(O.lastMSN=R.mediaSequenceNumber),(null===O.lastPart||void 0===O.lastPart)&&R.parts.length>0&&(O.lastPart=R.parts.length-1)}}catch(t){X.e(t)}finally{X.f()}}(i,p),i}function R(t,e,n,r,a){var i=e.discontinuity,o=e.key,s=e.map,c=e.byterange,u=e.uri;if(i&&(e.discontinuitySequence=n+1),o||(e.key=r),s||(e.map=a),c&&-1===c.offset){var T=t.segments;if(T.length>0){var f=T.at(-1);f.byterange&&f.uri===u?c.offset=f.byterange.offset+f.byterange.length:l.INVALIDPLAYLIST("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource")}else l.INVALIDPLAYLIST("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file")}return t.segments.push(e),[e.discontinuitySequence,e.key,e.map]}function b(t,e){var n=function(t){var e=t.indexOf(":");return-1===e?[t.slice(1).trim(),null]:[t.slice(1,e).trim(),t.slice(e+1).trim()]}(t),a=r(n,2),i=a[0],o=a[1],s=function(t){switch(t){case"EXTM3U":case"EXT-X-VERSION":return"Basic";case"EXTINF":case"EXT-X-BYTERANGE":case"EXT-X-DISCONTINUITY":case"EXT-X-PREFETCH-DISCONTINUITY":case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-PROGRAM-DATE-TIME":case"EXT-X-DATERANGE":case"EXT-X-CUE-OUT":case"EXT-X-CUE-IN":case"EXT-X-CUE-OUT-CONT":case"EXT-X-CUE":case"EXT-OATCLS-SCTE35":case"EXT-X-ASSET":case"EXT-X-SCTE35":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":return"Segment";case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":case"EXT-X-ENDLIST":case"EXT-X-PLAYLIST-TYPE":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PREFETCH":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return"MediaPlaylist";case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":return"MasterPlaylist";case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-START":return"MediaorMasterPlaylist";default:return"Unknown"}}(i);if(function(t,e){if("Segment"===t||"MediaPlaylist"===t)return void 0===e.isMasterPlaylist?void(e.isMasterPlaylist=!1):void(e.isMasterPlaylist&&S());if("MasterPlaylist"===t){if(void 0===e.isMasterPlaylist)return void(e.isMasterPlaylist=!0);!1===e.isMasterPlaylist&&S()}}(s,e),"Unknown"===s)return null;"MediaPlaylist"===s&&"EXT-X-RENDITION-REPORT"!==i&&"EXT-X-PREFETCH"!==i&&(e.hash[i]&&l.INVALIDPLAYLIST("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist"),e.hash[i]=!0);var c=function(t,e){switch(t){case"EXTM3U":case"EXT-X-DISCONTINUITY":case"EXT-X-ENDLIST":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-CUE-IN":return[null,null];case"EXT-X-VERSION":case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":return[l.toNumber(e),null];case"EXT-X-CUE-OUT":return Number.isNaN(Number(e))?[null,y(e)]:[l.toNumber(e),null];case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-DATERANGE":case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":case"EXT-X-START":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return[null,y(e)];case"EXTINF":return[E(e),null];case"EXT-X-BYTERANGE":return[h(e),null];case"EXT-X-PROGRAM-DATE-TIME":return[new Date(e),null];default:return[e,null]}}(i,o),u=r(c,2);return{name:i,category:s,value:u[0],attributes:u[1]}}function g(t,e){var n;return e.isMasterPlaylist?n=function(t,e){var n,i=new T.MasterPlaylist,o=!1,s=a(t.entries());try{var c=function(){var a=r(n.value,2),s=a[0],c=a[1],u=c.name,f=c.value,E=c.attributes;if("EXT-X-VERSION"===u)i.version=f;else if("EXT-X-STREAM-INF"===u){var h=t[s+1];("string"!=typeof h||h.startsWith("#EXT"))&&l.INVALIDPLAYLIST("EXT-X-STREAM-INF must be followed by a URI line");var p=N(t,E,h,!1,e);p&&("number"==typeof p.score&&(o=!0,p.score<0&&l.INVALIDPLAYLIST("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.")),i.variants.push(p))}else if("EXT-X-I-FRAME-STREAM-INF"===u){var I=N(t,E,E.URI,!0,e);I&&i.variants.push(I)}else if("EXT-X-SESSION-DATA"===u){var d=new T.SessionData({id:E["DATA-ID"],value:E.VALUE,uri:E.URI,language:E.LANGUAGE});i.sessionDataList.some((function(t){return t.id===d.id&&t.language===d.language}))&&l.INVALIDPLAYLIST("A Playlist MUST NOT contain more than one EXT-X-SESSION-DATA tag with the same DATA-ID attribute and the same LANGUAGE attribute."),i.sessionDataList.push(d)}else if("EXT-X-SESSION-KEY"===u){"NONE"===E.METHOD&&l.INVALIDPLAYLIST("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE");var y=new T.Key({method:E.METHOD,uri:E.URI,iv:E.IV,format:E.KEYFORMAT,formatVersion:E.KEYFORMATVERSIONS});i.sessionKeyList.some((function(t){return function(t,e){if(t.method!==e.method)return!1;if(t.uri!==e.uri)return!1;if(t.iv){if(!e.iv)return!1;if(t.iv.length!==e.iv.length)return!1;for(var n=0;n<t.iv.length;n++)if(t.iv[n]!==e.iv[n])return!1}else if(e.iv)return!1;return t.format===e.format&&t.formatVersion===e.formatVersion}(t,y)}))&&l.INVALIDPLAYLIST("A Master Playlist MUST NOT contain more than one EXT-X-SESSION-KEY tag with the same METHOD, URI, IV, KEYFORMAT, and KEYFORMATVERSIONS attribute values."),A(e,E),i.sessionKeyList.push(y)}else"EXT-X-INDEPENDENT-SEGMENTS"===u?(i.independentSegments&&l.INVALIDPLAYLIST("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist"),i.independentSegments=!0):"EXT-X-START"===u&&(i.start&&l.INVALIDPLAYLIST("EXT-X-START tag MUST NOT appear more than once in a Playlist"),"number"!=typeof E["TIME-OFFSET"]&&l.INVALIDPLAYLIST("EXT-X-START: TIME-OFFSET attribute is REQUIRED"),i.start={offset:E["TIME-OFFSET"],precise:E.PRECISE||!1})};for(s.s();!(n=s.n()).done;)c()}catch(t){s.e(t)}finally{s.f()}if(o){var u,f=a(i.variants);try{for(f.s();!(u=f.n()).done;)"number"!=typeof u.value.score&&l.INVALIDPLAYLIST("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute")}catch(t){f.e(t)}finally{f.f()}}if(e.isClosedCaptionsNone){var E,h=a(i.variants);try{for(h.s();!(E=h.n()).done;)E.value.closedCaptions.length>0&&l.INVALIDPLAYLIST("If there is a variant with CLOSED-CAPTIONS attribute of NONE, all EXT-X-STREAM-INF tags MUST have this attribute with a value of NONE")}catch(t){h.e(t)}finally{h.f()}}return i}(t,e):!(n=O(t,e)).isIFrame&&e.hasMap&&e.compatibleVersion<6&&(e.compatibleVersion=6),e.compatibleVersion>1&&(!n.version||n.version<e.compatibleVersion)&&l.INVALIDPLAYLIST("EXT-X-VERSION needs to be ".concat(e.compatibleVersion," or higher.")),n}e.default=function(t){var e={version:void 0,isMasterPlaylist:void 0,hasMap:!1,targetDuration:0,compatibleVersion:1,isClosedCaptionsNone:!1,hash:{}},n=g(function(t,e){var n,r=[],i=a(t.split("\n"));try{for(i.s();!(n=i.n()).done;){var o=n.value,s=Buffer.from(o.trim()).toString();if(s)if(s.startsWith("#")){if(s.startsWith("#EXT")){var c=b(s,e);c&&r.push(c)}}else r.push(s)}}catch(t){i.e(t)}finally{i.f()}return 0!==r.length&&"EXTM3U"===r[0].name||l.INVALIDPLAYLIST("The EXTM3U tag MUST be the first line."),r}(t,e),e);return n.source=t,n}},367:function(t,e,n){function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,i,o,s=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);c=!0);}catch(t){u=!0,a=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(t,e)||o(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=o(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){c=!0,i=t},f:function(){try{s||null==n.return||n.return()}finally{if(c)throw i}}}}function o(t,e){if(t){if("string"==typeof t)return s(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function c(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,(i=a.key,o=void 0,o=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var a=n.call(t,e||"default");if("object"!==r(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"),"symbol"===r(o)?o:String(o)),a)}var i,o}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(r){var a=Object.getOwnPropertyDescriptor(r,e);return a.get?a.get.call(arguments.length<3?t:n):a.value}},u.apply(this,arguments)}function l(t){var e=E();return function(){var n,a=p(t);if(e){var i=p(this).constructor;n=Reflect.construct(a,arguments,i)}else n=a.apply(this,arguments);return function(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,n)}}function T(t){var e="function"==typeof Map?new Map:void 0;return T=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return f(t,arguments,p(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)},T(t)}function f(t,e,n){return f=E()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var a=new(Function.bind.apply(t,r));return n&&h(a,n.prototype),a},f.apply(null,arguments)}function E(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}var I=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(e,n);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,a)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),d=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),A=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&I(e,t,n);return d(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});var y=A(n(771)),S=["#EXTINF","#EXT-X-BYTERANGE","#EXT-X-DISCONTINUITY","#EXT-X-STREAM-INF","#EXT-X-CUE-OUT","#EXT-X-CUE-IN","#EXT-X-KEY","#EXT-X-MAP"],v=["#EXT-X-MEDIA"],N=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}(i,t);var e,n,r,a=l(i);function i(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),(e=a.call(this)).baseUri=t,e}return e=i,n=[{key:"push",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];for(var a=function(){var e=s[o];if(!e.startsWith("#"))return u(p(i.prototype),"push",t).call(t,e),0;if(S.some((function(t){return e.startsWith(t)})))return u(p(i.prototype),"push",t).call(t,e),0;if(t.includes(e)){if(v.some((function(t){return e.startsWith(t)})))return 0;y.INVALIDPLAYLIST("Redundant item (".concat(e,")"))}u(p(i.prototype),"push",t).call(t,e)},o=0,s=n;o<s.length;o++)a();return this.length}}],n&&c(e.prototype,n),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),i}(T(Array));function m(t,e){var n=1e3;e&&(n=Math.pow(10,e));var r=Math.round(t*n)/n;return e?r.toFixed(e):r}function X(t){var e=['DATA-ID="'.concat(t.id,'"')];return t.language&&e.push('LANGUAGE="'.concat(t.language,'"')),t.value?e.push('VALUE="'.concat(t.value,'"')):t.uri&&e.push('URI="'.concat(t.uri,'"')),"#EXT-X-SESSION-DATA:".concat(e.join(","))}function O(t,e){var n=e?"#EXT-X-SESSION-KEY":"#EXT-X-KEY",r=["METHOD=".concat(t.method)];return t.uri&&r.push('URI="'.concat(t.uri,'"')),t.iv&&(16!==t.iv.length&&y.INVALIDPLAYLIST("IV must be a 128-bit unsigned integer"),r.push("IV=".concat(y.byteSequenceToHex(t.iv)))),t.format&&r.push('KEYFORMAT="'.concat(t.format,'"')),t.formatVersion&&r.push('KEYFORMATVERSIONS="'.concat(t.formatVersion,'"')),"".concat(n,":").concat(r.join(","))}function R(t,e){var n=e.isIFrameOnly?"#EXT-X-I-FRAME-STREAM-INF":"#EXT-X-STREAM-INF",r=["BANDWIDTH=".concat(e.bandwidth)];if(e.averageBandwidth&&r.push("AVERAGE-BANDWIDTH=".concat(e.averageBandwidth)),e.isIFrameOnly&&r.push('URI="'.concat(e.uri,'"')),e.codecs&&r.push('CODECS="'.concat(e.codecs,'"')),e.resolution&&r.push("RESOLUTION=".concat(e.resolution.width,"x").concat(e.resolution.height)),e.frameRate&&r.push("FRAME-RATE=".concat(m(e.frameRate,3))),e.hdcpLevel&&r.push("HDCP-LEVEL=".concat(e.hdcpLevel)),e.audio.length>0){r.push('AUDIO="'.concat(e.audio[0].groupId,'"'));var a,o=i(e.audio);try{for(o.s();!(a=o.n()).done;){var s=a.value;t.push(b(s))}}catch(t){o.e(t)}finally{o.f()}}if(e.video.length>0){r.push('VIDEO="'.concat(e.video[0].groupId,'"'));var c,u=i(e.video);try{for(u.s();!(c=u.n()).done;){var l=c.value;t.push(b(l))}}catch(t){u.e(t)}finally{u.f()}}if(e.subtitles.length>0){r.push('SUBTITLES="'.concat(e.subtitles[0].groupId,'"'));var T,f=i(e.subtitles);try{for(f.s();!(T=f.n()).done;){var E=T.value;t.push(b(E))}}catch(t){f.e(t)}finally{f.f()}}if(y.getOptions().allowClosedCaptionsNone&&0===e.closedCaptions.length)r.push("CLOSED-CAPTIONS=NONE");else if(e.closedCaptions.length>0){r.push('CLOSED-CAPTIONS="'.concat(e.closedCaptions[0].groupId,'"'));var h,p=i(e.closedCaptions);try{for(p.s();!(h=p.n()).done;){var I=h.value;t.push(b(I))}}catch(t){p.e(t)}finally{p.f()}}if(e.score&&r.push("SCORE=".concat(e.score)),e.allowedCpc){var d,A=[],S=i(e.allowedCpc);try{for(S.s();!(d=S.n()).done;){var v=d.value,N=v.format,X=v.cpcList;A.push("".concat(N,":").concat(X.join("/")))}}catch(t){S.e(t)}finally{S.f()}r.push('ALLOWED-CPC="'.concat(A.join(","),'"'))}e.videoRange&&r.push("VIDEO-RANGE=".concat(e.videoRange)),e.stableVariantId&&r.push('STABLE-VARIANT-ID="'.concat(e.stableVariantId,'"')),e.programId&&r.push("PROGRAM-ID=".concat(e.programId)),t.push("".concat(n,":").concat(r.join(","))),e.isIFrameOnly||t.push("".concat(e.uri))}function b(t){var e=["TYPE=".concat(t.type),'GROUP-ID="'.concat(t.groupId,'"'),'NAME="'.concat(t.name,'"')];return void 0!==t.isDefault&&e.push("DEFAULT=".concat(t.isDefault?"YES":"NO")),void 0!==t.autoselect&&e.push("AUTOSELECT=".concat(t.autoselect?"YES":"NO")),void 0!==t.forced&&e.push("FORCED=".concat(t.forced?"YES":"NO")),t.language&&e.push('LANGUAGE="'.concat(t.language,'"')),t.assocLanguage&&e.push('ASSOC-LANGUAGE="'.concat(t.assocLanguage,'"')),t.instreamId&&e.push('INSTREAM-ID="'.concat(t.instreamId,'"')),t.characteristics&&e.push('CHARACTERISTICS="'.concat(t.characteristics,'"')),t.channels&&e.push('CHANNELS="'.concat(t.channels,'"')),t.uri&&e.push('URI="'.concat(t.uri,'"')),"#EXT-X-MEDIA:".concat(e.join(","))}function g(t,e,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,o=!1,s="";if(e.discontinuity&&t.push("#EXT-X-DISCONTINUITY"),e.key){var c=O(e.key);c!==n&&(t.push(c),n=c)}if(e.map){var u=function(t){var e=['URI="'.concat(t.uri,'"')];t.byterange&&e.push('BYTERANGE="'.concat(P(t.byterange),'"'));return"#EXT-X-MAP:".concat(e.join(","))}(e.map);u!==r&&(t.push(u),r=u)}if(e.programDateTime&&t.push("#EXT-X-PROGRAM-DATE-TIME:".concat(y.formatDate(e.programDateTime))),e.dateRange&&t.push(function(t){var e=['ID="'.concat(t.id,'"')];t.start&&e.push('START-DATE="'.concat(y.formatDate(t.start),'"'));t.end&&e.push('END-DATE="'.concat(y.formatDate(t.end),'"'));t.duration&&e.push("DURATION=".concat(t.duration));t.plannedDuration&&e.push("PLANNED-DURATION=".concat(t.plannedDuration));t.classId&&e.push('CLASS="'.concat(t.classId,'"'));t.endOnNext&&e.push("END-ON-NEXT=YES");for(var n=0,r=Object.keys(t.attributes);n<r.length;n++){var a=r[n];a.startsWith("X-")?"number"==typeof t.attributes[a]?e.push("".concat(a,"=").concat(t.attributes[a])):e.push("".concat(a,'="').concat(t.attributes[a],'"')):a.startsWith("SCTE35-")&&e.push("".concat(a,"=").concat(y.byteSequenceToHex(t.attributes[a])))}return"#EXT-X-DATERANGE:".concat(e.join(","))}(e.dateRange)),e.markers.length>0&&(s=function(t,e){var n,r="",a=i(e);try{for(a.s();!(n=a.n()).done;){var o=n.value;if("OUT"===o.type)r="OUT",t.push("#EXT-X-CUE-OUT:DURATION=".concat(o.duration));else if("IN"===o.type)r="IN",t.push("#EXT-X-CUE-IN");else if("RAW"===o.type){var s=o.value?":".concat(o.value):"";t.push("#".concat(o.tagName).concat(s))}}}catch(t){a.e(t)}finally{a.f()}return r}(t,e.markers)),e.parts.length>0&&(o=function(t,e){var n,r=!1,a=i(e);try{for(a.s();!(n=a.n()).done;){var o=n.value;if(o.hint){var s=[];if(s.push("TYPE=PART",'URI="'.concat(o.uri,'"')),o.byterange){var c=o.byterange,u=c.offset,l=c.length;s.push("BYTERANGE-START=".concat(u)),l&&s.push("BYTERANGE-LENGTH=".concat(l))}t.push("#EXT-X-PRELOAD-HINT:".concat(s.join(","))),r=!0}else{var T=[];T.push("DURATION=".concat(o.duration),'URI="'.concat(o.uri,'"')),o.byterange&&T.push("BYTERANGE=".concat(P(o.byterange))),o.independent&&T.push("INDEPENDENT=YES"),o.gap&&T.push("GAP=YES"),t.push("#EXT-X-PART:".concat(T.join(",")))}}}catch(t){a.e(t)}finally{a.f()}return r}(t,e.parts)),o)return[n,r];var l,T,f,E=a<3?Math.round(e.duration):m(e.duration,(l=e.duration,T=l.toString(10),-1===(f=T.indexOf("."))?0:T.length-f-1));return t.push("#EXTINF:".concat(E,",").concat(unescape(encodeURIComponent(e.title||"")))),e.byterange&&t.push("#EXT-X-BYTERANGE:".concat(P(e.byterange))),Array.prototype.push.call(t,"".concat(e.uri)),[n,r,s]}function P(t){var e=t.offset,n=t.length;return"".concat(n,"@").concat(e)}e.default=function(t){y.PARAMCHECK(t),y.ASSERT("Not a playlist","playlist"===t.type);var e=new N(t.uri);return e.push("#EXTM3U"),t.version&&e.push("#EXT-X-VERSION:".concat(t.version)),t.independentSegments&&e.push("#EXT-X-INDEPENDENT-SEGMENTS"),t.start&&e.push("#EXT-X-START:TIME-OFFSET=".concat(m(t.start.offset)).concat(t.start.precise?",PRECISE=YES":"")),t.isMasterPlaylist?function(t,e){var n,r=i(e.sessionDataList);try{for(r.s();!(n=r.n()).done;){var a=n.value;t.push(X(a))}}catch(t){r.e(t)}finally{r.f()}var o,s=i(e.sessionKeyList);try{for(s.s();!(o=s.n()).done;){var c=o.value;t.push(O(c,!0))}}catch(t){s.e(t)}finally{s.f()}var u,l=i(e.variants);try{for(l.s();!(u=l.n()).done;)R(t,u.value)}catch(t){l.e(t)}finally{l.f()}}(e,t):function(t,e){var n="",r="",o=!1;if(e.targetDuration&&t.push("#EXT-X-TARGETDURATION:".concat(e.targetDuration)),e.lowLatencyCompatibility){var s=e.lowLatencyCompatibility,c=s.canBlockReload,u=s.canSkipUntil,l=s.holdBack,T=s.partHoldBack,f=[];f.push("CAN-BLOCK-RELOAD=".concat(c?"YES":"NO")),void 0!==u&&f.push("CAN-SKIP-UNTIL=".concat(u)),void 0!==l&&f.push("HOLD-BACK=".concat(l)),void 0!==T&&f.push("PART-HOLD-BACK=".concat(T)),t.push("#EXT-X-SERVER-CONTROL:".concat(f.join(",")))}e.partTargetDuration&&t.push("#EXT-X-PART-INF:PART-TARGET=".concat(e.partTargetDuration)),e.mediaSequenceBase&&t.push("#EXT-X-MEDIA-SEQUENCE:".concat(e.mediaSequenceBase)),e.discontinuitySequenceBase&&t.push("#EXT-X-DISCONTINUITY-SEQUENCE:".concat(e.discontinuitySequenceBase)),e.playlistType&&t.push("#EXT-X-PLAYLIST-TYPE:".concat(e.playlistType)),e.isIFrame&&t.push("#EXT-X-I-FRAMES-ONLY"),e.skip>0&&t.push("#EXT-X-SKIP:SKIPPED-SEGMENTS=".concat(e.skip));var E,h=i(e.segments);try{for(h.s();!(E=h.n()).done;){var p,I=a(g(t,E.value,n,r,e.version),3);n=I[0],r=I[1],"OUT"===(p=I[2])?o=!0:"IN"===p&&o&&(o=!1)}}catch(t){h.e(t)}finally{h.f()}"VOD"===e.playlistType&&o&&t.push("#EXT-X-CUE-IN"),e.prefetchSegments.length>2&&y.INVALIDPLAYLIST("The server must deliver no more than two prefetch segments");var d,A=i(e.prefetchSegments);try{for(A.s();!(d=A.n()).done;){var S=d.value;S.discontinuity&&t.push("#EXT-X-PREFETCH-DISCONTINUITY"),t.push("#EXT-X-PREFETCH:".concat(S.uri))}}catch(t){A.e(t)}finally{A.f()}e.endlist&&t.push("#EXT-X-ENDLIST");var v,N=i(e.renditionReports);try{for(N.s();!(v=N.n()).done;){var m=v.value,X=[];X.push('URI="'.concat(m.uri,'"'),"LAST-MSN=".concat(m.lastMSN)),void 0!==m.lastPart&&X.push("LAST-PART=".concat(m.lastPart)),t.push("#EXT-X-RENDITION-REPORT:".concat(X.join(",")))}}catch(t){N.e(t)}finally{N.f()}}(e,t),e.join("\n")}},890:function(t,e,n){function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function o(t,e,n){return(e=E(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,a=l(t);if(e){var i=l(this).constructor;n=Reflect.construct(a,arguments,i)}else n=a.apply(this,arguments);return function(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,n)}}function l(t){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},l(t)}function T(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,E(r.key),r)}}function f(t,e,n){return e&&T(t.prototype,e),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function E(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var a=n.call(t,e||"default");if("object"!==r(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===r(e)?e:String(e)}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var p=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(e,n);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,a)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),I=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),d=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&p(e,t,n);return I(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.RenditionReport=e.PrefetchSegment=e.PartialSegment=e.Segment=e.MediaPlaylist=e.MasterPlaylist=e.Playlist=e.SpliceInfo=e.DateRange=e.MediaInitializationSection=e.Key=e.SessionData=e.Variant=e.Rendition=void 0;var A=d(n(771)),y=f((function t(e){var n=e.type,r=e.uri,a=e.groupId,i=e.language,o=e.assocLanguage,s=e.name,c=e.isDefault,u=e.autoselect,l=e.forced,T=e.instreamId,f=e.characteristics,E=e.channels;h(this,t),A.PARAMCHECK(n,a,s),A.CONDITIONALASSERT(["SUBTITLES"===n,r],["CLOSED-CAPTIONS"===n,T],["CLOSED-CAPTIONS"===n,!r],[l,"SUBTITLES"===n]),this.type=n,this.uri=r,this.groupId=a,this.language=i,this.assocLanguage=o,this.name=s,this.isDefault=c,this.autoselect=u,this.forced=l,this.instreamId=T,this.characteristics=f,this.channels=E}));e.Rendition=y;var S=f((function t(e){var n=e.uri,r=e.isIFrameOnly,a=void 0!==r&&r,i=e.bandwidth,o=e.averageBandwidth,s=e.score,c=e.codecs,u=e.resolution,l=e.frameRate,T=e.hdcpLevel,f=e.allowedCpc,E=e.videoRange,p=e.stableVariantId,I=e.programId,d=e.audio,y=void 0===d?[]:d,S=e.video,v=void 0===S?[]:S,N=e.subtitles,m=void 0===N?[]:N,X=e.closedCaptions,O=void 0===X?[]:X,R=e.currentRenditions,b=void 0===R?{audio:0,video:0,subtitles:0,closedCaptions:0}:R;h(this,t),A.PARAMCHECK(n,i),this.uri=n,this.isIFrameOnly=a,this.bandwidth=i,this.averageBandwidth=o,this.score=s,this.codecs=c,this.resolution=u,this.frameRate=l,this.hdcpLevel=T,this.allowedCpc=f,this.videoRange=E,this.stableVariantId=p,this.programId=I,this.audio=y,this.video=v,this.subtitles=m,this.closedCaptions=O,this.currentRenditions=b}));e.Variant=S;var v=f((function t(e){var n=e.id,r=e.value,a=e.uri,i=e.language;h(this,t),A.PARAMCHECK(n,r||a),A.ASSERT("SessionData cannot have both value and uri, shoud be either.",!(r&&a)),this.id=n,this.value=r,this.uri=a,this.language=i}));e.SessionData=v;var N=f((function t(e){var n=e.method,r=e.uri,a=e.iv,i=e.format,o=e.formatVersion;h(this,t),A.PARAMCHECK(n),A.CONDITIONALPARAMCHECK(["NONE"!==n,r]),A.CONDITIONALASSERT(["NONE"===n,!(r||a||i||o)]),this.method=n,this.uri=r,this.iv=a,this.format=i,this.formatVersion=o}));e.Key=N;var m=f((function t(e){var n=e.hint,r=void 0!==n&&n,a=e.uri,i=e.mimeType,o=e.byterange;h(this,t),A.PARAMCHECK(a),this.hint=r,this.uri=a,this.mimeType=i,this.byterange=o}));e.MediaInitializationSection=m;var X=f((function t(e){var n=e.id,r=e.classId,a=e.start,i=e.end,o=e.duration,s=e.plannedDuration,c=e.endOnNext,u=e.attributes,l=void 0===u?{}:u;h(this,t),A.PARAMCHECK(n),A.CONDITIONALPARAMCHECK([!0===c,r]),A.CONDITIONALASSERT([i,a],[i,a<=i],[o,o>=0],[s,s>=0]),this.id=n,this.classId=r,this.start=a,this.end=i,this.duration=o,this.plannedDuration=s,this.endOnNext=c,this.attributes=l}));e.DateRange=X;var O=f((function t(e){var n=e.type,r=e.duration,a=e.tagName,i=e.value;h(this,t),A.PARAMCHECK(n),A.CONDITIONALPARAMCHECK(["OUT"===n,r]),A.CONDITIONALPARAMCHECK(["RAW"===n,a]),this.type=n,this.duration=r,this.tagName=a,this.value=i}));e.SpliceInfo=O;var R=f((function t(e){h(this,t),A.PARAMCHECK(e),this.type=e})),b=function(t){s(n,t);var e=u(n);function n(t){var r,a=t.isMasterPlaylist,i=t.uri,o=t.version,s=t.independentSegments,c=void 0!==s&&s,u=t.start,l=t.source;return h(this,n),r=e.call(this,"playlist"),A.PARAMCHECK(a),r.isMasterPlaylist=a,r.uri=i,r.version=o,r.independentSegments=c,r.start=u,r.source=l,r}return f(n)}(R);e.Playlist=b;var g=function(t){s(n,t);var e=u(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};h(this,n),t=e.call(this,i(i({},r),{},{isMasterPlaylist:!0}));var a=r.variants,o=void 0===a?[]:a,s=r.currentVariant,c=r.sessionDataList,u=void 0===c?[]:c,l=r.sessionKeyList,T=void 0===l?[]:l;return t.variants=o,t.currentVariant=s,t.sessionDataList=u,t.sessionKeyList=T,t}return f(n)}(b);e.MasterPlaylist=g;var P=function(t){s(n,t);var e=u(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};h(this,n),t=e.call(this,i(i({},r),{},{isMasterPlaylist:!1}));var a=r.targetDuration,o=r.mediaSequenceBase,s=void 0===o?0:o,c=r.discontinuitySequenceBase,u=void 0===c?0:c,l=r.endlist,T=void 0!==l&&l,f=r.playlistType,E=r.isIFrame,p=r.segments,I=void 0===p?[]:p,d=r.prefetchSegments,A=void 0===d?[]:d,y=r.lowLatencyCompatibility,S=r.partTargetDuration,v=r.renditionReports,N=void 0===v?[]:v,m=r.skip,X=void 0===m?0:m,O=r.hash;return t.targetDuration=a,t.mediaSequenceBase=s,t.discontinuitySequenceBase=u,t.endlist=T,t.playlistType=f,t.isIFrame=E,t.segments=I,t.prefetchSegments=A,t.lowLatencyCompatibility=y,t.partTargetDuration=S,t.renditionReports=N,t.skip=X,t.hash=O,t}return f(n)}(b);e.MediaPlaylist=P;var D=function(t){s(n,t);var e=u(n);function n(t){var r,a=t.uri,i=t.mimeType,o=t.data,s=t.duration,c=t.title,u=t.byterange,l=t.discontinuity,T=t.mediaSequenceNumber,f=void 0===T?0:T,E=t.discontinuitySequence,p=void 0===E?0:E,I=t.key,d=t.map,A=t.programDateTime,y=t.dateRange,S=t.markers,v=void 0===S?[]:S,N=t.parts,m=void 0===N?[]:N;return h(this,n),(r=e.call(this,"segment")).uri=a,r.mimeType=i,r.data=o,r.duration=s,r.title=c,r.byterange=u,r.discontinuity=l,r.mediaSequenceNumber=f,r.discontinuitySequence=p,r.key=I,r.map=d,r.programDateTime=A,r.dateRange=y,r.markers=v,r.parts=m,r}return f(n)}(R);e.Segment=D;var L=function(t){s(n,t);var e=u(n);function n(t){var r,a=t.hint,i=void 0!==a&&a,o=t.uri,s=t.duration,c=t.independent,u=t.byterange,l=t.gap;return h(this,n),r=e.call(this,"part"),A.PARAMCHECK(o),r.hint=i,r.uri=o,r.duration=s,r.independent=c,r.duration=s,r.byterange=u,r.gap=l,r}return f(n)}(R);e.PartialSegment=L;var C=function(t){s(n,t);var e=u(n);function n(t){var r,a=t.uri,i=t.discontinuity,o=t.mediaSequenceNumber,s=void 0===o?0:o,c=t.discontinuitySequence,u=void 0===c?0:c,l=t.key;return h(this,n),r=e.call(this,"prefetch"),A.PARAMCHECK(a),r.uri=a,r.discontinuity=i,r.mediaSequenceNumber=s,r.discontinuitySequence=u,r.key=l,r}return f(n)}(R);e.PrefetchSegment=C;var M=f((function t(e){var n=e.uri,r=e.lastMSN,a=e.lastPart;h(this,t),A.PARAMCHECK(n),this.uri=n,this.lastMSN=r,this.lastPart=a}));e.RenditionReport=M},771:(t,e)=>{function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,i,o,s=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);c=!0);}catch(t){u=!0,a=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(t,e)||a(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){c=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(c)throw o}}}}function a(t,e){if(t){if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}Object.defineProperty(e,"__esModule",{value:!0}),e.getOptions=e.setOptions=e.hasOwnProp=e.formatDate=e.camelify=e.splitByCommaWithPreservingQuotes=e.trim=e.splitAt=e.tryCatch=e.byteSequenceToHex=e.hexToByteSequence=e.toNumber=e.INVALIDPLAYLIST=e.CONDITIONALPARAMCHECK=e.PARAMCHECK=e.CONDITIONALASSERT=e.ASSERT=e.THROW=void 0;var o={};function s(t){if(o.strictMode)throw t;o.silent||console.error(t.message)}function c(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if("number"==typeof t)return t;var n=10===e?Number.parseFloat(t):Number.parseInt(t,e);return Number.isNaN(n)?0:n}e.THROW=s,e.ASSERT=function(t){for(var e=arguments.length,a=new Array(e>1?e-1:0),i=1;i<e;i++)a[i-1]=arguments[i];var o,c=r(a.entries());try{for(c.s();!(o=c.n()).done;){var u=n(o.value,2),l=u[0];u[1]||s(new Error("".concat(t," : Failed at [").concat(l,"]")))}}catch(t){c.e(t)}finally{c.f()}},e.CONDITIONALASSERT=function(){for(var t=arguments.length,e=new Array(t),a=0;a<t;a++)e[a]=arguments[a];var i,o=r(e.entries());try{for(o.s();!(i=o.n()).done;){var c=n(i.value,2),u=c[0],l=n(c[1],2),T=l[0],f=l[1];T&&(f||s(new Error("Conditional Assert : Failed at [".concat(u,"]"))))}}catch(t){o.e(t)}finally{o.f()}},e.PARAMCHECK=function(){for(var t=arguments.length,e=new Array(t),a=0;a<t;a++)e[a]=arguments[a];var i,o=r(e.entries());try{for(o.s();!(i=o.n()).done;){var c=n(i.value,2),u=c[0];void 0===c[1]&&s(new Error("Param Check : Failed at [".concat(u,"]")))}}catch(t){o.e(t)}finally{o.f()}},e.CONDITIONALPARAMCHECK=function(){for(var t=arguments.length,e=new Array(t),a=0;a<t;a++)e[a]=arguments[a];var i,o=r(e.entries());try{for(o.s();!(i=o.n()).done;){var c=n(i.value,2),u=c[0],l=n(c[1],2),T=l[0],f=l[1];T&&(void 0===f&&s(new Error("Conditional Param Check : Failed at [".concat(u,"]"))))}}catch(t){o.e(t)}finally{o.f()}},e.INVALIDPLAYLIST=function(t){s(new Error("Invalid Playlist : ".concat(t)))},e.toNumber=c,e.hexToByteSequence=function(t){(t.startsWith("0x")||t.startsWith("0X"))&&(t=t.slice(2));for(var e=[],n=0;n<t.length;n+=2)e.push(c(t.slice(n,n+2),16));return Buffer.from(e)},e.byteSequenceToHex=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;n<=e&&s(new Error("end must be larger than start : start=".concat(e,", end=").concat(n)));for(var r=[],a=e;a<n;a++)r.push("0".concat((255&t[a]).toString(16).toUpperCase()).slice(-2));return"0x".concat(r.join(""))},e.tryCatch=function(t,e){try{return t()}catch(t){return e(t)}},e.splitAt=function(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=-1,a=0,i=0;a<t.length;a++)if(t[a]===e){if(i++===n)return[t.slice(0,a),t.slice(a+1)];r=a}return-1!==r?[t.slice(0,r),t.slice(r+1)]:[t]},e.trim=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" ";return t?(t=t.trim()," "===e||(t.startsWith(e)&&(t=t.slice(1)),t.endsWith(e)&&(t=t.slice(0,-1))),t):t},e.splitByCommaWithPreservingQuotes=function(t){for(var e=[],n=!0,r=0,a=[],i=0;i<t.length;i++){var o=t[i];n&&","===o?(e.push(t.slice(r,i).trim()),r=i+1):'"'!==o&&"'"!==o||(n?(a.push(o),n=!1):o===a.at(-1)?(a.pop(),n=!0):a.push(o))}return e.push(t.slice(r).trim()),e},e.camelify=function(t){var e,n=[],a=!1,i=r(t);try{for(i.s();!(e=i.n()).done;){var o=e.value;"-"!==o&&"_"!==o?a?(n.push(o.toUpperCase()),a=!1):n.push(o.toLowerCase()):a=!0}}catch(t){i.e(t)}finally{i.f()}return n.join("")},e.formatDate=function(t){var e=t.getUTCFullYear(),n=("0"+(t.getUTCMonth()+1)).slice(-2),r=("0"+t.getUTCDate()).slice(-2),a=("0"+t.getUTCHours()).slice(-2),i=("0"+t.getUTCMinutes()).slice(-2),o=("0"+t.getUTCSeconds()).slice(-2),s=("00"+t.getUTCMilliseconds()).slice(-3);return"".concat(e,"-").concat(n,"-").concat(r,"T").concat(a,":").concat(i,":").concat(o,".").concat(s,"Z")},e.hasOwnProp=function(t,e){return Object.hasOwnProperty.call(t,e)},e.setOptions=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o=Object.assign(o,t)},e.getOptions=function(){return Object.assign({},o)}},492:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(e,n);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,a)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),a=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return a(e,t),e},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.setOptions=e.getOptions=e.types=e.stringify=e.parse=void 0;const s=n(771);Object.defineProperty(e,"getOptions",{enumerable:!0,get:function(){return s.getOptions}}),Object.defineProperty(e,"setOptions",{enumerable:!0,get:function(){return s.setOptions}});const c=o(n(463));e.parse=c.default;const u=o(n(367));e.stringify=u.default;const l=i(n(890));e.types=l}},e={};var n=function n(r){var a=e[r];if(void 0!==a)return a.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}(492);return n})())); | ||
//# sourceMappingURL=hls-parser.min.js.map |
{ | ||
"name": "hls-parser", | ||
"version": "0.10.7", | ||
"version": "0.10.8", | ||
"description": "A simple library to read/write HLS playlists", | ||
@@ -33,5 +33,5 @@ "main": "index.js", | ||
"@ava/typescript": "^4.1.0", | ||
"@babel/core": "^7.22.11", | ||
"@babel/eslint-parser": "^7.22.11", | ||
"@babel/preset-env": "^7.22.10", | ||
"@babel/core": "^7.23.0", | ||
"@babel/eslint-parser": "^7.22.15", | ||
"@babel/preset-env": "^7.22.20", | ||
"@tsconfig/node16": "^16.1.1", | ||
@@ -43,3 +43,3 @@ "ava": "^5.3.1", | ||
"terser-webpack-plugin": "^5.3.9", | ||
"ts-loader": "^9.4.4", | ||
"ts-loader": "^9.5.0", | ||
"typescript": "^5.2.2", | ||
@@ -108,2 +108,3 @@ "webpack": "^5.88.2", | ||
"@typescript-eslint/comma-dangle": 0, | ||
"@typescript-eslint/consistent-type-imports": 0, | ||
"@typescript-eslint/dot-notation": 0, | ||
@@ -110,0 +111,0 @@ "@typescript-eslint/member-delimiter-style": 0, |
@@ -805,2 +805,3 @@ "use strict"; | ||
} | ||
// @ts-expect-error TODO check if this is not a bug the third argument should be a discontinuitySequence | ||
addSegment(playlist, segment, currentKey, currentMap); | ||
@@ -883,3 +884,3 @@ if (!containsParts && segment.parts.length > 0) { | ||
} | ||
else { | ||
else if (dateRange.classId) { | ||
rangeList.set(dateRange.classId, [{ start, end }]); | ||
@@ -886,0 +887,0 @@ } |
95
parse.ts
@@ -8,2 +8,3 @@ import * as utils from './utils'; | ||
MediaInitializationSection, | ||
Byterange, | ||
DateRange, | ||
@@ -19,7 +20,9 @@ SpliceInfo, | ||
function unquote(str) { | ||
function unquote(str: string | undefined) { | ||
return utils.trim(str, '"'); | ||
} | ||
function getTagCategory(tagName) { | ||
type TagCategory = 'Basic' | 'Segment' | 'MasterPlaylist' | 'MediaPlaylist' | 'MediaorMasterPlaylist' | 'Unknown'; | ||
function getTagCategory(tagName: string): TagCategory { | ||
switch (tagName) { | ||
@@ -73,8 +76,8 @@ case 'EXTM3U': | ||
function parseEXTINF(param) { | ||
const pair = utils.splitAt(param, ','); | ||
function parseEXTINF(param: string) { | ||
const pair = utils.splitAt(param, ',') as [string, string]; | ||
return {duration: utils.toNumber(pair[0]), title: decodeURIComponent(escape(pair[1]))}; | ||
} | ||
function parseBYTERANGE(param) { | ||
function parseBYTERANGE(param: string): Byterange { | ||
const pair = utils.splitAt(param, '@'); | ||
@@ -84,8 +87,8 @@ return {length: utils.toNumber(pair[0]), offset: pair[1] ? utils.toNumber(pair[1]) : -1}; | ||
function parseResolution(str) { | ||
const pair = utils.splitAt(str, 'x'); | ||
function parseResolution(str: string) { | ||
const pair = utils.splitAt(str, 'x') as [string, string]; | ||
return {width: utils.toNumber(pair[0]), height: utils.toNumber(pair[1])}; | ||
} | ||
function parseAllowedCpc(str) { | ||
function parseAllowedCpc(str: string) { | ||
const message = 'ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration'; | ||
@@ -96,3 +99,3 @@ const list = str.split(','); | ||
} | ||
const allowedCpcList: {format; cpcList}[] = []; | ||
const allowedCpcList: {format: string; cpcList: string[]}[] = []; | ||
for (const item of list) { | ||
@@ -109,3 +112,3 @@ const [format, cpcText] = utils.splitAt(item, ':'); | ||
function parseIV(str) { | ||
function parseIV(str: string): Buffer { | ||
const iv = utils.hexToByteSequence(str); | ||
@@ -118,3 +121,3 @@ if (iv.length !== 16) { | ||
function parseUserAttribute(str) { | ||
function parseUserAttribute(str: string) { | ||
if (str.startsWith('"')) { | ||
@@ -129,3 +132,3 @@ return unquote(str); | ||
function setCompatibleVersionOfKey(params, attributes) { | ||
function setCompatibleVersionOfKey(params: Record<string, any>, attributes: Record<string, any>) { | ||
if (attributes['IV'] && params.compatibleVersion < 2) { | ||
@@ -143,3 +146,3 @@ params.compatibleVersion = 2; | ||
const [key, value] = utils.splitAt(item, '='); | ||
const val = unquote(value); | ||
const val = unquote(value)!; | ||
switch (key) { | ||
@@ -198,3 +201,3 @@ case 'URI': | ||
} else if (key.startsWith('X-')) { | ||
attributes[key] = parseUserAttribute(value); | ||
attributes[key] = parseUserAttribute(value!); | ||
} else { | ||
@@ -266,3 +269,3 @@ if (key === 'VIDEO-RANGE' && val !== 'SDR' && val !== 'HLG' && val !== 'PQ') { | ||
function splitTag(line) { | ||
function splitTag(line: string): [string, string | null] { | ||
const index = line.indexOf(':'); | ||
@@ -275,3 +278,3 @@ if (index === -1) { | ||
function parseRendition({attributes}) { | ||
function parseRendition({attributes}: Tag): Rendition { | ||
const rendition = new Rendition({ | ||
@@ -374,3 +377,3 @@ type: attributes['TYPE'], | ||
function sameKey(key1, key2) { | ||
function sameKey(key1: Key, key2: Key) { | ||
if (key1.method !== key2.method) { | ||
@@ -406,6 +409,6 @@ return false; | ||
function parseMasterPlaylist(lines, params) { | ||
function parseMasterPlaylist(lines: Line[], params: Record<string, any>): MasterPlaylist { | ||
const playlist = new MasterPlaylist(); | ||
let variantIsScored = false; | ||
for (const [index, {name, value, attributes}] of lines.entries()) { | ||
for (const [index, {name, value, attributes}] of (lines as Tag[]).entries()) { | ||
if (name === 'EXT-X-VERSION') { | ||
@@ -492,3 +495,3 @@ playlist.version = value; | ||
function parseSegment(lines, uri, start, end, mediaSequenceNumber, discontinuitySequence, params) { | ||
function parseSegment(lines: Line[], uri: string, start: number, end: number, mediaSequenceNumber: number, discontinuitySequence: number, params: Record<string, any>) { | ||
const segment = new Segment({uri, mediaSequenceNumber, discontinuitySequence}); | ||
@@ -498,3 +501,3 @@ let mapHint = false; | ||
for (let i = start; i <= end; i++) { | ||
const {name, value, attributes} = lines[i]; | ||
const {name, value, attributes} = lines[i] as Tag; | ||
if (name === 'EXTINF') { | ||
@@ -546,3 +549,3 @@ if (!Number.isInteger(value.duration) && params.compatibleVersion < 3) { | ||
} else if (name === 'EXT-X-DATERANGE') { | ||
const attrs = {}; | ||
const attrs: Record<string, any> = {}; | ||
for (const key of Object.keys(attributes)) { | ||
@@ -622,6 +625,6 @@ if (key.startsWith('SCTE35-') || key.startsWith('X-')) { | ||
function parsePrefetchSegment(lines, uri, start, end, mediaSequenceNumber, discontinuitySequence, params) { | ||
function parsePrefetchSegment(lines: Line[], uri: any, start: number, end: number, mediaSequenceNumber: number, discontinuitySequence: number, params: Record<string, any>) { | ||
const segment = new PrefetchSegment({uri, mediaSequenceNumber, discontinuitySequence}); | ||
for (let i = start; i <= end; i++) { | ||
const {name, attributes} = lines[i]; | ||
const {name, attributes} = lines[i] as Tag; | ||
if (name === 'EXTINF') { | ||
@@ -649,3 +652,3 @@ utils.INVALIDPLAYLIST('A prefetch segment must not be advertised with an EXTINF tag.'); | ||
function parseMediaPlaylist(lines, params) { | ||
function parseMediaPlaylist(lines: Line[], params: Record<string, any>) { | ||
const playlist = new MediaPlaylist(); | ||
@@ -661,3 +664,3 @@ let segmentStart = -1; | ||
for (const [index, line] of lines.entries()) { | ||
const {name, value, attributes, category} = line; | ||
const {name, value, attributes, category} = line as Tag; | ||
if (category === 'Segment') { | ||
@@ -780,3 +783,3 @@ if (segmentStart === -1) { | ||
if (segment) { | ||
[discontinuitySequence, currentKey, currentMap] = addSegment(playlist, segment, discontinuitySequence, currentKey, currentMap); | ||
[discontinuitySequence, currentKey, currentMap] = addSegment(playlist, segment, discontinuitySequence, currentKey!, currentMap!); | ||
if (!containsParts && segment.parts.length > 0) { | ||
@@ -796,2 +799,3 @@ containsParts = true; | ||
} | ||
// @ts-expect-error TODO check if this is not a bug the third argument should be a discontinuitySequence | ||
addSegment(playlist, segment, currentKey, currentMap); | ||
@@ -810,3 +814,3 @@ if (!containsParts && segment.parts.length > 0) { | ||
function addSegment(playlist, segment, discontinuitySequence, currentKey, currentMap?: any) { | ||
function addSegment(playlist: MediaPlaylist, segment: Segment, discontinuitySequence: number, currentKey?: Key, currentMap?: MediaInitializationSection): [number, Key, MediaInitializationSection] { | ||
const {discontinuity, key, map, byterange, uri} = segment; | ||
@@ -820,3 +824,3 @@ if (discontinuity) { | ||
if (!map) { | ||
segment.map = currentMap; | ||
segment.map = currentMap!; | ||
} | ||
@@ -826,3 +830,3 @@ if (byterange && byterange.offset === -1) { | ||
if (segments.length > 0) { | ||
const prevSegment = segments.at(-1); | ||
const prevSegment = segments.at(-1)!; | ||
if (prevSegment.byterange && prevSegment.uri === uri) { | ||
@@ -838,6 +842,6 @@ byterange.offset = prevSegment.byterange.offset + prevSegment.byterange.length; | ||
playlist.segments.push(segment); | ||
return [segment.discontinuitySequence, segment.key, segment.map]; | ||
return [segment.discontinuitySequence, segment.key!, segment.map]; | ||
} | ||
function checkDateRange(segments) { | ||
function checkDateRange(segments: Segment[]) { | ||
const earliestDates = new Map(); | ||
@@ -877,3 +881,3 @@ const rangeList = new Map(); | ||
range.push({start, end}); | ||
} else { | ||
} else if (dateRange.classId) { | ||
rangeList.set(dateRange.classId, [{start, end}]); | ||
@@ -935,3 +939,3 @@ } | ||
function CHECKTAGCATEGORY(category, params) { | ||
function CHECKTAGCATEGORY(category: TagCategory, params: Record<string, any>) { | ||
if (category === 'Segment' || category === 'MediaPlaylist') { | ||
@@ -959,3 +963,10 @@ if (params.isMasterPlaylist === undefined) { | ||
function parseTag(line, params) { | ||
type Tag = { | ||
name: string; | ||
category: TagCategory; | ||
value: any; | ||
attributes: any; | ||
}; | ||
function parseTag(line: string, params: Record<string, any>): Tag | null { | ||
const [name, param] = splitTag(line); | ||
@@ -977,4 +988,6 @@ const category = getTagCategory(name); | ||
function lexicalParse(text, params) { | ||
const lines: any[] = []; | ||
type Line = string | Tag; | ||
function lexicalParse(text: string, params: Record<string, any>) { | ||
const lines: Line[] = []; | ||
for (const l of text.split('\n')) { | ||
@@ -1003,3 +1016,3 @@ // V8 has garbage collection issues when cleaning up substrings split from strings greater | ||
} | ||
if (lines.length === 0 || lines[0].name !== 'EXTM3U') { | ||
if (lines.length === 0 || (lines[0] as Tag).name !== 'EXTM3U') { | ||
utils.INVALIDPLAYLIST('The EXTM3U tag MUST be the first line.'); | ||
@@ -1010,3 +1023,3 @@ } | ||
function semanticParse(lines, params) { | ||
function semanticParse(lines: Line[], params: Record<string, any>) { | ||
let playlist; | ||
@@ -1029,4 +1042,4 @@ if (params.isMasterPlaylist) { | ||
function parse(text) { | ||
const params = { | ||
function parse(text: string): MasterPlaylist | MediaPlaylist { | ||
const params: Record<string, any> = { | ||
version: undefined, | ||
@@ -1033,0 +1046,0 @@ isMasterPlaylist: undefined, |
@@ -369,3 +369,3 @@ "use strict"; | ||
if (dateRange.end) { | ||
attrs.push(`END-DATE="${dateRange.end}"`); | ||
attrs.push(`END-DATE="${utils.formatDate(dateRange.end)}"`); | ||
} | ||
@@ -372,0 +372,0 @@ if (dateRange.duration) { |
import * as utils from './utils'; | ||
import { | ||
Byterange, | ||
DateRange, Key, | ||
MasterPlaylist, | ||
MediaInitializationSection, | ||
MediaPlaylist, | ||
PartialSegment, | ||
Rendition, | ||
Segment, | ||
SessionData, | ||
SpliceInfo, | ||
Variant | ||
} from './types'; | ||
@@ -18,6 +31,6 @@ const ALLOW_REDUNDANCY = [ | ||
class LineArray extends Array { | ||
baseUri: string; | ||
class LineArray extends Array<string> { | ||
baseUri?: string; | ||
constructor(baseUri) { | ||
constructor(baseUri?: string) { | ||
super(); | ||
@@ -27,3 +40,3 @@ this.baseUri = baseUri; | ||
override push(...elems) { | ||
override push(...elems: string[]) { | ||
// redundancy check | ||
@@ -60,3 +73,3 @@ for (const elem of elems) { | ||
function getNumberOfDecimalPlaces(num) { | ||
function getNumberOfDecimalPlaces(num: number) { | ||
const str = num.toString(10); | ||
@@ -70,3 +83,3 @@ const index = str.indexOf('.'); | ||
function buildMasterPlaylist(lines, playlist) { | ||
function buildMasterPlaylist(lines: LineArray, playlist: MasterPlaylist) { | ||
for (const sessionData of playlist.sessionDataList) { | ||
@@ -83,3 +96,3 @@ lines.push(buildSessionData(sessionData)); | ||
function buildSessionData(sessionData) { | ||
function buildSessionData(sessionData: SessionData) { | ||
const attrs = [`DATA-ID="${sessionData.id}"`]; | ||
@@ -97,3 +110,3 @@ if (sessionData.language) { | ||
function buildKey(key, isSessionKey?: any) { | ||
function buildKey(key: Key, isSessionKey?: any) { | ||
const name = isSessionKey ? '#EXT-X-SESSION-KEY' : '#EXT-X-KEY'; | ||
@@ -119,3 +132,3 @@ const attrs = [`METHOD=${key.method}`]; | ||
function buildVariant(lines, variant) { | ||
function buildVariant(lines: LineArray, variant: Variant) { | ||
const name = variant.isIFrameOnly ? '#EXT-X-I-FRAME-STREAM-INF' : '#EXT-X-STREAM-INF'; | ||
@@ -192,3 +205,3 @@ const attrs = [`BANDWIDTH=${variant.bandwidth}`]; | ||
function buildRendition(rendition) { | ||
function buildRendition(rendition: Rendition) { | ||
const attrs = [ | ||
@@ -229,3 +242,3 @@ `TYPE=${rendition.type}`, | ||
function buildMediaPlaylist(lines, playlist) { | ||
function buildMediaPlaylist(lines: LineArray, playlist: MediaPlaylist) { | ||
let lastKey = ''; | ||
@@ -305,3 +318,3 @@ let lastMap = ''; | ||
function buildSegment(lines, segment, lastKey, lastMap, version = 1) { | ||
function buildSegment(lines: LineArray, segment: Segment, lastKey: string, lastMap: string, version = 1) { | ||
let hint = false; | ||
@@ -351,3 +364,3 @@ let markerType = ''; | ||
function buildMap(map) { | ||
function buildMap(map: MediaInitializationSection) { | ||
const attrs = [`URI="${map.uri}"`]; | ||
@@ -360,7 +373,7 @@ if (map.byterange) { | ||
function buildByteRange({offset, length}) { | ||
function buildByteRange({offset, length}: Byterange) { | ||
return `${length}@${offset}`; | ||
} | ||
function buildDateRange(dateRange) { | ||
function buildDateRange(dateRange: DateRange) { | ||
const attrs = [ | ||
@@ -373,3 +386,3 @@ `ID="${dateRange.id}"` | ||
if (dateRange.end) { | ||
attrs.push(`END-DATE="${dateRange.end}"`); | ||
attrs.push(`END-DATE="${utils.formatDate(dateRange.end)}"`); | ||
} | ||
@@ -402,3 +415,3 @@ if (dateRange.duration) { | ||
function buildMarkers(lines, markers) { | ||
function buildMarkers(lines: LineArray, markers: SpliceInfo[]) { | ||
let type = ''; | ||
@@ -420,3 +433,3 @@ for (const marker of markers) { | ||
function buildParts(lines, parts) { | ||
function buildParts(lines: LineArray, parts: PartialSegment[]) { | ||
let hint = false; | ||
@@ -454,3 +467,3 @@ for (const part of parts) { | ||
function stringify(playlist) { | ||
function stringify(playlist: MasterPlaylist | MediaPlaylist): string { | ||
utils.PARAMCHECK(playlist); | ||
@@ -470,5 +483,5 @@ utils.ASSERT('Not a playlist', playlist.type === 'playlist'); | ||
if (playlist.isMasterPlaylist) { | ||
buildMasterPlaylist(lines, playlist); | ||
buildMasterPlaylist(lines, playlist as MasterPlaylist); | ||
} else { | ||
buildMediaPlaylist(lines, playlist); | ||
buildMediaPlaylist(lines, playlist as MediaPlaylist); | ||
} | ||
@@ -475,0 +488,0 @@ // console.log('<<<'); |
31
types.ts
import * as utils from './utils'; | ||
type RenditionType = 'AUDIO' | 'VIDEO' | 'SUBTITLES' | 'CLOSED-CAPTIONS'; | ||
class Rendition { | ||
type: string; | ||
type: RenditionType; | ||
uri?: string; | ||
@@ -53,3 +55,3 @@ groupId: string; | ||
averageBandwidth?: number; | ||
score: any; | ||
score: number; | ||
codecs?: string; | ||
@@ -59,5 +61,5 @@ resolution?: { width: number; height: number }; | ||
hdcpLevel?: string; | ||
allowedCpc: any; | ||
videoRange: any; | ||
stableVariantId: any; | ||
allowedCpc: { format: string, cpcList: string[] }[]; | ||
videoRange: 'SDR' | 'HLG' | 'PQ'; | ||
stableVariantId: string; | ||
programId: any; | ||
@@ -159,3 +161,3 @@ audio: Rendition[]; | ||
type Byterange = { | ||
export type Byterange = { | ||
length: number; | ||
@@ -204,6 +206,6 @@ offset: number; | ||
attributes = {} | ||
}: any) { | ||
}: DateRange) { | ||
utils.PARAMCHECK(id); | ||
utils.CONDITIONALPARAMCHECK([endOnNext === true, classId]); | ||
utils.CONDITIONALASSERT([end, start], [end, start <= end], [duration, duration >= 0], [plannedDuration, plannedDuration >= 0]); | ||
utils.CONDITIONALASSERT([end, start], [end, start! <= end!], [duration, duration! >= 0], [plannedDuration, plannedDuration! >= 0]); | ||
this.id = id; | ||
@@ -301,4 +303,11 @@ this.classId = classId; | ||
type LowLatencyCompatibility = { | ||
canBlockReload: boolean, | ||
canSkipUntil: number, | ||
holdBack: number, | ||
partHoldBack: number, | ||
}; | ||
class MediaPlaylist extends Playlist { | ||
targetDuration?: number; | ||
targetDuration: number; | ||
mediaSequenceBase?: number; | ||
@@ -311,3 +320,3 @@ discontinuitySequenceBase?: number; | ||
prefetchSegments: PrefetchSegment[]; | ||
lowLatencyCompatibility?: Record<string, any>; | ||
lowLatencyCompatibility?: LowLatencyCompatibility; | ||
partTargetDuration?: number; | ||
@@ -335,3 +344,3 @@ renditionReports: RenditionReport[]; | ||
} = params; | ||
this.targetDuration = targetDuration; | ||
this.targetDuration = targetDuration!; | ||
this.mediaSequenceBase = mediaSequenceBase; | ||
@@ -338,0 +347,0 @@ this.discontinuitySequenceBase = discontinuitySequenceBase; |
20
utils.ts
@@ -20,3 +20,3 @@ | ||
function ASSERT(msg, ...options) { | ||
function ASSERT(msg: string, ...options: boolean[]) { | ||
for (const [index, param] of options.entries()) { | ||
@@ -59,3 +59,3 @@ if (!param) { | ||
function INVALIDPLAYLIST(msg) { | ||
function INVALIDPLAYLIST(msg: string) { | ||
THROW(new Error(`Invalid Playlist : ${msg}`)); | ||
@@ -75,3 +75,3 @@ } | ||
function hexToByteSequence(str) { | ||
function hexToByteSequence(str: string): Buffer { | ||
if (str.startsWith('0x') || str.startsWith('0X')) { | ||
@@ -87,3 +87,3 @@ str = str.slice(2); | ||
function byteSequenceToHex(sequence, start = 0, end = sequence.length) { | ||
function byteSequenceToHex(sequence: Buffer, start = 0, end = sequence.length) { | ||
if (end <= start) { | ||
@@ -99,3 +99,3 @@ THROW(new Error(`end must be larger than start : start=${start}, end=${end}`)); | ||
function tryCatch(body, errorHandler) { | ||
function tryCatch<T>(body: () => T, errorHandler: (err: unknown) => T): T { | ||
try { | ||
@@ -108,3 +108,3 @@ return body(); | ||
function splitAt(str: string, delimiter, index = 0) { | ||
function splitAt(str: string, delimiter: string, index = 0): [string] | [string, string] { | ||
let lastDelimiterPos = -1; | ||
@@ -125,3 +125,3 @@ for (let i = 0, j = 0; i < str.length; i++) { | ||
function trim(str: string, char = ' ') { | ||
function trim(str: string | undefined, char = ' ') { | ||
if (!str) { | ||
@@ -200,11 +200,11 @@ return str; | ||
function hasOwnProp(obj, propName) { | ||
function hasOwnProp(obj: object, propName: string): boolean { | ||
return Object.hasOwnProperty.call(obj, propName); | ||
} | ||
function setOptions(newOptions = {}) { | ||
function setOptions(newOptions: Partial<Options> = {}): void { | ||
options = Object.assign(options, newOptions); | ||
} | ||
function getOptions() { | ||
function getOptions(): Options { | ||
return Object.assign({}, options); | ||
@@ -211,0 +211,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
720146
7110