UNPKG

awscdk-construct-hls-session-runner

Version:

AWS CDK construct for deploying a Lambda function and SFN state machines to fetch an HLS manifest

2 lines 59.7 kB
/*! For license information please see hls-parser.min.js.LICENSE.txt */ !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={377: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,i,a,o,s=[],u=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}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 i(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,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){u=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw o}}}}function a(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.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=Array(e);n<e;n++)r[n]=t[n];return r}var s,u=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}: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}),l=this&&this.__importStar||(s=function(t){return s=Object.getOwnPropertyNames||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[e.length]=n);return e},s(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n=s(t),r=0;r<n.length;r++)"default"!==n[r]&&u(e,t,n[r]);return c(e,t),e});Object.defineProperty(e,"__esModule",{value:!0});var T=l(n(203)),f=n(31);function E(t){return T.trim(t,'"')}function d(t){var e=T.splitAt(t,",");return{duration:T.toNumber(e[0]),title:decodeURIComponent(escape(e[1]))}}function h(t){var e=T.splitAt(t,"@");return{length:T.toNumber(e[0]),offset:e[1]?T.toNumber(e[1]):-1}}function p(t){var e=T.splitAt(t,"x");return{width:T.toNumber(e[0]),height:T.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&&T.INVALIDPLAYLIST(e);var a,o=[],s=i(n);try{for(s.s();!(a=s.n()).done;){var u=a.value,c=r(T.splitAt(u,":"),2),l=c[0],f=c[1];l&&f?o.push({format:l,cpcList:f.split("/")}):T.INVALIDPLAYLIST(e)}}catch(t){s.e(t)}finally{s.f()}return o}function v(t){return t.startsWith('"')?E(t):t.startsWith("0x")||t.startsWith("0X")?T.hexToByteSequence(t):T.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,a,o={},s=i(T.splitByCommaWithPreservingQuotes(t));try{for(s.s();!(e=s.n()).done;){var u=e.value,c=r(T.splitAt(u,"="),2),l=c[0],f=c[1],d=E(f);switch(l){case"URI":o[l]=d;break;case"START-DATE":case"END-DATE":o[l]=new Date(d);break;case"IV":o[l]=(n=d,a=void 0,16!==(a=T.hexToByteSequence(n)).length&&T.INVALIDPLAYLIST("IV must be a 128-bit unsigned integer"),a);break;case"BYTERANGE":o[l]=h(d);break;case"RESOLUTION":o[l]=p(d);break;case"ALLOWED-CPC":o[l]=I(d);break;case"END-ON-NEXT":case"DEFAULT":case"AUTOSELECT":case"FORCED":case"PRECISE":case"CAN-BLOCK-RELOAD":case"INDEPENDENT":case"GAP":o[l]="YES"===d;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[l]=T.toNumber(d);break;default:l.startsWith("SCTE35-")?o[l]=T.hexToByteSequence(d):l.startsWith("X-")?o[l]=v(f):("VIDEO-RANGE"===l&&"SDR"!==d&&"HLG"!==d&&"PQ"!==d&&T.INVALIDPLAYLIST('VIDEO-RANGE: unknown value "'.concat(d,'"')),o[l]=d)}}}catch(t){s.e(t)}finally{s.f()}return o}function S(){T.INVALIDPLAYLIST("The file contains both media and master playlist tags.")}function N(t,e,n){var r,a=(r=e.attributes,new f.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[T.camelify(n)],s=function(t,e){var n,r=!1,a=i(t);try{for(a.s();!(n=a.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){a.e(t)}finally{a.f()}return r&&e.isDefault?"EXT-X-MEDIA A Group MUST NOT have more than one member with a DEFAULT attribute of YES.":""}(o,a);s&&T.INVALIDPLAYLIST(s),o.push(a),a.isDefault&&(t.currentRenditions[T.camelify(n)]=o.length-1)}function m(t,e,n,r,a){var o,s=new f.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"]}),u=i(t);try{for(u.s();!(o=u.n()).done;){var c=o.value;if("EXT-X-MEDIA"===c.name){var l=c.attributes,E=l.TYPE;if(E&&l["GROUP-ID"]||T.INVALIDPLAYLIST("EXT-X-MEDIA TYPE attribute is REQUIRED."),e[E]===l["GROUP-ID"]&&(N(s,c,E),"CLOSED-CAPTIONS"===E)){var d,h=i(s.closedCaptions);try{for(h.s();!(d=h.n()).done;){var p=d.value.instreamId;if(p&&p.startsWith("SERVICE")&&a.compatibleVersion<7){a.compatibleVersion=7;break}}}catch(t){h.e(t)}finally{h.f()}}}}}catch(t){u.e(t)}finally{u.f()}return function(t,e,n){for(var r=function(){var r=a[i];"CLOSED-CAPTIONS"===r&&"NONE"===t[r]?(n.isClosedCaptionsNone=!0,e.closedCaptions=[]):t[r]&&!e[T.camelify(r)].some((function(e){return e.groupId===t[r]}))&&T.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,"."))},i=0,a=["AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS"];i<a.length;i++)r()}(e,s,a),s.isIFrameOnly=r,s}function X(t,e,n,r,i,a,o){for(var s=new f.Segment({uri:e,mediaSequenceNumber:i,discontinuitySequence:a}),u=!1,c=!1,l=n;l<=r;l++){var E=D(t[l]),d=E.name,h=E.value,p=E.attributes;if("EXTINF"===d)!Number.isInteger(h.duration)&&o.compatibleVersion<3&&(o.compatibleVersion=3),Math.round(h.duration)>o.targetDuration&&T.INVALIDPLAYLIST("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration"),s.duration=h.duration,s.title=h.title;else if("EXT-X-BYTERANGE"===d)o.compatibleVersion<4&&(o.compatibleVersion=4),s.byterange=h;else if("EXT-X-DISCONTINUITY"===d)s.parts.length>0&&T.INVALIDPLAYLIST("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment."),s.discontinuity=!0;else if("EXT-X-GAP"===d)o.compatibleVersion<8&&(o.compatibleVersion=8),s.gap=!0;else if("EXT-X-KEY"===d)s.parts.length>0&&T.INVALIDPLAYLIST("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment."),A(o,p),s.key=new f.Key({method:p.METHOD,uri:p.URI,iv:p.IV,format:p.KEYFORMAT,formatVersion:p.KEYFORMATVERSIONS});else if("EXT-X-MAP"===d)s.parts.length>0&&T.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 f.MediaInitializationSection({uri:p.URI,byterange:p.BYTERANGE});else if("EXT-X-PROGRAM-DATE-TIME"===d)s.programDateTime=h;else if("EXT-X-DATERANGE"===d){for(var I={},v=0,y=Object.keys(p);v<y.length;v++){var S=y[v];(S.startsWith("SCTE35-")||S.startsWith("X-"))&&(I[S]=p[S])}s.dateRange=new f.DateRange({id:p.ID,classId:p.CLASS,start:p["START-DATE"],end:p["END-DATE"],duration:p.DURATION,plannedDuration:p["PLANNED-DURATION"],endOnNext:p["END-ON-NEXT"],attributes:I})}else if("EXT-X-CUE-OUT"===d)s.markers.push(new f.SpliceInfo({type:"OUT",duration:p&&p.DURATION||h}));else if("EXT-X-CUE-IN"===d)s.markers.push(new f.SpliceInfo({type:"IN"}));else if("EXT-X-CUE-OUT-CONT"===d||"EXT-X-CUE"===d||"EXT-OATCLS-SCTE35"===d||"EXT-X-ASSET"===d||"EXT-X-SCTE35"===d)s.markers.push(new f.SpliceInfo({type:"RAW",tagName:d,value:h}));else if("EXT-X-PRELOAD-HINT"!==d||p.TYPE)if("EXT-X-PRELOAD-HINT"===d&&"PART"===p.TYPE&&c)T.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"!==d&&"EXT-X-PRELOAD-HINT"!==d||p.URI){if("EXT-X-PRELOAD-HINT"===d&&"MAP"===p.TYPE)u&&T.INVALIDPLAYLIST("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist."),u=!0,o.hasMap=!0,s.map=new f.MediaInitializationSection({hint:!0,uri:p.URI,byterange:{length:p["BYTERANGE-LENGTH"],offset:p["BYTERANGE-START"]||0}});else if("EXT-X-PART"===d||"EXT-X-PRELOAD-HINT"===d&&"PART"===p.TYPE){"EXT-X-PART"!==d||p.DURATION||T.INVALIDPLAYLIST("EXT-X-PART: DURATION attribute is mandatory"),"EXT-X-PRELOAD-HINT"===d&&(c=!0);var N=new f.PartialSegment({hint:"EXT-X-PRELOAD-HINT"===d,uri:p.URI,byterange:"EXT-X-PART"===d?p.BYTERANGE:{length:p["BYTERANGE-LENGTH"],offset:p["BYTERANGE-START"]||0},duration:p.DURATION,independent:p.INDEPENDENT,gap:p.GAP});s.gap&&!N.gap&&T.INVALIDPLAYLIST("Partial segments must have GAP=YES if they are in a gap (EXT-X-GAP)"),s.parts.push(N)}}else T.INVALIDPLAYLIST("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory");else T.INVALIDPLAYLIST("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory")}return s}function g(t,e,n,r,i,a,o){for(var s=new f.PrefetchSegment({uri:e,mediaSequenceNumber:i,discontinuitySequence:a}),u=n;u<=r;u++){var c=t[u],l=c.name,E=c.attributes;"EXTINF"===l?T.INVALIDPLAYLIST("A prefetch segment must not be advertised with an EXTINF tag."):"EXT-X-DISCONTINUITY"===l?T.INVALIDPLAYLIST("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag."):"EXT-X-PREFETCH-DISCONTINUITY"===l?s.discontinuity=!0:"EXT-X-KEY"===l?(A(o,E),s.key=new f.Key({method:E.METHOD,uri:E.URI,iv:E.IV,format:E.KEYFORMAT,formatVersion:E.KEYFORMATVERSIONS})):"EXT-X-MAP"===l&&T.INVALIDPLAYLIST("Prefetch segments must not be advertised with an EXT-X-MAP tag.")}return s}function b(t,e){var n,a=new f.MediaPlaylist,o=-1,s=0,u=!1,c=!1,l=0,E=null,d=null,h=!1,p=i(t.entries());try{for(p.s();!(n=p.n()).done;){var I=r(n.value,2),v=I[0],A=I[1],y=D(A),S=y.name,N=y.value,m=y.attributes;if("Segment"!==y.category){if("EXT-X-VERSION"===S)void 0===a.version?a.version=N:T.INVALIDPLAYLIST("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.");else if("EXT-X-TARGETDURATION"===S)a.targetDuration=e.targetDuration=N;else if("EXT-X-MEDIA-SEQUENCE"===S)a.segments.length>0&&T.INVALIDPLAYLIST("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist."),a.mediaSequenceBase=s=N;else if("EXT-X-DISCONTINUITY-SEQUENCE"===S)a.segments.length>0&&T.INVALIDPLAYLIST("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist."),u&&T.INVALIDPLAYLIST("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag."),a.discontinuitySequenceBase=l=N;else if("EXT-X-ENDLIST"===S)a.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===S)a.playlistType=N;else if("EXT-X-I-FRAMES-ONLY"===S)e.compatibleVersion<4&&(e.compatibleVersion=4),a.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===S)a.independentSegments&&T.INVALIDPLAYLIST("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist"),a.independentSegments=!0;else if("EXT-X-START"===S)a.start&&T.INVALIDPLAYLIST("EXT-X-START tag MUST NOT appear more than once in a Playlist"),"number"!=typeof m["TIME-OFFSET"]&&T.INVALIDPLAYLIST("EXT-X-START: TIME-OFFSET attribute is REQUIRED"),a.start={offset:m["TIME-OFFSET"],precise:m.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===S)m["CAN-BLOCK-RELOAD"]||T.INVALIDPLAYLIST("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS"),a.lowLatencyCompatibility={canBlockReload:m["CAN-BLOCK-RELOAD"],canSkipUntil:m["CAN-SKIP-UNTIL"],holdBack:m["HOLD-BACK"],partHoldBack:m["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===S)m["PART-TARGET"]||T.INVALIDPLAYLIST("EXT-X-PART-INF: PART-TARGET attribute is mandatory"),a.partTargetDuration=m["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===S)m.URI||T.INVALIDPLAYLIST("EXT-X-RENDITION-REPORT: URI attribute is mandatory"),0===m.URI.search(/^[a-z]+:/)&&T.INVALIDPLAYLIST("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri"),a.renditionReports.push(new f.RenditionReport({uri:m.URI,lastMSN:m["LAST-MSN"],lastPart:m["LAST-PART"]}));else if("EXT-X-SKIP"===S)m["SKIPPED-SEGMENTS"]||T.INVALIDPLAYLIST("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory"),e.compatibleVersion<9&&(e.compatibleVersion=9),a.skip=m["SKIPPED-SEGMENTS"],s+=a.skip;else if("EXT-X-PREFETCH"===S){var b=g(t,N,-1===o?v:o,v-1,s++,l,e);b&&(b.discontinuity&&(b.discontinuitySequence++,l=b.discontinuitySequence),b.key?E=b.key:b.key=E,a.prefetchSegments.push(b)),c=!0,o=-1}else if("string"==typeof A){-1===o&&T.INVALIDPLAYLIST("A URI line is not preceded by any segment tags"),a.targetDuration||T.INVALIDPLAYLIST("The EXT-X-TARGETDURATION tag is REQUIRED"),c&&T.INVALIDPLAYLIST("These segments must appear after all complete segments.");var R=X(t,A,o,v-1,s++,l,e);if(R){var P=r(O(a,R,l,E,d),3);l=P[0],E=P[1],d=P[2],!h&&R.parts.length>0&&(h=!0)}o=-1}}else-1===o&&(o=v),"EXT-X-DISCONTINUITY"===S&&(u=!0)}}catch(t){p.e(t)}finally{p.f()}if(-1!==o){var L=X(t,"",o,t.length-1,s++,l,e);if(L){var C,M=L.parts;!(M.length>0)||a.endlist||null!==(C=M.at(-1))&&void 0!==C&&C.hint||T.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"),O(a,L,E,d),!h&&L.parts.length>0&&(h=!0)}}return function(t){for(var e=new Map,n=new Map,r=!1,a=!1,o=t.length-1;o>=0;o--){var s=t[o],u=s.programDateTime,c=s.dateRange;if(u&&(a=!0),c&&c.start){r=!0,c.endOnNext&&(c.end||c.duration)&&T.INVALIDPLAYLIST("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.");var l=c.start.getTime(),f=c.duration||0;c.end&&c.duration&&l+1e3*f!==c.end.getTime()&&T.INVALIDPLAYLIST("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION"),c.endOnNext&&(c.end=e.get(c.classId)),e.set(c.classId,c.start);var E=c.end?c.end.getTime():c.start.getTime()+1e3*(c.duration||0),d=n.get(c.classId);if(d){var h,p=i(d);try{for(p.s();!(h=p.n()).done;){var I=h.value;(I.start<=l&&I.end>l||I.start>=l&&I.start<E)&&T.INVALIDPLAYLIST("DATERANGE tags with the same CLASS should not overlap")}}catch(t){p.e(t)}finally{p.f()}d.push({start:l,end:E})}else c.classId&&n.set(c.classId,[{start:l,end:E}])}}r&&!a&&T.INVALIDPLAYLIST("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.")}(a.segments),a.lowLatencyCompatibility&&function(t,e){var n=t.lowLatencyCompatibility,a=t.targetDuration,o=t.partTargetDuration,s=t.segments,u=t.renditionReports,c=n.canSkipUntil,l=n.holdBack,f=n.partHoldBack;c<6*a&&T.INVALIDPLAYLIST("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.");l<3*a&&T.INVALIDPLAYLIST("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.");if(e){void 0===o&&T.INVALIDPLAYLIST("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags"),void 0===f&&T.INVALIDPLAYLIST("EXT-X-PART: PART-HOLD-BACK attribute is mandatory"),f<o&&T.INVALIDPLAYLIST("PART-HOLD-BACK must be at least PART-TARGET");var E,d=i(s.entries());try{for(d.s();!(E=d.n()).done;){var h=r(E.value,2),p=h[0],I=h[1].parts;I.length>0&&p<s.length-3&&T.INVALIDPLAYLIST("Remove EXT-X-PART tags from the Playlist after they are greater than three target durations from the end of the Playlist.");var v,A=i(I.entries());try{for(A.s();!(v=A.n()).done;){var y=r(v.value,2),S=y[0],N=y[1].duration;void 0!==N&&(N>o&&T.INVALIDPLAYLIST("PART-TARGET is the maximum duration of any Partial Segment"),S<I.length-1&&N<.85*o&&T.INVALIDPLAYLIST("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET"))}}catch(t){A.e(t)}finally{A.f()}}}catch(t){d.e(t)}finally{d.f()}}var m,X=i(u);try{for(X.s();!(m=X.n()).done;){var g,b=m.value,O=s.at(-1);null!==(g=b.lastMSN)&&void 0!==g||(b.lastMSN=O.mediaSequenceNumber),(null===b.lastPart||void 0===b.lastPart)&&O.parts.length>0&&(b.lastPart=O.parts.length-1)}}catch(t){X.e(t)}finally{X.f()}}(a,h),a}function O(t,e,n,r,i){var a=e.discontinuity,o=e.key,s=e.map,u=e.byterange,c=e.uri;if(a&&(e.discontinuitySequence=n+1),o||(e.key=r),s||(e.map=i),u&&-1===u.offset){var l=t.segments;if(l.length>0){var f=l.at(-1);f.byterange&&f.uri===c?u.offset=f.byterange.offset+f.byterange.length:T.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 T.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 R(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),i=r(n,2),a=i[0],o=i[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":case"EXT-X-GAP":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"}}(a);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"!==a&&"EXT-X-PREFETCH"!==a&&(e.hash[a]&&T.INVALIDPLAYLIST("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist"),e.hash[a]=!0);var u=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":case"EXT-X-GAP":return[null,null];case"EXT-X-VERSION":case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":return[T.toNumber(e),null];case"EXT-X-CUE-OUT":return Number.isNaN(Number(e))?[null,y(e)]:[T.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[d(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]}}(a,o),c=r(u,2);return{name:a,category:s,value:c[0],attributes:c[1]}}function P(t,e){var n;return e.isMasterPlaylist?n=function(t,e){var n,a=new f.MasterPlaylist,o=!1,s=i(t.entries());try{var u=function(){var i=r(n.value,2),s=i[0],u=D(i[1]),c=u.name,l=u.value,E=u.attributes;if("EXT-X-VERSION"===c)a.version=l;else if("EXT-X-STREAM-INF"===c){var d=t[s+1];("string"!=typeof d||d.startsWith("#EXT"))&&T.INVALIDPLAYLIST("EXT-X-STREAM-INF must be followed by a URI line");var h=m(t,E,d,!1,e);h&&("number"==typeof h.score&&(o=!0,h.score<0&&T.INVALIDPLAYLIST("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.")),a.variants.push(h))}else if("EXT-X-I-FRAME-STREAM-INF"===c){var p=m(t,E,E.URI,!0,e);p&&a.variants.push(p)}else if("EXT-X-SESSION-DATA"===c){var I=new f.SessionData({id:E["DATA-ID"],value:E.VALUE,uri:E.URI,language:E.LANGUAGE});a.sessionDataList.some((function(t){return t.id===I.id&&t.language===I.language}))&&T.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."),a.sessionDataList.push(I)}else if("EXT-X-SESSION-KEY"===c){"NONE"===E.METHOD&&T.INVALIDPLAYLIST("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE");var v=new f.Key({method:E.METHOD,uri:E.URI,iv:E.IV,format:E.KEYFORMAT,formatVersion:E.KEYFORMATVERSIONS});a.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.byteLength!==e.iv.byteLength)return!1;for(var n=0;n<t.iv.byteLength;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,v)}))&&T.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),a.sessionKeyList.push(v)}else"EXT-X-INDEPENDENT-SEGMENTS"===c?(a.independentSegments&&T.INVALIDPLAYLIST("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist"),a.independentSegments=!0):"EXT-X-START"===c&&(a.start&&T.INVALIDPLAYLIST("EXT-X-START tag MUST NOT appear more than once in a Playlist"),"number"!=typeof E["TIME-OFFSET"]&&T.INVALIDPLAYLIST("EXT-X-START: TIME-OFFSET attribute is REQUIRED"),a.start={offset:E["TIME-OFFSET"],precise:E.PRECISE||!1})};for(s.s();!(n=s.n()).done;)u()}catch(t){s.e(t)}finally{s.f()}if(o){var c,l=i(a.variants);try{for(l.s();!(c=l.n()).done;)"number"!=typeof c.value.score&&T.INVALIDPLAYLIST("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute")}catch(t){l.e(t)}finally{l.f()}}if(e.isClosedCaptionsNone){var E,d=i(a.variants);try{for(d.s();!(E=d.n()).done;)E.value.closedCaptions.length>0&&T.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){d.e(t)}finally{d.f()}}return a}(t,e):!(n=b(t,e)).isIFrame&&e.hasMap&&e.compatibleVersion<6&&(e.compatibleVersion=6),e.compatibleVersion>1&&(!n.version||n.version<e.compatibleVersion)&&T.INVALIDPLAYLIST("EXT-X-VERSION needs to be ".concat(e.compatibleVersion," or higher.")),n}function D(t){return"string"==typeof t?{}:t}e.default=function(t){var e={version:void 0,isMasterPlaylist:void 0,hasMap:!1,targetDuration:0,compatibleVersion:1,isClosedCaptionsNone:!1,hash:{}},n=P(function(t,e){var n,r=[],a=i(t.split("\n"));try{for(a.s();!(n=a.n()).done;){var o=n.value.trim();if(o)if(o.startsWith("#")){if(o.startsWith("#EXT")){var s=R(o,e);s&&r.push(s)}}else r.push(o)}}catch(t){a.e(t)}finally{a.f()}return 0!==r.length&&"EXTM3U"===r[0].name||T.INVALIDPLAYLIST("The EXTM3U tag MUST be the first line."),r}(t,e),e);return n.source=t,n}},887: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 i(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,i,a,o,s=[],u=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}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 a(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,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 a,s=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function o(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.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=Array(e);n<e;n++)r[n]=t[n];return r}function u(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,p(r.key),r)}}function c(t,e,n){return e=h(e),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)}(t,E()?Reflect.construct(e,n||[],h(t).constructor):e.apply(t,n))}function l(t,e,n,r){var i=T(h(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof i?function(t){return i.apply(n,t)}:i}function T(){return T="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},T.apply(null,arguments)}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;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,n)}function n(){return function(t,e,n){if(E())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&d(i,n.prototype),i}(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),d(n,t)},f(t)}function E(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(E=function(){return!!t})()}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},d(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function p(t){var e=function(t,e){if("object"!=r(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==r(e)?e:e+""}var I,v=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}: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}),y=this&&this.__importStar||(I=function(t){return I=Object.getOwnPropertyNames||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[e.length]=n);return e},I(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n=I(t),r=0;r<n.length;r++)"default"!==n[r]&&v(e,t,n[r]);return A(e,t),e});Object.defineProperty(e,"__esModule",{value:!0});var S=y(n(203)),N=["#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"],m=["#EXT-X-MEDIA"],X=function(t){function e(t){var n,r,i,a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=c(this,e),r=n,a=void 0,(i=p(i="baseUri"))in r?Object.defineProperty(r,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[i]=a,n.baseUri=t,n}return 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&&d(t,e)}(e,t),n=e,r=[{key:"push",value:function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];for(var a=function(){var n=s[o];if(!n.startsWith("#"))return l(e,"push",t,3)([n]),0;if(N.some((function(t){return n.startsWith(t)})))return l(e,"push",t,3)([n]),0;if(t.includes(n)){if(m.some((function(t){return n.startsWith(t)})))return 0;S.INVALIDPLAYLIST("Redundant item (".concat(n,")"))}l(e,"push",t,3)([n])},o=0,s=r;o<s.length;o++)a();return this.length}},{key:"join",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:",",n=this.length-1;n>=0;n--)this[n]||this.splice(n,1);return l(e,"join",this,3)([t])}}],r&&u(n.prototype,r),i&&u(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,i}(f(Array));function g(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 b(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.byteLength&&S.INVALIDPLAYLIST("IV must be a 128-bit unsigned integer"),r.push("IV=".concat(S.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(g(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 i,o=a(e.audio);try{for(o.s();!(i=o.n()).done;){var s=i.value;t.push(P(s))}}catch(t){o.e(t)}finally{o.f()}}if(e.video.length>0){r.push('VIDEO="'.concat(e.video[0].groupId,'"'));var u,c=a(e.video);try{for(c.s();!(u=c.n()).done;){var l=u.value;t.push(P(l))}}catch(t){c.e(t)}finally{c.f()}}if(e.subtitles.length>0){r.push('SUBTITLES="'.concat(e.subtitles[0].groupId,'"'));var T,f=a(e.subtitles);try{for(f.s();!(T=f.n()).done;){var E=T.value;t.push(P(E))}}catch(t){f.e(t)}finally{f.f()}}if(S.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 d,h=a(e.closedCaptions);try{for(h.s();!(d=h.n()).done;){var p=d.value;t.push(P(p))}}catch(t){h.e(t)}finally{h.f()}}if(e.score&&r.push("SCORE=".concat(e.score)),e.allowedCpc){var I,v=[],A=a(e.allowedCpc);try{for(A.s();!(I=A.n()).done;){var y=I.value,N=y.format,m=y.cpcList;v.push("".concat(N,":").concat(m.join("/")))}}catch(t){A.e(t)}finally{A.f()}r.push('ALLOWED-CPC="'.concat(v.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 P(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 D(t,e,n,r){var i,o,s,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,c=!1,l="";if(e.discontinuity&&t.push("#EXT-X-DISCONTINUITY"),e.gap&&t.push("#EXT-X-GAP"),e.key){var T=O(e.key);T!==n&&(t.push(T),n=T)}if(e.map){var f=function(t){var e=['URI="'.concat(t.uri,'"')];t.byterange&&e.push('BYTERANGE="'.concat(L(t.byterange),'"'));return"#EXT-X-MAP:".concat(e.join(","))}(e.map);f!==r&&(t.push(f),r=f)}if(e.programDateTime&&t.push("#EXT-X-PROGRAM-DATE-TIME:".concat(S.formatDate(e.programDateTime))),e.dateRange&&t.push(function(t){var e=['ID="'.concat(t.id,'"')];t.start&&e.push('START-DATE="'.concat(S.formatDate(t.start),'"'));t.end&&e.push('END-DATE="'.concat(S.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 i=r[n];i.startsWith("X-")?"number"==typeof t.attributes[i]?e.push("".concat(i,"=").concat(t.attributes[i])):e.push("".concat(i,'="').concat(t.attributes[i],'"')):i.startsWith("SCTE35-")&&e.push("".concat(i,"=").concat(S.byteSequenceToHex(t.attributes[i])))}return"#EXT-X-DATERANGE:".concat(e.join(","))}(e.dateRange)),e.markers.length>0&&(l=function(t,e){var n,r="",i=a(e);try{for(i.s();!(n=i.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){i.e(t)}finally{i.f()}return r}(t,e.markers)),e.parts.length>0&&(c=function(t,e){var n,r=!1,i=a(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(o.hint){var s=[];if(s.push("TYPE=PART",'URI="'.concat(o.uri,'"')),o.byterange){var u=o.byterange,c=u.offset,l=u.length;s.push("BYTERANGE-START=".concat(c)),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(L(o.byterange))),o.independent&&T.push("INDEPENDENT=YES"),o.gap&&T.push("GAP=YES"),t.push("#EXT-X-PART:".concat(T.join(",")))}}}catch(t){i.e(t)}finally{i.f()}return r}(t,e.parts)),c)return[n,r];if("number"==typeof e.duration&&!Number.isNaN(e.duration)){var E=u<3?Math.round(e.duration):g(e.duration,(i=e.duration,o=i.toString(10),-1===(s=o.indexOf("."))?0:o.length-s-1));t.push("#EXTINF:".concat(E,",").concat(unescape(encodeURIComponent(e.title||""))))}return e.byterange&&t.push("#EXT-X-BYTERANGE:".concat(L(e.byterange))),Array.prototype.push.call(t,"".concat(e.uri)),[n,r,l]}function L(t){var e=t.offset,n=t.length;return"".concat(n,"@").concat(e)}e.default=function(t,e){S.PARAMCHECK(t),S.ASSERT("Not a playlist","playlist"===t.type);var n=new X(t.uri);return n.push("#EXTM3U"),t.version&&n.push("#EXT-X-VERSION:".concat(t.version)),t.independentSegments&&n.push("#EXT-X-INDEPENDENT-SEGMENTS"),t.start&&n.push("#EXT-X-START:TIME-OFFSET=".concat(g(t.start.offset)).concat(t.start.precise?",PRECISE=YES":"")),t.isMasterPlaylist?function(t,e,n){var r,o=a(e.sessionDataList);try{for(o.s();!(r=o.n()).done;){var s=r.value;t.push(b(s))}}catch(t){o.e(t)}finally{o.f()}var u,c=a(e.sessionKeyList);try{for(c.s();!(u=c.n()).done;){var l=u.value;t.push(O(l,!0))}}catch(t){c.e(t)}finally{c.f()}var T,f=a(e.variants.entries());try{for(f.s();!(T=f.n()).done;){var E=i(T.value,2),d=E[0],h=E[1],p=t.length;R(t,h),null!=n&&n.variantProcessor&&n.variantProcessor(t,p,t.length-1,h,d)}}catch(t){f.e(t)}finally{f.f()}}(n,t,e):function(t,e,n){var r="",o="",s=!1;if(e.targetDuration&&t.push("#EXT-X-TARGETDURATION:".concat(e.targetDuration)),e.lowLatencyCompatibility){var u=e.lowLatencyCompatibility,c=u.canBlockReload,l=u.canSkipUntil,T=u.holdBack,f=u.partHoldBack,E=[];E.push("CAN-BLOCK-RELOAD=".concat(c?"YES":"NO")),void 0!==l&&E.push("CAN-SKIP-UNTIL=".concat(l)),void 0!==T&&E.push("HOLD-BACK=".concat(T)),void 0!==f&&E.push("PART-HOLD-BACK=".concat(f)),t.push("#EXT-X-SERVER-CONTROL:".concat(E.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 d,h=a(e.segments.entries());try{for(h.s();!(d=h.n()).done;){var p,I=i(d.value,2),v=I[0],A=I[1],y=t.length,N=i(D(t,A,r,o,e.version),3);r=N[0],o=N[1],"OUT"===(p=N[2])?s=!0:"IN"===p&&s&&(s=!1),null!=n&&n.segmentProcessor&&n.segmentProcessor(t,y,t.length-1,A,v)}}catch(t){h.e(t)}finally{h.f()}"VOD"===e.playlistType&&s&&t.push("#EXT-X-CUE-IN"),e.prefetchSegments.length>2&&S.INVALIDPLAYLIST("The server must deliver no more than two prefetch segments");var m,X=a(e.prefetchSegments);try{for(X.s();!(m=X.n()).done;){var g=m.value;g.discontinuity&&t.push("#EXT-X-PREFETCH-DISCONTINUITY"),t.push("#EXT-X-PREFETCH:".concat(g.uri))}}catch(t){X.e(t)}finally{X.f()}e.endlist&&t.push("#EXT-X-ENDLIST");var b,O=a(e.renditionReports);try{for(O.s();!(b=O.n()).done;){var R=b.value,P=[];P.push('URI="'.concat(R.uri,'"'),"LAST-MSN=".concat(R.lastMSN)),void 0!==R.lastPart&&P.push("LAST-PART=".concat(R.lastPart)),t.push("#EXT-X-RENDITION-REPORT:".concat(P.join(",")))}}catch(t){O.e(t)}finally{O.f()}}(n,t,e),n.join("\n")}},31: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 i(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 a(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){d(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function o(t,e,n){return e=u(e),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)}(t,s()?Reflect.construct(e,n||[],u(t).constructor):e.apply(t,n))}function s(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(s=function(){return!!t})()}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function c(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&&l(t,e)}function l(t,e){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},l(t,e)}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,h(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,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e,n){return(e=h(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(t){var e=function(t,e){if("object"!=r(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==r(e)?e:e+""}var p,I=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),v=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||(p=function(t){return p=Object.getOwnPropertyNames||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[e.length]=n);return e},p(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n=p(t),r=0;r<n.length;r++)"default"!==n[r]&&I(e,t,n[r]);return v(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 y=A(n(203)),S=f((function t(e){var n=e.type,r=e.uri,i=e.groupId,a=e.language,o=e.assocLanguage,s=e.name,u=e.isDefault,c=e.autoselect,l=e.forced,T=e.instreamId,f=e.characteristics,h=e.channels;E(this,t),d(this,"type",void 0),d(this,"uri",void 0),d(this,"groupId",void 0),d(this,"language",void 0),d(this,"assocLanguage",void 0),d(this,"name",void 0),d(this,"isDefault",void 0),d(this,"autoselect",void 0),d(this,"forced",void 0),d(this,"instreamId",void 0),d(this,"characteristics",void 0),d(this,"channels",void 0),y.PARAMCHECK(n,i,s),y.CONDITIONALASSERT(["SUBTITLES"===n,r],["CLOSED-CAPTIONS"===n,T],["CLOSED-CAPTIONS"===n,!r],[l,"SUBTITLES"===n]),this.type=n,this.uri=r,this.groupId=i,this.language=a,this.assocLanguage=o,this.name=s,this.isDefault=u,this.autoselect=c,this.forced=l,this.instreamId=T,this.characteristics=f,this.channels=h}));e.Rendition=S;var N=f((function t(e){var n=e.uri,r=e.isIFrameOnly,i=void 0!==r&&r,a=e.bandwidth,o=e.averageBandwidth,s=e.score,u=e.codecs,c=e.resolution,l=e.frameRate,T=e.hdcpLevel,f=e.allowedCpc,h=e.videoRange,p=e.stableVariantId,I=e.programId,v=e.audio,A=void 0===v?[]:v,S=e.video,N=void 0===S?[]:S,m=e.subtitles,X=void 0===m?[]:m,g=e.closedCaptions,b=void 0===g?[]:g,O=e.currentRenditions,R=void 0===O?{audio:0,video:0,subtitles:0,closedCaptions:0}:O;E(this,t),d(this,"uri",void 0),d(this,"isIFrameOnly",void 0),d(this,"bandwidth",void 0),d(this,"averageBandwidth",void 0),d(this,"score",void 0),d(this,"codecs",void 0),d(this,"resolution",void 0),d(this,"frameRate",void 0),d(this,"hdcpLevel",void 0),d(this,"allowedCpc",void 0),d(this,"videoRange",void 0),d(this,"stableVariantId",void 0),d(this,"programId",void 0),d(this,"audio",void 0),d(this,"video",void 0),d(this,"subtitles",void 0),d(this,"closedCaptions",void 0),d(this,"currentRenditions",void 0),y.PARAMCHECK(n,a),this.uri=n,this.isIFrameOnly=i,this.bandwidth=a,this.averageBandwidth=o,this.score=s,this.codecs=u,this.resolution=c,this.frameRate=l,this.hdcpLevel=T,this.allowedCpc=f,this.videoRange=h,this.stableVariantId=p,this.programId=I,this.audio=A,this.video=N,this.subtitles=X,this.closedCaptions=b,this.currentRenditions=R}));e.Variant=N;var m=f((function t(e){var n=e.id,r=e.value,i=e.uri,a=e.language;E(this,t),d(this,"id",void 0),d(this,"value",void 0),d(this,"uri",void 0),d(this,"language",void 0),y.PARAMCHECK(n,r||i),y.ASSERT("SessionData cannot have both value and uri, shoud be either.",!(r&&i)),this.id=n,this.value=r,this.uri=i,this.language=a}));e.SessionData=m;var X=f((function t(e){var n=e.method,r=e.uri,i=e.iv,a=e.format,o=e.formatVersion;E(this,t),d(this,"method",void 0),d(this,"uri",void 0),d(this,"iv",void 0),d(this,"format",void 0),d(this,"formatVersion",void 0),y.PARAMCHECK(n),y.CONDITIONALPARAMCHECK(["NONE"!==n,r]),y.CONDITIONALASSERT(["NONE"===n,!(r||i||a||o)]),this.method=n,this.uri=r,this.iv=i,this.format=a,this.formatVersion=o}));e.Key=X;var g=f((function t(e){var n=e.hint,r=void 0!==n&&n,i=e.uri,a=e.mimeType,o=e.byterange;E(this,t),d(this,"hint",void 0),d(this,"uri",void 0),d(this,"mimeType",void 0),d(this,"byterange",void 0),y.PARAMCHECK(i),this.hint=r,this.uri=i,this.mimeType=a,this.byterange=o}));e.MediaInitializationSection=g;var b=f((function t(e){var n=e.id,r=e.classId,i=e.start,a=e.end,o=e.duration,s=e.plannedDuration,u=e.endOnNext,c=e.attributes,l=void 0===c?{}:c;E(this,t),d(this,"id",void 0),d(this,"classId",void 0),d(this,"start",void 0),d(this,"end",void 0),d(this,"duration",void 0),d(this,"plannedDuration",void 0),d(this,"endOnNext",void 0),d(this,"attributes",void 0),y.PARAMCHECK(n),y.CONDITIONALPARAMCHECK([!0===u,r]),y.CONDITIONALASSERT([a,i],[a,i<=a],[o,o>=0],[s,s>=0]),this.id=n,this.classId=r,this.start=i,this.end=a,this.duration=o,this.plannedDuration=s,this.endOnNext=u,this.attributes=l}));e.DateRange=b;var O=f((function t(e){var n=e.type,r=e.duration,i=e.tagName,a=e.value;E(this,t),d(this,"type",void 0),d(this,"duration",void 0),d(this,"tagName",void 0),d(this,"value",void 0),y.PARAMCHECK(n),y.CONDITIONALPARAMCHECK(["OUT"===n,r]),y.CONDITIONALPARAMCHECK(["RAW"===n,i]),this.type=n,this.duration=r,this.tagName=i,this.value=a}));e.SpliceInfo=O;var R=f((function t(e){E(this,t),d(this,"type",void 0),y.PARAMCHECK(e),this.type=e})),P=function(t){function e(t){var n,r=t.isMasterPlaylist,i=t.uri,a=t.version,s=t.independentSegments,u=void 0!==s&&s,c=t.start,l=t.source;return E(this,e),d(n=o(this,e,["playlist"]),"isMasterPlaylist",void 0),d(n,"uri",void 0),d(n,"version",void 0),d(n,"independentSegments",void 0),d(n,"start",void 0),d(n,"source",void 0),y.PARAMCHECK(r),n.isMasterPlaylist=r,n.uri=i,n.version=a,n.independentSegments=u,n.start=c,n.source=l,n}return c(e,t),f(e)}(R);e.Playlist=P;var D=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,e),d(t=o(this,e,[a(a({},n),{},{isMasterPlaylist:!0})]),"variants",void 0),d(t,"currentVariant",void 0),d(t,"sessionDataList",void 0),d(t,"sessionKeyList",void 0);var r=n.variants,i=void 0===r?[]:r,s=n.currentVariant,u=n.sessionDataList,c=void 0===u?[]:u,l=n.sessionKeyList,T=void 0===l?[]:l;return t.variants=i,t.currentVariant=s,t.sessionDataList=c,t.sessionKeyList=T,t}return c(e,t),f(e)}(P);e.MasterPlaylist=D;var L=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,e),d(t=o(this,e,[a(a({},n),{},{isMasterPlaylist:!1})]),"targetDuration",void 0),d(t,"mediaSequenceBase",void 0),d(t,"discontinuitySequenceBase",void 0),d(t,"endlist",void 0),d(t,"playlistType",void 0),d(t,"isIFrame",void 0),d(t,"segments",void 0),d(t,"prefetchSegments",void 0),d(t,"lowLatencyCompatibility",void 0),d(t,"partTargetDuration",void 0),d(t,"renditionReports",void 0),d(t,"skip",void 0),d(t,"hash",void 0);var r=n.targetDuration,i