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