mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
8 lines
20 KiB
JavaScript
8 lines
20 KiB
JavaScript
|
||
/*!
|
||
* artplayer-plugin-multiple-subtitles.js v1.1.0
|
||
* Github: https://github.com/zhw2590582/ArtPlayer
|
||
* (c) 2017-2026 Harvey Zhao
|
||
* Released under the MIT License.
|
||
*/
|
||
!function(e,t,n,r,i){var o="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},a="function"==typeof o[r]&&o[r],s=a.i||{},c=a.cache||{},l="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,n){if(!c[t]){if(!e[t]){if(i[t])return i[t];var s="function"==typeof o[r]&&o[r];if(!n&&s)return s(t,!0);if(a)return a(t,!0);if(l&&"string"==typeof t)return l(t);var f=Error("Cannot find module '"+t+"'");throw f.code="MODULE_NOT_FOUND",f}p.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},p.cache={};var d=c[t]=new u.Module(t);e[t][0].call(d.exports,p,d,d.exports,o)}return c[t].exports;function p(e){var t=p.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var n={__esModule:!0};return t.forEach(function(e){var t=e[0],r=e[1],i=e[2]||e[0],o=u(r);"*"===t?Object.keys(o).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})}):"*"===i?Object.defineProperty(n,t,{enumerable:!0,value:o}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===i?o.__esModule?o.default:o:o[i]}})}),n}return u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.require=l,this.exports={}},u.modules=e,u.cache=c,u.parent=a,u.distDir=void 0,u.publicUrl=void 0,u.devServer=void 0,u.i=s,u.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(u,"root",{get:function(){return o[r]}}),o[r]=u;for(var f=0;f<t.length;f++)u(t[f]);if(n){var d=u(n);"object"==typeof exports&&"u">typeof module?module.exports=d:"function"==typeof define&&define.amd&&define(function(){return d})}}({bNEbP:[function(e,t,n,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"default",function(){return f});var o=e("@swc/helpers/cjs/_async_to_generator.cjs"),a=e("@swc/helpers/cjs/_object_spread.cjs"),s=e("@swc/helpers/cjs/_object_spread_props.cjs"),c=e("@swc/helpers/cjs/_to_consumable_array.cjs"),l=e("@swc/helpers/cjs/_ts_generator.cjs"),u=e("./parser");function f(e){var t=e.subtitles,n=void 0===t?[]:t;return function(e){return(0,o._)(function(){var t,r,i,f,d,p,v,h,m;function b(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=function(e){for(var t=new(0,u.WebVTTParser)().parse("","metadata"),n=0;n<e.length;n++){var r,i=e[n];if(!i.updated){i.updated=!0;for(var o=0;o<i.cues.length;o++)for(var a=i.cues[o],s=0;s<a.tree.children.length;s++){var l=a.tree.children[s];l.value='<div class="art-subtitle-'.concat(i.name,'">').concat(l.value,"</div>")}}(r=t.cues).push.apply(r,(0,c._)(i.cues))}return t}(t),i=v.serialize(n.cues);URL.revokeObjectURL(m);var o=URL.createObjectURL(new Blob([i],{type:"text/vtt"}));m=o,e.option.subtitle.escape=!1,e.subtitle.init((0,s._)((0,a._)({},e.option.subtitle),{url:o,type:"vtt",onVttLoad:r}))}return(0,l._)(this,function(a){switch(a.label){case 0:return r=(t=e.constructor.utils).unescape,i=t.getExt,f=t.srtToVtt,d=t.assToVtt,p=new(0,u.WebVTTParser),v=new(0,u.WebVTTSerializer),[4,Promise.all(n.map(function(e){return function(e,t){return(0,o._)(function(e,t){var n,r,i,o,a;return(0,l._)(this,function(s){switch(s.label){case 0:return n=t.getExt,r=t.srtToVtt,i=t.assToVtt,[4,fetch(e.url)];case 1:return[4,s.sent().arrayBuffer()];case 2:switch(o=s.sent(),a=new TextDecoder(e.encoding||"utf-8").decode(o),e.type||n(e.url)){case"srt":return[2,r(a)];case"ass":return[2,i(a)];case"vtt":return[2,a];default:return[2,""]}}})}).apply(this,arguments)}(e,{getExt:i,srtToVtt:f,assToVtt:d})}))];case 1:return h=a.sent().map(function(e,t){var r=p.parse(e,"metadata");return r.url=n[t].url,r.name=n[t].name,r}),m="",b(h),[2,{name:"multipleSubtitles",tracks:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return b(e.map(function(e){return h.find(function(t){return t.name===e})}))},reset:function(){return b(h)}}]}})})()}}"u">typeof window&&(window.artplayerPluginMultipleSubtitles=f)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_object_spread_props.cjs":"3G1wX","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","./parser":"hxyrW","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,n,r){"use strict";function i(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}n._=function(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,c,"next",e)}function c(e){i(a,r,o,s,c,"throw",e)}s(void 0)})}}},{}],kyoEj:[function(e,t,n,r){"use strict";var i=e("9f9b8a24218ee51e");n._=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){i._(e,t,n[t])})}return e}},{"9f9b8a24218ee51e":"ltU3W"}],ltU3W:[function(e,t,n,r){"use strict";n._=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},{}],"3G1wX":[function(e,t,n,r){"use strict";n._=function(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}},{}],i81N6:[function(e,t,n,r){"use strict";var i=e("d402183024004bc7"),o=e("3209e2b12672cd18"),a=e("fc58adb8f1bff142"),s=e("5e213dc122a10171");n._=function(e){return i._(e)||o._(e)||s._(e)||a._()}},{d402183024004bc7:"hfQG0","3209e2b12672cd18":"fQrlQ",fc58adb8f1bff142:"fWabh","5e213dc122a10171":"fh7mx"}],hfQG0:[function(e,t,n,r){"use strict";var i=e("5bd5b10bf87fc8e");n._=function(e){if(Array.isArray(e))return i._(e)}},{"5bd5b10bf87fc8e":"1WOAB"}],"1WOAB":[function(e,t,n,r){"use strict";n._=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}},{}],fQrlQ:[function(e,t,n,r){"use strict";n._=function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}},{}],fWabh:[function(e,t,n,r){"use strict";n._=function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{}],fh7mx:[function(e,t,n,r){"use strict";var i=e("3ee51b7dc02d0c44");n._=function(e,t){if(e){if("string"==typeof e)return i._(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i._(e,t)}}},{"3ee51b7dc02d0c44":"1WOAB"}],eltGh:[function(e,t,n,r){"use strict";n._=function(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(a,"next",{value:c(0)}),s(a,"throw",{value:c(1)}),s(a,"return",{value:c(2)}),"function"==typeof Symbol&&s(a,Symbol.iterator,{value:function(){return this}}),a;function c(s){return function(c){var l=[s,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}},{}],hxyrW:[function(e,t,n,r){var i=e("@swc/helpers/cjs/_object_spread.cjs");!function(){var e={direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center"},t=function(t){t||(t={"&":"&","<":"<",">":">","&lrm":"","&rlm":""," ":" "}),this.entities=t,this.parse=function(n,i){n=n.replace(/\0/g,"�");var a=Date.now(),s=0,c=n.split(/\r\n|\r|\n/),l=!1,u=[],f=[],d=[];function p(e,t){d.push({message:e,line:s+1,col:t})}var v=c[s],h=v.length,m="WEBVTT",b=0,g=m.length;for("\uFEFF"===v[0]&&(b=1,g+=1),(h<g||v.indexOf(m)!==0+b||h>g&&" "!==v[g]&&" "!==v[g])&&p('No valid signature. (File needs to start with "WEBVTT".)'),s++;""!=c[s]&&void 0!=c[s];){if(p("No blank line after the signature."),-1!=c[s].indexOf("--\x3e")){l=!0;break}s++}for(;void 0!=c[s];){for(;!l&&""==c[s];)s++;if(!l&&void 0==c[s])break;var y=Object.assign({},e,{id:"",startTime:0,endTime:0,pauseOnExit:!1,direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center",text:"",tree:null}),j=!0;if(-1==c[s].indexOf("--\x3e")){if(y.id=c[s],/^NOTE($|[ \t])/.test(y.id)){for(s++;""!=c[s]&&void 0!=c[s];)-1!=c[s].indexOf("--\x3e")&&p("Cannot have timestamp in a comment."),s++;continue}if(/^STYLE($|[ \t])/.test(y.id)){var w=[],T=!1;for(s++;""!=c[s]&&void 0!=c[s];)-1!=c[s].indexOf("--\x3e")&&(p("Cannot have timestamp in a style block."),T=!0),w.push(c[s]),s++;if(f.length){p("Style blocks cannot appear after the first cue.");continue}T||u.push(w.join("\n"));continue}if(""==c[++s]||void 0==c[s]){p("Cue identifier cannot be standalone.");continue}if(-1==c[s].indexOf("--\x3e")){j=!1,p("Cue identifier needs to be followed by timestamp.");continue}}l=!1;var _=new r(c[s],p),O=0;if(f.length>0&&(O=f[f.length-1].startTime),j&&!_.parse(y,O)){for(y=null,s++;""!=c[s]&&void 0!=c[s];){if(-1!=c[s].indexOf("--\x3e")){l=!0;break}s++}continue}for(s++;""!=c[s]&&void 0!=c[s];){if(-1!=c[s].indexOf("--\x3e")){p("Blank line missing before cue."),l=!0;break}""!=y.text&&(y.text+="\n"),y.text+=c[s],s++}var x=new o(y.text,p,i,t);y.tree=x.parse(y.startTime,y.endTime),f.push(y)}return f.sort(function(e,t){return e.startTime<t.startTime?-1:e.startTime>t.startTime?1:e.endTime>t.endTime?-1:+(e.endTime<t.endTime)}),{cues:f,errors:d,time:Date.now()-a,styles:u}}},r=function(e,t){var n=/[\u0020\t\f]/,r=/[^\u0020\t\f]/,e=e,i=0,o=function(e){t(e,i+1)};function a(t){for(;void 0!=e[i]&&t.test(e[i]);)i++}function s(t){for(var n="";void 0!=e[i]&&t.test(e[i]);)n+=e[i],i++;return n}function c(){var t,n,r,a,c="minutes";if(void 0==e[i])return void o("No timestamp found.");if(!/\d/.test(e[i]))return void o("Timestamp must start with a character in the range 0-9.");if(((t=s(/\d/)).length>2||parseInt(t,10)>59)&&(c="hours"),":"!=e[i])return void o("No time unit separator found.");if(i++,2!=(n=s(/\d/)).length)return void o("Must be exactly two digits.");if("hours"==c||":"==e[i]){if(":"!=e[i])return void o("No seconds found or minutes is greater than 59.");if(i++,2!=(r=s(/\d/)).length)return void o("Must be exactly two digits.")}else{if(2!=t.length)return void o("Must be exactly two digits.");r=n,n=t,t="0"}return"."!=e[i]?void o('No decimal separator (".") found.'):(i++,3!=(a=s(/\d/)).length)?void o("Milliseconds must be given in three digits."):parseInt(n,10)>59?void o("You cannot have more than 59 minutes."):parseInt(r,10)>59?void o("You cannot have more than 59 seconds."):3600*parseInt(t,10)+60*parseInt(n,10)+parseInt(r,10)+parseInt(a,10)/1e3}this.parse=function(t,s){return(a(n),t.startTime=c(),void 0==t.startTime)?void 0:(t.startTime<s&&o("Start timestamp is not greater than or equal to start timestamp of previous cue."),r.test(e[i])&&o("Timestamp not separated from '--\x3e' by whitespace."),a(n),"-"!=e[i]||"-"!=e[++i]||">"!=e[++i])?void o("No valid timestamp separator found."):(i++,r.test(e[i])&&o("'--\x3e' not separated from timestamp by whitespace."),a(n),t.endTime=c(),void 0!=t.endTime)?(t.endTime<=t.startTime&&o("End timestamp is not greater than start timestamp."),r.test(e[i]),a(n),!function(e,t){for(var r=e.split(n),i=[],a=0;a<r.length;a++)if(""!=r[a]){var s=r[a].indexOf(":"),c=r[a].slice(0,s),l=r[a].slice(s+1);if(-1!=i.indexOf(c)&&o("Duplicate setting."),i.push(c),""==l)return void o("No value for setting defined.");if("vertical"==c){if("rl"!=l&&"lr"!=l){o("Writing direction can only be set to 'rl' or 'rl'.");continue}t.direction=l}else if("line"==c){if(/,/.test(l)){var u=l.split(",");l=u[0];var f=u[1]}if(!/^[-\d](\d*)(\.\d+)?%?$/.test(l)){o("Line position takes a number or percentage.");continue}if(-1!=l.indexOf("-",1)){o("Line position can only have '-' at the start.");continue}if(-1!=l.indexOf("%")&&l.indexOf("%")!=l.length-1){o("Line position can only have '%' at the end.");continue}if("-"==l[0]&&"%"==l[l.length-1]){o("Line position cannot be a negative percentage.");continue}var d=l,p=!1;if("%"==l[l.length-1]&&(p=!0,d=l.slice(0,l.length-1),parseInt(l,10)>100)){o("Line position cannot be >100%.");continue}if(""===d||isNaN(d)||!isFinite(d)){o("Line position needs to be a number");continue}if(void 0!==f){if(!["start","center","end"].includes(f)){o("Line alignment needs to be one of start, center or end");continue}t.lineAlign=f}t.snapToLines=!p,t.linePosition=parseFloat(d),parseFloat(d).toString()!==d&&(t.nonSerializable=!0)}else if("position"==c){if(/,/.test(l)){var u=l.split(",");l=u[0];var v=u[1]}if("%"!=l[l.length-1]){o("Text position must be a percentage.");continue}if(parseInt(l,10)>100||0>parseInt(l,10)){o("Text position needs to be between 0 and 100%.");continue}if(""===(d=l.slice(0,l.length-1))||isNaN(d)||!isFinite(d)){o("Line position needs to be a number");continue}if(void 0!==v){if(!["line-left","center","line-right"].includes(v)){o("Position alignment needs to be one of line-left, center or line-right");continue}t.positionAlign=v}t.textPosition=parseFloat(d)}else if("size"==c){if("%"!=l[l.length-1]){o("Size must be a percentage.");continue}if(parseInt(l,10)>100){o("Size cannot be >100%.");continue}var h=l.slice(0,l.length-1);if(void 0===h||""===h||isNaN(h)){o("Size needs to be a number"),h=100;continue}if((h=parseFloat(h))<0||h>100){o("Size needs to be between 0 and 100%.");continue}t.size=h}else if("align"==c){var m=["start","center","end","left","right"];if(-1==m.indexOf(l)){o("Alignment can only be set to one of "+m.join(", ")+".");continue}t.alignment=l}else o("Invalid setting.")}}(e.substring(i),t),!0):void 0},this.parseTimestamp=function(){var t=c();return void 0!=e[i]?void o("Timestamp must not have trailing characters."):t}},o=function(e,t,n,o){this.entities=o;var a=this,e=e,s=0,c=function(e){"metadata"!=n&&t(e,s+1)};this.parse=function(t,l){var u={children:[]},f=u,d=[];function p(e){f.children.push({type:"object",name:e[1],classes:e[2],children:[],parent:f}),f=f.children[f.children.length-1]}for(;void 0!=e[s];){var v=function(){for(var t="data",n="",r="",i=[];void 0!=e[s-1]||0==s;){var l=e[s];if("data"==t)if("&"==l)r=l,t="escape";else if("<"==l&&""==n)t="tag";else{if("<"==l||void 0==l)return["text",n];n+=l}else if("escape"==t)if("<"==l||void 0==l){c("Incorrect escape.");var u=void 0;return(u=r.match(/^&#([0-9]+)$/))?n+=String.fromCharCode(u[1]):a.entities[r]?n+=a.entities[r]:n+=r,["text",n]}else if("&"==l)c("Incorrect escape."),n+=r,r=l;else if(/[a-z#0-9]/i.test(l))r+=l;else if(";"==l){var f=void 0;(f=r.match(/^&#(x?[0-9]+)$/))?n+=String.fromCharCode("0"+f[1]):a.entities[r+l]?n+=a.entities[r+l]:(f=Object.keys(o).find(function(e){return r.startsWith(e)}))?n+=a.entities[f]+r.slice(f.length)+l:(c("Incorrect escape."),n+=r+";"),t="data"}else c("Incorrect escape."),n+=r+l,t="data";else if("tag"==t)if(" "==l||"\n"==l||"\f"==l||" "==l)t="start tag annotation";else if("."==l)t="start tag class";else if("/"==l)t="end tag";else if(/\d/.test(l))n=l,t="timestamp tag";else{if(">"==l||void 0==l)return">"==l&&s++,["start tag","",[],""];n=l,t="start tag"}else if("start tag"==t)if(" "==l||"\f"==l||" "==l)t="start tag annotation";else if("\n"==l)r=l,t="start tag annotation";else if("."==l)t="start tag class";else{if(">"==l||void 0==l)return">"==l&&s++,["start tag",n,[],""];n+=l}else if("start tag class"==t)if(" "==l||"\f"==l||" "==l)r&&i.push(r),r="",t="start tag annotation";else if("\n"==l)r&&i.push(r),r=l,t="start tag annotation";else if("."==l)r&&i.push(r),r="";else{if(">"==l||void 0==l)return">"==l&&s++,r&&i.push(r),["start tag",n,i,""];r+=l}else if("start tag annotation"==t)if(">"==l||void 0==l)return">"==l&&s++,["start tag",n,i,r=r.split(/[\u0020\t\f\r\n]+/).filter(function(e){if(e)return!0}).join(" ")];else r+=l;else if("end tag"==t)if(">"==l||void 0==l)return">"==l&&s++,["end tag",n];else n+=l;else if("timestamp tag"==t)if(">"==l||void 0==l)return">"==l&&s++,["timestamp",n];else n+=l;else c("Never happens.");s++}}();if("text"==v[0])f.children.push({type:"text",value:v[1],parent:f});else if("start tag"==v[0]){"chapters"==n&&c("Start tags not allowed in chapter title text.");var h=v[1];"v"!=h&&"lang"!=h&&""!=v[3]&&c("Only<v>and<lang>can have an annotation."),"c"==h||"i"==h||"b"==h||"u"==h||"ruby"==h||"rt"==h&&"ruby"==f.name?p(v):"v"==h?(function(){for(var e=f;e;){if("v"==e.name)return!0;e=e.parent}}()&&c("<v>cannot be nested inside itself."),p(v),f.value=v[3],v[3]||c("<v>requires an annotation.")):"lang"==h?(p(v),f.value=v[3]):c("Incorrect start tag.")}else if("end tag"==v[0])"chapters"==n&&c("End tags not allowed in chapter title text."),v[1]==f.name?f=f.parent:"ruby"==v[1]&&"rt"==f.name?f=f.parent.parent:c("Incorrect end tag.");else if("timestamp"==v[0]){"chapters"==n&&c("Timestamp not allowed in chapter title text.");var m=new r(v[1],c).parseTimestamp();void 0!=m&&((m<=t||m>=l)&&c("Timestamp must be between start timestamp and end timestamp."),d.length>0&&d[d.length-1]>=m&&c("Timestamp must be greater than any previous timestamp."),f.children.push({type:"timestamp",value:m,parent:f}),d.push(m))}}for(;f.parent;)"v"!=f.name&&c("Required end tag missing."),f=f.parent;return function e(t){var n=(0,i._)({},t);return t.children&&(n.children=t.children.map(e)),n.parent&&delete n.parent,n}(u)}},a=function(){function t(e){var t=("00"+1e3*(e-Math.floor(e)).toFixed(3)).slice(-3),n=0,r=0,i=0;return e>=3600&&(n=Math.floor(e/3600)),r=Math.floor((e-3600*n)/60),i=Math.floor(e-3600*n-60*r),(n?n+":":"")+(""+r).padStart(2,"0")+":"+(""+i).padStart(2,"0")+"."+t}this.serialize=function(n,r){var i="WEBVTT\n\n";if(r)for(var o=0;o<r.length;o++)i+="STYLE\n"+r[o]+"\n\n";for(var o=0;o<n.length;o++)i+=function(n){var r,i;return(void 0!==n.id?n.id+"\n":"")+t(n.startTime)+" --\x3e "+t(n.endTime)+(r="",(i=Object.keys(e).filter(function(t){return n[t]!==e[t]})).includes("direction")&&(r+=" vertical:"+n.direction),i.includes("alignment")&&(r+=" align:"+n.alignment),i.includes("size")&&(r+=" size:"+n.size+"%"),(i.includes("lineAlign")||i.includes("linePosition"))&&(r+=" line:"+n.linePosition+(n.snapToLines?"":"%")+(n.lineAlign&&n.lineAlign!=e.lineAlign?","+n.lineAlign:"")),(i.includes("textPosition")||i.includes("positionAlign"))&&(r+=" position:"+n.textPosition+"%"+(n.positionAlign&&n.positionAlign!==e.positionAlign?","+n.positionAlign:"")),r)+"\n"+function e(n){for(var r="",i=0;i<n.length;i++){var o=n[i];if("text"==o.type)r+=o.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");else if("object"==o.type){if(r+="<"+o.name,o.classes)for(var a=0;a<o.classes.length;a++)r+="."+o.classes[a];o.value&&(r+=" "+o.value),r+=">",o.children&&(r+=e(o.children)),r+="</"+o.name+">"}else"timestamp"==o.type?r+="<"+t(o.value)+">":r+="<"+o.value+">"}return r}(n.tree.children)+"\n\n"}(n[o]);return i}};function s(e){e.WebVTTParser=t,e.WebVTTCueTimingsAndSettingsParser=r,e.WebVTTCueTextParser=o,e.WebVTTSerializer=a}"u">typeof window&&s(window),s(n)}()},{"@swc/helpers/cjs/_object_spread.cjs":"kyoEj"}],qpMMf:[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["bNEbP"],"bNEbP","parcelRequire4dc0",{}); |