UNPKG

imsc

Version:

Renders IMSC 1.1 documents to HTML5 fragments

98 lines 50.4 kB
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(f,t,q){f!=Array.prototype&&f!=Object.prototype&&(f[t]=q.value)};$jscomp.getGlobal=function(f){return"undefined"!=typeof window&&window===f?f:"undefined"!=typeof global&&null!=global?global:f};$jscomp.global=$jscomp.getGlobal(this); $jscomp.polyfill=function(f,t,q,u){if(t){q=$jscomp.global;f=f.split(".");for(u=0;u<f.length-1;u++){var r=f[u];r in q||(q[r]={});q=q[r]}f=f[f.length-1];u=q[f];t=t(u);t!=u&&null!=t&&$jscomp.defineProperty(q,f,{configurable:!0,writable:!0,value:t})}};$jscomp.polyfill("Math.sign",function(f){return f?f:function(f){f=Number(f);return 0===f||isNaN(f)?f:0<f?1:-1}},"es6","es3"); (function(f){"object"===typeof exports&&"undefined"!==typeof module?module.exports=f():"function"===typeof define&&define.amd?define([],f):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).imsc=f()})(function(){return function(){function f(t,q,u){function r(p,J){if(!q[p]){if(!t[p]){var a="function"==typeof require&&require;if(!J&&a)return a(p,!0);if(h)return h(p,!0);J=Error("Cannot find module '"+p+"'");throw J.code="MODULE_NOT_FOUND",J;}J= q[p]={exports:{}};t[p][0].call(J.exports,function(a){return r(t[p][1][a]||a)},J,J.exports,f,t,q,u)}return q[p].exports}for(var h="function"==typeof require&&require,p=0;p<u.length;p++)r(u[p]);return r}return f}()({1:[function(f,t,q){(function(u,f,h,p,q){function r(b){if("contents"in b){var a="styleAttrs"in b?b.styleAttrs[p.byName.ruby.qname]:null;a="span"===b.kind&&("container"===a||"textContainer"===a||"textContainer"===a);for(var d=b.contents.length-1;0<=d;d--)!a||"styleAttrs"in b.contents[d]&& p.byName.ruby.qname in b.contents[d].styleAttrs?r(b.contents[d]):delete b.contents[d]}}function a(b,d,g,c){var e=c&&"seq"===c.timeContainer,A=0;c&&(A=e&&g?g.end:c.begin);d.begin=d.explicit_begin?d.explicit_begin+A:A;g=d.begin;c=null;for(var z in d.sets)a(b,d.sets[z],c,d),g="seq"===d.timeContainer?d.sets[z].end:Math.max(g,d.sets[z].end),c=d.sets[z];if("contents"in d)for(var F in d.contents)a(b,d.contents[F],c,d),g="seq"===d.timeContainer?d.contents[F].end:Math.max(g,d.contents[F].end),c=d.contents[F]; else g=e?d.begin:Number.POSITIVE_INFINITY;d.end=null!==d.explicit_end&&null!==d.explicit_dur?Math.min(d.begin+d.explicit_dur,A+d.explicit_end):null===d.explicit_end&&null!==d.explicit_dur?d.begin+d.explicit_dur:null!==d.explicit_end&&null===d.explicit_dur?A+d.explicit_end:g;delete d.explicit_begin;delete d.explicit_dur;delete d.explicit_end;b._registerEvent(d)}function e(b){this.node=b}function m(){this.events=[];this.head=new c;this.body=null}function c(){this.styling=new b;this.layout=new z}function b(){this.styles= {};this.initials={}}function d(){this.styleRefs=this.styleAttrs=this.id=null}function g(){this.styleAttrs=null}function z(){this.regions={}}function L(b,d){this.kind="image";this.src=b;this.type=d}function H(b){this.id=b}function k(b){this.regionID=b}function C(b){this.styleAttrs=b}function n(b){this.sets=b}function B(b){this.contents=b}function v(b,d,a){this.explicit_begin=b;this.explicit_end=d;this.explicit_dur=a}function y(){this.kind="body"}function w(){this.kind="div"}function t(){this.kind= "p"}function G(){this.kind="span"}function D(){this.kind="span"}function O(){this.kind="br"}function N(){}function T(){}function U(b){return b&&"xml:id"in b.attributes?b.attributes["xml:id"].value||null:null}function P(b){return b&&"style"in b.attributes?b.attributes.style.value.split(" "):[]}function Q(b,d){var a={};if(null!==b)for(var g in b.attributes){var c=b.attributes[g].uri+" "+b.attributes[g].local,e=p.byQName[c];if(void 0!==e){var z=e.parse(b.attributes[g].value);null!==z?(a[c]=z,e===p.byName.zIndex&& K(d,"zIndex attribute present but not used by IMSC1 since regions do not overlap")):I(d,"Cannot parse styling attribute "+c+" --\x3e "+b.attributes[g].value)}}return a}function M(b,d,a){for(var g in b.attributes)if(b.attributes[g].uri===d&&b.attributes[g].local===a)return b.attributes[g].value;return null}function Y(b,d){b=M(b,h.ns_tts,"extent");if(null===b)return null;var a=b.split(" ");if(2!==a.length)return K(d,"Malformed extent (ignoring)"),null;b=q.parseLength(a[0]);a=q.parseLength(a[1]);return a&& b?{h:a,w:b}:(K(d,"Malformed extent values (ignoring)"),null)}function R(b,d,a){var g=/^(\d{2,}):(\d\d):(\d\d(?:\.\d+)?)$/,c=/^(\d{2,}):(\d\d):(\d\d):(\d{2,})$/,e=/^(\d+(?:\.\d+)?)t$/,z=/^(\d+(?:\.\d+)?)ms$/,A=/^(\d+(?:\.\d+)?)s$/,F=/^(\d+(?:\.\d+)?)h$/,x=/^(\d+(?:\.\d+)?)m$/,m,h=null;null!==(m=/^(\d+(?:\.\d+)?)f$/.exec(a))?null!==d&&(h=parseFloat(m[1])/d):null!==(m=e.exec(a))?null!==b&&(h=parseFloat(m[1])/b):null!==(m=z.exec(a))?h=parseFloat(m[1])/1E3:null!==(m=A.exec(a))?h=parseFloat(m[1]):null!== (m=F.exec(a))?h=3600*parseFloat(m[1]):null!==(m=x.exec(a))?h=60*parseFloat(m[1]):null!==(m=g.exec(a))?h=3600*parseInt(m[1])+60*parseInt(m[2])+parseFloat(m[3]):null!==(m=c.exec(a))&&null!==d&&(h=3600*parseInt(m[1])+60*parseInt(m[2])+parseInt(m[3])+(null===m[4]?0:parseInt(m[4])/d));return h}function V(b,d,a){for(;0<d.styleRefs.length;){var g=d.styleRefs.pop();g in b.styles?(V(b,b.styles[g],a),S(b.styles[g].styleAttrs,d.styleAttrs)):I(a,"Non-existant style id referenced")}}function W(b,d,a,g){for(var c= d.length-1;0<=c;c--){var e=d[c];e in b.styles?S(b.styles[e].styleAttrs,a):I(g,"Non-existant style id referenced")}}function S(b,d){for(var a in b)a in d||(d[a]=b[a])}function K(b,d){if(b&&b.warn&&b.warn(d))throw d;}function I(b,d){if(b&&b.error&&b.error(d))throw d;}function E(b,d){b&&b.fatal&&b.fatal(d);throw d;}function X(b,d){for(var a=0,g=b.length-1,c;a<=g;){c=Math.floor((a+g)/2);var e=b[c];if(e<d)a=c+1;else if(e>d)g=c-1;else return{found:!0,index:c}}return{found:!1,index:a}}u.fromXML=function(A, x,F){var n=f.parser(!0,{xmlns:!0}),l=[],u=[],C=[],H=0,k=null;n.onclosetag=function(d){if(l[0]instanceof b)for(var a in l[0].styles)V(l[0],l[0].styles[a],x);else if(l[0]instanceof t||l[0]instanceof G){if(1<l[0].contents.length){d=[l[0].contents[0]];for(a=1;a<l[0].contents.length;a++)l[0].contents[a]instanceof D&&d[d.length-1]instanceof D?d[d.length-1].text+=l[0].contents[a].text:d.push(l[0].contents[a]);l[0].contents=d}l[0]instanceof G&&1===l[0].contents.length&&l[0].contents[0]instanceof D&&(l[0].text= l[0].contents[0].text,delete l[0].contents)}else if(l[0]instanceof e)if(l[0].node.uri===h.ns_tt&&"metadata"===l[0].node.local)H--;else if(0<H&&F&&"onCloseTag"in F)F.onCloseTag();C.shift();u.shift();l.shift()};n.ontext=function(b){if(void 0!==l[0])if(l[0]instanceof G||l[0]instanceof t){var d=new D;d.initFromText(k,l[0],b,C[0],x);l[0].contents.push(d)}else if(l[0]instanceof e&&0<H&&F&&"onText"in F)F.onText(b)};n.onopentag=function(a){var A=a.attributes["xml:space"];A?C.unshift(A.value):0===C.length? C.unshift("default"):C.unshift(C[0]);(A=a.attributes["xml:lang"])?u.unshift(A.value):0===u.length?u.unshift(""):u.unshift(u[0]);if(a.uri===h.ns_tt)if("tt"===a.local)null!==k&&E(x,"Two <tt> elements at ("+this.line+","+this.column+")"),k=new m,k.initFromNode(a,x),l.unshift(k);else if("head"===a.local)l[0]instanceof m||E(x,"Parent of <head> element is not <tt> at ("+this.line+","+this.column+")"),l.unshift(k.head);else if("styling"===a.local)l[0]instanceof c||E(x,"Parent of <styling> element is not <head> at ("+ this.line+","+this.column+")"),l.unshift(k.head.styling);else if("style"===a.local)if(l[0]instanceof b){var n=new d;n.initFromNode(a,x);n.id?k.head.styling.styles[n.id]=n:I(x,"<style> element missing @id attribute");l.unshift(n)}else l[0]instanceof N?(n=new d,n.initFromNode(a,x),S(n.styleAttrs,l[0].styleAttrs),l.unshift(n)):E(x,"Parent of <style> element is not <styling> or <region> at ("+this.line+","+this.column+")");else if("initial"===a.local)if(l[0]instanceof b){A=new g;A.initFromNode(a,x);for(n in A.styleAttrs)k.head.styling.initials[n]= A.styleAttrs[n];l.unshift(A)}else E(x,"Parent of <initial> element is not <styling> at ("+this.line+","+this.column+")");else if("layout"===a.local)l[0]instanceof c||E(x,"Parent of <layout> element is not <head> at "+this.line+","+this.column+")"),l.unshift(k.head.layout);else if("region"===a.local)l[0]instanceof z||E(x,"Parent of <region> element is not <layout> at "+this.line+","+this.column+")"),n=new N,n.initFromNode(k,a,x),!n.id||n.id in k.head.layout.regions?I(x,"Ignoring <region> with duplicate or missing @id at "+ this.line+","+this.column+")"):k.head.layout.regions[n.id]=n,l.unshift(n);else if("body"===a.local)l[0]instanceof m||E(x,"Parent of <body> element is not <tt> at "+this.line+","+this.column+")"),null!==k.body&&E(x,"Second <body> element at "+this.line+","+this.column+")"),n=new y,n.initFromNode(k,a,x),k.body=n,l.unshift(n);else if("div"===a.local){l[0]instanceof w||l[0]instanceof y||E(x,"Parent of <div> element is not <body> or <div> at "+this.line+","+this.column+")");n=new w;n.initFromNode(k,l[0], a,x);if(A=n.styleAttrs[p.byName.backgroundImage.qname])n.contents.push(new L(A)),delete n.styleAttrs[p.byName.backgroundImage.qname];l[0].contents.push(n);l.unshift(n)}else"image"===a.local?(l[0]instanceof w||E(x,"Parent of <image> element is not <div> at "+this.line+","+this.column+")"),n=new L,n.initFromNode(k,l[0],a,x),l[0].contents.push(n),l.unshift(n)):"p"===a.local?(l[0]instanceof w||E(x,"Parent of <p> element is not <div> at "+this.line+","+this.column+")"),n=new t,n.initFromNode(k,l[0],a, x),l[0].contents.push(n),l.unshift(n)):"span"===a.local?(l[0]instanceof G||l[0]instanceof t||E(x,"Parent of <span> element is not <span> or <p> at "+this.line+","+this.column+")"),n=new G,n.initFromNode(k,l[0],a,C[0],x),l[0].contents.push(n),l.unshift(n)):"br"===a.local?(l[0]instanceof G||l[0]instanceof t||E(x,"Parent of <br> element is not <span> or <p> at "+this.line+","+this.column+")"),n=new O,n.initFromNode(k,l[0],a,x),l[0].contents.push(n),l.unshift(n)):"set"===a.local?(l[0]instanceof G||l[0]instanceof t||l[0]instanceof w||l[0]instanceof y||l[0]instanceof N||l[0]instanceof O||E(x,"Parent of <set> element is not a content element or a region at "+this.line+","+this.column+")"),n=new T,n.initFromNode(k,l[0],a,x),l[0].sets.push(n),l.unshift(n)):l.unshift(new e(a));else l.unshift(new e(a));if(l[0]instanceof e)if(a.uri===h.ns_tt&&"metadata"===a.local)H++;else if(0<H&&F&&"onOpenTag"in F){n=[];for(var f in a.attributes)n[a.attributes[f].uri+" "+a.attributes[f].local]={uri:a.attributes[f].uri,local:a.attributes[f].local, value:a.attributes[f].value};F.onOpenTag(a.uri,a.local,n)}};n.write(A).close();delete k.head.styling.styles;A=!1;for(var q in k.head.layout.regions){A=!0;break}A||(q=N.prototype.createDefaultRegion(),k.head.layout.regions[q.id]=q);for(var v in k.head.layout.regions)a(k,k.head.layout.regions[v],null,null);k.body&&a(k,k.body,null,null);k.body&&r(k.body);return k};m.prototype.initFromNode=function(b,a){var d=M(b,h.ns_ttp,"cellResolution"),g=15;var c=32;null!==d&&(d=/(\d+) (\d+)/.exec(d),null!==d?(c= parseInt(d[1]),g=parseInt(d[2])):K(a,"Malformed cellResolution value (using initial value instead)"));this.cellLength={h:new q.ComputedLength(0,1/g),w:new q.ComputedLength(1/c,0)};g=M(b,h.ns_ttp,"frameRate");d=30;null!==g&&(c=/(\d+)/.exec(g),null!==c?d=parseInt(c[1]):K(a,"Malformed frame rate attribute (using initial value instead)"));c=M(b,h.ns_ttp,"frameRateMultiplier");var e=1;null!==c&&(c=/(\d+) (\d+)/.exec(c),null!==c?e=parseInt(c[1])/parseInt(c[2]):K(a,"Malformed frame rate multiplier attribute (using initial value instead)")); d*=e;e=1;c=M(b,h.ns_ttp,"tickRate");null===c?null!==g&&(e=d):(c=/(\d+)/.exec(c),null!==c?e=parseInt(c[1]):K(a,"Malformed tick rate attribute (using initial value instead)"));this.effectiveFrameRate=d;this.tickRate=e;c=M(b,h.ns_ittp,"aspectRatio");null===c&&(c=M(b,h.ns_ttp,"displayAspectRatio"));g=null;null!==c&&(d=/(\d+)\s+(\d+)/.exec(c),null!==d?(c=parseInt(d[1]),d=parseInt(d[2]),0!==c&&0!==d?g=c/d:I(a,"Illegal aspectRatio values (ignoring)")):I(a,"Malformed aspectRatio attribute (ignoring)"));this.aspectRatio= g;g=M(b,h.ns_ttp,"timeBase");null!==g&&"media"!==g&&E(a,"Unsupported time base");b=Y(b,a);null===b?this.pxLength={h:null,w:null}:("px"===b.h.unit&&"px"===b.w.unit||E(a,"Extent on TT must be in px or absent"),this.pxLength={h:new q.ComputedLength(0,1/b.h.value),w:new q.ComputedLength(1/b.w.value,0)});this.dimensions={h:new q.ComputedLength(0,1),w:new q.ComputedLength(1,0)}};m.prototype._registerEvent=function(b){if(!(b.end<=b.begin)){var a=X(this.events,b.begin);a.found||this.events.splice(a.index, 0,b.begin);b.end!==Number.POSITIVE_INFINITY&&(a=X(this.events,b.end),a.found||this.events.splice(a.index,0,b.end))}};m.prototype.getMediaTimeRange=function(){return[this.events[0],this.events[this.events.length-1]]};m.prototype.getMediaTimeEvents=function(){return this.events};d.prototype.initFromNode=function(b,a){this.id=U(b);this.styleAttrs=Q(b,a);this.styleRefs=P(b)};g.prototype.initFromNode=function(b,a){this.styleAttrs={};for(var d in b.attributes)if(b.attributes[d].uri===h.ns_itts||b.attributes[d].uri=== h.ns_ebutts||b.attributes[d].uri===h.ns_tts)this.styleAttrs[b.attributes[d].uri+" "+b.attributes[d].local]=b.attributes[d].value};L.prototype.initFromNode=function(b,a,d,c){(this.src="src"in d.attributes?d.attributes.src.value:null)||I(c,"Invalid image@src attribute");(this.type="type"in d.attributes?d.attributes.type.value:null)||I(c,"Invalid image@type attribute");C.prototype.initFromNode.call(this,b,a,d,c);v.prototype.initFromNode.call(this,b,a,d,c);n.prototype.initFromNode.call(this,b,a,d,c); k.prototype.initFromNode.call(this,b,a,d,c)};H.prototype.initFromNode=function(b,a,d,c){this.id=U(d)};k.prototype.initFromNode=function(b,a,d,c){this.regionID=d&&"region"in d.attributes?d.attributes.region.value:""};C.prototype.initFromNode=function(b,d,a,c){this.styleAttrs=Q(a,c);null!==b.head&&null!==b.head.styling&&W(b.head.styling,P(a),this.styleAttrs,c)};n.prototype.initFromNode=function(b,a,d,c){this.sets=[]};B.prototype.initFromNode=function(b,a,d,c){this.contents=[]};v.prototype.initFromNode= function(b,a,d,c){a=null;d&&"begin"in d.attributes&&(a=R(b.tickRate,b.effectiveFrameRate,d.attributes.begin.value),null===a&&K(c,"Malformed begin value "+d.attributes.begin.value+" (using 0)"));var g=null;d&&"dur"in d.attributes&&(g=R(b.tickRate,b.effectiveFrameRate,d.attributes.dur.value),null===g&&K(c,"Malformed dur value "+d.attributes.dur.value+" (ignoring)"));var e=null;d&&"end"in d.attributes&&(e=R(b.tickRate,b.effectiveFrameRate,d.attributes.end.value),null===e&&K(c,"Malformed end value (ignoring)")); this.explicit_begin=a;this.explicit_end=e;this.explicit_dur=g;(b=d&&"timeContainer"in d.attributes?d.attributes.timeContainer.value:null)&&"par"!==b?"seq"===b?c="seq":(I(c,"Illegal value of timeContainer (assuming 'par')"),c="par"):c="par";this.timeContainer=c};y.prototype.initFromNode=function(b,d,a){C.prototype.initFromNode.call(this,b,null,d,a);v.prototype.initFromNode.call(this,b,null,d,a);n.prototype.initFromNode.call(this,b,null,d,a);k.prototype.initFromNode.call(this,b,null,d,a);B.prototype.initFromNode.call(this, b,null,d,a)};w.prototype.initFromNode=function(b,d,a,c){C.prototype.initFromNode.call(this,b,d,a,c);v.prototype.initFromNode.call(this,b,d,a,c);n.prototype.initFromNode.call(this,b,d,a,c);k.prototype.initFromNode.call(this,b,d,a,c);B.prototype.initFromNode.call(this,b,d,a,c)};t.prototype.initFromNode=function(b,d,a,c){C.prototype.initFromNode.call(this,b,d,a,c);v.prototype.initFromNode.call(this,b,d,a,c);n.prototype.initFromNode.call(this,b,d,a,c);k.prototype.initFromNode.call(this,b,d,a,c);B.prototype.initFromNode.call(this, b,d,a,c)};G.prototype.initFromNode=function(b,d,a,c,g){C.prototype.initFromNode.call(this,b,d,a,g);v.prototype.initFromNode.call(this,b,d,a,g);n.prototype.initFromNode.call(this,b,d,a,g);k.prototype.initFromNode.call(this,b,d,a,g);B.prototype.initFromNode.call(this,b,d,a,g);this.space=c};D.prototype.initFromText=function(b,d,a,c,g){v.prototype.initFromNode.call(this,b,d,null,g);this.text=a;this.space=c};O.prototype.initFromNode=function(b,d,a,c){k.prototype.initFromNode.call(this,b,d,a,c);v.prototype.initFromNode.call(this, b,d,a,c)};N.prototype.createDefaultRegion=function(){var b=new N;b.id="";b.styleAttrs={};b.sets=[];v.call(b,0,Number.POSITIVE_INFINITY,null);return b};N.prototype.initFromNode=function(b,d,a){H.prototype.initFromNode.call(this,b,null,d,a);C.prototype.initFromNode.call(this,b,null,d,a);v.prototype.initFromNode.call(this,b,null,d,a);n.prototype.initFromNode.call(this,b,null,d,a);null!==b.head&&null!==b.head.styling&&W(b.head.styling,P(d),this.styleAttrs,a)};T.prototype.initFromNode=function(b,d,a,c){v.prototype.initFromNode.call(this, b,d,a,c);b=Q(a,c);this.value=this.qname=null;for(var g in b){if(this.qname){I(c,"More than one style specified on set");break}this.qname=g;this.value=b[g]}}})("undefined"===typeof q?this.imscDoc={}:q,"undefined"===typeof sax?f("sax"):sax,"undefined"===typeof imscNames?f("./names"):imscNames,"undefined"===typeof imscStyles?f("./styles"):imscStyles,"undefined"===typeof imscUtils?f("./utils"):imscUtils)},{"./names":5,"./styles":6,"./utils":7,sax:void 0}],2:[function(f,t,q){(function(u,f,h){function p(b, d,c){if("region"===c.kind){var e=document.createElement("div");e.style.position="absolute"}else if("body"===c.kind)e=document.createElement("div");else if("div"===c.kind)e=document.createElement("div");else if("image"===c.kind){if(e=document.createElement("img"),null!==b.imgResolver&&null!==c.src){var g=b.imgResolver(c.src,e);g&&(e.src=g);e.height=b.regionH;e.width=b.regionW}}else if("p"===c.kind)e=document.createElement("p");else if("span"===c.kind){if("container"===c.styleAttrs[h.byName.ruby.qname])e= document.createElement("ruby"),b.ruby=!0;else if("base"===c.styleAttrs[h.byName.ruby.qname])e=document.createElement("rb");else if("text"===c.styleAttrs[h.byName.ruby.qname])e=document.createElement("rt");else if("baseContainer"===c.styleAttrs[h.byName.ruby.qname])e=document.createElement("rbc");else if("textContainer"===c.styleAttrs[h.byName.ruby.qname])e=document.createElement("rtc");else{if("delimiter"===c.styleAttrs[h.byName.ruby.qname])return;e=document.createElement("span")}(g=c.styleAttrs[h.byName.textEmphasis.qname])&& "none"!==g&&(b.textEmphasis=!0)}else"br"===c.kind&&(e=document.createElement("br"));if(e){d.appendChild(e);e.style.margin="0";for(var u in m)d=m[u],g=c.styleAttrs[d.qname],void 0!==g&&null!==d.map&&d.map(b,e,c,g);u=e;if("region"===c.kind)if(d=c.styleAttrs[h.byName.writingMode.qname],"lrtb"===d||"lr"===d)b.ipd="lr",b.bpd="tb";else if("rltb"===d||"rl"===d)b.ipd="rl",b.bpd="tb";else if("tblr"===d)b.ipd="tb",b.bpd="lr";else if("tbrl"===d||"tb"===d)b.ipd="tb",b.bpd="rl";if(d=c.styleAttrs[h.byName.linePadding.qname])g= d.toUsedLength(b.w,b.h),0<g&&("tb"===b.bpd?(u.style.paddingLeft=g+"px",u.style.paddingRight=g+"px"):(u.style.paddingTop=g+"px",u.style.paddingBottom=g+"px"),b.lp=d);(d=c.styleAttrs[h.byName.multiRowAlign.qname])&&"auto"!==d&&(u=document.createElement("span"),u.style.display="inline-block",u.style.textAlign=d,e.appendChild(u),b.mra=d);(d=c.styleAttrs[h.byName.rubyReserve.qname])&&"none"!==d[0]&&(b.rubyReserve=d);c.styleAttrs[h.byName.fillLineGap.qname]&&(b.flg=!0);if("span"===c.kind&&c.text)if(h.byName.textCombine.qname in c.styleAttrs&&"all"===c.styleAttrs[h.byName.textCombine.qname][0])e.textContent=c.text;else for(d=0;d<c.text.length;d++)g=document.createElement("span"),g.textContent=c.text.charAt(d),e.appendChild(g);for(var k in c.contents)p(b,u,c.contents[k]);k=[];if((b.lp||b.mra||b.flg||b.ruby||b.textEmphasis||b.rubyReserve)&&"p"===c.kind){a(b,u,k,null);if(b.rubyReserve){for(d=0;d<k.length;d++){g=document.createElement("ruby");var f=document.createElement("rb");f.textContent="\u200b";g.appendChild(f);var n=b.rubyReserve[1].toUsedLength(b.w, b.h)+"px";if("both"===b.rubyReserve[0]){f=document.createElement("rtc");f.style.rubyPosition="under";f.textContent="\u200b";f.style.fontSize=n;var B=document.createElement("rtc");B.style.rubyPosition="over";B.textContent="\u200b";B.style.fontSize=n;g.appendChild(f);g.appendChild(B)}else f=document.createElement("rtc"),f.textContent="\u200b",f.style.fontSize=n,f.style.rubyPosition="after"===b.rubyReserve[0]||"outside"===b.rubyReserve[0]&&0<d?"tb"===b.bpd||"rl"===b.bpd?"under":"over":"tb"===b.bpd|| "rl"===b.bpd?"over":"under",g.appendChild(f);k[d].elements[0].node.parentElement.insertBefore(g,k[d].elements[0].node)}b.rubyReserve=null}if(b.ruby||b.rubyReserve){for(d=0;d<k.length;d++)for(g=0;g<k[d].rbc.length;g++)""===k[d].rbc[g].style.rubyPosition&&(k[d].rbc[g].style.rubyPosition="tb"===b.bpd?0===d?"over":"under":"rl"===b.bpd?0===d?"over":"under":0===d?"under":"over");b.ruby=null}if(b.textEmphasis){for(d=0;d<k.length;d++)for(g=0;g<k[d].te.length;g++)k[d].te[g].style.textEmphasisPosition="tb"=== b.bpd?0===d?"left over":"left under":"rl"===b.bpd?0===d?"right under":"left under":0===d?"left under":"right under";b.textEmphasis=null}if(b.mra){for(d=0;d<k.length-1;d++)f=k[d].elements.length,0!==f&&!1===k[d].br&&(g=document.createElement("br"),f=k[d].elements[f-1].node,f.parentElement.insertBefore(g,f.nextSibling));b.mra=null}if(b.lp){d=b.lp.toUsedLength(b.w,b.h);for(var v in k)g=k[v].elements[k[v].start_elem],f=k[v].elements[k[v].end_elem],0!==k[v].elements.length&&("lr"===b.ipd?(g.node.style.paddingLeft= d+"px",g.node.style.marginLeft="-"+d+"px"):"rl"===b.ipd?(g.node.style.paddingRight=d+"px",g.node.style.marginRight="-"+d+"px"):"tb"===b.ipd&&(g.node.style.paddingTop=d+"px",g.node.style.marginTop="-"+d+"px"),g.node.style.backgroundColor=g.bgcolor,"lr"===b.ipd?(f.node.style.paddingRight=d+"px",f.node.style.marginRight="-"+d+"px"):"rl"===b.ipd?(f.node.style.paddingLeft=d+"px",f.node.style.marginLeft="-"+d+"px"):"tb"===b.ipd&&(f.node.style.paddingBottom=d+"px",f.node.style.marginBottom="-"+d+"px"),f.node.style.backgroundColor= f.bgcolor);b.lp=null}if(b.flg){d=q(u.getBoundingClientRect(),b);v=d.before;d=d.after;g=Math.sign(d-v);for(f=0;f<=k.length;f++){B=0===f?v:f===k.length?d:(k[f].before+k[f-1].after)/2;if(0<f)for(var y=0;y<k[f-1].elements.length;y++)if(null!==k[f-1].elements[y].bgcolor){var w=k[f-1].elements[y];0>g*(w.after-B)&&(n=Math.ceil(Math.abs(B-w.after))+"px",w.node.style.backgroundColor=w.bgcolor,"lr"===b.bpd?w.node.style.paddingRight=n:"rl"===b.bpd?w.node.style.paddingLeft=n:"tb"===b.bpd&&(w.node.style.paddingBottom= n))}if(f<k.length)for(y=0;y<k[f].elements.length;y++)w=k[f].elements[y],null!==w.bgcolor&&0<g*(w.before-B)&&(n=Math.ceil(Math.abs(w.before-B))+"px",w.node.style.backgroundColor=w.bgcolor,"lr"===b.bpd?w.node.style.paddingLeft=n:"rl"===b.bpd?w.node.style.paddingRight=n:"tb"===b.bpd&&(w.node.style.paddingTop=n))}b.flg=null}}"region"===c.kind&&(a(b,u,k),"tb"===b.bpd&&b.enableRollUp&&0<c.contents.length&&"after"===c.styleAttrs[h.byName.displayAlign.qname]&&(c=new r(""===c.id?"_":c.id,k),b.currentISDState[c.id]= c,b.previousISDState&&c.id in b.previousISDState&&0<b.previousISDState[c.id].plist.length&&1<c.plist.length&&c.plist[c.plist.length-2].text===b.previousISDState[c.id].plist[b.previousISDState[c.id].plist.length-1].text&&(b=e.firstElementChild,c=c.plist[c.plist.length-1].after-c.plist[c.plist.length-1].before,b.style.bottom="-"+c+"px",b.style.transition="transform 0.4s",b.style.position="relative",b.style.transform="translateY(-"+c+"px)")))}else if(b=b.errorHandler,c="Error processing ISD element kind: "+ c.kind,b&&b.error&&b.error(c))throw c;}function r(b,d){this.id=b;this.plist=d}function q(b,d){var a={before:null,after:null,start:null,end:null};"tb"===d.bpd?(a.before=b.top,a.after=b.bottom,"lr"===d.ipd?(a.start=b.left,a.end=b.right):(a.start=b.right,a.end=b.left)):"lr"===d.bpd?(a.before=b.left,a.after=b.right,a.start=b.top,a.end=b.bottom):"rl"===d.bpd&&(a.before=b.right,a.after=b.left,a.start=b.top,a.end=b.bottom);return a}function a(b,d,c,e){if("rt"!==d.localName&&"rtc"!==d.localName)if(e=d.style.backgroundColor|| e,0===d.childElementCount)if("span"===d.localName||"rb"===d.localName){var g=d.getBoundingClientRect();if(0!==g.height&&0!==g.width){b=q(g,b);if(!(g=0===c.length)){g=b.before;var z=b.after,m=c[c.length-1].before,h=c[c.length-1].after;g=!(z<h&&g>m||h<=z&&m>=g)}g?c.push({before:b.before,after:b.after,start:b.start,end:b.end,start_elem:0,end_elem:0,elements:[],rbc:[],te:[],text:"",br:!1}):(g=Math.sign(b.after-b.before),z=Math.sign(b.end-b.start),0>g*(b.before-c[c.length-1].before)&&(c[c.length-1].before= b.before),0<g*(b.after-c[c.length-1].after)&&(c[c.length-1].after=b.after),0>z*(b.start-c[c.length-1].start)&&(c[c.length-1].start=b.start,c[c.length-1].start_elem=c[c.length-1].elements.length),0<z*(b.end-c[c.length-1].end)&&(c[c.length-1].end=b.end,c[c.length-1].end_elem=c[c.length-1].elements.length));c[c.length-1].text+=d.textContent;c[c.length-1].elements.push({node:d,bgcolor:e,before:b.before,after:b.after})}}else"br"===d.localName&&0!==c.length&&(c[c.length-1].br=!0);else for(d=d.firstChild;d;)d.nodeType=== Node.ELEMENT_NODE&&(a(b,d,c,e),"ruby"===d.localName||"rtc"===d.localName?0<c.length&&c[c.length-1].rbc.push(d):"span"===d.localName&&""!==d.style.textEmphasisStyle&&c[c.length-1].te.push(d)),d=d.nextSibling}function e(b,a){this.qname=b;this.map=a}u.render=function(b,a,c,e,m,h,f,u,n){e=e||a.clientHeight;m=m||a.clientWidth;if(null!==b.aspectRatio){var d=e*b.aspectRatio;d>m?e=Math.round(m/b.aspectRatio):m=d}d=document.createElement("div");d.style.position="relative";d.style.width=m+"px";d.style.height= e+"px";d.style.margin="auto";d.style.top=0;d.style.bottom=0;d.style.left=0;d.style.right=0;d.style.zIndex=0;c={h:e,w:m,regionH:null,regionW:null,imgResolver:c,displayForcedOnlyMode:h||!1,isd:b,errorHandler:f,previousISDState:u,enableRollUp:n||!1,currentISDState:{},flg:null,lp:null,mra:null,ipd:null,bpd:null,ruby:null,textEmphasis:null,rubyReserve:null};a.appendChild(d);for(var g in b.contents)p(c,d,b.contents[g]);return c.currentISDState};var m=[new e("http://www.w3.org/ns/ttml#styling backgroundColor", function(b,a,c,e){0!==e[3]&&(a.style.backgroundColor="rgba("+e[0].toString()+","+e[1].toString()+","+e[2].toString()+","+(e[3]/255).toString()+")")}),new e("http://www.w3.org/ns/ttml#styling color",function(b,a,c,e){a.style.color="rgba("+e[0].toString()+","+e[1].toString()+","+e[2].toString()+","+(e[3]/255).toString()+")"}),new e("http://www.w3.org/ns/ttml#styling direction",function(b,a,c,e){a.style.direction=e}),new e("http://www.w3.org/ns/ttml#styling display",function(b,a,c,e){}),new e("http://www.w3.org/ns/ttml#styling displayAlign", function(b,a,c,e){a.style.display="flex";a.style.flexDirection="column";"before"===e?a.style.justifyContent="flex-start":"center"===e?a.style.justifyContent="center":"after"===e&&(a.style.justifyContent="flex-end")}),new e("http://www.w3.org/ns/ttml#styling extent",function(b,a,c,e){b.regionH=e.h.toUsedLength(b.w,b.h);b.regionW=e.w.toUsedLength(b.w,b.h);var d=e=0;if(c=c.styleAttrs["http://www.w3.org/ns/ttml#styling padding"])e=c[0].toUsedLength(b.w,b.h)+c[2].toUsedLength(b.w,b.h),d=c[1].toUsedLength(b.w, b.h)+c[3].toUsedLength(b.w,b.h);a.style.height=b.regionH-e+"px";a.style.width=b.regionW-d+"px"}),new e("http://www.w3.org/ns/ttml#styling fontFamily",function(b,a,c,e){b=[];for(var d in e)"monospaceSerif"===e[d]?(b.push("Courier New"),b.push('"Liberation Mono"'),b.push("Courier"),b.push("monospace")):"proportionalSansSerif"===e[d]?(b.push("Arial"),b.push("Helvetica"),b.push('"Liberation Sans"'),b.push("sans-serif")):"monospace"===e[d]?b.push("monospace"):"sansSerif"===e[d]?b.push("sans-serif"):"serif"=== e[d]?b.push("serif"):"monospaceSansSerif"===e[d]?(b.push("Consolas"),b.push("monospace")):"proportionalSerif"===e[d]?b.push("serif"):b.push(e[d]);a.style.fontFamily=b.join(",")}),new e("http://www.w3.org/ns/ttml#styling shear",function(b,a,c,e){0!==e&&(c=-Math.asin(e/100),a.style.transform="tb"===b.bpd?"skewX("+c+"rad)":"skewY("+c+"rad)")}),new e("http://www.w3.org/ns/ttml#styling fontSize",function(b,a,c,e){a.style.fontSize=e.toUsedLength(b.w,b.h)+"px"}),new e("http://www.w3.org/ns/ttml#styling fontStyle", function(b,a,c,e){a.style.fontStyle=e}),new e("http://www.w3.org/ns/ttml#styling fontWeight",function(b,a,c,e){a.style.fontWeight=e}),new e("http://www.w3.org/ns/ttml#styling lineHeight",function(b,a,c,e){a.style.lineHeight="normal"===e?"normal":e.toUsedLength(b.w,b.h)+"px"}),new e("http://www.w3.org/ns/ttml#styling opacity",function(b,a,c,e){a.style.opacity=e}),new e("http://www.w3.org/ns/ttml#styling origin",function(b,a,c,e){a.style.top=e.h.toUsedLength(b.w,b.h)+"px";a.style.left=e.w.toUsedLength(b.w, b.h)+"px"}),new e("http://www.w3.org/ns/ttml#styling overflow",function(b,a,c,e){a.style.overflow=e}),new e("http://www.w3.org/ns/ttml#styling padding",function(b,a,c,e){c=[];c[0]=e[0].toUsedLength(b.w,b.h)+"px";c[1]=e[3].toUsedLength(b.w,b.h)+"px";c[2]=e[2].toUsedLength(b.w,b.h)+"px";c[3]=e[1].toUsedLength(b.w,b.h)+"px";a.style.padding=c.join(" ")}),new e("http://www.w3.org/ns/ttml#styling position",function(b,a,c,e){a.style.top=e.h.toUsedLength(b.w,b.h)+"px";a.style.left=e.w.toUsedLength(b.w,b.h)+ "px"}),new e("http://www.w3.org/ns/ttml#styling rubyAlign",function(b,a,c,e){a.style.rubyAlign=e}),new e("http://www.w3.org/ns/ttml#styling rubyPosition",function(b,a,c,e){if("before"===e||"after"===e)a.parentElement.style.rubyPosition="tb"===b.bpd?"before"===e?"over":"under":"rl"===b.bpd?"before"===e?"over":"under":"before"===e?"under":"over"}),new e("http://www.w3.org/ns/ttml#styling showBackground",null),new e("http://www.w3.org/ns/ttml#styling textAlign",function(b,a,c,e){b=c.styleAttrs[h.byName.direction.qname]; a.style.textAlign="start"===e?"rtl"===b?"right":"left":"end"===e?"rtl"===b?"left":"right":e}),new e("http://www.w3.org/ns/ttml#styling textDecoration",function(b,a,c,e){a.style.textDecoration=e.join(" ").replace("lineThrough","line-through")}),new e("http://www.w3.org/ns/ttml#styling textOutline",function(b,a,c,e){}),new e("http://www.w3.org/ns/ttml#styling textShadow",function(b,a,c,e){c=c.styleAttrs[h.byName.textOutline.qname];if("none"===e&&"none"===c)a.style.textShadow="";else{var d=[];"none"!== c&&d.push("rgba("+c.color[0].toString()+","+c.color[1].toString()+","+c.color[2].toString()+","+(c.color[3]/255).toString()+") 0px 0px "+c.thickness.toUsedLength(b.w,b.h)+"px");if("none"!==e)for(var g in e)d.push(e[g].x_off.toUsedLength(b.w,b.h)+"px "+e[g].y_off.toUsedLength(b.w,b.h)+"px "+e[g].b_radius.toUsedLength(b.w,b.h)+"px rgba("+e[g].color[0].toString()+","+e[g].color[1].toString()+","+e[g].color[2].toString()+","+(e[g].color[3]/255).toString()+")");a.style.textShadow=d.join(",")}}),new e("http://www.w3.org/ns/ttml#styling textCombine", function(b,a,c,e){a.style.textCombineUpright=e.join(" ")}),new e("http://www.w3.org/ns/ttml#styling textEmphasis",function(b,a,c,e){"none"!==e.style&&(a.style.textEmphasisStyle=e.style+" "+e.symbol)}),new e("http://www.w3.org/ns/ttml#styling unicodeBidi",function(b,a,c,e){a.style.unicodeBidi="bidiOverride"===e?"bidi-override":e}),new e("http://www.w3.org/ns/ttml#styling visibility",function(b,a,c,e){a.style.visibility=e}),new e("http://www.w3.org/ns/ttml#styling wrapOption",function(b,a,c,e){a.style.whiteSpace= "wrap"===e?"preserve"===c.space?"pre-wrap":"normal":"preserve"===c.space?"pre":"noWrap"}),new e("http://www.w3.org/ns/ttml#styling writingMode",function(b,a,c,e){if("lrtb"===e||"lr"===e)b.writingMode="horizontal-tb";else if("rltb"===e||"rl"===e)b.writingMode="horizontal-tb";else if("tblr"===e)b.writingMode="vertical-lr";else if("tbrl"===e||"tb"===e)b.writingMode="vertical-rl";a.style.writingMode=b.writingMode}),new e("http://www.w3.org/ns/ttml#styling zIndex",function(b,a,c,e){a.style.zIndex=e}), new e("http://www.w3.org/ns/ttml/profile/imsc1#styling forcedDisplay",function(b,a,c,e){b.displayForcedOnlyMode&&!1===e&&(a.style.visibility="hidden")})],c;for(c in m);})("undefined"===typeof q?this.imscHTML={}:q,"undefined"===typeof imscNames?f("./names"):imscNames,"undefined"===typeof imscStyles?f("./styles"):imscStyles,"undefined"===typeof imscUtils?f("./utils"):imscUtils)},{"./names":5,"./styles":6,"./utils":7}],3:[function(f,t,q){(function(f,r,h,p){function u(c,b,d,e,f,r,t,k,C){if(b<t.begin|| b>=t.end)return null;r="regionID"in t&&""!==t.regionID?t.regionID:r;if(null!==f&&r!==d.id&&(!("contents"in t)||"contents"in t&&0===t.contents.length||""!==r))return null;var g=new m(t);for(B in t.sets)b<t.sets[B].begin||b>=t.sets[B].end||(g.styleAttrs[t.sets[B].qname]=t.sets[B].value);var B={};for(var v in g.styleAttrs)if(B[v]=!0,v===h.byName.writingMode.qname&&!(h.byName.direction.qname in g.styleAttrs)){var y=g.styleAttrs[v];if("lrtb"===y||"lr"===y)g.styleAttrs[h.byName.direction.qname]="ltr";else if("rltb"=== y||"rl"===y)g.styleAttrs[h.byName.direction.qname]="rtl"}if(null!==f)for(var w in h.all)if(v=h.all[w],v.qname===h.byName.textDecoration.qname){y=f.styleAttrs[v.qname];var z=g.styleAttrs[v.qname],G=[];void 0===z?G=y:-1===z.indexOf("none")?((-1===z.indexOf("noUnderline")&&-1!==y.indexOf("underline")||-1!==z.indexOf("underline"))&&G.push("underline"),(-1===z.indexOf("noLineThrough")&&-1!==y.indexOf("lineThrough")||-1!==z.indexOf("lineThrough"))&&G.push("lineThrough"),(-1===z.indexOf("noOverline")&&-1!== y.indexOf("overline")||-1!==z.indexOf("overline"))&&G.push("overline")):G.push("none");g.styleAttrs[v.qname]=G}else v.qname!==h.byName.fontSize.qname||v.qname in g.styleAttrs||"span"!==g.kind||"textContainer"!==g.styleAttrs[h.byName.ruby.qname]?v.qname!==h.byName.fontSize.qname||v.qname in g.styleAttrs||"span"!==g.kind||"text"!==g.styleAttrs[h.byName.ruby.qname]?v.inherit&&v.qname in f.styleAttrs&&!(v.qname in g.styleAttrs)&&(g.styleAttrs[v.qname]=f.styleAttrs[v.qname]):(y=f.styleAttrs[h.byName.fontSize.qname], g.styleAttrs[v.qname]="textContainer"===f.styleAttrs[h.byName.ruby.qname]?y:new p.ComputedLength(.5*y.rw,.5*y.rh)):(y=f.styleAttrs[h.byName.fontSize.qname],g.styleAttrs[v.qname]=new p.ComputedLength(.5*y.rw,.5*y.rh));for(var D in h.all)(w=h.all[D],w.qname in g.styleAttrs||w.qname===h.byName.position.qname&&h.byName.origin.qname in g.styleAttrs||w.qname===h.byName.origin.qname&&h.byName.position.qname in g.styleAttrs||(v=c.head.styling.initials[w.qname]||w.initial,"region"!==g.kind&&(!1!==w.inherit|| null===v)))||(g.styleAttrs[w.qname]=w.parse(v),B[w.qname]=!0);for(var J in h.all)if(D=h.all[J],D.qname in B&&null!==D.compute)if(w=D.compute(c,f,g,g.styleAttrs[D.qname],C),null!==w)g.styleAttrs[D.qname]=w;else if(D="Style '"+D.qname+"' on element '"+g.kind+"' cannot be computed",k&&k.error&&k.error(D))throw D;if("none"===g.styleAttrs[h.byName.display.qname])return null;if(null===f)var H=null===e?[]:[e];else"contents"in t&&(H=t.contents);for(var O in H)f=u(c,b,d,e,g,r,H[O],k,C),null!==f&&g.contents.push(f.element); for(var L in g.styleAttrs)(L===h.byName.rubyAlign.qname?"span"!==g.kind||"container"!==g.styleAttrs[h.byName.ruby.qname]:L===h.byName.rubyPosition.qname?"span"!==g.kind||"textContainer"!==g.styleAttrs[h.byName.ruby.qname]&&"text"!==g.styleAttrs[h.byName.ruby.qname]:-1===h.byQName[L].applies.indexOf(g.kind))&&delete g.styleAttrs[L];"span"===g.kind&&g.text&&"default"===g.space&&(c=g.text.replace(/\s+/g," "),g.text=c);if("p"===g.kind){c=[];q(g,c);b=0;d="after_br";for(e=0;;)if("after_br"===d)b>=c.length|| "br"===c[b].kind?(d="before_br",e=b,b--):("preserve"!==c[b].space&&(c[b].text=c[b].text.replace(/^\s+/g,"")),0<c[b].text.length?(d="looking_br",b++):c.splice(b,1));else if("before_br"===d)if(0>b||"br"===c[b].kind){if(d="after_br",b=e+1,b>=c.length)break}else if("preserve"!==c[b].space&&(c[b].text=c[b].text.replace(/\s+$/g,"")),0<c[b].text.length){if(d="after_br",b=e+1,b>=c.length)break}else c.splice(b,1),b--;else b>=c.length||"br"===c[b].kind?(d="before_br",e=b,b--):b++;a(g)}return"div"===g.kind&& h.byName.backgroundImage.qname in g.styleAttrs||"br"===g.kind||"image"===g.kind||"contents"in g&&0<g.contents.length||"span"===g.kind&&null!==g.text||"region"===g.kind&&"always"===g.styleAttrs[h.byName.showBackground.qname]?{region_id:r,element:g}:null}function q(a,b){if("contents"in a)for(var c in a.contents)q(a.contents[c],b);else"span"!==a.kind&&"br"!==a.kind||b.push(a)}function a(c){if("br"===c.kind)return!1;if("text"in c)return 0===c.text.length;if("contents"in c){for(var b=c.contents.length;b--;)a(c.contents[b])&& c.contents.splice(b,1);return 0===c.contents.length}}function e(a){this.contents=[];this.aspectRatio=a.aspectRatio}function m(a){this.kind=a.kind||"region";a.id&&(this.id=a.id);this.styleAttrs={};for(var b in a.styleAttrs)this.styleAttrs[b]=a.styleAttrs[b];"src"in a&&(this.src=a.src);"type"in a&&(this.type=a.type);if("text"in a)this.text=a.text;else if("region"===this.kind||"contents"in a)this.contents=[];"space"in a&&(this.space=a.space)}f.generateISD=function(a,b,d){var c=new e(a),m={},f;for(f in a.head.layout.regions){var h= u(a,b,a.head.layout.regions[f],a.body,null,"",a.head.layout.regions[f],d,m);null!==h&&c.contents.push(h.element)}return c}})("undefined"===typeof q?this.imscISD={}:q,"undefined"===typeof imscNames?f("./names"):imscNames,"undefined"===typeof imscStyles?f("./styles"):imscStyles,"undefined"===typeof imscUtils?f("./utils"):imscUtils)},{"./names":5,"./styles":6,"./utils":7}],4:[function(f,t,q){q.generateISD=f("./isd").generateISD;q.fromXML=f("./doc").fromXML;q.renderHTML=f("./html").render},{"./doc":1, "./html":2,"./isd":3}],5:[function(f,t,q){f="undefined"===typeof q?this.imscNames={}:q;f.ns_tt="http://www.w3.org/ns/ttml";f.ns_tts="http://www.w3.org/ns/ttml#styling";f.ns_ttp="http://www.w3.org/ns/ttml#parameter";f.ns_xml="http://www.w3.org/XML/1998/namespace";f.ns_itts="http://www.w3.org/ns/ttml/profile/imsc1#styling";f.ns_ittp="http://www.w3.org/ns/ttml/profile/imsc1#parameter";f.ns_smpte="http://www.smpte-ra.org/schemas/2052-1/2010/smpte-tt";f.ns_ebutts="urn:ebu:tt:style"},{}],6:[function(f, t,q){(function(f,r,h){function p(a,e,f,c,b,d,g,h){this.name=e;this.ns=a;this.qname=a+" "+e;this.inherit=b;this.animatable=d;this.initial=f;this.applies=c;this.parse=g;this.compute=h}f.all=[new p(r.ns_tts,"backgroundColor","transparent",["body","div","p","region","span"],!1,!0,h.parseColor,null),new p(r.ns_tts,"color","white",["span"],!0,!0,h.parseColor,null),new p(r.ns_tts,"direction","ltr",["p","span"],!0,!0,function(a){return a},null),new p(r.ns_tts,"display","auto",["body","div","p","region","span"], !1,!0,function(a){return a},null),new p(r.ns_tts,"displayAlign","before",["region"],!1,!0,function(a){return a},null),new p(r.ns_tts,"extent","auto",["tt","region"],!1,!0,function(a){if("auto"===a)return a;var e=a.split(" ");if(2!==e.length)return null;a=h.parseLength(e[0]);return(e=h.parseLength(e[1]))&&a?{h:e,w:a}:null},function(a,e,f,c,b){if("auto"===c)e=new h.ComputedLength(0,1);else if(e=h.toComputedLength(c.h.value,c.h.unit,null,a.dimensions.h,null,a.pxLength.h),null===e)return null;if("auto"=== c)a=new h.ComputedLength(1,0);else if(a=h.toComputedLength(c.w.value,c.w.unit,null,a.dimensions.w,null,a.pxLength.w),null===a)return null;return{h:e,w:a}}),new p(r.ns_tts,"fontFamily","default",["span"],!0,!0,function(a){a=a.split(",");var e=[],f;for(f in a)"'"!==a[f].charAt(0)&&'"'!==a[f].charAt(0)?"default"===a[f]?e.push("monospaceSerif"):e.push(a[f]):e.push(a[f]);return e},null),new p(r.ns_tts,"shear","0%",["p"],!0,!0,h.parseLength,function(a,e,f,c){if("%"===c.unit)a=100<Math.abs(c.value)?100* Math.sign(c.value):c.value;else return null;return a}),new p(r.ns_tts,"fontSize","1c",["span"],!0,!0,h.parseLength,function(a,e,m,c,b){return h.toComputedLength(c.value,c.unit,null!==e?e.styleAttrs[f.byName.fontSize.qname]:a.cellLength.h,null!==e?e.styleAttrs[f.byName.fontSize.qname]:a.cellLength.h,a.cellLength.h,a.pxLength.h)}),new p(r.ns_tts,"fontStyle","normal",["span"],!0,!0,function(a){return a},null),new p(r.ns_tts,"fontWeight","normal",["span"],!0,!0,function(a){return a},null),new p(r.ns_tts, "lineHeight","normal",["p"],!0,!0,function(a){return"normal"===a?a:h.parseLength(a)},function(a,e,m,c,b){if("normal"===c)a=c;else if(a=h.toComputedLength(c.value,c.unit,m.styleAttrs[f.byName.fontSize.qname],m.styleAttrs[f.byName.fontSize.qname],a.cellLength.h,a.pxLength.h),null===a)return null;return a}),new p(r.ns_tts,"opacity",1,["region"],!1,!0,parseFloat,null),new p(r.ns_tts,"origin","auto",["region"],!1,!0,function(a){if("auto"===a)return a;var e=a.split(" ");if(2!==e.length)return null;a=h.parseLength(e[0]); return(e=h.parseLength(e[1]))&&a?{h:e,w:a}:null},function(a,e,f,c,b){if("auto"===c)e=new h.ComputedLength(0,0);else if(e=h.toComputedLength(c.h.value,c.h.unit,null,a.dimensions.h,null,a.pxLength.h),null===e)return null;if("auto"===c)a=new h.ComputedLength(0,0);else if(a=h.toComputedLength(c.w.value,c.w.unit,null,a.dimensions.w,null,a.pxLength.w),null===a)return null;return{h:e,w:a}}),new p(r.ns_tts,"overflow","hidden",["region"],!1,!0,function(a){return a},null),new p(r.ns_tts,"padding","0px",["region"], !1,!0,function(a){a=a.split(" ");if(4<a.length)return null;var e=[],f;for(f in a){var c=h.parseLength(a[f]);if(!c)return null;e.push(c)}return e},function(a,e,m,c,b){if(1===c.length)e=[c[0],c[0],c[0],c[0]];else if(2===c.length)e=[c[0],c[1],c[0],c[1]];else if(3===c.length)e=[c[0],c[1],c[2],c[1]];else if(4===c.length)e=[c[0],c[1],c[2],c[3]];else return null;c=m.styleAttrs[f.byName.writingMode.qname];if("lrtb"===c||"lr"===c)e=[e[0],e[3],e[2],e[1]];else if("rltb"===c||"rl"===c)e=[e[0],e[1],e[2],e[3]]; else if("tblr"===c)e=[e[3],e[0],e[1],e[2]];else if("tbrl"===c||"tb"===c)e=[e[3],e[2],e[1],e[0]];else return null;c=[];for(var d in e)if(0===e[d].value)c[d]=new h.ComputedLength(0,0);else if(c[d]=h.toComputedLength(e[d].value,e[d].unit,m.styleAttrs[f.byName.fontSize.qname],"0"===d||"2"===d?m.styleAttrs[f.byName.extent.qname].h:m.styleAttrs[f.byName.extent.qname].w,"0"===d||"2"===d?a.cellLength.h:a.cellLength.w,"0"===d||"2"===d?a.pxLength.h:a.pxLength.w),null===c[d])return null;return c}),new p(r.ns_tts, "position","top left",["region"],!1,!0,function(a){return h.parsePosition(a)},function(a,e,m,c){e=h.toComputedLength(c.v.offset.value,c.v.offset.unit,null,new h.ComputedLength(-m.styleAttrs[f.byName.extent.qname].h.rw,a.dimensions.h.rh-m.styleAttrs[f.byName.extent.qname].h.rh),null,a.pxLength.h);if(null===e)return null;"bottom"===c.v.edge&&(e=new h.ComputedLength(-e.rw-m.styleAttrs[f.byName.extent.qname].h.rw,a.dimensions.h.rh-e.rh-m.styleAttrs[f.byName.extent.qname].h.rh));var b=h.toComputedLength(c.h.offset.value, c.h.offset.unit,null,new h.ComputedLength(a.dimensions.w.rw-m.styleAttrs[f.byName.extent.qname].w.rw,-m.styleAttrs[f.byName.extent.qname].w.rh),null,a.pxLength.w);if(null===e)return null;"right"===c.h.edge&&(b=new h.ComputedLength(a.dimensions.w.rw-b.rw-m.styleAttrs[f.byName.extent.qname].w.rw,-b.rh-m.styleAttrs[f.byName.extent.qname].w.rh));return{h:e,w:b}}),new p(r.ns_tts,"ruby","none",["span"],!1,!0,function(a){return a},null),new p(r.ns_tts,"rubyAlign","center",["span"],!0,!0,function(a){return"center"!== a&&"spaceAround"!==a?null:a},null),new p(r.ns_tts,"rubyPosition","outside",["span"],!0,!0,function(a){return a},null),new p(r.ns_tts,"rubyReserve","none",["p"],!0,!0,function(a){var e=a.split(" ");a=[null,null];if(0===e.length||2<e.length||"none"!==e[0]&&"both"!==e[0]&&"after"!==e[0]&&"before"!==e[0]&&"outside"!==e[0])return null;a[0]=e[0];if(2===e.length&&"none"!==e[0])if(e=h.parseLength(e[1]))a[1]=e;else return null;return a},function(a,e,m,c,b){if("none"===c[0])return c;a=null===c[1]?new h.ComputedLength(.5* m.styleAttrs[f.byName.fontSize.qname].rw,.5*m.styleAttrs[f.byName.fontSize.qname].rh):h.toComputedLength(c[1].value,c[1].unit,m.styleAttrs[f.byName.fontSize.qname],m.styleAttrs[f.byName.fontSize.qname],a.cellLength.h,a.pxLength.h);return null===a?null:[c[0],a]}),new p(r.ns_tts,"showBackground","always",["region"],!1,!0,function(a){return a},null),new p(r.ns_tts,"textAlign","start",["p"],!0,!0,function(a){return a},function(a,e,f,c,b){return"left"===c?"start":"right"===c?"end":c}),new p(r.ns_tts,"textCombine", "none",["span"],!0,!0,function(a){a=a.split(" ");if(1===a.length){if("none"===a[0]||"all"===a[0])return[a[0]];if("digits"===a[0])return[a[0],2]}else if(2===a.length&&"digits"===a[0]){var e=parseInt(a[1],10);if(!isNaN(e))return[a[0],e]}return null},null),new p(r.ns_tts,"textDecoration","none",["span"],!0,!0,function(a){return a.split(" ")},null),new p(r.ns_tts,"textEmphasis","none",["span"],!1,!0,function(a){a=a.split(" ");var e={style:"filled",symbol:"circle",color:null,position:null},f;for(f in a)if("none"=== a[f]||"auto"===a[f])e.style=a[f];else if("filled"===a[f]||"open"===a[f])e.style=a[f];else if("circle"===a[f]||"dot"===a[f]||"sesame"===a[f])e.symbol=a[f];else if("current"===a[f])e.color=a[f];else if("outside"===a[f])e.position="outside";else{if("before"===a[f]||"after"===a[f])return null;e.color=h.parseColor(a[f]);if(null===e.color)return null}return e},null),new p(r.ns_tts,"textOutline","none",["span"],!0,!0,function(a){if("none"===a)return a;var e={};a=a.split(" ");if(0===a.length||2<a.length)return null; var f=h.parseColor(a[0]);e.color=f;null!==f&&a.shift();if(1!==a.length)return null;a=h.parseLength(a[0]);if(!a)return null;e.thickness=a;return e},function(a,e,m,c,b){if("none"===c)return c;e={};e.color=null===c.color?m.styleAttrs[f.byName.color.qname]:c.color;e.thickness=h.toComputedLength(c.thickness.value,c.thickness.unit,m.styleAttrs[f.byName.fontSize.qname],m.styleAttrs[f.byName.fontSize.qname],a.cellLength.h,a.pxLength.h);return null===e.thickness?null:e}),new p(r.ns_tts,"textShadow","none", ["span"],!0,!0,h.parseTextShadow,function(a,e,m,c){if("none"===c)return c;e=[];for(var b in c){var d={};d.x_off=h.toComputedLength(c[b][0].value,c[b][0].unit,null,m.styleAttrs[f.byName.fontSize.qname],null,a.pxLength.w);if(null===d.x_off)return null;d.y_off=h.toComputedLength(c[b][1].value,c[b][1].unit,null,m.styleAttrs[f.byName.fontSize.qname],null,a.pxLength.h);if(null===d.y_off)return null;if(null===c[b][2])d.b_radius=0;else if(d.b_radius=h.toComputedLength(c[b][2].value,c[b][2].unit,null,m.styleAttrs[f.byName.fontSize.qname], null,a.pxLength.h),null===d.b_radius)return null;d.color=null===c[b][3]?m.styleAttrs[f.byName.color.qname]:c[b][3];e.push(d)}return e}),new p(r.ns_tts,"unicodeBidi","normal",["span","p"],!1,!0,function(a){return a},null),new p(r.ns_tts,"visibility","visible",["body","div","p","region","span"],!0,!0,function(a){return a},null),new p(r.ns_tts,"wrapOption","wrap",["span"],!0,!0,function(a){return a},null),new p(r.ns_tts,"writingMode","lrtb",["region"],!1,!0,function(a){return a},null),new p(r.ns_tts, "zIndex","auto",["region"],!1,!0,function(a){"auto"!==a&&(a=parseInt(a),isNaN(a)&&(a=null));return a},null),new p(r.ns_ebutts,"linePadding","0c",["p"],!0,!1,h.parseLength,function(a,e,f,c,b){return h.toComputedLength(c.value,c.unit,null,null,a.cellLength.w,null)}),new p(r.ns_ebutts,"multiRowAlign","auto",["p"],!0,!1,function(a){return a},null),new p(r.ns_smpte,"backgroundImage",null,["div"],!1,!1,function(a){return a},null),new p(r.ns_itts,"forcedDisplay","false",["body","div","p","region","span"], !0,!0,function(a){return"true"===a?!0:!1},null),new p(r.ns_itts,"fillLineGap","false",["p"],!0,!0,function(a){return"true"===a?!0:!1},null)];f.byQName={};for(var u in f.all)f.byQName[f.all[u].qname]=f.all[u];f.byName={};for(var q in f.all)f.byName[f.all[q].name]=f.all[q]})("undefined"===typeof q?this.imscStyles={}:q,"undefined"===typeof imscNames?f("./names"):imscNames,"undefined"===typeof imscUtils?f("./utils"):imscUtils)},{"./names":5,"./utils":7}],7:[function(f,t,q){(function(f){var r=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?/, h=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/,p=/rgba\(\s*(\d+),\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/,q={transparent:[0,0,0,0],black:[0,0,0,255],silver:[192,192,192,255],gray:[128,128,128,255],white:[255,255,255,255],maroon:[128,0,0,255],red:[255,0,0,255],purple:[128,0,128,255],fuchsia:[255,0,255,255],magenta:[255,0,255,255],green:[0,128,0,255],lime:[0,255,0,255],olive:[128,128,0,255],yellow:[255,255,0,255],navy:[0,0,128,255],blue:[0,0,255,255],teal:[0,128,128,255],aqua:[0,255,255,255],cyan:[0, 255,255,255]};f.parseColor=function(a){var e,f=null;a in q?f=q[a]:null!==(e=r.exec(a))?f=[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16),void 0!==e[4]?parseInt(e[4],16):255]:null!==(e=h.exec(a))?f=[parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),255]:null!==(e=p.exec(a))&&(f=[parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseInt(e[4])]);return f};var t=/^((?:\+|\-)?\d*(?:\.\d+)?)(px|em|c|%|rh|rw)$/;f.parseLength=function(a){var e,f=null;null!==(e=t.exec(a))&&(f={value:parseFloat(e[1]),unit:e[2]}); return f};f.parseTextShadow=function(a){a=a.split(",");var e=[],h;for(h in a){var c=a[h].split(" ");if(1===c.length&&"none"===c[0])return"none";if(1<c.length&&5>c.length){var b=[null,null,null,null],d=f.parseLength(c.shift());if(null===d)return null;b[0]=d;d=f.parseLength(c.shift());if(null===d)return null;b[1]=d;if(0!==c.length&&(d=f.parseLength(c[0]),null!==d&&(b[2]=d,c.shift()),0!==c.length)){c=f.parseColor(c[0]);if(null===c)return null;b[3]=c}e.push(b)}}return e};f.parsePosition=function(a){a= a.split(" ");var e=function(a){return"center"===a||"left"===a||"top"===a||"bottom"===a||"right"===a};if(4<a.length)return null;for(var h in a)if(!e(a[h])){var c=f.parseLength(a[h]);if(null===c)return null;a[h]=c}h={h:{edge:"left",offset:{value:50,unit:"%"}},v:{edge:"top",offset:{value:50,unit:"%"}}};for(c=0;c<a.length;){var b=a[c++];if(e(b)){var d={value:0,unit:"%"};2!==a.length&&c<a.length&&!e(a[c])&&(d=a[c++]);"right"===b?(h.h.edge=b,h.h.offset=d):"bottom"===b?(h.v.edge=b,h.v.offset=d):"left"=== b?h.h.offset=d:"top"===b&&(h.v.offset=d)}else if(1===a.length||2===a.length)1===c?h.h.offset=b:h.v.offset=b;else return null}return h};f.ComputedLength=function(a,e){this.rw=a;this.rh=e};f.ComputedLength.prototype.toUsedLength=function(a,e){return a*this.rw+e*this.rh};f.toComputedLength=function