diff --git a/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/dash.all.min.js b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/dash.all.min.js new file mode 100644 index 000000000..48284b9f5 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/dash.all.min.js @@ -0,0 +1,6 @@ +function X2JS(e,t,n){function r(e){var t=e.localName;return null==t&&(t=e.baseName),(null==t||""==t)&&(t=e.nodeName),t}function i(e){return e.prefix}function o(e){return"string"==typeof e?e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/"):e}function a(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(///g,"/")}function s(o){if(o.nodeType==b.DOCUMENT_NODE){var u,l,d,c=o.firstChild;for(l=0,d=o.childNodes.length;d>l;l+=1)if(o.childNodes[l].nodeType!==b.COMMENT_NODE){c=o.childNodes[l];break}if(n)u=s(c);else{u={};var f=r(c);u[f]=s(c)}return u}if(o.nodeType==b.ELEMENT_NODE){var u=new Object;u.__cnt=0;for(var g=o.childNodes,h=0;hS;S++){var P=e[S];P.test.call(this,v.value)&&(E=P.converter.call(this,v.value))}u[t+v.name]=E}var T=i(o);return null!=T&&""!=T&&(u.__cnt++,u.__prefix=T),1==u.__cnt&&null!=u["#text"]&&(u=u["#text"]),null!=u["#text"]&&(u.__text=u["#text"],M&&(u.__text=a(u.__text)),delete u["#text"],delete u["#text_asArray"]),null!=u["#cdata-section"]&&(u.__cdata=u["#cdata-section"],delete u["#cdata-section"],delete u["#cdata-section_asArray"]),(null!=u.__text||null!=u.__cdata)&&(u.toString=function(){return(null!=this.__text?this.__text:"")+(null!=this.__cdata?this.__cdata:"")}),u}return o.nodeType==b.TEXT_NODE||o.nodeType==b.CDATA_SECTION_NODE?o.nodeValue:o.nodeType==b.COMMENT_NODE?null:void 0}function u(e,t,n,r){var i="<"+(null!=e&&null!=e.__prefix?e.__prefix+":":"")+t;if(null!=n)for(var o=0;o":">"}function l(e,t){return""}function d(e,t){return-1!==e.indexOf(t,e.length-t.length)}function c(e,t){return d(t.toString(),"_asArray")||0==t.toString().indexOf("_")||e[t]instanceof Function?!0:!1}function f(e){var t=0;if(e instanceof Object)for(var n in e)c(e,n)||t++;return t}function g(e){var t=[];if(e instanceof Object)for(var n in e)-1==n.toString().indexOf("__")&&0==n.toString().indexOf("_")&&t.push(n);return t}function h(e){var t="";return null!=e.__cdata&&(t+=""),null!=e.__text&&(t+=M?o(e.__text):e.__text),t}function p(e){var t="";return e instanceof Object?t+=h(e):null!=e&&(t+=M?o(e):e),t}function m(e,t,n){var r="";if(0==e.length)r+=u(e,t,n,!0);else for(var i=0;i0)for(var r in e)if(!c(e,r)){var i=e[r],o=g(i);if(null==i||void 0==i)t+=u(i,r,o,!0);else if(i instanceof Object)if(i instanceof Array)t+=m(i,r,o);else{var a=f(i);a>0||null!=i.__text||null!=i.__cdata?(t+=u(i,r,o,!1),t+=y(i),t+=l(i,r)):t+=u(i,r,o,!0)}else t+=u(i,r,o,!1),t+=p(i),t+=l(i,r)}return t+=p(e)}(null===t||void 0===t)&&(t="_"),(null===n||void 0===n)&&(n=!1);var v="1.0.11",M=!1,b={ELEMENT_NODE:1,TEXT_NODE:3,CDATA_SECTION_NODE:4,COMMENT_NODE:8,DOCUMENT_NODE:9};this.parseXmlString=function(e){var t;if(window.DOMParser){var n=new window.DOMParser;t=n.parseFromString(e,"text/xml")}else 0==e.indexOf("")+2)),t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e);return t},this.xml2json=function(e){return s(e)},this.xml_str2json=function(e){var t=this.parseXmlString(e);return this.xml2json(t)},this.json2xml_str=function(e){return y(e)},this.json2xml=function(e){var t=this.json2xml_str(e);return this.parseXmlString(t)},this.getVersion=function(){return v},this.escapeMode=function(e){M=e}}function ObjectIron(e){var t;for(t=[],i=0,len=e.length;len>i;i+=1)t.push(e[i].isRoot?"root":e[i].name);var n=function(e,t){var n;if(null!==e&&null!==t)for(n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||(t[n]=e[n]))},r=function(e,t,r){var i,o,a,s,u;if(null!==e&&0!==e.length)for(i=0,o=e.length;o>i;i+=1)a=e[i],t.hasOwnProperty(a.name)&&(r.hasOwnProperty(a.name)?a.merge&&(s=t[a.name],u=r[a.name],"object"==typeof s&&"object"==typeof u?n(s,u):r[a.name]=null!=a.mergeFunction?a.mergeFunction(s,u):s+u):r[a.name]=t[a.name])},o=function(e,t){var n,i,a,s,u,l,d,c=e;if(null!==c.children&&0!==c.children.length)for(n=0,i=c.children.length;i>n;n+=1)if(l=c.children[n],t.hasOwnProperty(l.name))if(l.isArray)for(u=t[l.name+"_asArray"],a=0,s=u.length;s>a;a+=1)d=u[a],r(c.properties,t,d),o(l,d);else d=t[l.name],r(c.properties,t,d),o(l,d)},a=function(n){var r,i,s,u,l,d,c;if(null===n)return n;if("object"!=typeof n)return n;for(r=0,i=t.length;i>r;r+=1)"root"===t[r]&&(l=e[r],d=n,o(l,d));for(u in n)if(n.hasOwnProperty(u)){if(s=t.indexOf(u),-1!==s)if(l=e[s],l.isArray)for(c=n[u+"_asArray"],r=0,i=c.length;i>r;r+=1)d=c[r],o(l,d);else d=n[u],o(l,d);a(n[u])}return n};return{run:a}}if(function(e){e(void 0,Q={})}(function(e,t){function n(e,t){t.stack&&"object"==typeof e&&null!==e&&e.stack&&-1===e.stack.indexOf(F)&&(e.stack=r(e.stack)+"\n"+F+"\n"+r(t.stack))}function r(e){for(var e=e.split("\n"),t=[],n=0;n=w&&K>=o}else r=!1;!r&&!(-1!==i.indexOf("(module.js:")||-1!==i.indexOf("(node.js:"))&&t.push(i)}return t.join("\n")}function i(){if(Error.captureStackTrace){var e,t,n=Error.prepareStackTrace;return Error.prepareStackTrace=function(n,r){e=r[1].getFileName(),t=r[1].getLineNumber()},Error().stack,Error.prepareStackTrace=n,S=e,t}}function o(e,t,n){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t+" is deprecated, use "+n+" instead.",Error("").stack),e.apply(e,arguments)}}function a(){function e(e){n&&(t=g(e),A(n,function(e,n){R(function(){t.promiseDispatch.apply(t,n)})},void 0),r=n=void 0)}var t,n=[],r=[],i=I(a.prototype),o=I(s.prototype);return o.promiseDispatch=function(e,i,o){var a=C(arguments);n?(n.push(a),"when"===i&&o[1]&&r.push(o[1])):R(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){return n?o:t.valueOf()},Error.captureStackTrace&&(Error.captureStackTrace(o,a),o.stack=o.stack.substring(o.stack.indexOf("\n")+1)),T(o),i.promise=o,i.resolve=e,i.reject=function(t){e(f(t))},i.notify=function(e){n&&A(r,function(t,n){R(function(){n(e)})},void 0)},i}function s(e,t,n,r){void 0===t&&(t=function(e){return f(Error("Promise does not support operation: "+e))});var i=I(s.prototype);return i.promiseDispatch=function(n,r,o){var a;try{a=e[r]?e[r].apply(i,o):t.call(i,r,o)}catch(s){a=f(s)}n&&n(a)},n&&(i.valueOf=n),r&&(i.exception=r),T(i),i}function u(e){return l(e)?e.valueOf():e}function l(e){return e&&"function"==typeof e.promiseDispatch}function d(e){return!l(u(e))}function c(e){return e=u(e),l(e)&&"exception"in e}function f(e){var e=e||Error(),t=s({when:function(t){if(t){var n=B(Q,this);-1!==n&&(j.splice(n,1),Q.splice(n,1))}return t?t(e):f(e)}},function(){return f(e)},function(){return this},e);return!U&&"undefined"!=typeof window&&!window.Touch&&window.console&&console.log("Should be empty:",j),U=!0,Q.push(t),j.push(e),t}function g(e){if(l(e))return e;if((e=u(e))&&"function"==typeof e.then){var t=a();return e.then(t.resolve,t.reject,t.notify),t.promise}return s({when:function(){return e},get:function(t){return e[t]},put:function(t,n){return e[t]=n,e},del:function(t){return delete e[t],e},post:function(t,n){return e[t].apply(e,n)},apply:function(t){return e.apply(void 0,t)},keys:function(){return q(e)}},void 0,function(){return e})}function h(e,t,r,i){function o(e){try{return t?t(e):e}catch(n){return f(n)}}function s(e){if(r){n(e,d);try{return r(e)}catch(t){return f(t)}}return f(e)}var u=a(),l=!1,d=g(e);return R(function(){d.promiseDispatch(function(e){l||(l=!0,u.resolve(o(e)))},"when",[function(e){l||(l=!0,u.resolve(s(e)))}])}),d.promiseDispatch(void 0,"when",[void 0,function(e){u.notify(i?i(e):e)}]),u.promise}function p(e,t,n){return h(e,function(e){return M(e).then(function(e){return t.apply(void 0,e)},n)},n)}function m(e,t,n){var r=a();return R(function(){g(e).promiseDispatch(r.resolve,t,n)}),r.promise}function y(e){return function(t){var n=C(arguments,1);return m(t,e,n)}}function v(e){var t=C(arguments,1);return V(e,t)}function M(e){return h(e,function(e){var t=e.length;if(0===t)return g(e);var n=a();return A(e,function(r,i,o){d(i)?(e[o]=u(i),0===--t&&n.resolve(e)):h(i,function(r){e[o]=r,0===--t&&n.resolve(e)}).fail(n.reject)},void 0),n.promise})}function b(e,t){return h(e,void 0,t)}function E(e,t){var n=C(arguments,2),r=a();return n.push(r.makeNodeResolver()),H(e,t,n).fail(r.reject),r.promise}var S,w=i(),P=function(){},T=Object.freeze||P;"undefined"!=typeof cajaVM&&(T=cajaVM.def);var R;if("undefined"!=typeof process)R=process.nextTick;else if("function"==typeof setImmediate)R=setImmediate;else if("undefined"!=typeof MessageChannel){var _=new MessageChannel,L={},x=L;_.port1.onmessage=function(){L=L.next;var e=L.task;delete L.task,e()},R=function(e){x=x.next={task:e},_.port2.postMessage(0)}}else R=function(e){setTimeout(e,0)};var O;Function.prototype.bind?(O=Function.prototype.bind,O=O.bind(O.call)):O=function(e){return function(){return e.call.apply(e,arguments)}};var D,C=O(Array.prototype.slice),A=O(Array.prototype.reduce||function(e,t){var n=0,r=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=r)throw new TypeError}for(;r>n;n++)n in this&&(t=e(t,this[n],n));return t}),B=O(Array.prototype.indexOf||function(e){for(var t=0;t2?C(arguments,1):n)}},t.promise=function(e){var t=a();return v(e,t.resolve,t.reject,t.notify).fail(t.reject),t.promise},t.makePromise=s,s.prototype.then=function(e,t,n){return h(this,e,t,n)},s.prototype.thenResolve=function(e){return h(this,function(){return e})},A("isResolved isFulfilled isRejected dispatch when spread get put del post send invoke keys fapply fcall fbind all allResolved timeout delay catch finally fail fin progress end done nfcall nfapply nfbind ncall napply nbind npost nsend ninvoke nend nodeify".split(" "),function(e,n){s.prototype[n]=function(){return t[n].apply(t,[this].concat(C(arguments)))}},void 0),s.prototype.toSource=function(){return this.toString()},s.prototype.toString=function(){return"[object Promise]"},T(s.prototype),t.nearer=u,t.isPromise=l,t.isResolved=function(e){return d(e)||c(e)},t.isFulfilled=d,t.isRejected=c;var U,Q=[],j=[];t.reject=f,t.resolve=g,t.master=function(e){return s({isDef:function(){}},function(t,n){return m(e,t,n)},function(){return u(e)})},t.when=h,t.spread=p,t.async=function(e){return function(){function t(e,t){var o;try{o=n[e](t)}catch(a){return"[object StopIteration]"===k(a)||a instanceof D?a.value:f(a)}return h(o,r,i)}var n=e.apply(this,arguments),r=t.bind(t,"send"),i=t.bind(t,"throw");return r()}},t["return"]=function(e){throw new D(e)},t.promised=function(e){return function(){return p([this,M(arguments)],function(t,n){return e.apply(t,n)})}},t.dispatch=m,t.dispatcher=y,t.get=y("get"),t.put=y("put"),t["delete"]=t.del=y("del");var H=t.post=y("post");t.send=function(e,t){var n=C(arguments,2);return H(e,t,n)},t.invoke=o(t.send,"invoke","send");var V=t.fapply=y("apply");t["try"]=v,t.fcall=v,t.fbind=function(e){var t=C(arguments,1);return function(){var n=t.concat(C(arguments));return V(e,n)}},t.keys=y("keys"),t.all=M,t.allResolved=function(e){return h(e,function(e){return h(M(N(e,function(e){return h(e,P,P)})),function(){return N(e,g)})})},t["catch"]=t.fail=b,t.progress=function(e,t){return h(e,void 0,void 0,t)},t["finally"]=t.fin=function(e,t){return h(e,function(e){return h(t(),function(){return e})},function(e){return h(t(),function(){return f(e)})})},t.done=function(e,r,i,o){r=r||i||o?h(e,r,i,o):e,b(r,function(r){R(function(){if(n(r,e),!t.onerror)throw r;t.onerror(r)})})},t.timeout=function(e,t){var n=a(),r=setTimeout(function(){n.reject(Error("Timed out after "+t+" ms"))},t);return h(e,function(e){clearTimeout(r),n.resolve(e)},function(e){clearTimeout(r),n.reject(e)}),n.promise},t.delay=function(e,t){void 0===t&&(t=e,e=void 0);var n=a();return setTimeout(function(){n.resolve(e)},t),n.promise},t.nfapply=function(e,t){var n=C(t),r=a();return n.push(r.makeNodeResolver()),V(e,n).fail(r.reject),r.promise},t.nfcall=function(e){var t=C(arguments,1),n=a();return t.push(n.makeNodeResolver()),V(e,t).fail(n.reject),n.promise},t.nfbind=function(e){var t=C(arguments,1);return function(){var n=t.concat(C(arguments)),r=a();return n.push(r.makeNodeResolver()),V(e,n).fail(r.reject),r.promise}},t.npost=function(e,t,n){var n=C(n),r=a();return n.push(r.makeNodeResolver()),H(e,t,n).fail(r.reject),r.promise},t.nsend=E,t.ninvoke=o(E,"ninvoke","nsend"),t.nodeify=function(e,t){return t?void e.then(function(e){R(function(){t(null,e)})},function(e){R(function(){t(e)})}):e};var K=i()}),function(e){"use strict";var t={VERSION:"0.5.3"};t.System=function(){this._mappings={},this._outlets={},this._handlers={},this.strictInjections=!0,this.autoMapOutlets=!1,this.postInjectionHook="setup"},t.System.prototype={_createAndSetupInstance:function(e,t){var n=new t;return this.injectInto(n,e),n},_retrieveFromCacheOrCreate:function(e,t){"undefined"==typeof t&&(t=!1);var n;if(!this._mappings.hasOwnProperty(e))throw new Error(1e3);var r=this._mappings[e];return!t&&r.isSingleton?(null==r.object&&(r.object=this._createAndSetupInstance(e,r.clazz)),n=r.object):n=r.clazz?this._createAndSetupInstance(e,r.clazz):r.object,n},mapOutlet:function(e,t,n){if("undefined"==typeof e)throw new Error(1010);return t=t||"global",n=n||e,this._outlets.hasOwnProperty(t)||(this._outlets[t]={}),this._outlets[t][n]=e,this},getObject:function(e){if("undefined"==typeof e)throw new Error(1020);return this._retrieveFromCacheOrCreate(e)},mapValue:function(e,t){if("undefined"==typeof e)throw new Error(1030);return this._mappings[e]={clazz:null,object:t,isSingleton:!0},this.autoMapOutlets&&this.mapOutlet(e),this.hasMapping(e)&&this.injectInto(t,e),this},hasMapping:function(e){if("undefined"==typeof e)throw new Error(1040);return this._mappings.hasOwnProperty(e)},mapClass:function(e,t){if("undefined"==typeof e)throw new Error(1050);if("undefined"==typeof t)throw new Error(1051);return this._mappings[e]={clazz:t,object:null,isSingleton:!1},this.autoMapOutlets&&this.mapOutlet(e),this},mapSingleton:function(e,t){if("undefined"==typeof e)throw new Error(1060);if("undefined"==typeof t)throw new Error(1061);return this._mappings[e]={clazz:t,object:null,isSingleton:!0},this.autoMapOutlets&&this.mapOutlet(e),this},instantiate:function(e){if("undefined"==typeof e)throw new Error(1070);return this._retrieveFromCacheOrCreate(e,!0)},injectInto:function(e,t){if("undefined"==typeof e)throw new Error(1080);if("object"==typeof e){var n=[];this._outlets.hasOwnProperty("global")&&n.push(this._outlets.global),"undefined"!=typeof t&&this._outlets.hasOwnProperty(t)&&n.push(this._outlets[t]);for(var r in n){var i=n[r];for(var o in i){var a=i[o];(!this.strictInjections||o in e)&&(e[o]=this.getObject(a))}}"setup"in e&&e.setup.call(e)}return this},unmap:function(e){if("undefined"==typeof e)throw new Error(1090);return delete this._mappings[e],this},unmapOutlet:function(e,t){if("undefined"==typeof e)throw new Error(1100);if("undefined"==typeof t)throw new Error(1101);return delete this._outlets[e][t],this},mapHandler:function(e,t,n,r,i){if("undefined"==typeof e)throw new Error(1110);return t=t||"global",n=n||e,"undefined"==typeof r&&(r=!1),"undefined"==typeof i&&(i=!1),this._handlers.hasOwnProperty(e)||(this._handlers[e]={}),this._handlers[e].hasOwnProperty(t)||(this._handlers[e][t]=[]),this._handlers[e][t].push({handler:n,oneShot:r,passEvent:i}),this},unmapHandler:function(e,t,n){if("undefined"==typeof e)throw new Error(1120);if(t=t||"global",n=n||e,this._handlers.hasOwnProperty(e)&&this._handlers[e].hasOwnProperty(t)){var r=this._handlers[e][t];for(var i in r){var o=r[i];if(o.handler===n){r.splice(i,1);break}}}return this},notify:function(e){if("undefined"==typeof e)throw new Error(1130);var t=Array.prototype.slice.call(arguments),n=t.slice(1);if(this._handlers.hasOwnProperty(e)){var r=this._handlers[e];for(var i in r){var o,a=r[i];"global"!==i&&(o=this.getObject(i));var s,u,l=[];for(s=0,u=a.length;u>s;s++){var d,c=a[s];d=o&&"string"==typeof c.handler?o[c.handler]:c.handler,c.oneShot&&l.unshift(s),c.passEvent?d.apply(o,t):d.apply(o,n)}for(s=0,u=l.length;u>s;s++)a.splice(l[s],1)}}return this}},e.dijon=t}(this),"undefined"==typeof utils)var utils={};"undefined"==typeof utils.Math&&(utils.Math={}),utils.Math.to64BitNumber=function(e,t){var n,r,i;return n=new goog.math.Long(0,t),r=new goog.math.Long(e,0),i=n.add(r),i.toNumber()},goog={},goog.math={},goog.math.Long=function(e,t){this.low_=0|e,this.high_=0|t},goog.math.Long.IntCache_={},goog.math.Long.fromInt=function(e){if(e>=-128&&128>e){var t=goog.math.Long.IntCache_[e];if(t)return t}var n=new goog.math.Long(0|e,0>e?-1:0);return e>=-128&&128>e&&(goog.math.Long.IntCache_[e]=n),n},goog.math.Long.fromNumber=function(e){return isNaN(e)||!isFinite(e)?goog.math.Long.ZERO:e<=-goog.math.Long.TWO_PWR_63_DBL_?goog.math.Long.MIN_VALUE:e+1>=goog.math.Long.TWO_PWR_63_DBL_?goog.math.Long.MAX_VALUE:0>e?goog.math.Long.fromNumber(-e).negate():new goog.math.Long(0|e%goog.math.Long.TWO_PWR_32_DBL_,0|e/goog.math.Long.TWO_PWR_32_DBL_)},goog.math.Long.fromBits=function(e,t){return new goog.math.Long(e,t)},goog.math.Long.fromString=function(e,t){if(0==e.length)throw Error("number format error: empty string");var n=t||10;if(2>n||n>36)throw Error("radix out of range: "+n);if("-"==e.charAt(0))return goog.math.Long.fromString(e.substring(1),n).negate();if(e.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+e);for(var r=goog.math.Long.fromNumber(Math.pow(n,8)),i=goog.math.Long.ZERO,o=0;oa){var u=goog.math.Long.fromNumber(Math.pow(n,a));i=i.multiply(u).add(goog.math.Long.fromNumber(s))}else i=i.multiply(r),i=i.add(goog.math.Long.fromNumber(s))}return i},goog.math.Long.TWO_PWR_16_DBL_=65536,goog.math.Long.TWO_PWR_24_DBL_=1<<24,goog.math.Long.TWO_PWR_32_DBL_=goog.math.Long.TWO_PWR_16_DBL_*goog.math.Long.TWO_PWR_16_DBL_,goog.math.Long.TWO_PWR_31_DBL_=goog.math.Long.TWO_PWR_32_DBL_/2,goog.math.Long.TWO_PWR_48_DBL_=goog.math.Long.TWO_PWR_32_DBL_*goog.math.Long.TWO_PWR_16_DBL_,goog.math.Long.TWO_PWR_64_DBL_=goog.math.Long.TWO_PWR_32_DBL_*goog.math.Long.TWO_PWR_32_DBL_,goog.math.Long.TWO_PWR_63_DBL_=goog.math.Long.TWO_PWR_64_DBL_/2,goog.math.Long.ZERO=goog.math.Long.fromInt(0),goog.math.Long.ONE=goog.math.Long.fromInt(1),goog.math.Long.NEG_ONE=goog.math.Long.fromInt(-1),goog.math.Long.MAX_VALUE=goog.math.Long.fromBits(-1,2147483647),goog.math.Long.MIN_VALUE=goog.math.Long.fromBits(0,-2147483648),goog.math.Long.TWO_PWR_24_=goog.math.Long.fromInt(1<<24),goog.math.Long.prototype.toInt=function(){return this.low_},goog.math.Long.prototype.toNumber=function(){return this.high_*goog.math.Long.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},goog.math.Long.prototype.toString=function(e){var t=e||10;if(2>t||t>36)throw Error("radix out of range: "+t);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(goog.math.Long.MIN_VALUE)){var n=goog.math.Long.fromNumber(t),r=this.div(n),i=r.multiply(n).subtract(this);return r.toString(t)+i.toInt().toString(t)}return"-"+this.negate().toString(t)}for(var o=goog.math.Long.fromNumber(Math.pow(t,6)),i=this,a="";;){var s=i.div(o),u=i.subtract(s.multiply(o)).toInt(),l=u.toString(t);if(i=s,i.isZero())return l+a;for(;l.length<6;)l="0"+l;a=""+l+a}},goog.math.Long.prototype.getHighBits=function(){return this.high_},goog.math.Long.prototype.getLowBits=function(){return this.low_},goog.math.Long.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:goog.math.Long.TWO_PWR_32_DBL_+this.low_},goog.math.Long.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(goog.math.Long.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var e=0!=this.high_?this.high_:this.low_,t=31;t>0&&0==(e&1<0},goog.math.Long.prototype.greaterThanOrEqual=function(e){return this.compare(e)>=0},goog.math.Long.prototype.compare=function(e){if(this.equals(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.subtract(e).isNegative()?-1:1},goog.math.Long.prototype.negate=function(){return this.equals(goog.math.Long.MIN_VALUE)?goog.math.Long.MIN_VALUE:this.not().add(goog.math.Long.ONE)},goog.math.Long.prototype.add=function(e){var t=this.high_>>>16,n=65535&this.high_,r=this.low_>>>16,i=65535&this.low_,o=e.high_>>>16,a=65535&e.high_,s=e.low_>>>16,u=65535&e.low_,l=0,d=0,c=0,f=0;return f+=i+u,c+=f>>>16,f&=65535,c+=r+s,d+=c>>>16,c&=65535,d+=n+a,l+=d>>>16,d&=65535,l+=t+o,l&=65535,goog.math.Long.fromBits(c<<16|f,l<<16|d)},goog.math.Long.prototype.subtract=function(e){return this.add(e.negate())},goog.math.Long.prototype.multiply=function(e){if(this.isZero())return goog.math.Long.ZERO;if(e.isZero())return goog.math.Long.ZERO;if(this.equals(goog.math.Long.MIN_VALUE))return e.isOdd()?goog.math.Long.MIN_VALUE:goog.math.Long.ZERO;if(e.equals(goog.math.Long.MIN_VALUE))return this.isOdd()?goog.math.Long.MIN_VALUE:goog.math.Long.ZERO;if(this.isNegative())return e.isNegative()?this.negate().multiply(e.negate()):this.negate().multiply(e).negate();if(e.isNegative())return this.multiply(e.negate()).negate();if(this.lessThan(goog.math.Long.TWO_PWR_24_)&&e.lessThan(goog.math.Long.TWO_PWR_24_))return goog.math.Long.fromNumber(this.toNumber()*e.toNumber());var t=this.high_>>>16,n=65535&this.high_,r=this.low_>>>16,i=65535&this.low_,o=e.high_>>>16,a=65535&e.high_,s=e.low_>>>16,u=65535&e.low_,l=0,d=0,c=0,f=0;return f+=i*u,c+=f>>>16,f&=65535,c+=r*u,d+=c>>>16,c&=65535,c+=i*s,d+=c>>>16,c&=65535,d+=n*u,l+=d>>>16,d&=65535,d+=r*s,l+=d>>>16,d&=65535,d+=i*a,l+=d>>>16,d&=65535,l+=t*u+n*s+r*a+i*o,l&=65535,goog.math.Long.fromBits(c<<16|f,l<<16|d)},goog.math.Long.prototype.div=function(e){if(e.isZero())throw Error("division by zero");if(this.isZero())return goog.math.Long.ZERO;if(this.equals(goog.math.Long.MIN_VALUE)){if(e.equals(goog.math.Long.ONE)||e.equals(goog.math.Long.NEG_ONE))return goog.math.Long.MIN_VALUE;if(e.equals(goog.math.Long.MIN_VALUE))return goog.math.Long.ONE;var t=this.shiftRight(1),n=t.div(e).shiftLeft(1);if(n.equals(goog.math.Long.ZERO))return e.isNegative()?goog.math.Long.ONE:goog.math.Long.NEG_ONE;var r=this.subtract(e.multiply(n)),i=n.add(r.div(e));return i}if(e.equals(goog.math.Long.MIN_VALUE))return goog.math.Long.ZERO;if(this.isNegative())return e.isNegative()?this.negate().div(e.negate()):this.negate().div(e).negate();if(e.isNegative())return this.div(e.negate()).negate();for(var o=goog.math.Long.ZERO,r=this;r.greaterThanOrEqual(e);){for(var n=Math.max(1,Math.floor(r.toNumber()/e.toNumber())),a=Math.ceil(Math.log(n)/Math.LN2),s=48>=a?1:Math.pow(2,a-48),u=goog.math.Long.fromNumber(n),l=u.multiply(e);l.isNegative()||l.greaterThan(r);)n-=s,u=goog.math.Long.fromNumber(n),l=u.multiply(e);u.isZero()&&(u=goog.math.Long.ONE),o=o.add(u),r=r.subtract(l)}return o},goog.math.Long.prototype.modulo=function(e){return this.subtract(this.div(e).multiply(e))},goog.math.Long.prototype.not=function(){return goog.math.Long.fromBits(~this.low_,~this.high_)},goog.math.Long.prototype.and=function(e){return goog.math.Long.fromBits(this.low_&e.low_,this.high_&e.high_)},goog.math.Long.prototype.or=function(e){return goog.math.Long.fromBits(this.low_|e.low_,this.high_|e.high_)},goog.math.Long.prototype.xor=function(e){return goog.math.Long.fromBits(this.low_^e.low_,this.high_^e.high_)},goog.math.Long.prototype.shiftLeft=function(e){if(e&=63,0==e)return this;var t=this.low_;if(32>e){var n=this.high_;return goog.math.Long.fromBits(t<>>32-e)}return goog.math.Long.fromBits(0,t<e){var n=this.low_;return goog.math.Long.fromBits(n>>>e|t<<32-e,t>>e)}return goog.math.Long.fromBits(t>>e-32,t>=0?0:-1)},goog.math.Long.prototype.shiftRightUnsigned=function(e){if(e&=63,0==e)return this;var t=this.high_;if(32>e){var n=this.low_;return goog.math.Long.fromBits(n>>>e|t<<32-e,t>>>e)}return 32==e?goog.math.Long.fromBits(t,0):goog.math.Long.fromBits(t>>>e-32,0)};var UTF8={};UTF8.encode=function(e){for(var t=[],n=0;nr?t.push(r):2048>r?(t.push(192|r>>6),t.push(128|63&r)):65536>r?(t.push(224|r>>12),t.push(128|63&r>>6),t.push(128|63&r)):(t.push(240|r>>18),t.push(128|63&r>>12),t.push(128|63&r>>6),t.push(128|63&r))}return t},UTF8.decode=function(e){for(var t=[],n=0;nr||(224>r?(r=(31&r)<<6,r|=63&e[n++]):240>r?(r=(15&r)<<12,r|=(63&e[n++])<<6,r|=63&e[n++]):(r=(7&r)<<18,r|=(63&e[n++])<<12,r|=(63&e[n++])<<6,r|=63&e[n++])),t.push(String.fromCharCode(r))}return t.join("")};var BASE64={};if(function(e){var t=function(t){for(var n=0,r=[],i=0|t.length/3;0>18)),r.push(e.charAt(63&o>>12)),r.push(e.charAt(63&o>>6)),r.push(e.charAt(63&o))}if(2==t.length-n){var o=(t[n]<<16)+(t[n+1]<<8);r.push(e.charAt(63&o>>18)),r.push(e.charAt(63&o>>12)),r.push(e.charAt(63&o>>6)),r.push("=")}else if(1==t.length-n){var o=t[n]<<16;r.push(e.charAt(63&o>>18)),r.push(e.charAt(63&o>>12)),r.push("==")}return r.join("")},n=function(){for(var t=[],n=0;no;o+=1)c=f.getInt8(h),l+=String.fromCharCode(c),h+=1;"moof"!==l&&"traf"!==l&&"sidx"!==l?h+=d-8:"sidx"===l&&(h-=8)}if(i=f.getUint32(h,!1)+h,i>e.byteLength)throw"sidx terminates after array buffer";for(g.version=f.getUint8(h+8),h+=12,g.timescale=f.getUint32(h+4,!1),h+=8,0===g.version?(g.earliest_presentation_time=f.getUint32(h,!1),g.first_offset=f.getUint32(h+4,!1),h+=8):(g.earliest_presentation_time=utils.Math.to64BitNumber(f.getUint32(h+4,!1),f.getUint32(h,!1)),g.first_offset=(f.getUint32(h+8,!1)<<32)+f.getUint32(h+12,!1),h+=16),g.first_offset+=i+(t||0),g.reference_count=f.getUint16(h+2,!1),h+=4,g.references=[],n=g.first_offset,r=g.earliest_presentation_time,o=0;o>>31,s=2147483647&s,u=f.getUint32(h+4,!1),h+=12,g.references.push({size:s,type:a,offset:n,duration:u,time:r,timescale:g.timescale}),n+=s,r+=u;if(h!==i)throw"Error: final pos "+h+" differs from SIDX end "+i;return g},t=function(t,n,r){var i,o,a,s,u,l,d,c;for(i=e.call(this,t,r),o=i.references,a=[],u=0,l=o.length;l>u;u+=1)s=new Dash.vo.Segment,s.duration=o[u].duration,s.media=n,s.startTime=o[u].time,s.timescale=o[u].timescale,d=o[u].offset,c=o[u].offset+o[u].size-1,s.mediaRange=d+"-"+c,a.push(s);return this.debug.log("Parsed SIDX box: "+a.length+" segments."),Q.when(a)},n=function(e,t){var r,i,o,a,s,u,l,d=Q.defer(),c=new DataView(e),f=0,g="",h=0,p=!1,m=this;for(m.debug.log("Searching for initialization.");"moov"!==g&&fa;a+=1)s=c.getInt8(f),g+=String.fromCharCode(s),f+=1;"moov"!==g&&(f+=h-8)}return o=c.byteLength-f,"moov"!==g?(m.debug.log("Loading more bytes to find initialization."),t.range.start=0,t.range.end=t.bytesLoaded+t.bytesToLoad,u=new XMLHttpRequest,u.onloadend=function(){p||d.reject("Error loading initialization.")},u.onload=function(){p=!0,t.bytesLoaded=t.range.end,n.call(m,u.response).then(function(e){d.resolve(e)})},u.onerror=function(){d.reject("Error loading initialization.")},u.open("GET",t.url),u.responseType="arraybuffer",u.setRequestHeader("Range","bytes="+t.range.start+"-"+t.range.end),u.send(null)):(r=f-8,i=r+h-1,l=r+"-"+i,m.debug.log("Found the initialization. Range: "+l),d.resolve(l)),d.promise},r=function(e){var t=Q.defer(),r=new XMLHttpRequest,i=!0,o=this,a={url:e,range:{},searching:!1,bytesLoaded:0,bytesToLoad:1500,request:r};return o.debug.log("Start searching for initialization."),a.range.start=0,a.range.end=a.bytesToLoad,r.onload=function(){r.status<200||r.status>299||(i=!1,a.bytesLoaded=a.range.end,n.call(o,r.response,a).then(function(e){t.resolve(e)}))},r.onloadend=r.onerror=function(){i&&(i=!1,o.errHandler.downloadError("initialization",a.url,r),t.reject(r))},r.open("GET",a.url),r.responseType="arraybuffer",r.setRequestHeader("Range","bytes="+a.range.start+"-"+a.range.end),r.send(null),o.debug.log("Perform init search: "+a.url),t.promise},i=function(e,n){var r,o,a,s,u,l,d,c,f=Q.defer(),g=new DataView(e),h=new XMLHttpRequest,p=0,m="",y=0,v=!0,M=!1,b=this;for(b.debug.log("Searching for SIDX box."),b.debug.log(n.bytesLoaded+" bytes loaded.");"sidx"!==m&&pu;u+=1)l=g.getInt8(p),m+=String.fromCharCode(l),p+=1;"sidx"!==m&&(p+=y-8)}if(r=g.byteLength-p,"sidx"!==m)f.reject();else if(y-8>r)b.debug.log("Found SIDX but we don't have all of it."),n.range.start=0,n.range.end=n.bytesLoaded+(y-r),h.onload=function(){h.status<200||h.status>299||(v=!1,n.bytesLoaded=n.range.end,i.call(b,h.response,n).then(function(e){f.resolve(e)}))},h.onloadend=h.onerror=function(){v&&(v=!1,b.errHandler.downloadError("SIDX",n.url,h),f.reject(h))},h.open("GET",n.url),h.responseType="arraybuffer",h.setRequestHeader("Range","bytes="+n.range.start+"-"+n.range.end),h.send(null);else if(n.range.start=p-8,n.range.end=n.range.start+y,b.debug.log("Found the SIDX box. Start: "+n.range.start+" | End: "+n.range.end),o=new ArrayBuffer(n.range.end-n.range.start),s=new Uint8Array(o),a=new Uint8Array(e,n.range.start,n.range.end-n.range.start),s.set(a),d=this.parseSIDX.call(this,o,n.range.start),c=d.references,null!==c&&void 0!==c&&c.length>0&&(M=1===c[0].type),M){b.debug.log("Initiate multiple SIDX load.");var E,S,w,P,T,R,_=[];for(E=0,S=c.length;S>E;E+=1)w=c[E].offset,P=c[E].offset+c[E].size-1,T=w+"-"+P,_.push(this.loadSegments.call(b,n.url,T));Q.all(_).then(function(e){for(R=[],E=0,S=e.length;S>E;E+=1)R=R.concat(e[E]);f.resolve(R)},function(e){f.reject(e)})}else b.debug.log("Parsing segments from SIDX."),t.call(b,o,n.url,n.range.start).then(function(e){f.resolve(e)});return f.promise},o=function(e,n){var r,o=Q.defer(),a=new XMLHttpRequest,s=!0,u=this,l={url:e,range:{},searching:!1,bytesLoaded:0,bytesToLoad:1500,request:a};return null===n?(u.debug.log("No known range for SIDX request."),l.searching=!0,l.range.start=0,l.range.end=l.bytesToLoad):(r=n.split("-"),l.range.start=parseFloat(r[0]),l.range.end=parseFloat(r[1])),a.onload=function(){a.status<200||a.status>299||(s=!1,l.searching?(l.bytesLoaded=l.range.end,i.call(u,a.response,l).then(function(e){o.resolve(e)})):t.call(u,a.response,l.url,l.range.start).then(function(e){o.resolve(e)}))},a.onloadend=a.onerror=function(){s&&(s=!1,u.errHandler.downloadError("SIDX",l.url,a),o.reject(a))},a.open("GET",l.url),a.responseType="arraybuffer",a.setRequestHeader("Range","bytes="+l.range.start+"-"+l.range.end),a.send(null),u.debug.log("Perform SIDX load: "+l.url),o.promise};return{debug:void 0,errHandler:void 0,loadSegments:o,loadInitialization:r,parseSegments:t,parseSIDX:e,findSIDX:i}},Dash.dependencies.BaseURLExtensions.prototype={constructor:Dash.dependencies.BaseURLExtensions},Dash.dependencies.DashHandler=function(){"use strict";var e,t,n,r=-1,i=function(e,t){var n=null;return t&&t.Representation_asArray&&t.Representation_asArray.length>0&&(n=t.Representation_asArray[e]),n},o=function(e,t){var n=t.toString();return e.split("$Number$").join(n)},a=function(e,t){var n=t.toString();return e.split("$Time$").join(n)},s=function(e,t){var n=t.toString();return e.split("$Bandwidth$").join(n)},u=function(e,t){if(null===t||-1===e.indexOf("$RepresentationID$"))return e;var n=t.toString();return e.split("$RepresentationID$").join(n)},l=function(e,t){var n;return n=e===t?e:-1!==e.indexOf("http://")?e:t+e},d=function(e,t){var r=Q.defer(),o=i(e,t),a=null,d=null,c=null,f=null,g=this;return o?(g.debug.log("Getting the initialization request."),o.hasOwnProperty("SegmentTemplate")?o.SegmentTemplate.hasOwnProperty("initialization")&&(d=o.SegmentTemplate.initialization,d=s(d,o.bandwidth),d=u(d,o.id)):o.hasOwnProperty("SegmentList")&&o.SegmentList.hasOwnProperty("Initialization")&&o.SegmentList.Initialization.hasOwnProperty("range")?(d=o.SegmentList.Initialization.hasOwnProperty("sourceURL")?o.SegmentList.Initialization.sourceURL:o.BaseURL,f=o.SegmentList.Initialization.range):o.hasOwnProperty("SegmentList")&&o.SegmentList.hasOwnProperty("Initialization")&&o.SegmentList.Initialization.hasOwnProperty("sourceURL")?d=o.SegmentList.Initialization.sourceURL:o.hasOwnProperty("SegmentBase")&&o.SegmentBase.hasOwnProperty("Initialization")&&o.SegmentBase.Initialization.hasOwnProperty("range")?(d=o.BaseURL,f=o.SegmentBase.Initialization.range):o.hasOwnProperty("mimeType")&&g.manifestExt.getIsTextTrack(o.mimeType)?(d=o.BaseURL,f=0):(c=o.BaseURL,g.baseURLExt.loadInitialization(c).then(function(t){g.debug.log("Got an initialization."),a=new MediaPlayer.vo.SegmentRequest,a.streamType=n,a.type="Initialization Segment",a.url=l(c,o.BaseURL),a.range=t,a.quality=e,r.resolve(a)},function(e){r.reject(e)})),d&&d.length>0&&(g.debug.log("Got an initialization."),a=new MediaPlayer.vo.SegmentRequest,a.streamType=n,a.type="Initialization Segment",a.url=l(d,o.BaseURL),a.range=f,a.quality=e,r.resolve(a)),r.promise):Q.reject("no represenation")},c=function(n){var i,o,a,s,u,l,d=!1;return this.debug.log("Checking for stream end..."),e?(this.debug.log("Live never ends! (TODO)"),d=!1):n.hasOwnProperty("segments")&&null!==n.segments?(this.debug.log("Segments: "+r+" / "+n.segments.length),d=r>=n.segments.length):n.hasOwnProperty("SegmentTemplate")&&!n.SegmentTemplate.hasOwnProperty("SegmentTimeline")&&(o=1,u=1,s=t,n.SegmentTemplate.hasOwnProperty("duration")&&(i=n.SegmentTemplate.duration,n.SegmentTemplate.hasOwnProperty("timescale")&&(o=n.SegmentTemplate.timescale),n.SegmentTemplate.hasOwnProperty("startNumber")&&(u=n.SegmentTemplate.startNumber),a=i/o,l=r-u,this.debug.log("SegmentTemplate: "+a+" * "+l+" = "+a*l+" / "+s),d=a*l>=s)),Q.when(d)},f=function(e,n){var r,i,s,u,l,d,c,f,g=[],h=0,p=1,m=1;for(e.hasOwnProperty("startNumber")&&(p=e.startNumber),e.hasOwnProperty("timescale")&&(m=e.timescale),r=n.S_asArray,s=0,u=r.length;u>s;s+=1)for(i=r[s],d=0,i.hasOwnProperty("r")&&(d=i.r),0>d&&(d=(t-h/m)/(i.d/m)-1),l=0;d>=l;l+=1)c=new Dash.vo.Segment,c.timescale=m,0===l&&i.hasOwnProperty("t")?(c.startTime=i.t,h=i.t):c.startTime=h,c.duration=i.d,f=e.media,f=o(f,p),f=a(f,c.startTime),c.media=f,g.push(c),h+=c.duration,p+=1;return Q.when(g)},g=function(e){var t,n,r,i,o,a=[],s=1;for(e.hasOwnProperty("startNumber")&&(s=Math.max(e.startNumber,1)),o=(s-1)*e.duration,t=0,n=e.SegmentURL_asArray.length;n>t;t+=1)i=e.SegmentURL_asArray[t],r=new Dash.vo.Segment,r.media=i.media,r.mediaRange=i.mediaRange,r.index=i.index,r.indexRange=i.indexRange,r.timescale=e.timescale,r.duration=e.duration,r.startTime=o+t*e.duration,a.push(r);return Q.when(a)},h=function(e){var t=e.BaseURL,n=null;return e.hasOwnProperty("SegmentBase")&&e.SegmentBase.hasOwnProperty("indexRange")&&(n=e.SegmentBase.indexRange),this.baseURLExt.loadSegments(t,n)},p=function(e){var t;return t=e.hasOwnProperty("SegmentTemplate")&&!e.SegmentTemplate.hasOwnProperty("SegmentTimeline")?Q.when(null):e.hasOwnProperty("segments")&&null!==e.segments?Q.when(e.segments):e.hasOwnProperty("SegmentTemplate")&&e.SegmentTemplate.hasOwnProperty("SegmentTimeline")?f.call(this,e.SegmentTemplate,e.SegmentTemplate.SegmentTimeline):e.hasOwnProperty("SegmentList")?g.call(this,e.SegmentList):h.call(this,e)},m=function(e,t){var n,r,i,o,a=-1;if(t&&t.length>0)for(o=t.length-1;o>=0;o--){if(n=t[o],r=n.startTime/n.timescale,i=n.duration/n.timescale,e+Dash.dependencies.DashHandler.EPSILON>=r&&e-Dash.dependencies.DashHandler.EPSILON<=r+i){a=o;break}-1===a&&e-Dash.dependencies.DashHandler.EPSILON>r+i&&(a=o+1)}return-1===a&&(console.log("Couldn't figure out a time!"),console.log("Time: "+e),console.log(t)),Q.when(a)},y=function(e,t){var n,r,i=-1,o=1,a=1;if(!t.hasOwnProperty("duration"))throw"Expected 'duration' attribute on SegmentTemplate!";return n=t.duration,t.hasOwnProperty("timescale")&&(o=t.timescale),t.hasOwnProperty("startNumber")&&(a=t.startNumber),r=n/o,i=Math.floor(e/r),i+=a,Q.when(i)},v=function(e,t,r,i){var d,c,f=new MediaPlayer.vo.SegmentRequest,g=1,h=1;return t.hasOwnProperty("timescale")&&(g=t.timescale),t.hasOwnProperty("startNumber")&&(h=t.startNumber),c=t.duration*e/g,c=Math.floor(c),d=t.media,d=o(d,e),d=a(d,c),d=s(d,r.bandwidth),d=u(d,r.id),f.streamType=n,f.type="Media Segment",f.url=l(d,r.BaseURL),f.duration=t.duration/g,f.timescale=g,f.startTime=(e-h)*t.duration/g,f.quality=i,f.index=e,Q.when(f)},M=function(e,t,r,i){if(null===t||void 0===t)return Q.when(null);var d,c=new MediaPlayer.vo.SegmentRequest;return d=l(t.media,r.BaseURL),d=o(d,e),d=a(d,t.startTime),d=s(d,r.bandwidth),d=u(d,r.id),c.streamType=n,c.type="Media Segment",c.url=d,c.range=t.mediaRange,c.startTime=t.startTime/t.timescale,c.duration=t.duration/t.timescale,c.timescale=t.timescale,c.quality=i,c.index=e,Q.when(c)},b=function(e,t,n){var o,a,s,u=i(t,n),l=!1,d=this;return u?(d.debug.log("Getting the request for time: "+e),o=Q.defer(),p.call(d,u).then(function(t){var n;if(d.debug.log("Got segments."),d.debug.log(t),null===t){if(!u.hasOwnProperty("SegmentTemplate"))throw"Expected SegmentTemplate!";l=!0,d.debug.log("No segments found, so we must be using a SegmentTemplate."),n=y.call(d,e,u.SegmentTemplate)}else d.debug.log("Got a list of segments, so dig deeper."),u.segments=t,l=!1,n=m.call(d,e,t);return n},function(){o.reject()}).then(function(t){return d.debug.log("Index for time "+e+" is "+t),r=t,c.call(d,u)}).then(function(e){var n=null;return d.debug.log("Stream finished? "+e),e?(a=new MediaPlayer.vo.SegmentRequest,a.action=a.ACTION_COMPLETE,a.index=r,d.debug.log("Signal complete."),d.debug.log(a),o.resolve(a)):l?n=v.call(d,r,u.SegmentTemplate,u,t):(s=u.segments[r],n=M.call(d,r,s,u,t)),n}).then(function(e){d.debug.log("Got a request."),d.debug.log(e),o.resolve(e)}),o.promise):Q.reject("no represenation")},E=function(e,t){var n,o,a,s=i(e,t),u=this;if(!s)return Q.reject("no represenation");if(u.debug.log("Getting the next request."),-1===r)throw"You must call getSegmentRequestForTime first.";return r+=1,u.debug.log("New index: "+r),n=Q.defer(),c.call(u,s).then(function(t){u.debug.log("Stream finished? "+t),t?(o=new MediaPlayer.vo.SegmentRequest,o.action=o.ACTION_COMPLETE,o.index=r,u.debug.log("Signal complete."),u.debug.log(o),n.resolve(o)):p.call(u,s).then(function(t){var n;if(u.debug.log("Got segments."),u.debug.log(t),null===t){if(!s.hasOwnProperty("SegmentTemplate"))throw"Expected SegmentTemplate!";u.debug.log("No segments found, so we must be using a SegmentTemplate."),n=v.call(u,r,s.SegmentTemplate,s,e)}else s.segments=t,a=s.segments[r],n=M.call(u,r,a,s,e);return n},function(){n.reject()}).then(function(e){u.debug.log("Got a request."),u.debug.log(e),n.resolve(e)})}),n.promise},S=function(e,t,n,r){var o,a,s,u=this,l=i(e,t),d=Math.max(n-r,0),c=Q.defer(),f=0,g=1;return l?(p.call(u,l).then(function(e){if(null===e||void 0===e){if(!l.hasOwnProperty("SegmentTemplate"))throw"Expected SegmentTemplate!";l.SegmentTemplate.hasOwnProperty("timescale")&&(g=l.SegmentTemplate.timescale),s=l.SegmentTemplate.duration,o=s/g}else a=e[0],a.hasOwnProperty("timescale")&&(g=a.timescale),s=a.duration,o=s/g;f=Math.ceil(d/o),c.resolve(f)},function(){c.resolve(0)}),c.promise):Q.reject("no represenation")},w=function(t,n){var o,a,s,u,l=this,d=i(t,n),c=!1,f=1,g=1,h=Q.defer();return d?(a=r,0>a&&(c=e,a=0),p.call(l,d).then(function(e){if(null===e||void 0===e){if(!d.hasOwnProperty("SegmentTemplate"))throw"Expected SegmentTemplate!";u=d.SegmentTemplate.duration,d.SegmentTemplate.hasOwnProperty("timescale")&&(f=d.SegmentTemplate.timescale),d.SegmentTemplate.hasOwnProperty("startNumber")&&(g=d.SegmentTemplate.startNumber),o=u/f*Math.max(a-g,0)}else(c||a>=e.length)&&(a=e.length-1),s=e[a].startTime,u=e[a].duration,e[a].hasOwnProperty("timescale")&&(f=e[a].timescale),o=s/f;h.resolve(o)},function(){h.reject()}),h.promise):Q.reject("no represenation")};return{debug:void 0,baseURLExt:void 0,manifestModel:void 0,manifestExt:void 0,errHandler:void 0,getType:function(){return n},setType:function(e){n=e},getIsLive:function(){return e},setIsLive:function(t){e=t},getDuration:function(){return t},setDuration:function(e){t=e},getInitRequest:d,getSegmentRequestForTime:b,getNextSegmentRequest:E,getCurrentTime:w,getSegmentCountForDuration:S}},Dash.dependencies.DashHandler.EPSILON=.003,Dash.dependencies.DashHandler.prototype={constructor:Dash.dependencies.DashHandler},Dash.dependencies.DashManifestExtensions=function(){"use strict"},Dash.dependencies.DashManifestExtensions.prototype={constructor:Dash.dependencies.DashManifestExtensions,getIsAudio:function(e){"use strict";var t,n,r,i=e.ContentComponent_asArray,o=!1,a=!1;if(i)for(t=0,n=i.length;n>t;t+=1)"audio"===i[t].contentType&&(o=!0,a=!0);if(e.hasOwnProperty("mimeType")&&(o=-1!==e.mimeType.indexOf("audio"),a=!0),!a)for(t=0,n=e.Representation_asArray.length;!a&&n>t;)r=e.Representation_asArray[t],r.hasOwnProperty("mimeType")&&(o=-1!==r.mimeType.indexOf("audio"),a=!0),t+=1;return o&&(e.type="audio"),Q.when(o)},getIsVideo:function(e){"use strict";var t,n,r,i=e.ContentComponent_asArray,o=!1,a=!1;if(i)for(t=0,n=i.length;n>t;t+=1)"video"===i[t].contentType&&(o=!0,a=!0);if(e.hasOwnProperty("mimeType")&&(o=-1!==e.mimeType.indexOf("video"),a=!0),!a)for(t=0,n=e.Representation_asArray.length;!a&&n>t;)r=e.Representation_asArray[t],r.hasOwnProperty("mimeType")&&(o=-1!==r.mimeType.indexOf("video"),a=!0),t+=1;return o&&(e.type="video"),Q.when(o)},getIsText:function(e){"use strict";var t,n,r,i=e.ContentComponent_asArray,o=!1,a=!1;if(i)for(t=0,n=i.length;n>t;t+=1)"text"===i[t].contentType&&(o=!0,a=!0);if(e.hasOwnProperty("mimeType")&&(o=-1!==e.mimeType.indexOf("text"),a=!0),!a)for(t=0,n=e.Representation_asArray.length;!a&&n>t;)r=e.Representation_asArray[t],r.hasOwnProperty("mimeType")&&(o=-1!==r.mimeType.indexOf("text"),a=!0),t+=1;return Q.when(o)},getIsTextTrack:function(e){return"text/vtt"===e||"application/ttml+xml"===e},getIsMain:function(){"use strict";return Q.when(!1)},processAdaptation:function(e){"use strict";return void 0!==e.Representation_asArray&&null!==e.Representation_asArray&&e.Representation_asArray.sort(function(e,t){return e.bandwidth-t.bandwidth}),e},getDataForId:function(e,t,n){"use strict";var r,i,o=t.Period_asArray[n].AdaptationSet_asArray;for(r=0,i=o.length;i>r;r+=1)if(o[r].hasOwnProperty("id")&&o[r].id===e)return Q.when(o[r]);return Q.when(null)},getDataForIndex:function(e,t,n){"use strict";var r=t.Period_asArray[n].AdaptationSet_asArray;return Q.when(r[e])},getDataIndex:function(e,t,n){"use strict";var r,i,o=t.Period_asArray[n].AdaptationSet_asArray;for(r=0,i=o.length;i>r;r+=1)if(o[r]===e)return Q.when(r);return Q.when(-1)},getVideoData:function(e,t){"use strict";var n,r,i=this,o=e.Period_asArray[t].AdaptationSet_asArray,a=Q.defer(),s=[];for(n=0,r=o.length;r>n;n+=1)s.push(this.getIsVideo(o[n]));return Q.all(s).then(function(e){var t=!1;for(n=0,r=e.length;r>n;n+=1)e[n]===!0&&(t=!0,a.resolve(i.processAdaptation(o[n])));t||a.resolve(null)}),a.promise},getTextData:function(e,t){"use strict";var n,r,i=this,o=e.Period_asArray[t].AdaptationSet_asArray,a=Q.defer(),s=[];for(n=0,r=o.length;r>n;n+=1)s.push(this.getIsText(o[n]));return Q.all(s).then(function(e){var t=!1;for(n=0,r=e.length;r>n;n+=1)e[n]===!0&&(t=!0,a.resolve(i.processAdaptation(o[n])));t||a.resolve(null)}),a.promise},getAudioDatas:function(e,t){"use strict";var n,r,i=this,o=e.Period_asArray[t].AdaptationSet_asArray,a=Q.defer(),s=[];for(n=0,r=o.length;r>n;n+=1)s.push(this.getIsAudio(o[n]));return Q.all(s).then(function(e){var t=[];for(n=0,r=e.length;r>n;n+=1)e[n]===!0&&t.push(i.processAdaptation(o[n]));a.resolve(t)}),a.promise},getPrimaryAudioData:function(e,t){"use strict";var n,r,i=Q.defer(),o=[],a=this;return this.getAudioDatas(e,t).then(function(e){for(e&&0!==e.length||i.resolve(null),n=0,r=e.length;r>n;n+=1)o.push(a.getIsMain(e[n]));Q.all(o).then(function(t){var o=!1;for(n=0,r=t.length;r>n;n+=1)t[n]===!0&&(o=!0,i.resolve(a.processAdaptation(e[n])));o||i.resolve(e[0])})}),i.promise},getCodec:function(e){"use strict";var t=e.Representation_asArray[0],n=t.mimeType+';codecs="'+t.codecs+'"';return Q.when(n)},getMimeType:function(e){"use strict";return Q.when(e.Representation_asArray[0].mimeType)},getKID:function(e){"use strict";return e&&e.hasOwnProperty("cenc:default_KID")?e["cenc:default_KID"]:null},getContentProtectionData:function(e){"use strict";return Q.when(e&&e.hasOwnProperty("ContentProtection_asArray")&&0!==e.ContentProtection_asArray.length?e.ContentProtection_asArray:null)},getSegmentInfoFor:function(e){return e.hasOwnProperty("SegmentBase")?e.SegmentBase:e.hasOwnProperty("SegmentList")?e.SegmentList:e.hasOwnProperty("SegmentTemplate")?e.SegmentTemplate:null},getLiveOffset:function(e){"use strict";var t=15;return e.hasOwnProperty("suggestedPresentationDelay")&&(t=e.suggestedPresentationDelay),Q.when(t)},getLiveStart:function(e,t){var n,r,i=0,o=1,a=1,s=null,u=null;return r=e.Period_asArray[t].AdaptationSet_asArray[1].Representation_asArray[0],r.hasOwnProperty("SegmentList")?(s=r.SegmentList,s.hasOwnProperty("startNumber")&&(o=Math.max(s.startNumber,1)),s.hasOwnProperty("timescale")&&(a=s.timescale),n=s.duration,i=(o-1)*n/a):r.hasOwnProperty("SegmentTemplate")&&(u=r.SegmentTemplate,u.hasOwnProperty("startNumber")&&(o=Math.max(u.startNumber,1)),u.hasOwnProperty("timescale")&&(a=u.timescale),n=u.duration,i=u.hasOwnProperty("SegmentTimeline")?u.SegmentTimeline.S_asArray[0].t/a:(o-1)*n/a),Q.when(i)},getLiveEdge:function(e,t){"use strict";var n,r=this,i=Q.defer(),o=0,a=new Date,s=e.availabilityStartTime;return r.getLiveOffset(e).then(function(u){e.hasOwnProperty("availabilityEndTime")?(n=e.availabilityEndTime,o=(n.getTime()-s.getTime())/1e3):o=(a.getTime()-s.getTime())/1e3,r.getLiveStart(e,t).then(function(e){o+=e,o-=u,i.resolve(o)})}),i.promise},getPresentationOffset:function(e,t){var n,r,i=this,o=Q.defer(),a=0,s=1;return i.getRepresentationFor(e,t).then(function(e){r=i.getSegmentInfoFor(e),null!==r&&void 0!==r&&r.hasOwnProperty("presentationTimeOffset")&&(n=r.presentationTimeOffset,r.hasOwnProperty("timescale")&&(s=r.timescale),a=n/s),o.resolve(a)}),o.promise},getIsLive:function(e){"use strict";var t=!1,n="dynamic";return e.hasOwnProperty("type")&&(t=e.type===n),t},getIsDVR:function(e,t){"use strict";var n,r;return n=!isNaN(e.timeShiftBufferDepth),r=t&&n,Q.when(r)},getIsOnDemand:function(e){"use strict";var t=!1;return e.profiles&&e.profiles.length>0&&(t=-1!==e.profiles.indexOf("urn:mpeg:dash:profile:isoff-on-demand:2011")),Q.when(t)},getDuration:function(e,t){"use strict";var n=0/0;return t?n=Number.POSITIVE_INFINITY:e.mediaPresentationDuration?n=e.mediaPresentationDuration:e.availabilityEndTime&&e.availabilityStartTime&&(n=e.availabilityEndTime.getTime()-e.availabilityStartTime.getTime()),Q.when(n)},getDurationForPeriod:function(e,t,n){"use strict";var r=0/0;return n?r=Number.POSITIVE_INFINITY:t.Period_asArray.length>1&&void 0!==t.Period_asArray[e].duration?r=t.Period_asArray[e].duration:t.mediaPresentationDuration?r=t.mediaPresentationDuration:t.availabilityEndTime&&t.availabilityStartTime&&(r=t.availabilityEndTime.getTime()-t.availabilityStartTime.getTime()),Q.when(r)},getBandwidth:function(e){"use strict";return Q.when(e.bandwidth)},getRefreshDelay:function(e){"use strict";var t=0/0;return e.hasOwnProperty("minimumUpdatePeriod")&&(t=parseFloat(e.minimumUpdatePeriod)),Q.when(t)},getRepresentationCount:function(e){"use strict";return Q.when(e.Representation_asArray.length)},getRepresentationFor:function(e,t){"use strict";return Q.when(t.Representation_asArray[e])},getPeriodCount:function(e){"use strict";return Q.when(e.Period_asArray.length)},getTimestampOffsetForPeriod:function(e,t,n,r){var i,o=this,a=Q.defer();return o.getPresentationOffset(n,r).then(function(n){o.getPeriodStart(t,e).then(function(e){i=e-n,a.resolve(i)})}),a.promise},getPeriodStart:function(e,t){var n,r,i=this,o=i.getIsLive(e),a=null,s=null,u=null;for(n=0;t>=n;n+=1)a=e.Period_asArray[n],a.hasOwnProperty("start")?r=a.start:null!==s&&null!==u?r=s+u:0!==n||o||(r=0),a.hasOwnProperty("duration")&&(u=a.duration),s=r;return Q.when(r)}},Dash.dependencies.DashMetricsExtensions=function(){"use strict";var e=function(e,t){var n,r,i,o,a,s,u,l;for(s=0;so;o+=1)a=u.getInt8(l),i+=String.fromCharCode(a),l+=1;"moof"!==i&&"traf"!==i&&"tfdt"!==i&&(l+=r-8)}if(l===u.byteLength)throw"Error finding live offset.";return n=u.getUint8(l),this.debug.log("position: "+l),0===n?(l+=4,t=u.getUint32(l,!1)):(l+=r-16,t=utils.Math.to64BitNumber(u.getUint32(l+4,!1),u.getUint32(l,!1))),s.resolve({version:n,base_media_decode_time:t}),s.promise},t=function(e){for(var t,n,r,i,o,a,s,u=new DataView(e),l=0;"sidx"!==o&&li;i+=1)s=u.getInt8(l),o+=String.fromCharCode(s),l+=1;"moof"!==o&&"traf"!==o&&"sidx"!==o?l+=a-8:"sidx"===o&&(l-=8)}return t=u.getUint8(l+8),l+=12,n=u.getUint32(l+4,!1),l+=8,r=0===t?u.getUint32(l,!1):utils.Math.to64BitNumber(u.getUint32(l+4,!1),u.getUint32(l,!1)),Q.when({earliestPresentationTime:r,timescale:n})},n=function(t){var n,r,i,o=Q.defer(),a=new XMLHttpRequest,s=!1;return n=t,a.onloadend=function(){s||(r="Error loading fragment: "+n,o.reject(r))},a.onload=function(){s=!0,i=e(a.response),o.resolve(i)},a.onerror=function(){r="Error loading fragment: "+n,o.reject(r)},a.responseType="arraybuffer",a.open("GET",n),a.send(null),o.promise};return{debug:void 0,loadFragment:n,parseTFDT:e,parseSIDX:t}},Dash.dependencies.FragmentExtensions.prototype={constructor:Dash.dependencies.FragmentExtensions},Dash.vo.Segment=function(){"use strict";this.indexRange=null,this.index=null,this.mediaRange=null,this.media=null,this.duration=0/0,this.startTime=0/0,this.timescale=0/0},Dash.vo.Segment.prototype={constructor:Dash.vo.Segment},MediaPlayer.dependencies.AbrController=function(){"use strict";var e=!0,t={},n={},r=function(e){ +var n;return t.hasOwnProperty(e)||(t[e]=0),n=t[e]},i=function(e,n){t[e]=n},o=function(e){var t;return n.hasOwnProperty(e)||(n[e]=0),t=n[e]},a=function(e,t){n[e]=t};return{debug:void 0,abrRulesCollection:void 0,manifestExt:void 0,metricsModel:void 0,getAutoSwitchBitrate:function(){return e},setAutoSwitchBitrate:function(t){e=t},getMetricsFor:function(e){var t=Q.defer(),n=this;return n.manifestExt.getIsVideo(e).then(function(r){r?t.resolve(n.metricsModel.getMetricsFor("video")):n.manifestExt.getIsAudio(e).then(function(e){t.resolve(e?n.metricsModel.getMetricsFor("audio"):n.metricsModel.getMetricsFor("stream"))})}),t.promise},getPlaybackQuality:function(t,n){var s,u,l,d,c,f,g=this,h=Q.defer(),p=MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,m=MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,y=[];return c=r(t),f=o(t),g.debug.log("ABR enabled? ("+e+")"),e?(g.debug.log("Check ABR rules."),g.getMetricsFor(n).then(function(e){g.abrRulesCollection.getRules().then(function(r){for(s=0,u=r.length;u>s;s+=1)y.push(r[s].checkIndex(c,e,n));Q.all(y).then(function(e){for(g.debug.log(e),d={},d[MediaPlayer.rules.SwitchRequest.prototype.STRONG]=MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,d[MediaPlayer.rules.SwitchRequest.prototype.WEAK]=MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,d[MediaPlayer.rules.SwitchRequest.prototype.DEFAULT]=MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,s=0,u=e.length;u>s;s+=1)l=e[s],l.quality!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&(d[l.priority]=Math.min(d[l.priority],l.quality));d[MediaPlayer.rules.SwitchRequest.prototype.WEAK]!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&(m=MediaPlayer.rules.SwitchRequest.prototype.WEAK,p=d[MediaPlayer.rules.SwitchRequest.prototype.WEAK]),d[MediaPlayer.rules.SwitchRequest.prototype.DEFAULT]!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&(m=MediaPlayer.rules.SwitchRequest.prototype.DEFAULT,p=d[MediaPlayer.rules.SwitchRequest.prototype.DEFAULT]),d[MediaPlayer.rules.SwitchRequest.prototype.STRONG]!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&(m=MediaPlayer.rules.SwitchRequest.prototype.STRONG,p=d[MediaPlayer.rules.SwitchRequest.prototype.STRONG]),p!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&void 0!==p&&(c=p),m!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&void 0!==m&&(f=m),g.manifestExt.getRepresentationCount(n).then(function(e){0>c&&(c=0),c>=e&&(c=e-1),f!=MediaPlayer.rules.SwitchRequest.prototype.STRONG&&f!=MediaPlayer.rules.SwitchRequest.prototype.WEAK&&(f=MediaPlayer.rules.SwitchRequest.prototype.DEFAULT),i(t,c),g.debug.log("New quality of "+c),a(t,f),g.debug.log("New confidence of "+f),h.resolve({quality:c,confidence:f})})})})})):(g.debug.log("Unchanged quality of "+c),h.resolve({quality:c,confidence:f})),h.promise},setPlaybackQuality:function(e,t){var n=r(e);t!==n&&i(e,t)},getQualityFor:function(e){return r(e)}}},MediaPlayer.dependencies.AbrController.prototype={constructor:MediaPlayer.dependencies.AbrController},MediaPlayer.dependencies.BufferController=function(){"use strict";var e,t,n,r,i=.5,o=22,a="WAITING",s="READY",u="VALIDATING",l="LOADING",d=a,c=!1,f=!1,g=!1,h=!0,p=[],m=!1,y=-1,v=!0,M=-1,b=!1,E=!1,S=!1,w=!1,P=[],T=null,R=Q.defer(),_=null,L=null,x=-1,O=0,D=0,C=null,A=0,B=!1,N=null,I=0,q=!1,k=null,F=null,U=null,j=null,H=!0,V=function(e){var t=this;t.debug.log("BufferController "+n+" setState to:"+e),d=e,null!==C&&t.fragmentController.onBufferControllerStateChange()},K=function(e,t){var n=0,r=null;H===!1&&(r=j.start,n=e.getTime()-r.getTime(),j.duration=n,j.stopreason=t,H=!0)},W=function(){var e=this.manifestModel.getValue(),t=this.manifestExt.getIsLive(e);return S=!0,Q.when(t)},G=function(){if(c&&f){var e=this;W.call(this).then(function(t){E=t,e.debug.log("BufferController begin "+n+" validation"),V.call(e,s),e.requestScheduler.startScheduling(e,ye),C=e.fragmentController.attachBufferController(e)})}},z=function(){var e;this.requestScheduler.isScheduled(this)||(m===!1&&(e=new Date,K(e,MediaPlayer.vo.metrics.PlayList.Trace.USER_REQUEST_STOP_REASON),U=this.metricsModel.addPlayList(n,e,0,MediaPlayer.vo.metrics.PlayList.INITIAL_PLAY_START_REASON)),this.debug.log("BufferController "+n+" start."),f=!0,g=!0,G.call(this))},X=function(e){var t;this.debug.log("BufferController "+n+" seek: "+e),m=!0,y=e,t=new Date,K(t,MediaPlayer.vo.metrics.PlayList.Trace.USER_REQUEST_STOP_REASON),U=this.metricsModel.addPlayList(n,t,y,MediaPlayer.vo.metrics.PlayList.SEEK_START_REASON),z.call(this)},Z=function(){d!==a&&(this.debug.log("BufferController "+n+" stop."),V.call(this,a),this.requestScheduler.stopScheduling(this),this.fragmentController.cancelPendingRequestsForModel(C),f=!1,g=!1,K(new Date,MediaPlayer.vo.metrics.PlayList.Trace.USER_REQUEST_STOP_REASON))},Y=function(e,t){var n=null;return t&&t.Representation_asArray&&t.Representation_asArray.length>0&&(n=t.Representation_asArray[e]),n},$=function(){var e=this;d===l&&(b&&(b=!1,this.videoModel.stallStream(n,b)),V.call(e,s))},J=function(e){if(this.fragmentController.isInitializationRequest(e))V.call(this,s);else{V.call(this,l);var t=this,n=t.fragmentController.getLoadingTime(t);setTimeout(function(){(k||F)&&(V.call(t,s),me.call(t))},n)}},ee=function(e,t){this.fragmentController.isInitializationRequest(e)?se.call(this,e,t):te.call(this,e,t)},te=function(e,t){var r=this;r.debug.log(n+" Bytes finished loading: "+e.url),I||isNaN(e.duration)||(I=e.duration),r.fragmentController.process(t.data).then(function(t){null!==t&&null!==T?Q.when(T.promise).then(function(){ne.call(r,t,e.quality).then(function(){R.promise.then(function(t){t.index-1!==e.index||w||(w=!0,b&&(b=!1,r.videoModel.stallStream(n,b)),V.call(r,s),r.system.notify("bufferingCompleted"))})})}):r.debug.log("No "+n+" bytes to push.")})},ne=function(e,t){var r=this,i=e==N,s=i?_:Q.defer(),u=i?P.length:P.push(s),l=Y(M,r.getData()),c=r.videoModel.getCurrentTime(),f=new Date;return r.debug.log("Push ("+n+") bytes: "+e.byteLength),H===!0&&d!==a&&-1!==M&&(H=!1,j=r.metricsModel.appendPlayListTrace(U,l.id,null,f,c,null,1,null)),Q.when(i||2>u||P[u-2].promise).then(function(){F&&oe.call(r).then(function(){return t!==M?(s.resolve(),void(i&&(_=null,N=null))):void Q.when(L?L.promise:!0).then(function(){r.sourceBufferExt.append(F,e,r.videoModel).then(function(){i&&(_=null,N=null),r.requestScheduler.isScheduled(r)||z.call(r),B=!1,re.call(r).then(function(){s.resolve()}),F&&r.sourceBufferExt.getAllRanges(F).then(function(e){if(e&&(r.debug.log("Append "+n+" complete: "+e.length),e.length>0)){var t,i;for(r.debug.log("Number of buffered "+n+" ranges: "+e.length),t=0,i=e.length;i>t;t+=1)r.debug.log("Buffered "+n+" Range: "+e.start(t)+" - "+e.end(t))}})},function(t){t.err.code===o&&(N=e,_=s,B=!0,D=0,Z.call(r))})})})}),s.promise},re=function(){if(!k&&!F)return Q.when(!1);var e=this,t=Q.defer(),r=he.call(e);return e.sourceBufferExt.getBufferLength(F,r).then(function(r){A=r,e.metricsModel.addBufferLevel(n,new Date,A),ie.call(e),t.resolve()}),t.promise},ie=function(){var e=this.bufferExt.getLeastBufferLevel(),t=2*I,n=A-e;n>t&&!L?(D=0,L=Q.defer()):t>n&&L&&(L.resolve(),L=null)},oe=function(){var e,t=this,n=Q.defer(),r=0;return B?(e=function(){ae.call(t).then(function(t){r+=t,r>=I?n.resolve():setTimeout(e,1e3*I)})},e.call(t),n.promise):Q.when(!0)},ae=function(){var e,n,r=this,i=Q.defer(),o=r.videoModel.getCurrentTime(),a=0;return n=r.fragmentController.getExecutedRequestForTime(C,o),e=n&&!isNaN(n.startTime)?n.startTime:Math.floor(o),I=n&&!isNaN(n.duration)?n.duration:1,r.sourceBufferExt.getBufferRange(F,o).then(function(n){null===n&&y===o&&F.buffered.length>0&&(e=F.buffered.end(F.buffered.length-1)),a=F.buffered.start(0),r.sourceBufferExt.remove(F,a,e,O,t).then(function(){r.fragmentController.removeExecutedRequestsBeforeTime(C,e),i.resolve(e-a)})}),i.promise},se=function(e,t){var r=this,i=t.data,o=e.quality;r.debug.log(n+" Initialization finished loading: "+e.url),r.fragmentController.process(i).then(function(t){null!==t?(p[o]=t,o===M&&ne.call(r,t,e.quality).then(function(){T.resolve()})):r.debug.log("No "+n+" bytes to push.")})},ue=function(){var e=this,t=e.manifestModel.getValue(),n=e.manifestExt.getIsLive(t);d===l&&V.call(e,s),n||e.system.notify("segmentLoadingFailed")},le=function(e){this.debug.log(n+" Stream is complete."),K(new Date,MediaPlayer.vo.metrics.PlayList.Trace.END_OF_CONTENT_STOP_REASON),Z.call(this),R.resolve(e)},de=function(e,t){var r,i=null,o=this.bufferExt.getTopQualityIndex(n),a=[];if(h&&(this.debug.log("Marking a special seek for initial "+n+" playback."),m||(m=!0,y=0),h=!1),v){for(T=Q.defer(),p=[],r=0;o>=r;r+=1)a.push(this.indexHandler.getInitRequest(r,k));M=t,i=Q.all(a)}else i=Q.when(null),e&&(T=Q.defer(),M=t,p[t]&&ne.call(this,p[t],t).then(function(){T.resolve()}));return i},ce=function(t){var r,i=this;if(v&&!m)i.debug.log("Data changed - loading the "+n+" fragment for time: "+e),r=i.indexHandler.getSegmentRequestForTime(e,t,k);else{var o=Q.defer(),a=i.videoModel.getCurrentTime();r=o.promise,i.sourceBufferExt.getBufferRange(F,a).then(function(e){m=!1,null!==e&&(a=e.end),i.debug.log("Loading the "+n+" fragment for time: "+a),i.indexHandler.getSegmentRequestForTime(a,t,k).then(function(e){o.resolve(e)},function(){o.reject()})},function(){o.reject()})}return v=!1,r},fe=function(e){var t=this;null!==e?t.fragmentController.isFragmentLoadedOrPending(t,e)?"complete"!==e.action?t.indexHandler.getNextSegmentRequest(M,k).then(fe.bind(t)):(Z.call(t),V.call(t,s)):(t.debug.log("Loading an "+n+" fragment: "+e.url),Q.when(L?L.promise:!0).then(function(){t.fragmentController.prepareFragmentForLoading(t,e,J,ee,ue,le).then(function(){V.call(t,s)})})):V.call(t,s)},ge=function(){g&&(r>A&&r0?(D--,ce.call(e,M).then(fe.bind(e))):(d===u&&V.call(e,s),$.call(e))},ye=function(){var e,t=this,r=!1,o=null,a=new Date,c=t.videoModel.getCurrentTime(),f=he.call(t);if(t.debug.log("BufferController.validate() "+n+" | state: "+d),t.debug.log(n+" Playback rate: "+t.videoModel.getElement().playbackRate),t.debug.log(n+" Working time: "+f),t.debug.log(n+" Video time: "+c),t.debug.log("Current "+n+" buffer length: "+A),ge.call(t),d===l&&i>A)b||(t.debug.log("Stalling "+n+" Buffer: "+n),K(new Date,MediaPlayer.vo.metrics.PlayList.Trace.REBUFFERING_REASON),b=!0,g=!0,t.videoModel.stallStream(n,b));else if(d===s){V.call(t,u);var h=t.manifestModel.getValue().minBufferTime;t.bufferExt.decideBufferLength(h,O,g).then(function(e){t.debug.log("Buffer time: "+e),t.setMinBufferTime(e),t.requestScheduler.adjustExecuteInterval()}),t.abrController.getPlaybackQuality(n,k).then(function(i){var s=i.quality;if(t.debug.log(n+" Playback quality: "+s),t.debug.log("Populate "+n+" buffers."),void 0!==s&&(e=s),r=s!==M,r===!0){if(t.fragmentController.abortRequestsForModel(C),o=Y(e,t.getData()),null===o||void 0===o)throw"Unexpected error!";t.manifestExt.getTimestampOffsetForPeriod(x,t.manifestModel.getValue(),s,k).then(function(e){F.timestampOffset!==e&&(F.timestampOffset=e)}),K(new Date,MediaPlayer.vo.metrics.PlayList.Trace.REPRESENTATION_SWITCH_STOP_REASON),t.metricsModel.addRepresentationSwitch(n,a,c,o.id)}return t.debug.log(r?n+" Quality changed to: "+s:"Quality didn't change."),pe.call(t,s)}).then(function(i){D=i,de.call(t,r,e).then(function(e){if(null!==e){var r,i,o=e.length;for(i=0;o>i;i+=1)r=e[i],t.debug.log("Loading "+n+" initialization: "+r.url),t.debug.log(r),t.fragmentController.prepareFragmentForLoading(t,r,J,ee,ue,le).then(function(){V.call(t,s)})}}),me.call(t)})}else d===u&&V.call(t,s)};return{videoModel:void 0,metricsModel:void 0,manifestExt:void 0,manifestModel:void 0,bufferExt:void 0,sourceBufferExt:void 0,abrController:void 0,fragmentExt:void 0,indexHandler:void 0,debug:void 0,system:void 0,errHandler:void 0,initialize:function(e,t,n,r,i,o,a,s){var u=this,l=u.manifestModel.getValue(),d=u.manifestExt.getIsLive(l);u.setMediaSource(s),u.setVideoModel(i),u.setType(e),u.setPeriodIndex(t),u.setData(n).then(function(){c=!0,G.call(u)}),u.setBuffer(r),u.setScheduler(o),u.setFragmentController(a),u.indexHandler.setIsLive(d),u.manifestExt.getDurationForPeriod(t,u.manifestModel.getValue()).then(function(e){O=e,u.indexHandler.setDuration(e),u.bufferExt.decideBufferLength(l.minBufferTime,O,g).then(function(e){u.setMinBufferTime(e)})})},getType:function(){return n},setType:function(e){n=e,void 0!==this.indexHandler&&this.indexHandler.setType(e)},getPeriodIndex:function(){return x},setPeriodIndex:function(e){x=e},getVideoModel:function(){return this.videoModel},setVideoModel:function(e){this.videoModel=e},getScheduler:function(){return this.requestScheduler},setScheduler:function(e){this.requestScheduler=e},getFragmentController:function(){return this.fragmentController},setFragmentController:function(e){this.fragmentController=e},getAutoSwitchBitrate:function(){var e=this;return e.abrController.getAutoSwitchBitrate()},setAutoSwitchBitrate:function(e){var t=this;t.abrController.setAutoSwitchBitrate(e)},getData:function(){return k},setData:function(t){var r=this,i=Q.defer(),o=k;return o||(o=t),r.abrController.getPlaybackQuality(n,o).then(function(a){r.indexHandler.getCurrentTime(a.quality,o).then(function(o){v=!0,e=o,k=t,r.seek(o),r.bufferExt.updateData(k,n),i.resolve()})}),i.promise},getBuffer:function(){return F},setBuffer:function(e){F=e},getMinBufferTime:function(){return r},setMinBufferTime:function(e){r=e},setMediaSource:function(e){t=e},isReady:function(){return d===s},isBufferingCompleted:function(){return w},clearMetrics:function(){var e=this;null!==n&&""!==n&&e.metricsModel.clearCurrentMetricsForType(n)},updateBufferState:function(){var e=this;B&&N&&!q?(q=!0,ne.call(e,N,M).then(function(){q=!1})):re.call(e)},reset:function(e){var n=this;Z.call(n),n.clearMetrics(),n.fragmentController.abortRequestsForModel(C),n.fragmentController.detachBufferController(C),C=null,P=[],T=null,p=[],R=Q.defer(),e||(n.sourceBufferExt.abort(t,F),n.sourceBufferExt.removeSourceBuffer(t,F)),k=null,F=null},start:z,seek:X,stop:Z}},MediaPlayer.dependencies.BufferController.prototype={constructor:MediaPlayer.dependencies.BufferController},MediaPlayer.dependencies.BufferExtensions=function(){"use strict";var e,t,n=0,r=0,i=null,o=null,a=function(e){var t=this.metricsExt.getCurrentHttpRequest(e);return null!==t?(t.tresponse.getTime()-t.trequest.getTime())/1e3:0},s=function(){var e,t=this,a=Q.defer();return Q.when(i?t.abrController.getPlaybackQuality("audio",i):n).then(function(i){Q.when(o?t.abrController.getPlaybackQuality("video",o):r).then(function(t){e=i.quality===n&&t.quality===r,e=e||i.confidence===MediaPlayer.rules.SwitchRequest.prototype.STRONG&&t.confidence===MediaPlayer.rules.SwitchRequest.prototype.STRONG,a.resolve(e)})}),a.promise};return{system:void 0,videoModel:void 0,manifestExt:void 0,metricsExt:void 0,metricsModel:void 0,abrController:void 0,bufferMax:void 0,updateData:function(e,t){var a=e.Representation_asArray.length-1;"audio"===t?(n=a,i=e):"video"===t&&(r=a,o=e)},getTopQualityIndex:function(e){var t=null;return"audio"===e?t=n:"video"===e&&(t=r),t},decideBufferLength:function(t,n){return e=MediaPlayer.dependencies.BufferExtensions.DEFAULT_MIN_BUFFER_TIMEt?Math.max(MediaPlayer.dependencies.BufferExtensions.DEFAULT_MIN_BUFFER_TIME,t):t>=n?Math.min(n,MediaPlayer.dependencies.BufferExtensions.DEFAULT_MIN_BUFFER_TIME):Math.min(n,t),Q.when(e)},getLeastBufferLevel:function(){var e=this.metricsModel.getReadOnlyMetricsFor("video"),t=this.metricsExt.getCurrentBufferLevel(e),n=this.metricsModel.getReadOnlyMetricsFor("audio"),r=this.metricsExt.getCurrentBufferLevel(n),i=null;return i=null===t||null===r?null!==r?r.level:null!==t?t.level:null:Math.min(r.level,t.level)},getRequiredBufferLength:function(n,r,i,o){var u,l=this,d=l.metricsModel.getReadOnlyMetricsFor("video"),c=l.metricsModel.getReadOnlyMetricsFor("audio"),f=o>=MediaPlayer.dependencies.BufferExtensions.LONG_FORM_CONTENT_DURATION_THRESHOLD,g=Q.defer(),h=null;return l.bufferMax===MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_MIN?(u=e,g.resolve(u)):l.bufferMax===MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_INFINITY?(u=o,g.resolve(u)):l.bufferMax===MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_REQUIRED?(t=e,i||n||(h=s.call(l)),Q.when(h).then(function(e){e&&(t=f?MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_TOP_QUALITY_LONG_FORM:MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_TOP_QUALITY),u=t+r+Math.max(a.call(l,d),a.call(l,c)),g.resolve(u)})):g.reject("invalid bufferMax value: "+l.bufferMax),g.promise},getBufferTarget:function(){return void 0===t?e:t}}},MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_REQUIRED="required",MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_MIN="min",MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_INFINITY="infinity",MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_STARTUP=1,MediaPlayer.dependencies.BufferExtensions.DEFAULT_MIN_BUFFER_TIME=8,MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_TOP_QUALITY=30,MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_TOP_QUALITY_LONG_FORM=300,MediaPlayer.dependencies.BufferExtensions.LONG_FORM_CONTENT_DURATION_THRESHOLD=600,MediaPlayer.dependencies.BufferExtensions.prototype.constructor=MediaPlayer.dependencies.BufferExtensions,MediaPlayer.utils.Capabilities=function(){"use strict"},MediaPlayer.utils.Capabilities.prototype={constructor:MediaPlayer.utils.Capabilities,supportsMediaSource:function(){"use strict";var e="WebKitMediaSource"in window,t="MediaSource"in window;return e||t},supportsMediaKeys:function(){"use strict";var e="WebKitMediaKeys"in window,t="MSMediaKeys"in window,n="MediaKeys"in window;return e||t||n},supportsCodec:function(e,t){"use strict";if(!(e instanceof HTMLVideoElement))throw"element must be of type HTMLVideoElement.";var n=e.canPlayType(t);return"probably"===n}},MediaPlayer.utils.Debug=function(){"use strict";var e=!0;return{eventBus:void 0,setLogToBrowserConsole:function(t){e=t},getLogToBrowserConsole:function(){return e},log:function(t){e&&console.log(t),this.eventBus.dispatchEvent({type:"log",message:t})}}},MediaPlayer.dependencies.ErrorHandler=function(){"use strict";return{eventBus:void 0,capabilityError:function(e){this.eventBus.dispatchEvent({type:"error",error:"capability",event:e})},downloadError:function(e,t,n){this.eventBus.dispatchEvent({type:"error",error:"download",event:{id:e,url:t,request:n}})},manifestError:function(e,t,n){this.eventBus.dispatchEvent({type:"error",error:"manifestError",event:{message:e,id:t,manifest:n}})},mediaSourceError:function(e){this.eventBus.dispatchEvent({type:"error",error:"mediasource",event:e})},mediaKeySessionError:function(e){this.eventBus.dispatchEvent({type:"error",error:"key_session",event:e})},mediaKeyMessageError:function(e){this.eventBus.dispatchEvent({type:"error",error:"key_message",event:e})},mediaKeySystemSelectionError:function(e){this.eventBus.dispatchEvent({type:"error",error:"key_system_selection",event:e})}}},MediaPlayer.dependencies.ErrorHandler.prototype={constructor:MediaPlayer.dependencies.ErrorHandler},MediaPlayer.utils.EventBus=function(){"use strict";var e,t=function(t,n){var r=(n?"1":"0")+t;return r in e||(e[r]=[]),e[r]},n=function(){e={}};return n(),{addEventListener:function(e,n,r){var i=t(e,r),o=i.indexOf(n);-1===o&&i.push(n)},removeEventListener:function(e,n,r){var i=t(e,r),o=i.indexOf(n);-1!==o&&i.splice(o,1)},dispatchEvent:function(e){for(var n=t(e.type,!1).slice(),r=0;rr;r++)if(e[r].getContext()==t)return e[r];return null},n=function(){for(var t=!0,n=e.length,r=0;n>r;r++)if(!e[r].isReady()){t=!1;break}return t},r=function(){for(var t=0;t0&&(t=new Uint8Array(e)),Q.when(t)},attachBufferController:function(n){if(!n)return null;var r=t(n);return r||(r=this.system.getObject("fragmentModel"),r.setContext(n),e.push(r)),r},detachBufferController:function(t){var n=e.indexOf(t);n>-1&&e.splice(n,1)},onBufferControllerStateChange:function(){n()&&r.call(this)},isFragmentLoadedOrPending:function(e,n){var r,i=t(e);return i?r=i.isFragmentLoadedOrPending(n):!1},getPendingRequests:function(e){var n=t(e);return n?n.getPendingRequests():null},getLoadingRequests:function(e){var n=t(e);return n?n.getLoadingRequests():null},isInitializationRequest:function(e){return e&&e.type&&"initialization segment"===e.type.toLowerCase()},getLoadingTime:function(e){var n=t(e);return n?n.getLoadingTime():null},getExecutedRequestForTime:function(e,t){return e?e.getExecutedRequestForTime(t):null},removeExecutedRequest:function(e,t){e&&e.removeExecutedRequest(t)},removeExecutedRequestsBeforeTime:function(e,t){e&&e.removeExecutedRequestsBeforeTime(t)},cancelPendingRequestsForModel:function(e){e&&e.cancelPendingRequests()},abortRequestsForModel:function(e){e&&e.abortRequests()},prepareFragmentForLoading:function(e,n,r,i,o,a){var s=t(e);return s&&n&&!this.isFragmentLoadedOrPending(e,n)?(s.addRequest(n),s.setCallbacks(r,i,o,a),Q.when(!0)):Q.when(null)}}},MediaPlayer.dependencies.FragmentController.prototype={constructor:MediaPlayer.dependencies.FragmentController},MediaPlayer.dependencies.FragmentLoader=function(){"use strict";var e=3,t=500,n=[],r=function(e,i){var o=new XMLHttpRequest,a=null,s=!0,u=!0,l=this;n.push(o),e.requestStartDate=new Date,e.firstByteDate=e.requestStartDate,o.open("GET",e.url,!0),o.responseType="arraybuffer",e.range&&o.setRequestHeader("Range","bytes="+e.range),o.onprogress=function(t){s&&(s=!1,(!t.lengthComputable||t.lengthComputable&&t.total!=t.loaded)&&(e.firstByteDate=new Date))},o.onload=function(){if(!(o.status<200||o.status>299)){u=!1,e.requestEndDate=new Date;var t=e.requestEndDate,n=o.response,r=e.firstByteDate.getTime()-e.requestStartDate.getTime(),i=e.requestEndDate.getTime()-e.firstByteDate.getTime(),s=e.requestEndDate.getTime()-e.requestStartDate.getTime();l.debug.log("segment loaded: ("+o.status+", "+r+"ms, "+i+"ms, "+s+"ms) "+e.url),a=l.metricsModel.addHttpRequest(e.streamType,null,e.type,e.url,null,e.range,e.requestStartDate,e.firstByteDate,e.requestEndDate,o.status,null,e.duration),l.metricsModel.appendHttpTrace(a,t,(new Date).getTime()-t.getTime(),[n.byteLength]),e.deferred.resolve({data:n,request:e})}},o.onloadend=o.onerror=function(){if(-1!==n.indexOf(o)&&(n.splice(n.indexOf(o),1),u)){u=!1,e.requestEndDate=new Date;var s=e.firstByteDate.getTime()-e.requestStartDate.getTime(),d=e.requestEndDate.getTime()-e.firstByteDate.getTime(),c=e.requestEndDate.getTime()-e.requestStartDate.getTime();l.debug.log("segment loaded: ("+o.status+", "+s+"ms, "+d+"ms, "+c+"ms) "+e.url),a=l.metricsModel.addHttpRequest(e.streamType,null,e.type,e.url,null,e.range,e.requestStartDate,e.firstByteDate,e.requestEndDate,o.status,null,e.duration),i>0?(l.debug.log("Failed loading segment: "+e.url+", retry in "+t+"ms attempts: "+i),i--,setTimeout(function(){r.call(l,e,i)},t)):(l.debug.log("Failed loading segment: "+e.url+" no retry attempts left"),l.errHandler.downloadError("content",e.url,o),e.deferred.reject(o))}},o.send()};return{metricsModel:void 0,errHandler:void 0,debug:void 0,load:function(t){return t?(t.deferred=Q.defer(),r.call(this,t,e),t.deferred.promise):Q.when(null)},abort:function(){var e,t,r=n.length;for(e=0;r>e;e+=1)t=n[e],n[e]=null,t.abort(),t=null;n=[]}}},MediaPlayer.dependencies.FragmentLoader.prototype={constructor:MediaPlayer.dependencies.FragmentLoader},MediaPlayer.dependencies.FragmentModel=function(){"use strict";var e,t,n,r,i,o=[],a=[],s=[],u=5,l=function(i){var a,u=this;t.call(e,i),a=function(t,r){s.splice(s.indexOf(t),1),o.push(t),n.call(e,t,r),t.deferred=null},u.fragmentLoader.load(i).then(a.bind(e,i),r.bind(e,i))},d=function(e,t){var n=function(e,n){return e[t]n[t]?1:0};e.sort(n)},c=function(e,t){var n,r,i=e.length-1;for(r=i;r>=0;r-=1)if(n=e[r],n.url===t.url&&n.startTime===t.startTime)return!0;return!1},f=function(e){var t=o.indexOf(e);-1!==t&&o.splice(t,1)};return{system:void 0,debug:void 0,fragmentLoader:void 0,setContext:function(t){e=t},getContext:function(){return e},addRequest:function(e){e&&(a.push(e),d.call(this,a,"index"))},setCallbacks:function(e,o,a,s){t=e,i=s,r=a,n=o},isFragmentLoadedOrPending:function(e){for(var t,n=this,r=!1,i=o.length-1,u=i;u>=0;u-=1)if(t=o[u],e.startTime===t.startTime||"complete"===t.action&&e.action===t.action){if(n.debug.log(e.streamType+" Fragment already loaded for time: "+e.startTime),e.url===t.url){n.debug.log(e.streamType+" Fragment url already loaded: "+e.url),r=!0;break}f(e)}return r||(r=c.call(n,a,e)||c.call(n,s,e)),r},isReady:function(){return e.isReady()},getPendingRequests:function(){return a},getLoadingRequests:function(){return s},getLoadingTime:function(){var e,t,n=0;for(t=o.length-1;t>=0;t-=1)if(e=o[t],e.requestEndDate instanceof Date&&e.firstByteDate instanceof Date){n=e.requestEndDate.getTime()-e.firstByteDate.getTime();break}return n},getExecutedRequestForTime:function(e){var t,n=o.length-1,r=0/0,i=0/0,a=null;for(t=n;t>=0;t-=1)if(a=o[t],r=a.startTime,i=r+a.duration,!isNaN(r)&&!isNaN(i)&&e>r&&i>e)return a;return null},removeExecutedRequest:function(e){f.call(this,e)},removeExecutedRequestsBeforeTime:function(e){var t,n=o.length-1,r=0/0,i=null;for(t=n;t>=0;t-=1)i=o[t],r=i.startTime,!isNaN(r)&&e>r&&f.call(this,i)},cancelPendingRequests:function(){a=[]},abortRequests:function(){this.fragmentLoader.abort(),s=[]},executeCurrentRequest:function(){var t,n=this;if(0!==a.length&&!(s.length>=u))switch(t=a.shift(),t.action){case"complete":o.push(t),i.call(e,t);break;case"download":s.push(t),l.call(n,t);break;default:this.debug.log("Unknown request action.")}}}},MediaPlayer.dependencies.FragmentModel.prototype={constructor:MediaPlayer.dependencies.FragmentModel},MediaPlayer.dependencies.ManifestLoader=function(){"use strict";var e=3,t=500,n=null,r=function(e){var t=null;return-1!==e.indexOf("/")&&(t=e.substring(0,e.lastIndexOf("/")+1)),t},i=function(e,o){var a=r(e),s=new XMLHttpRequest,u=new Date,l=!0,d=this;this.debug.log("Start loading manifest: "+e),s.open("GET",e,!0),s.onload=function(){s.status<200||s.status>299||(l=!1,d.metricsModel.addHttpRequest("stream",null,"MPD",e,null,null,u,new Date,s.status,null,null),d.parser.parse(s.responseText,a).then(function(t){t.mpdUrl=e,n.resolve(t)},function(){n.reject(s)}))},s.onloadend=s.onerror=function(){l&&(l=!1,d.metricsModel.addHttpRequest("stream",null,"MPD",e,null,null,u,new Date,s.status,null,null),o>0?(d.debug.log("Failed loading manifest: "+e+", retry in "+t+"ms attempts: "+o),o--,setTimeout(function(){i.call(d,e,o)},t)):(d.debug.log("Failed loading manifest: "+e+" no retry attempts left"),d.errHandler.downloadError("manifest",e,s),n.reject(s)))},s.send()};return{debug:void 0,parser:void 0,errHandler:void 0,metricsModel:void 0,load:function(t){return n=Q.defer(),i.call(this,t,e),n.promise}}},MediaPlayer.dependencies.ManifestLoader.prototype={constructor:MediaPlayer.dependencies.ManifestLoader},MediaPlayer.models.ManifestModel=function(){"use strict";var e;return{getValue:function(){return e},setValue:function(t){e=t}}},MediaPlayer.models.ManifestModel.prototype={constructor:MediaPlayer.models.ManifestModel},MediaPlayer.dependencies.ManifestUpdater=function(){"use strict";var e=0/0,t=null,n=null,r=function(){null!==t&&(clearInterval(t),t=null)},i=function(){r.call(this),isNaN(e)||(this.debug.log("Refresh manifest in "+e+" seconds."),t=setInterval(n.bind(this),1e3*e,this))},o=function(){var t=this,n=t.manifestModel.getValue();void 0!==n&&null!==n&&t.manifestExt.getRefreshDelay(n).then(function(n){e=n,i.call(t)})};return n=function(){var e=this,t=e.manifestModel.getValue(),n=t.mpdUrl;t.hasOwnProperty("Location")&&(n=t.Location),e.debug.log("Refresh manifest @ "+n),e.manifestLoader.load(n).then(function(t){e.manifestModel.setValue(t),e.debug.log("Manifest has been refreshed."),e.debug.log(t),o.call(e),e.system.notify("manifestUpdated")})},{debug:void 0,system:void 0,manifestModel:void 0,manifestExt:void 0,manifestLoader:void 0,setup:function(){o.call(this)},init:function(){o.call(this)},stop:function(){r.call(this)}}},MediaPlayer.dependencies.ManifestUpdater.prototype={constructor:MediaPlayer.dependencies.ManifestUpdater},MediaPlayer.dependencies.MediaSourceExtensions=function(){"use strict"},MediaPlayer.dependencies.MediaSourceExtensions.prototype={constructor:MediaPlayer.dependencies.MediaSourceExtensions,createMediaSource:function(){"use strict";var e="WebKitMediaSource"in window,t="MediaSource"in window;return t?Q.when(new MediaSource):e?Q.when(new WebKitMediaSource):null},attachMediaSource:function(e,t){"use strict";return t.setSource(window.URL.createObjectURL(e)),Q.when(!0)},detachMediaSource:function(e){"use strict";return e.setSource(""),Q.when(!0)},setDuration:function(e,t){"use strict";return e.duration=t,Q.when(e.duration)},signalEndOfStream:function(e){"use strict";return e.endOfStream(),Q.when(!0)}},MediaPlayer.models.MetricsModel=function(){"use strict";return{system:void 0,streamMetrics:{},clearCurrentMetricsForType:function(e){delete this.streamMetrics[e]},clearAllCurrentMetrics:function(){this.streamMetrics={}},getReadOnlyMetricsFor:function(e){return this.streamMetrics.hasOwnProperty(e)?this.streamMetrics[e]:null},getMetricsFor:function(e){var t;return this.streamMetrics.hasOwnProperty(e)?t=this.streamMetrics[e]:(t=this.system.getObject("metrics"),this.streamMetrics[e]=t),t},addTcpConnection:function(e,t,n,r,i,o){var a=new MediaPlayer.vo.metrics.TCPConnection;return a.tcpid=t,a.dest=n,a.topen=r,a.tclose=i,a.tconnect=o,this.getMetricsFor(e).TcpList.push(a),a},addHttpRequest:function(e,t,n,r,i,o,a,s,u,l,d,c){var f=new MediaPlayer.vo.metrics.HTTPRequest;return f.tcpid=t,f.type=n,f.url=r,f.actualurl=i,f.range=o,f.trequest=a,f.tresponse=s,f.tfinish=u,f.responsecode=l,f.interval=d,f.mediaduration=c,this.getMetricsFor(e).HttpList.push(f),f},appendHttpTrace:function(e,t,n,r){var i=new MediaPlayer.vo.metrics.HTTPRequest.Trace;return i.s=t,i.d=n,i.b=r,e.trace.push(i),i},addRepresentationSwitch:function(e,t,n,r,i){var o=new MediaPlayer.vo.metrics.RepresentationSwitch;return o.t=t,o.mt=n,o.to=r,o.lto=i,this.getMetricsFor(e).RepSwitchList.push(o),o},addBufferLevel:function(e,t,n){var r=new MediaPlayer.vo.metrics.BufferLevel;return r.t=t,r.level=n,this.getMetricsFor(e).BufferLevel.push(r),r},addPlayList:function(e,t,n,r){var i=new MediaPlayer.vo.metrics.PlayList;return i.start=t,i.mstart=n,i.starttype=r,this.getMetricsFor(e).PlayList.push(i),i},appendPlayListTrace:function(e,t,n,r,i,o,a,s){var u=new MediaPlayer.vo.metrics.PlayList.Trace;return u.representationid=t,u.subreplevel=n,u.start=r,u.mstart=i,u.duration=o,u.playbackspeed=a,u.stopreason=s,e.trace.push(u),u}}},MediaPlayer.models.MetricsModel.prototype={constructor:MediaPlayer.models.MetricsModel},MediaPlayer.dependencies.ProtectionController=function(){"use strict";var e=null,t=null,n=function(e){var t=this;t.protectionModel.removeKeySystem(e)},r=function(e,n){for(var r=this,i=0;ii;i+=1)if(a=o.start(i),s=o.end(i),null===u){if(d=Math.abs(a-t),t>=a&&s>t){u=a,l=s;continue}if(c>=d){u=a,l=s;continue}}else{if(d=a-l,!(c>=d))break;l=s}if(null!==u)return Q.when({start:u,end:l})}return Q.when(null)},getAllRanges:function(e){var t=null;try{return t=e.buffered,Q.when(t)}catch(n){return Q.when(null)}},getBufferLength:function(e,t,n){"use strict";var r=this,i=Q.defer();return r.getBufferRange(e,t,n).then(function(e){i.resolve(null===e?0:e.end-t)}),i.promise},waitForUpdateEnd:function(e){"use strict";var t,n=Q.defer(),r=50,i=function(){e.updating||(clearInterval(t),n.resolve(!0))},o=function(){e.removeEventListener("updateend",o,!1),n.resolve(!0)};if(e.hasOwnProperty("addEventListener"))try{e.addEventListener("updateend",o,!1)}catch(a){t=setInterval(i,r)}else t=setInterval(i,r);return n.promise},append:function(e,t){var n=Q.defer();try{"append"in e?e.append(t):"appendBuffer"in e&&e.appendBuffer(t),this.waitForUpdateEnd(e).then(function(){n.resolve()})}catch(r){n.reject({err:r,data:t})}return n.promise},remove:function(e,t,n,r,i){var o=Q.defer();try{t>=0&&r>t&&n>t&&"ended"!==i.readyState&&e.remove(t,n),this.waitForUpdateEnd(e).then(function(){o.resolve()})}catch(a){o.reject(a)}return o.promise},abort:function(e,t){"use strict";var n=Q.defer();try{"open"===e.readyState&&t.abort(),n.resolve()}catch(r){n.reject(r.description)}return n.promise}},MediaPlayer.dependencies.Stream=function(){"use strict";var e,t,n,r,i,o,a,s,u,l,d,c,f,g,h,p,m=null,y=null,v=null,M=null,b=-1,E=null,S=-1,w=null,P=-1,T=!0,R=!1,_=!1,L=null,x=[],O=-1,D=null,C=function(){this.debug.log("Attempting play..."),R&&(this.debug.log("Do play."),this.videoModel.play())},A=function(){this.debug.log("Do pause."),this.videoModel.pause()},B=function(e){this.debug.log("Attempting seek..."),R&&(this.debug.log("Do seek: "+e),this.system.notify("setCurrentTime"),this.videoModel.setCurrentTime(e),M&&M.seek(e),E&&E.seek(e))},N=function(e){var t,n=this;if(t="msneedkey"!==e.type?e.type:m,x.push({type:t,initData:e.initData}),this.debug.log("DRM: Key required for - "+t),v&&m&&!L)try{L=n.protectionController.selectKeySystem(m,v)}catch(r){A.call(n),n.debug.log(r),n.errHandler.mediaKeySystemSelectionError(r)}L&&n.protectionController.ensureKeySession(L,t,e.initData)},I=function(e){var t=this,n=null,r=null,i=null,o=null;this.debug.log("DRM: Got a key message..."),n=e.target,r=new Uint16Array(e.message.buffer),i=String.fromCharCode.apply(null,r),o=e.destinationURL,t.protectionController.updateFromMessage(L,n,i,o).fail(function(e){A.call(t),t.debug.log(e),t.errHandler.mediaKeyMessageError(e)})},q=function(){this.debug.log("DRM: Key added.")},k=function(){var e,t=event.target;switch(e="DRM: MediaKeyError - sessionId: "+t.sessionId+" errorCode: "+t.error.code+" systemErrorCode: "+t.error.systemCode+" [",t.error.code){case 1:e+="MEDIA_KEYERR_UNKNOWN - An unspecified error occurred. This value is used for errors that don't match any of the other codes.";break;case 2:e+="MEDIA_KEYERR_CLIENT - The Key System could not be installed or updated.";break;case 3:e+="MEDIA_KEYERR_SERVICE - The message passed into update indicated an error from the license service.";break;case 4:e+="MEDIA_KEYERR_OUTPUT - There is no available output device with the required characteristics for the content protection system.";break;case 5:e+="MEDIA_KEYERR_HARDWARECHANGE - A hardware configuration change caused a content protection error.";break;case 6:e+="MEDIA_KEYERR_DOMAIN - An error occurred in a multi-device domain licensing configuration. The most common error is a failure to join the domain."}e+="]",this.debug.log(e),this.errHandler.mediaKeySessionError(e)},F=function(e){var t=Q.defer(),n=this,r=function(i){n.debug.log("MediaSource is open!"),n.debug.log(i),e.removeEventListener("sourceopen",r),e.removeEventListener("webkitsourceopen",r),t.resolve(e)};return n.debug.log("MediaSource should be closed. The actual readyState is: "+e.readyState),e.addEventListener("sourceopen",r,!1),e.addEventListener("webkitsourceopen",r,!1),n.mediaSourceExt.attachMediaSource(e,n.videoModel),n.debug.log("MediaSource attached to video. Waiting on open..."),t.promise},U=function(){var n=this;M&&M.reset(_),E&&E.reset(_),t&&n.mediaSourceExt.detachMediaSource(n.videoModel),R=!1,L=null,x=[],v=null,M=null,E=null,w=null,m=null,y=null,t=null,e=null},j=function(t,n,r,i){if(t&&n&&r)if(null===M&&null===E&&null===w){var o="No streams to play.";this.errHandler.manifestError(o,"nostreams",e),this.debug.log(o),i.reject()}else this.debug.log("MediaSource initialized!"),i.resolve(!0)},H=function(){this.debug.log("Getting MediaSource ready...");var e=Q.defer(),n=!1,r=!1,i=!1,o=this,a=o.manifestModel.getValue(),s=o.manifestExt.getIsLive(a);return o.debug.log("Gathering information for buffers. (1)"),o.manifestExt.getDuration(a,s).then(function(){o.manifestExt.getVideoData(a,O).then(function(s){return null!==s?(o.debug.log("Create video buffer."),o.manifestExt.getDataIndex(s,a,O).then(function(e){b=e,o.debug.log("Save video track: "+b)}),o.manifestExt.getCodec(s).then(function(e){return o.debug.log("Video codec: "+e),m=e,o.manifestExt.getContentProtectionData(s).then(function(n){if(o.debug.log("Video contentProtection"),n&&!o.capabilities.supportsMediaKeys())return o.errHandler.capabilityError("mediakeys"),Q.when(null);if(v=n,!o.capabilities.supportsCodec(o.videoModel.getElement(),e)){var r="Video Codec ("+e+") is not supported.";return o.errHandler.manifestError(r,"codec",a),o.debug.log(r),Q.when(null)}return o.sourceBufferExt.createSourceBuffer(t,e)})}).then(function(a){null===a?o.debug.log("No buffer was created, skipping video stream."):(M=o.system.getObject("bufferController"),M.initialize("video",O,s,a,o.videoModel,o.requestScheduler,o.fragmentController,t),o.debug.log("Video is ready!")),n=!0,j.call(o,n,r,i,e)},function(){o.errHandler.mediaSourceError("Error creating video source buffer."),n=!0,j.call(o,n,r,i,e)})):(o.debug.log("No video data."),n=!0,j.call(o,n,r,i,e)),o.manifestExt.getAudioDatas(a,O)}).then(function(s){return null!==s&&s.length>0?(o.debug.log("Have audio streams: "+s.length),o.manifestExt.getPrimaryAudioData(a,O).then(function(s){o.manifestExt.getDataIndex(s,a,O).then(function(e){S=e,o.debug.log("Save audio track: "+S)}),o.manifestExt.getCodec(s).then(function(e){return o.debug.log("Audio codec: "+e),y=e,o.manifestExt.getContentProtectionData(s).then(function(n){if(o.debug.log("Audio contentProtection"),n&&!o.capabilities.supportsMediaKeys())return o.errHandler.capabilityError("mediakeys"),Q.when(null);if(v=n,!o.capabilities.supportsCodec(o.videoModel.getElement(),e)){var r="Audio Codec ("+e+") is not supported.";return o.errHandler.manifestError(r,"codec",a),o.debug.log(r),Q.when(null)}return o.sourceBufferExt.createSourceBuffer(t,e)})}).then(function(a){null===a?o.debug.log("No buffer was created, skipping audio stream."):(E=o.system.getObject("bufferController"),E.initialize("audio",O,s,a,o.videoModel,o.requestScheduler,o.fragmentController,t),o.debug.log("Audio is ready!")),r=!0,j.call(o,n,r,i,e)},function(){o.errHandler.mediaSourceError("Error creating audio source buffer."),r=!0,j.call(o,n,r,i,e)})})):(o.debug.log("No audio streams."),r=!0,j.call(o,n,r,i,e)),o.manifestExt.getTextData(a,O)}).then(function(s){var u;null!==s?(o.manifestExt.getDataIndex(s,a,O).then(function(e){P=e,o.debug.log("Save text track: "+P)}),o.manifestExt.getMimeType(s).then(function(e){return u=e,o.sourceBufferExt.createSourceBuffer(t,u)}).then(function(t){null===t?o.debug.log("Source buffer was not created for text track"):(w=o.system.getObject("textController"),w.initialize(O,s,t,o.videoModel),t.hasOwnProperty("initialize")&&t.initialize(u,w),o.debug.log("Text is ready!"),i=!0,j.call(o,n,r,i,e))},function(t){o.debug.log("Error creating text source buffer:"),o.debug.log(t),o.errHandler.mediaSourceError("Error creating text source buffer."),i=!0,j.call(o,n,r,i,e)})):(o.debug.log("No text tracks."),i=!0,j.call(o,n,r,i,e))})}),e.promise},V=function(){var e=this,n=Q.defer(),r=e.manifestModel.getValue(),i=e.manifestExt.getIsLive(r);return e.debug.log("Getting ready for playback..."),e.manifestExt.getDurationForPeriod(O,e.manifestModel.getValue(),i).then(function(e){c=e}),e.manifestExt.getDuration(e.manifestModel.getValue(),i).then(function(n){return e.debug.log("Setting duration: "+n),e.mediaSourceExt.setDuration(t,n)}).then(function(){return e.debug.log("Duration successfully set."),e.manifestExt.getPeriodStart(e.manifestModel.getValue(),O)}).then(function(e){D=e,R=!0,n.resolve(!0)}),n.promise},K=function(){var e=this;e.debug.log("Got loadmetadata event."),n.resolve(null)},W=function(){this.debug.log("Got play event."),R&&(null!==D?(this.debug.log("Starting segment loading at offset: "+D),M&&M.seek(D),E&&E.seek(D),w&&w.seek(D)):(M&&M.start(),E&&E.start(),w&&w.start()))},G=function(){this.debug.log("Got pause event."),this.scheduleWhilePaused||ee.call(this)},z=function(e){var t=e.srcElement.error,n=t.code,r="";if(-1!==n){switch(n){case 1:r="MEDIA_ERR_ABORTED";break;case 2:r="MEDIA_ERR_NETWORK";break;case 3:r="MEDIA_ERR_DECODE";break;case 4:r="MEDIA_ERR_SRC_NOT_SUPPORTED";break;case 5:r="MEDIA_ERR_ENCRYPTED"}_=!0,this.debug.log("Video Element Error: "+r),this.debug.log(t),this.errHandler.mediaSourceError(r),this.reset()}},X=function(){this.debug.log("Got seeking event.");var e=this.videoModel.getCurrentTime();M&&M.seek(e),E&&E.seek(e)},Z=function(){this.debug.log("Seek complete."),this.videoModel.listen("seeking",s),this.videoModel.unlisten("seeked",u)},Y=function(){J.call(this)},$=function(){J.call(this)},J=function(){M&&M.updateBufferState(),E&&E.updateBufferState()},ee=function(){M&&M.stop(),E&&E.stop()},te=function(r){var i=this;return i.debug.log("Stream start loading."),e=r,i.mediaSourceExt.createMediaSource().then(function(e){return i.debug.log("MediaSource created."),F.call(i,e)}).then(function(e){return t=e,i.debug.log("MediaSource set up."),H.call(i)}).then(function(){return i.debug.log("Start initializing playback."),V.call(i)}).then(function(){return T?(i.debug.log("Playback initialized!"),n.promise):void 0}).then(function(){i.debug.log("element loaded!"),0===O&&C.call(i)})},ne=function(){this.debug.log("Current time has changed, block programmatic seek."),this.videoModel.unlisten("seeking",s),this.videoModel.listen("seeked",u)},re=function(){M&&!M.isBufferingCompleted()||E&&!E.isBufferingCompleted()||t&&this.mediaSourceExt.signalEndOfStream(t)},ie=function(){ee.call(this)},oe=function(){var e,t,n=this,r=n.manifestModel.getValue();n.debug.log("Manifest updated... set new data on buffers."),M&&(e=M.getData(),e&&e.hasOwnProperty("id")?n.manifestExt.getDataForId(e.id,r,O).then(function(e){M.setData(e)}):n.manifestExt.getDataForIndex(b,r,O).then(function(e){M.setData(e)})),E&&(t=E.getData(),t&&t.hasOwnProperty("id")?n.manifestExt.getDataForId(t.id,r,O).then(function(e){E.setData(e)}):n.manifestExt.getDataForIndex(S,r,O).then(function(e){E.setData(e)}))};return{system:void 0,videoModel:void 0,manifestLoader:void 0,manifestModel:void 0,mediaSourceExt:void 0,sourceBufferExt:void 0,bufferExt:void 0,manifestExt:void 0,fragmentController:void 0,abrController:void 0,fragmentExt:void 0,protectionModel:void 0,protectionController:void 0,protectionExt:void 0,capabilities:void 0,debug:void 0,metricsExt:void 0,errHandler:void 0,requestScheduler:void 0,scheduleWhilePaused:void 0,setup:function(){this.system.mapHandler("manifestUpdated",void 0,oe.bind(this)),this.system.mapHandler("setCurrentTime",void 0,ne.bind(this)),this.system.mapHandler("bufferingCompleted",void 0,re.bind(this)),this.system.mapHandler("segmentLoadingFailed",void 0,ie.bind(this)),n=Q.defer(),i=W.bind(this),o=G.bind(this),a=z.bind(this),s=X.bind(this),u=Z.bind(this),d=Y.bind(this),l=$.bind(this),r=K.bind(this)},load:function(e,t){O=t,te.call(this,e)},setVideoModel:function(e){this.videoModel=e,this.videoModel.listen("play",i),this.videoModel.listen("pause",o),this.videoModel.listen("error",a),this.videoModel.listen("seeking",s),this.videoModel.listen("timeupdate",l),this.videoModel.listen("progress",d),this.videoModel.listen("loadedmetadata",r)},initProtection:function(){f=N.bind(this),g=I.bind(this),h=q.bind(this),p=k.bind(this),this.protectionModel=this.system.getObject("protectionModel"),this.protectionModel.init(this.getVideoModel()),this.protectionController=this.system.getObject("protectionController"),this.protectionController.init(this.videoModel,this.protectionModel),this.protectionModel.listenToNeedKey(f),this.protectionModel.listenToKeyMessage(g),this.protectionModel.listenToKeyError(p),this.protectionModel.listenToKeyAdded(h)},getVideoModel:function(){return this.videoModel},getManifestExt:function(){var e=this;return e.manifestExt},setAutoPlay:function(e){T=e},getAutoPlay:function(){return T},reset:function(){A.call(this),this.videoModel.unlisten("play",i),this.videoModel.unlisten("pause",o),this.videoModel.unlisten("error",a),this.videoModel.unlisten("seeking",s),this.videoModel.unlisten("timeupdate",l),this.videoModel.unlisten("progress",d),this.videoModel.unlisten("loadedmetadata",r),U.call(this),this.protectionController&&this.protectionController.teardownKeySystem(L),this.protectionController=void 0,this.protectionModel=void 0,this.fragmentController=void 0,this.requestScheduler=void 0,n=Q.defer()},getDuration:function(){return c},setPeriodIndex:function(e){O=e},getPeriodIndex:function(){return O},getStartTime:function(){return D},play:C,seek:B,pause:A}},MediaPlayer.dependencies.Stream.prototype={constructor:MediaPlayer.dependencies.Stream},MediaPlayer.dependencies.StreamController=function(){"use strict";var e,t=[],n=4,r=3,i=!0,o=null,a=function(){e.play()},s=function(){e.pause()},u=function(t){e.seek(t)},l=function(e,t){var n=e.getElement(),r=t.getElement();return r.parentNode||n.parentNode.insertBefore(r,n),n.style.width="0px",r.style.width="100%",f(n,r),c(e),d(t),Q.when(!0)},d=function(e){e.listen("seeking",p),e.listen("progress",g),y()&&e.listen("timeupdate",h)},c=function(e){e.unlisten("seeking",p),e.unlisten("progress",g),e.unlisten("timeupdate",h)},f=function(e,t){["controls","loop","muted","playbackRate","volume"].forEach(function(n){t[n]=e[n]})},g=function(){var t=e.getVideoModel().getElement().buffered;if(t.length){var r=t.length-1,i=t.end(r),o=e.getStartTime()+e.getDuration()-i;n>o&&(e.getVideoModel().unlisten("progress",g),m())}},h=function(){if(!e.getVideoModel().getElement().seeking){var t=e.getStartTime()+e.getDuration(),n=e.getVideoModel().getCurrentTime();r>t-n&&E(e,y())}},p=function(){var t=e.getVideoModel().getCurrentTime(),n=v(t);n&&n!==e&&E(e,n,t)},m=function(){var e=y();e&&e.seek(e.getStartTime())},y=function(){var n=e.getPeriodIndex()+1;return ni;i++)if(r=t[i],n+=r.getDuration(),n>e)return r},M=function(){var e=this.system.getObject("videoModel"),t=document.createElement("video");return e.setElement(t),e},b=function(e){e.parentNode&&e.parentNode.removeChild(e)},E=function(t,n,r){t&&n&&t!==n&&Q.when(o||!0).then(function(){t.pause(),e=n,o=l(t.getVideoModel(),n.getVideoModel()),u(r?t.getVideoModel().getCurrentTime():n.getStartTime()),a()})};return{system:void 0,videoModel:void 0,manifestLoader:void 0,manifestUpdater:void 0,manifestModel:void 0,mediaSourceExt:void 0,sourceBufferExt:void 0,bufferExt:void 0,manifestExt:void 0,fragmentController:void 0,abrController:void 0,fragmentExt:void 0,capabilities:void 0,debug:void 0,metricsExt:void 0,errHandler:void 0,getManifestExt:function(){return e.getManifestExt()},setAutoPlay:function(e){i=e},getAutoPlay:function(){return i},getVideoModel:function(){return this.videoModel},setVideoModel:function(e){this.videoModel=e},load:function(n){var r,o=this;o.manifestLoader.load(n).then(function(n){o.manifestModel.setValue(n),o.debug.log("Manifest has loaded."),o.debug.log(o.manifestModel.getValue()),o.manifestUpdater.init(),o.manifestExt.getPeriodCount(n).then(function(a){for(var s=0;a>s;s++)r=o.system.getObject("stream"),r.setVideoModel(0===s?o.videoModel:M.call(o)),r.initProtection(),r.setAutoPlay(i),r.load(n,s),t.push(r);e=t[0],d(e.getVideoModel())})},function(){o.reset()})},reset:function(){e&&c(e.getVideoModel());for(var n=0,r=t.length;r>n;n++){var i=t[n];i.reset(),i!==e&&b(i.getVideoModel().getElement())}t=[],this.manifestUpdater.stop(),this.manifestModel.setValue(null),o=null,e=null},play:a,seek:u,pause:s}},MediaPlayer.dependencies.StreamController.prototype={constructor:MediaPlayer.dependencies.StreamController},MediaPlayer.models.VideoModel=function(){"use strict";var e,t=[],n=function(){return t.length>0},r=function(n){null!==n&&t[n]!==!0&&(t.push(n),t[n]=!0,e.playbackRate=0)},i=function(r){if(null!==r){t[r]=!1;var i=t.indexOf(r);-1!==i&&t.splice(i,1),n()===!1&&(e.playbackRate=1)}},o=function(e,t){t?r(e):i(e)};return{system:void 0,setup:function(){},play:function(){e.play()},pause:function(){e.pause()},isPaused:function(){return e.paused},getPlaybackRate:function(){return e.playbackRate},setPlaybackRate:function(t){e.playbackRate=t},getCurrentTime:function(){return e.currentTime},setCurrentTime:function(t){e.currentTime!=t&&(e.currentTime=t)},listen:function(t,n){e.addEventListener(t,n,!1)},unlisten:function(t,n){e.removeEventListener(t,n,!1)},getElement:function(){return e},setElement:function(t){e=t},setSource:function(t){e.src=t},stallStream:o,isStalled:n}},MediaPlayer.models.VideoModel.prototype={constructor:MediaPlayer.models.VideoModel},MediaPlayer.dependencies.VideoModelExtensions=function(){"use strict";return{getDroppedFrames:function(e){var t=null!==e.webkitDroppedFrameCount,n=-1;return t&&(n=e.webkitDroppedFrameCount),n}}},MediaPlayer.dependencies.VideoModelExtensions.prototype={constructor:MediaPlayer.dependencies.VideoModelExtensions},MediaPlayer.dependencies.TextController=function(){var e,t,n="LOADING",r="READY",i=!1,o=-1,a=r,s=function(e){this.debug.log("TextController setState to:"+e),a=e},u=function(){if(i&&a===r){var t=this;s.call(t,n),t.indexHandler.getInitRequest(0,e).then(function(e){t.debug.log("Loading text track initialization: "+e.url),t.debug.log(e),t.fragmentLoader.load(e).then(d.bind(t,e),c.bind(t,e)),s.call(t,n)})}},l=function(){u.call(this)},d=function(e,n){var r=this;r.debug.log(" Text track Bytes finished loading: "+e.url),r.fragmentController.process(n.data).then(function(e){null!==e&&(r.debug.log("Push text track bytes: "+e.byteLength),r.sourceBufferExt.append(t,e,r.videoModel))})},c=function(){};return{videoModel:void 0,fragmentLoader:void 0,fragmentController:void 0,indexHandler:void 0,sourceBufferExt:void 0,debug:void 0,initialize:function(e,t,n,r){var o=this;o.setVideoModel(r),o.setPeriodIndex(e),o.setData(t),o.setBuffer(n),i=!0},getPeriodIndex:function(){return o},setPeriodIndex:function(e){o=e},getVideoModel:function(){return this.videoModel},setVideoModel:function(e){this.videoModel=e},getData:function(){return e},setData:function(t){e=t},getBuffer:function(){return t},setBuffer:function(e){t=e},reset:function(e,n){e||(this.sourceBufferExt.abort(n,t),this.sourceBufferExt.removeSourceBuffer(n,t))},start:l}},MediaPlayer.dependencies.TextController.prototype={constructor:MediaPlayer.dependencies.TextController},MediaPlayer.utils.TextTrackExtensions=function(){"use strict";return{addTextTrack:function(e,t,n,r,i){var o=e.addTextTrack("captions",n,r);o["default"]=i,o.mode="showing";for(var a in t){var s=t[a];o.addCue(new TextTrackCue(s.start,s.end,s.data))}return Q.when(o)},deleteCues:function(e){for(var t=e.textTracks[0],n=t.cues,r=n.length;r>=0;r--)t.removeCue(n[r]);t.mode="disabled"}}},MediaPlayer.dependencies.TextVTTSourceBuffer=function(){var e,t,n;return{system:void 0,eventBus:void 0,initialize:function(r,i){n=r,e=i.getVideoModel().getElement(),t=i.getData()},append:function(n){var r=this;r.getParser().parse(String.fromCharCode.apply(null,new Uint16Array(n))).then(function(n){var i=t.Representation_asArray[0].id,o=t.lang;r.getTextTrackExtensions().addTextTrack(e,n,i,o,!0).then(function(){r.eventBus.dispatchEvent({type:"updateend"})})})},abort:function(){this.getTextTrackExtensions().deleteCues(e)},getParser:function(){var e;return"text/vtt"===n&&(e=this.system.getObject("vttParser")),e},getTextTrackExtensions:function(){return this.system.getObject("textTrackExtensions")},addEventListener:function(e,t,n){this.eventBus.addEventListener(e,t,n)},removeEventListener:function(e,t,n){this.eventBus.removeEventListener(e,t,n)}}},MediaPlayer.dependencies.TextVTTSourceBuffer.prototype={constructor:MediaPlayer.dependencies.TextVTTSourceBuffer},MediaPlayer.utils.VTTParser=function(){"use strict";var e=function(e){var t=e.split(":"),n=t.length-1;return e=60*parseInt(t[n-1],10)+parseFloat(t[n],10),2===n&&(e+=3600*parseInt(t[0],10)),e};return{parse:function(t){var n,r=/(?:\r\n|\r|\n)/gm,i=/-->/,o=/(^[\s]+|[\s]+$)/g,a=[];t=t.split(r),n=t.length;for(var s=0;n>s;s++){var u=t[s];if(u.length>0&&"WEBVTT"!==u&&u.match(i)){var l=u.split(i),d=t[s+1];a.push({start:e(l[0].replace(o,"")),end:e(l[1].replace(o,"")),data:d})}}return Q.when(a)}}},MediaPlayer.rules.BaseRulesCollection=function(){ +"use strict";var e=[];return{downloadRatioRule:void 0,insufficientBufferRule:void 0,getRules:function(){return Q.when(e)},setup:function(){var e=this;e.getRules().then(function(t){t.push(e.downloadRatioRule),t.push(e.insufficientBufferRule)})}}},MediaPlayer.rules.BaseRulesCollection.prototype={constructor:MediaPlayer.rules.BaseRulesCollection},MediaPlayer.rules.DownloadRatioRule=function(){"use strict";var e=function(e,t,n){var r=this,i=Q.defer();return r.manifestExt.getRepresentationFor(e,n).then(function(e){r.manifestExt.getBandwidth(e).then(function(e){i.resolve(e/t)})}),i.promise};return{debug:void 0,manifestExt:void 0,checkIndex:function(t,n,r){var i,o,a,s,u,l,d,c,f,g,h=this,p=n.HttpList,m=.75;return h.debug.log("Checking download ratio rule..."),n?null===p||void 0===p||0===p.length?(h.debug.log("No requests made for this stream yet, bailing."),Q.when(new MediaPlayer.rules.SwitchRequest)):(i=p[p.length-1],a=(i.tfinish.getTime()-i.trequest.getTime())/1e3,o=(i.tfinish.getTime()-i.tresponse.getTime())/1e3,0>=a?(h.debug.log("Don't know how long the download of the last fragment took, bailing."),Q.when(new MediaPlayer.rules.SwitchRequest)):null===i.mediaduration||void 0===i.mediaduration||i.mediaduration<=0?(h.debug.log("Don't know the duration of the last media fragment, bailing."),Q.when(new MediaPlayer.rules.SwitchRequest)):(d=Q.defer(),u=i.mediaduration/a,s=i.mediaduration/o*m,isNaN(s)||isNaN(u)?(h.debug.log("Total time: "+a+"s"),h.debug.log("Download time: "+o+"s"),h.debug.log("The ratios are NaN, bailing."),Q.when(new MediaPlayer.rules.SwitchRequest)):(h.debug.log("Total ratio: "+u),h.debug.log("Download ratio: "+s),h.debug.log("Download ratio: "+s),isNaN(s)?(h.debug.log("Invalid ratio, bailing."),d.resolve(new MediaPlayer.rules.SwitchRequest)):1>s?(h.debug.log("Download ratio is poor."),t>0?(h.debug.log("We are not at the lowest bitrate, so switch down."),h.manifestExt.getRepresentationFor(t-1,r).then(function(e){h.manifestExt.getBandwidth(e).then(function(e){h.manifestExt.getRepresentationFor(t,r).then(function(n){h.manifestExt.getBandwidth(n).then(function(n){l=e/n,h.debug.log("Switch ratio: "+l),l>s?(h.debug.log("Things must be going pretty bad, switch all the way down."),d.resolve(new MediaPlayer.rules.SwitchRequest(0))):(h.debug.log("Things could be better, so just switch down one index."),d.resolve(new MediaPlayer.rules.SwitchRequest(t-1)))})})})})):(h.debug.log("We are at the lowest bitrate and cannot switch down, use current."),d.resolve(new MediaPlayer.rules.SwitchRequest(t)))):(h.debug.log("Download ratio is good."),h.manifestExt.getRepresentationCount(r).then(function(n){n-=1,n>t?(h.debug.log("We are not at the highest bitrate, so switch up."),h.manifestExt.getRepresentationFor(t+1,r).then(function(i){h.manifestExt.getBandwidth(i).then(function(i){h.manifestExt.getRepresentationFor(t,r).then(function(o){h.manifestExt.getBandwidth(o).then(function(o){if(l=i/o,h.debug.log("Switch ratio: "+l),s>=l)if(s>1e3)h.debug.log("Tons of bandwidth available, go all the way up."),d.resolve(new MediaPlayer.rules.SwitchRequest(n-1));else if(s>100)h.debug.log("Just enough bandwidth available, switch up one."),d.resolve(new MediaPlayer.rules.SwitchRequest(t+1));else{for(h.debug.log("Not exactly sure where to go, so do some math."),f=-1,c=[];(f+=1)f&&!(st&&(u=MediaPlayer.rules.SwitchRequest.prototype.STRONG,a.debug.log("Apply STRONG to buffer rule.")),s?(a.debug.log("The buffer ran dry recently, switch down."),Q.when(new MediaPlayer.rules.SwitchRequest(n-1,u))):e>t?(a.debug.log("Too many dry buffer hits, quit switching bitrates."),Q.when(new MediaPlayer.rules.SwitchRequest(n,u))):Q.when(new MediaPlayer.rules.SwitchRequest(MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,u)))))}}},MediaPlayer.rules.InsufficientBufferRule.prototype={constructor:MediaPlayer.rules.InsufficientBufferRule},MediaPlayer.rules.LimitSwitchesRule=function(){"use strict";var e=10,t=2e4,n=5,r=0;return{debug:void 0,checkIndex:function(i,o){if(r>0)return r-=1,Q.when(new MediaPlayer.rules.SwitchRequest(i,MediaPlayer.rules.SwitchRequest.prototype.STRONG));var a,s,u,l=this,d=!1,c=(new Date).getTime(),f=o.RepSwitchList.length;for(l.debug.log("Checking limit switches rule..."),u=f-1;u>=0;u-=1){if(a=o.RepSwitchList[u],s=c-a.t.getTime(),s>=t){l.debug.log("Reached time limit, bailing.");break}if(u>=e){l.debug.log("Found too many switches within validation time, force the stream to not change."),d=!0;break}}return d?(l.debug.log("Wait some time before allowing another switch."),r=n,Q.when(new MediaPlayer.rules.SwitchRequest(i,MediaPlayer.rules.SwitchRequest.prototype.STRONG))):Q.when(new MediaPlayer.rules.SwitchRequest(MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,MediaPlayer.rules.SwitchRequest.prototype.STRONG))}}},MediaPlayer.rules.LimitSwitchesRule.prototype={constructor:MediaPlayer.rules.LimitSwitchesRule},MediaPlayer.rules.SwitchRequest=function(e,t){"use strict";this.quality=e,this.priority=t,void 0===this.quality&&(this.quality=999),void 0===this.priority&&(this.priority=.5)},MediaPlayer.rules.SwitchRequest.prototype={constructor:MediaPlayer.rules.SwitchRequest,NO_CHANGE:999,DEFAULT:.5,STRONG:1,WEAK:0},MediaPlayer.models.MetricsList=function(){"use strict";return{TcpList:[],HttpList:[],RepSwitchList:[],BufferLevel:[],PlayList:[],DroppedFrames:[]}},MediaPlayer.models.MetricsList.prototype={constructor:MediaPlayer.models.MetricsList},MediaPlayer.vo.SegmentRequest=function(){"use strict";this.action="download",this.startTime=0/0,this.streamType=null,this.type=null,this.duration=0/0,this.timescale=0/0,this.range=null,this.url=null,this.requestStartDate=null,this.firstByteDate=null,this.requestEndDate=null,this.deferred=null,this.quality=0/0,this.index=0/0},MediaPlayer.vo.SegmentRequest.prototype={constructor:MediaPlayer.vo.SegmentRequest,ACTION_DOWNLOAD:"download",ACTION_COMPLETE:"complete"},MediaPlayer.vo.metrics.BufferLevel=function(){"use strict";this.t=null,this.level=null},MediaPlayer.vo.metrics.BufferLevel.prototype={constructor:MediaPlayer.vo.metrics.BufferLevel},MediaPlayer.vo.metrics.DroppedFrames=function(){"use strict";this.time=null,this.droppedFrames=null},MediaPlayer.vo.metrics.DroppedFrames.prototype={constructor:MediaPlayer.vo.metrics.DroppedFrames},MediaPlayer.vo.metrics.HTTPRequest=function(){"use strict";this.tcpid=null,this.type=null,this.url=null,this.actualurl=null,this.range=null,this.trequest=null,this.tresponse=null,this.tfinish=null,this.responsecode=null,this.interval=null,this.mediaduration=null,this.trace=[]},MediaPlayer.vo.metrics.HTTPRequest.prototype={constructor:MediaPlayer.vo.metrics.HTTPRequest},MediaPlayer.vo.metrics.HTTPRequest.Trace=function(){"use strict";this.s=null,this.d=null,this.b=[]},MediaPlayer.vo.metrics.HTTPRequest.Trace.prototype={constructor:MediaPlayer.vo.metrics.HTTPRequest.Trace},MediaPlayer.vo.metrics.PlayList=function(){"use strict";this.start=null,this.mstart=null,this.starttype=null,this.trace=[]},MediaPlayer.vo.metrics.PlayList.Trace=function(){"use strict";this.representationid=null,this.subreplevel=null,this.start=null,this.mstart=null,this.duration=null,this.playbackspeed=null,this.stopreason=null},MediaPlayer.vo.metrics.PlayList.prototype={constructor:MediaPlayer.vo.metrics.PlayList},MediaPlayer.vo.metrics.PlayList.INITIAL_PLAY_START_REASON="initial_start",MediaPlayer.vo.metrics.PlayList.SEEK_START_REASON="seek",MediaPlayer.vo.metrics.PlayList.Trace.prototype={constructor:MediaPlayer.vo.metrics.PlayList.Trace()},MediaPlayer.vo.metrics.PlayList.Trace.USER_REQUEST_STOP_REASON="user_request",MediaPlayer.vo.metrics.PlayList.Trace.REPRESENTATION_SWITCH_STOP_REASON="representation_switch",MediaPlayer.vo.metrics.PlayList.Trace.END_OF_CONTENT_STOP_REASON="end_of_content",MediaPlayer.vo.metrics.PlayList.Trace.REBUFFERING_REASON="rebuffering",MediaPlayer.vo.metrics.RepresentationSwitch=function(){"use strict";this.t=null,this.mt=null,this.to=null,this.lto=null},MediaPlayer.vo.metrics.RepresentationSwitch.prototype={constructor:MediaPlayer.vo.metrics.RepresentationSwitch},MediaPlayer.vo.metrics.TCPConnection=function(){"use strict";this.tcpid=null,this.dest=null,this.topen=null,this.tclose=null,this.tconnect=null},MediaPlayer.vo.metrics.TCPConnection.prototype={constructor:MediaPlayer.vo.metrics.TCPConnection}; \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.blockUI.min.js b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.blockUI.min.js new file mode 100644 index 000000000..fa14fb14a --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.blockUI.min.js @@ -0,0 +1 @@ +!function(){"use strict";function e(e){function t(t,n){var s,h,k=t==window,y=n&&void 0!==n.message?n.message:void 0;if(n=e.extend({},e.blockUI.defaults,n||{}),!n.ignoreIfBlocked||!e(t).data("blockUI.isBlocked")){if(n.overlayCSS=e.extend({},e.blockUI.defaults.overlayCSS,n.overlayCSS||{}),s=e.extend({},e.blockUI.defaults.css,n.css||{}),n.onOverlayClick&&(n.overlayCSS.cursor="pointer"),h=e.extend({},e.blockUI.defaults.themedCSS,n.themedCSS||{}),y=void 0===y?n.message:y,k&&p&&o(window,{fadeOut:0}),y&&"string"!=typeof y&&(y.parentNode||y.jquery)){var m=y.jquery?y[0]:y,v={};e(t).data("blockUI.history",v),v.el=m,v.parent=m.parentNode,v.display=m.style.display,v.position=m.style.position,v.parent&&v.parent.removeChild(m)}e(t).data("blockUI.onUnblock",n.onUnblock);var g,I,w,U,x=n.baseZ;g=e(r||n.forceIframe?'':''),I=e(n.theme?'':''),n.theme&&k?(U='"):n.theme?(U='"):U=k?'':'',w=e(U),y&&(n.theme?(w.css(h),w.addClass("ui-widget-content")):w.css(s)),n.theme||I.css(n.overlayCSS),I.css("position",k?"fixed":"absolute"),(r||n.forceIframe)&&g.css("opacity",0);var C=[g,I,w],S=e(k?"body":t);e.each(C,function(){this.appendTo(S)}),n.theme&&n.draggable&&e.fn.draggable&&w.draggable({handle:".ui-dialog-titlebar",cancel:"li"});var O=f&&(!e.support.boxModel||e("object,embed",k?null:t).length>0);if(u||O){if(k&&n.allowBodyStretch&&e.support.boxModel&&e("html,body").css("height","100%"),(u||!e.support.boxModel)&&!k)var E=d(t,"borderTopWidth"),T=d(t,"borderLeftWidth"),M=E?"(0 - "+E+")":0,B=T?"(0 - "+T+")":0;e.each(C,function(e,t){var o=t[0].style;if(o.position="absolute",2>e)k?o.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:"+n.quirksmodeOffsetHack+') + "px"'):o.setExpression("height",'this.parentNode.offsetHeight + "px"'),k?o.setExpression("width",'jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):o.setExpression("width",'this.parentNode.offsetWidth + "px"'),B&&o.setExpression("left",B),M&&o.setExpression("top",M);else if(n.centerY)k&&o.setExpression("top",'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'),o.marginTop=0;else if(!n.centerY&&k){var i=n.css&&n.css.top?parseInt(n.css.top,10):0,s="((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "+i+') + "px"';o.setExpression("top",s)}})}if(y&&(n.theme?w.find(".ui-widget-content").append(y):w.append(y),(y.jquery||y.nodeType)&&e(y).show()),(r||n.forceIframe)&&n.showOverlay&&g.show(),n.fadeIn){var j=n.onBlock?n.onBlock:c,H=n.showOverlay&&!y?j:c,z=y?j:c;n.showOverlay&&I._fadeIn(n.fadeIn,H),y&&w._fadeIn(n.fadeIn,z)}else n.showOverlay&&I.show(),y&&w.show(),n.onBlock&&n.onBlock();if(i(1,t,n),k?(p=w[0],b=e(n.focusableElements,p),n.focusInput&&setTimeout(l,20)):a(w[0],n.centerX,n.centerY),n.timeout){var W=setTimeout(function(){k?e.unblockUI(n):e(t).unblock(n)},n.timeout);e(t).data("blockUI.timeout",W)}}}function o(t,o){var s,l=t==window,a=e(t),d=a.data("blockUI.history"),c=a.data("blockUI.timeout");c&&(clearTimeout(c),a.removeData("blockUI.timeout")),o=e.extend({},e.blockUI.defaults,o||{}),i(0,t,o),null===o.onUnblock&&(o.onUnblock=a.data("blockUI.onUnblock"),a.removeData("blockUI.onUnblock"));var r;r=l?e("body").children().filter(".blockUI").add("body > .blockUI"):a.find(">.blockUI"),o.cursorReset&&(r.length>1&&(r[1].style.cursor=o.cursorReset),r.length>2&&(r[2].style.cursor=o.cursorReset)),l&&(p=b=null),o.fadeOut?(s=r.length,r.stop().fadeOut(o.fadeOut,function(){0===--s&&n(r,d,o,t)})):n(r,d,o,t)}function n(t,o,n,i){var s=e(i);if(!s.data("blockUI.isBlocked")){t.each(function(e,t){this.parentNode&&this.parentNode.removeChild(this)}),o&&o.el&&(o.el.style.display=o.display,o.el.style.position=o.position,o.parent&&o.parent.appendChild(o.el),s.removeData("blockUI.history")),s.data("blockUI.static")&&s.css("position","static"),"function"==typeof n.onUnblock&&n.onUnblock(i,n);var l=e(document.body),a=l.width(),d=l[0].style.width;l.width(a-1).width(a),l[0].style.width=d}}function i(t,o,n){var i=o==window,l=e(o);if((t||(!i||p)&&(i||l.data("blockUI.isBlocked")))&&(l.data("blockUI.isBlocked",t),i&&n.bindEvents&&(!t||n.showOverlay))){var a="mousedown mouseup keydown keypress keyup touchstart touchend touchmove";t?e(document).bind(a,n,s):e(document).unbind(a,s)}}function s(t){if("keydown"===t.type&&t.keyCode&&9==t.keyCode&&p&&t.data.constrainTabKey){var o=b,n=!t.shiftKey&&t.target===o[o.length-1],i=t.shiftKey&&t.target===o[0];if(n||i)return setTimeout(function(){l(i)},10),!1}var s=t.data,a=e(t.target);return a.hasClass("blockOverlay")&&s.onOverlayClick&&s.onOverlayClick(t),a.parents("div."+s.blockMsgClass).length>0?!0:0===a.parents().children().filter("div.blockUI").length}function l(e){if(b){var t=b[e===!0?b.length-1:0];t&&t.focus()}}function a(e,t,o){var n=e.parentNode,i=e.style,s=(n.offsetWidth-e.offsetWidth)/2-d(n,"borderLeftWidth"),l=(n.offsetHeight-e.offsetHeight)/2-d(n,"borderTopWidth");t&&(i.left=s>0?s+"px":"0"),o&&(i.top=l>0?l+"px":"0")}function d(t,o){return parseInt(e.css(t,o),10)||0}e.fn._fadeIn=e.fn.fadeIn;var c=e.noop||function(){},r=/MSIE/.test(navigator.userAgent),u=/MSIE 6.0/.test(navigator.userAgent)&&!/MSIE 8.0/.test(navigator.userAgent),f=(document.documentMode||0,e.isFunction(document.createElement("div").style.setExpression));e.blockUI=function(e){t(window,e)},e.unblockUI=function(e){o(window,e)},e.growlUI=function(t,o,n,i){var s=e('
');t&&s.append("

"+t+"

"),o&&s.append("

"+o+"

"),void 0===n&&(n=3e3);var l=function(t){t=t||{},e.blockUI({message:s,fadeIn:"undefined"!=typeof t.fadeIn?t.fadeIn:700,fadeOut:"undefined"!=typeof t.fadeOut?t.fadeOut:1e3,timeout:"undefined"!=typeof t.timeout?t.timeout:n,centerY:!1,showOverlay:!1,onUnblock:i,css:e.blockUI.defaults.growlCSS})};l();s.css("opacity");s.mouseover(function(){l({fadeIn:0,timeout:3e4});var t=e(".blockMsg");t.stop(),t.fadeTo(300,1)}).mouseout(function(){e(".blockMsg").fadeOut(1e3)})},e.fn.block=function(o){if(this[0]===window)return e.blockUI(o),this;var n=e.extend({},e.blockUI.defaults,o||{});return this.each(function(){var t=e(this);n.ignoreIfBlocked&&t.data("blockUI.isBlocked")||t.unblock({fadeOut:0})}),this.each(function(){"static"==e.css(this,"position")&&(this.style.position="relative",e(this).data("blockUI.static",!0)),this.style.zoom=1,t(this,o)})},e.fn.unblock=function(t){return this[0]===window?(e.unblockUI(t),this):this.each(function(){o(this,t)})},e.blockUI.version=2.66,e.blockUI.defaults={message:"

Please wait...

",title:null,draggable:!0,theme:!1,css:{padding:0,margin:0,width:"30%",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{width:"30%",top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:.6,cursor:"wait"},cursorReset:"default",growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px",opacity:.6,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:!1,baseZ:1e3,centerX:!0,centerY:!0,allowBodyStretch:!0,bindEvents:!0,constrainTabKey:!0,fadeIn:200,fadeOut:400,timeout:0,showOverlay:!0,focusInput:!0,focusableElements:":input:enabled:visible",onBlock:null,onUnblock:null,onOverlayClick:null,quirksmodeOffsetHack:4,blockMsgClass:"blockMsg",ignoreIfBlocked:!1};var p=null,b=[]}"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery"],e):e(jQuery)}(); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.fileupload-process.min.js b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.fileupload-process.min.js new file mode 100644 index 000000000..beee5454a --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.fileupload-process.min.js @@ -0,0 +1 @@ +!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./jquery.fileupload"],e):e(window.jQuery)}(function(e){"use strict";var s=e.blueimp.fileupload.prototype.options.add;e.widget("blueimp.fileupload",e.blueimp.fileupload,{options:{processQueue:[],add:function(r,i){var o=e(this);i.process(function(){return o.fileupload("process",i)}),s.call(this,r,i)}},processActions:{},_processFile:function(s,r){var i=this,o=e.Deferred().resolveWith(i,[s]),t=o.promise();return this._trigger("process",null,s),e.each(s.processQueue,function(s,o){var n=function(s){return r.errorThrown?e.Deferred().rejectWith(i,[r]).promise():i.processActions[o.action].call(i,s,o)};t=t.pipe(n,o.always&&n)}),t.done(function(){i._trigger("processdone",null,s),i._trigger("processalways",null,s)}).fail(function(){i._trigger("processfail",null,s),i._trigger("processalways",null,s)}),t},_transformProcessQueue:function(s){var r=[];e.each(s.processQueue,function(){var i={},o=this.action,t=this.prefix===!0?o:this.prefix;e.each(this,function(r,o){i[r]="string"===e.type(o)&&"@"===o.charAt(0)?s[o.slice(1)||(t?t+r.charAt(0).toUpperCase()+r.slice(1):r)]:o}),r.push(i)}),s.processQueue=r},processing:function(){return this._processing},process:function(s){var r=this,i=e.extend({},this.options,s);return i.processQueue&&i.processQueue.length&&(this._transformProcessQueue(i),0===this._processing&&this._trigger("processstart"),e.each(s.files,function(o){var t=o?e.extend({},i):i,n=function(){return s.errorThrown?e.Deferred().rejectWith(r,[s]).promise():r._processFile(t,s)};t.index=o,r._processing+=1,r._processingQueue=r._processingQueue.pipe(n,n).always(function(){r._processing-=1,0===r._processing&&r._trigger("processstop")})})),this._processingQueue},_create:function(){this._super(),this._processing=0,this._processingQueue=e.Deferred().resolveWith(this).promise()}})}); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.fileupload-validate.min.js b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.fileupload-validate.min.js new file mode 100644 index 000000000..ea3f06422 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jquery.fileupload-validate.min.js @@ -0,0 +1 @@ +!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./jquery.fileupload-process"],e):e(window.jQuery)}(function(e){"use strict";e.blueimp.fileupload.prototype.options.processQueue.push({action:"validate",always:!0,acceptFileTypes:"@",maxFileSize:"@",minFileSize:"@",maxNumberOfFiles:"@",disabled:"@disableValidation"}),e.widget("blueimp.fileupload",e.blueimp.fileupload,{options:{getNumberOfFiles:e.noop,messages:{maxNumberOfFiles:"Maximum number of files exceeded",acceptFileTypes:"File type not allowed",maxFileSize:"File is too large",minFileSize:"File is too small"}},processActions:{validate:function(i,l){if(l.disabled)return i;var r,s=e.Deferred(),t=this.options,o=i.files[i.index];return(l.minFileSize||l.maxFileSize)&&(r=o.size),"number"===e.type(l.maxNumberOfFiles)&&(t.getNumberOfFiles()||0)+i.files.length>l.maxNumberOfFiles?o.error=t.i18n("maxNumberOfFiles"):!l.acceptFileTypes||l.acceptFileTypes.test(o.type)||l.acceptFileTypes.test(o.name)?r>l.maxFileSize?o.error=t.i18n("maxFileSize"):"number"===e.type(r)&&r').prop("disabled")),e.support.xhrFileUpload=!(!window.ProgressEvent||!window.FileReader),e.support.xhrFormDataFileUpload=!!window.FormData,e.support.blobSlice=window.Blob&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice),e.widget("blueimp.fileupload",{options:{dropZone:e(document),pasteZone:e(document),fileInput:void 0,replaceFileInput:!0,paramName:void 0,singleFileUploads:!0,limitMultiFileUploads:void 0,limitMultiFileUploadSize:void 0,limitMultiFileUploadSizeOverhead:512,sequentialUploads:!1,limitConcurrentUploads:void 0,forceIframeTransport:!1,redirect:void 0,redirectParamName:void 0,postMessage:void 0,multipart:!0,maxChunkSize:void 0,uploadedBytes:void 0,recalculateProgress:!0,progressInterval:100,bitrateInterval:500,autoUpload:!0,messages:{uploadedBytes:"Uploaded bytes exceed file size"},i18n:function(t,i){return t=this.messages[t]||t.toString(),i&&e.each(i,function(e,i){t=t.replace("{"+e+"}",i)}),t},formData:function(e){return e.serializeArray()},add:function(t,i){return t.isDefaultPrevented()?!1:void((i.autoUpload||i.autoUpload!==!1&&e(this).fileupload("option","autoUpload"))&&i.process().done(function(){i.submit()}))},processData:!1,contentType:!1,cache:!1},_specialOptions:["fileInput","dropZone","pasteZone","multipart","forceIframeTransport"],_blobSlice:e.support.blobSlice&&function(){var e=this.slice||this.webkitSlice||this.mozSlice;return e.apply(this,arguments)},_BitrateTimer:function(){this.timestamp=Date.now?Date.now():(new Date).getTime(),this.loaded=0,this.bitrate=0,this.getBitrate=function(e,t,i){var r=e-this.timestamp;return(!this.bitrate||!i||r>i)&&(this.bitrate=(t-this.loaded)*(1e3/r)*8,this.loaded=t,this.timestamp=e),this.bitrate}},_isXHRUpload:function(t){return!t.forceIframeTransport&&(!t.multipart&&e.support.xhrFileUpload||e.support.xhrFormDataFileUpload)},_getFormData:function(t){var i;return"function"===e.type(t.formData)?t.formData(t.form):e.isArray(t.formData)?t.formData:"object"===e.type(t.formData)?(i=[],e.each(t.formData,function(e,t){i.push({name:e,value:t})}),i):[]},_getTotal:function(t){var i=0;return e.each(t,function(e,t){i+=t.size||1}),i},_initProgressObject:function(t){var i={loaded:0,total:0,bitrate:0};t._progress?e.extend(t._progress,i):t._progress=i},_initResponseObject:function(e){var t;if(e._response)for(t in e._response)e._response.hasOwnProperty(t)&&delete e._response[t];else e._response={}},_onProgress:function(t,i){if(t.lengthComputable){var r,n=Date.now?Date.now():(new Date).getTime();if(i._time&&i.progressInterval&&n-i._time").prop("href",t.url).prop("host");t.dataType="iframe "+(t.dataType||""),t.formData=this._getFormData(t),t.redirect&&i&&i!==location.host&&t.formData.push({name:t.redirectParamName||"redirect",value:t.redirect})},_initDataSettings:function(e){this._isXHRUpload(e)?(this._chunkedUpload(e,!0)||(e.data||this._initXHRData(e),this._initProgressListener(e)),e.postMessage&&(e.dataType="postmessage "+(e.dataType||""))):this._initIframeSettings(e)},_getParamName:function(t){var i=e(t.fileInput),r=t.paramName;return r?e.isArray(r)||(r=[r]):(r=[],i.each(function(){for(var t=e(this),i=t.prop("name")||"files[]",n=(t.prop("files")||[1]).length;n;)r.push(i),n-=1}),r.length||(r=[i.prop("name")||"files[]"])),r},_initFormSettings:function(t){t.form&&t.form.length||(t.form=e(t.fileInput.prop("form")),t.form.length||(t.form=e(this.options.fileInput.prop("form")))),t.paramName=this._getParamName(t),t.url||(t.url=t.form.prop("action")||location.href),t.type=(t.type||"string"===e.type(t.form.prop("method"))&&t.form.prop("method")||"").toUpperCase(),"POST"!==t.type&&"PUT"!==t.type&&"PATCH"!==t.type&&(t.type="POST"),t.formAcceptCharset||(t.formAcceptCharset=t.form.attr("accept-charset"))},_getAJAXSettings:function(t){var i=e.extend({},this.options,t);return this._initFormSettings(i),this._initDataSettings(i),i},_getDeferredState:function(e){return e.state?e.state():e.isResolved()?"resolved":e.isRejected()?"rejected":"pending"},_enhancePromise:function(e){return e.success=e.done,e.error=e.fail,e.complete=e.always,e},_getXHRPromise:function(t,i,r){var n=e.Deferred(),s=n.promise();return i=i||this.options.context||s,t===!0?n.resolveWith(i,r):t===!1&&n.rejectWith(i,r),s.abort=n.promise,this._enhancePromise(s)},_addConvenienceMethods:function(t,i){var r=this,n=function(t){return e.Deferred().resolveWith(r,t).promise()};i.process=function(t,s){return(t||s)&&(i._processQueue=this._processQueue=(this._processQueue||n([this])).pipe(function(){return i.errorThrown?e.Deferred().rejectWith(r,[i]).promise():n(arguments)}).pipe(t,s)),this._processQueue||n([this])},i.submit=function(){return"pending"!==this.state()&&(i.jqXHR=this.jqXHR=r._trigger("submit",e.Event("submit",{delegatedEvent:t}),this)!==!1&&r._onSend(t,this)),this.jqXHR||r._getXHRPromise()},i.abort=function(){return this.jqXHR?this.jqXHR.abort():(this.errorThrown="abort",r._trigger("fail",null,this),r._getXHRPromise(!1))},i.state=function(){return this.jqXHR?r._getDeferredState(this.jqXHR):this._processQueue?r._getDeferredState(this._processQueue):void 0},i.processing=function(){return!this.jqXHR&&this._processQueue&&"pending"===r._getDeferredState(this._processQueue)},i.progress=function(){return this._progress},i.response=function(){return this._response}},_getUploadedBytes:function(e){var t=e.getResponseHeader("Range"),i=t&&t.split("-"),r=i&&i.length>1&&parseInt(i[1],10);return r&&r+1},_chunkedUpload:function(t,i){t.uploadedBytes=t.uploadedBytes||0;var r,n,s=this,o=t.files[0],a=o.size,l=t.uploadedBytes,p=t.maxChunkSize||a,u=this._blobSlice,d=e.Deferred(),h=d.promise();return this._isXHRUpload(t)&&u&&(l||a>p)&&!t.data?i?!0:l>=a?(o.error=t.i18n("uploadedBytes"),this._getXHRPromise(!1,t.context,[null,"error",o.error])):(n=function(){var i=e.extend({},t),h=i._progress.loaded;i.blob=u.call(o,l,l+p,o.type),i.chunkSize=i.blob.size,i.contentRange="bytes "+l+"-"+(l+i.chunkSize-1)+"/"+a,s._initXHRData(i),s._initProgressListener(i),r=(s._trigger("chunksend",null,i)!==!1&&e.ajax(i)||s._getXHRPromise(!1,i.context)).done(function(r,o,p){l=s._getUploadedBytes(p)||l+i.chunkSize,h+i.chunkSize-i._progress.loaded&&s._onProgress(e.Event("progress",{lengthComputable:!0,loaded:l-i.uploadedBytes,total:l-i.uploadedBytes}),i),t.uploadedBytes=i.uploadedBytes=l,i.result=r,i.textStatus=o,i.jqXHR=p,s._trigger("chunkdone",null,i),s._trigger("chunkalways",null,i),a>l?n():d.resolveWith(i.context,[r,o,p])}).fail(function(e,t,r){i.jqXHR=e,i.textStatus=t,i.errorThrown=r,s._trigger("chunkfail",null,i),s._trigger("chunkalways",null,i),d.rejectWith(i.context,[e,t,r])})},this._enhancePromise(h),h.abort=function(){return r.abort()},n(),h):!1},_beforeSend:function(e,t){0===this._active&&(this._trigger("start"),this._bitrateTimer=new this._BitrateTimer,this._progress.loaded=this._progress.total=0,this._progress.bitrate=0),this._initResponseObject(t),this._initProgressObject(t),t._progress.loaded=t.loaded=t.uploadedBytes||0,t._progress.total=t.total=this._getTotal(t.files)||1,t._progress.bitrate=t.bitrate=0,this._active+=1,this._progress.loaded+=t.loaded,this._progress.total+=t.total},_onDone:function(t,i,r,n){var s=n._progress.total,o=n._response;n._progress.loadeda._sending)for(var r=a._slots.shift();r;){if("pending"===a._getDeferredState(r)){r.resolve();break}r=a._slots.shift()}0===a._active&&a._trigger("stop")})};return this._beforeSend(t,l),this.options.sequentialUploads||this.options.limitConcurrentUploads&&this.options.limitConcurrentUploads<=this._sending?(this.options.limitConcurrentUploads>1?(s=e.Deferred(),this._slots.push(s),o=s.pipe(p)):(this._sequence=this._sequence.pipe(p,p),o=this._sequence),o.abort=function(){return n=[void 0,"abort","abort"],r?r.abort():(s&&s.rejectWith(l.context,n),p())},this._enhancePromise(o)):p()},_onAdd:function(t,i){var r,n,s,o,a=this,l=!0,p=e.extend({},this.options,i),u=i.files,d=u.length,h=p.limitMultiFileUploads,c=p.limitMultiFileUploadSize,f=p.limitMultiFileUploadSizeOverhead,g=0,_=this._getParamName(p),m=0;if(!c||d&&void 0!==u[0].size||(c=void 0),(p.singleFileUploads||h||c)&&this._isXHRUpload(p))if(p.singleFileUploads||c||!h)if(!p.singleFileUploads&&c)for(s=[],r=[],o=0;d>o;o+=1)g+=u[o].size+f,(o+1===d||g+u[o+1].size+f>c||h&&o+1-m>=h)&&(s.push(u.slice(m,o+1)),n=_.slice(m,o+1),n.length||(n=_),r.push(n),m=o+1,g=0);else r=_;else for(s=[],r=[],o=0;d>o;o+=h)s.push(u.slice(o,o+h)),n=_.slice(o,o+h),n.length||(n=_),r.push(n);else s=[u],r=[_];return i.originalFiles=u,e.each(s||u,function(n,o){var p=e.extend({},i);return p.files=s?o:[o],p.paramName=r[n],a._initResponseObject(p),a._initProgressObject(p),a._addConvenienceMethods(t,p),l=a._trigger("add",e.Event("add",{delegatedEvent:t}),p)}),l},_replaceFileInput:function(t){var i=t.clone(!0);e("
").append(i)[0].reset(),t.after(i).detach(),e.cleanData(t.unbind("remove")),this.options.fileInput=this.options.fileInput.map(function(e,r){return r===t[0]?i[0]:r}),t[0]===this.element[0]&&(this.element=i)},_handleFileTreeEntry:function(t,i){var r,n=this,s=e.Deferred(),o=function(e){e&&!e.entry&&(e.entry=t),s.resolve([e])};return i=i||"",t.isFile?t._file?(t._file.relativePath=i,s.resolve(t._file)):t.file(function(e){e.relativePath=i,s.resolve(e)},o):t.isDirectory?(r=t.createReader(),r.readEntries(function(e){n._handleFileTreeEntries(e,i+t.name+"/").done(function(e){s.resolve(e)}).fail(o)},o)):s.resolve([]),s.promise()},_handleFileTreeEntries:function(t,i){var r=this;return e.when.apply(e,e.map(t,function(e){return r._handleFileTreeEntry(e,i)})).pipe(function(){return Array.prototype.concat.apply([],arguments)})},_getDroppedFiles:function(t){t=t||{};var i=t.items;return i&&i.length&&(i[0].webkitGetAsEntry||i[0].getAsEntry)?this._handleFileTreeEntries(e.map(i,function(e){var t;return e.webkitGetAsEntry?(t=e.webkitGetAsEntry(),t&&(t._file=e.getAsFile()),t):e.getAsEntry()})):e.Deferred().resolve(e.makeArray(t.files)).promise()},_getSingleFileInputFiles:function(t){t=e(t);var i,r,n=t.prop("webkitEntries")||t.prop("entries");if(n&&n.length)return this._handleFileTreeEntries(n);if(i=e.makeArray(t.prop("files")),i.length)void 0===i[0].name&&i[0].fileName&&e.each(i,function(e,t){t.name=t.fileName,t.size=t.fileSize});else{if(r=t.prop("value"),!r)return e.Deferred().resolve([]).promise();i=[{name:r.replace(/^.*\\/,"")}]}return e.Deferred().resolve(i).promise()},_getFileInputFiles:function(t){return t instanceof e&&1!==t.length?e.when.apply(e,e.map(t,this._getSingleFileInputFiles)).pipe(function(){return Array.prototype.concat.apply([],arguments)}):this._getSingleFileInputFiles(t)},_onChange:function(t){var i=this,r={fileInput:e(t.target),form:e(t.target.form)};this._getFileInputFiles(r.fileInput).always(function(n){r.files=n,i.options.replaceFileInput&&i._replaceFileInput(r.fileInput),i._trigger("change",e.Event("change",{delegatedEvent:t}),r)!==!1&&i._onAdd(t,r)})},_onPaste:function(t){var i=t.originalEvent&&t.originalEvent.clipboardData&&t.originalEvent.clipboardData.items,r={files:[]};i&&i.length&&(e.each(i,function(e,t){var i=t.getAsFile&&t.getAsFile();i&&r.files.push(i)}),this._trigger("paste",e.Event("paste",{delegatedEvent:t}),r)!==!1&&this._onAdd(t,r))},_onDrop:function(t){t.dataTransfer=t.originalEvent&&t.originalEvent.dataTransfer;var i=this,r=t.dataTransfer,n={};r&&r.files&&r.files.length&&(t.preventDefault(),this._getDroppedFiles(r).always(function(r){n.files=r,i._trigger("drop",e.Event("drop",{delegatedEvent:t}),n)!==!1&&i._onAdd(t,n)}))},_onDragOver:function(t){t.dataTransfer=t.originalEvent&&t.originalEvent.dataTransfer;var i=t.dataTransfer;i&&-1!==e.inArray("Files",i.types)&&this._trigger("dragover",e.Event("dragover",{delegatedEvent:t}))!==!1&&(t.preventDefault(),i.dropEffect="copy")},_initEventHandlers:function(){this._isXHRUpload(this.options)&&(this._on(this.options.dropZone,{dragover:this._onDragOver,drop:this._onDrop}),this._on(this.options.pasteZone,{paste:this._onPaste})),e.support.fileInput&&this._on(this.options.fileInput,{change:this._onChange})},_destroyEventHandlers:function(){this._off(this.options.dropZone,"dragover drop"),this._off(this.options.pasteZone,"paste"),this._off(this.options.fileInput,"change")},_setOption:function(t,i){var r=-1!==e.inArray(t,this._specialOptions);r&&this._destroyEventHandlers(),this._super(t,i),r&&(this._initSpecialOptions(),this._initEventHandlers())},_initSpecialOptions:function(){var t=this.options;void 0===t.fileInput?t.fileInput=this.element.is('input[type="file"]')?this.element:this.element.find('input[type="file"]'):t.fileInput instanceof e||(t.fileInput=e(t.fileInput)),t.dropZone instanceof e||(t.dropZone=e(t.dropZone)),t.pasteZone instanceof e||(t.pasteZone=e(t.pasteZone))},_getRegExp:function(e){var t=e.split("/"),i=t.pop();return t.shift(),new RegExp(t.join("/"),i)},_isRegExpOption:function(t,i){return"url"!==t&&"string"===e.type(i)&&/^\/.*\/[igm]{0,3}$/.test(i)},_initDataAttributes:function(){var t=this,i=this.options,r=e(this.element[0].cloneNode(!1));e.each(r.data(),function(e,n){var s="data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();r.attr(s)&&(t._isRegExpOption(e,n)&&(n=t._getRegExp(n)),i[e]=n)})},_create:function(){this._initDataAttributes(),this._initSpecialOptions(),this._slots=[],this._sequence=this._getXHRPromise(!0),this._sending=this._active=0,this._initProgressObject(this),this._initEventHandlers()},active:function(){return this._active},progress:function(){return this._progress},add:function(t){var i=this;t&&!this.options.disabled&&(t.fileInput&&!t.files?this._getFileInputFiles(t.fileInput).always(function(e){t.files=e,i._onAdd(null,t)}):(t.files=e.makeArray(t.files),this._onAdd(null,t)))},send:function(t){if(t&&!this.options.disabled){if(t.fileInput&&!t.files){var i,r,n=this,s=e.Deferred(),o=s.promise();return o.abort=function(){return r=!0,i?i.abort():(s.reject(null,"abort","abort"),o)},this._getFileInputFiles(t.fileInput).always(function(e){if(!r){if(!e.length)return void s.reject();t.files=e,i=n._onSend(null,t).then(function(e,t,i){s.resolve(e,t,i)},function(e,t,i){s.reject(e,t,i)})}}),this._enhancePromise(o)}if(t.files=e.makeArray(t.files),t.files.length)return this._onSend(null,t)}return this._getXHRPromise(!1,t&&t.context)}})}); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/swfobject.min.js b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/swfobject.min.js new file mode 100644 index 000000000..4556a14fd --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/swfobject.min.js @@ -0,0 +1 @@ +var swfobject=function(){function e(){if(!G){try{var e=M.getElementsByTagName("body")[0].appendChild(h("span"));e.parentNode.removeChild(e)}catch(t){return}G=!0;for(var n=R.length,a=0;n>a;a++)R[a]()}}function t(e){G?e():R[R.length]=e}function n(e){if(typeof x.addEventListener!=L)x.addEventListener("load",e,!1);else if(typeof M.addEventListener!=L)M.addEventListener("load",e,!1);else if(typeof x.attachEvent!=L)m(x,"onload",e);else if("function"==typeof x.onload){var t=x.onload;x.onload=function(){t(),e()}}else x.onload=e}function a(){P?i():r()}function i(){var e=M.getElementsByTagName("body")[0],t=h(k);t.setAttribute("type",O);var n=e.appendChild(t);if(n){var a=0;!function(){if(typeof n.GetVariable!=L){var i=n.GetVariable("$version");i&&(i=i.split(" ")[1].split(","),X.pv=[parseInt(i[0],10),parseInt(i[1],10),parseInt(i[2],10)])}else if(10>a)return a++,void setTimeout(arguments.callee,10);e.removeChild(t),n=null,r()}()}else r()}function r(){var e=D.length;if(e>0)for(var t=0;e>t;t++){var n=D[t].id,a=D[t].callbackFn,i={success:!1,id:n};if(X.pv[0]>0){var r=y(n);if(r)if(!g(D[t].swfVersion)||X.wk&&X.wk<312)if(D[t].expressInstall&&s()){var f={};f.data=D[t].expressInstall,f.width=r.getAttribute("width")||"0",f.height=r.getAttribute("height")||"0",r.getAttribute("class")&&(f.styleclass=r.getAttribute("class")),r.getAttribute("align")&&(f.align=r.getAttribute("align"));for(var d={},u=r.getElementsByTagName("param"),p=u.length,v=0;p>v;v++)"movie"!=u[v].getAttribute("name").toLowerCase()&&(d[u[v].getAttribute("name")]=u[v].getAttribute("value"));l(f,d,n,a)}else c(r),a&&a(i);else b(n,!0),a&&(i.success=!0,i.ref=o(n),a(i))}else if(b(n,!0),a){var h=o(n);h&&typeof h.SetVariable!=L&&(i.success=!0,i.ref=h),a(i)}}}function o(e){var t=null,n=y(e);if(n&&"OBJECT"==n.nodeName)if(typeof n.SetVariable!=L)t=n;else{var a=n.getElementsByTagName(k)[0];a&&(t=a)}return t}function s(){return!J&&g("6.0.65")&&(X.win||X.mac)&&!(X.wk&&X.wk<312)}function l(e,t,n,a){J=!0,A=a||null,N={success:!1,id:n};var i=y(n);if(i){"OBJECT"==i.nodeName?(E=f(i),S=null):(E=i,S=n),e.id=F,(typeof e.width==L||!/%$/.test(e.width)&&parseInt(e.width,10)<310)&&(e.width="310"),(typeof e.height==L||!/%$/.test(e.height)&&parseInt(e.height,10)<137)&&(e.height="137"),M.title=M.title.slice(0,47)+" - Flash Player Installation";var r=X.ie&&X.win?"ActiveX":"PlugIn",o="MMredirectURL="+x.location.toString().replace(/&/g,"%26")+"&MMplayerType="+r+"&MMdoctitle="+M.title;if(typeof t.flashvars!=L?t.flashvars+="&"+o:t.flashvars=o,X.ie&&X.win&&4!=i.readyState){var s=h("div");n+="SWFObjectNew",s.setAttribute("id",n),i.parentNode.insertBefore(s,i),i.style.display="none",function(){4==i.readyState?i.parentNode.removeChild(i):setTimeout(arguments.callee,10)}()}d(e,t,n)}}function c(e){if(X.ie&&X.win&&4!=e.readyState){var t=h("div");e.parentNode.insertBefore(t,e),t.parentNode.replaceChild(f(e),t),e.style.display="none",function(){4==e.readyState?e.parentNode.removeChild(e):setTimeout(arguments.callee,10)}()}else e.parentNode.replaceChild(f(e),e)}function f(e){var t=h("div");if(X.win&&X.ie)t.innerHTML=e.innerHTML;else{var n=e.getElementsByTagName(k)[0];if(n){var a=n.childNodes;if(a)for(var i=a.length,r=0;i>r;r++)1==a[r].nodeType&&"PARAM"==a[r].nodeName||8==a[r].nodeType||t.appendChild(a[r].cloneNode(!0))}}return t}function d(e,t,n){var a,i=y(n);if(X.wk&&X.wk<312)return a;if(i)if(typeof e.id==L&&(e.id=n),X.ie&&X.win){var r="";for(var o in e)e[o]!=Object.prototype[o]&&("data"==o.toLowerCase()?t.movie=e[o]:"styleclass"==o.toLowerCase()?r+=' class="'+e[o]+'"':"classid"!=o.toLowerCase()&&(r+=" "+o+'="'+e[o]+'"'));var s="";for(var l in t)t[l]!=Object.prototype[l]&&(s+='');i.outerHTML='"+s+"",W[W.length]=e.id,a=y(e.id)}else{var c=h(k);c.setAttribute("type",O);for(var f in e)e[f]!=Object.prototype[f]&&("styleclass"==f.toLowerCase()?c.setAttribute("class",e[f]):"classid"!=f.toLowerCase()&&c.setAttribute(f,e[f]));for(var d in t)t[d]!=Object.prototype[d]&&"movie"!=d.toLowerCase()&&u(c,d,t[d]);i.parentNode.replaceChild(c,i),a=c}return a}function u(e,t,n){var a=h("param");a.setAttribute("name",t),a.setAttribute("value",n),e.appendChild(a)}function p(e){var t=y(e);t&&"OBJECT"==t.nodeName&&(X.ie&&X.win?(t.style.display="none",function(){4==t.readyState?v(e):setTimeout(arguments.callee,10)}()):t.parentNode.removeChild(t))}function v(e){var t=y(e);if(t){for(var n in t)"function"==typeof t[n]&&(t[n]=null);t.parentNode.removeChild(t)}}function y(e){var t=null;try{t=M.getElementById(e)}catch(n){}return t}function h(e){return M.createElement(e)}function m(e,t,n){e.attachEvent(t,n),H[H.length]=[e,t,n]}function g(e){var t=X.pv,n=e.split(".");return n[0]=parseInt(n[0],10),n[1]=parseInt(n[1],10)||0,n[2]=parseInt(n[2],10)||0,t[0]>n[0]||t[0]==n[0]&&t[1]>n[1]||t[0]==n[0]&&t[1]==n[1]&&t[2]>=n[2]?!0:!1}function w(e,t,n,a){if(!X.ie||!X.mac){var i=M.getElementsByTagName("head")[0];if(i){var r=n&&"string"==typeof n?n:"screen";if(a&&(T=null,I=null),!T||I!=r){var o=h("style");o.setAttribute("type","text/css"),o.setAttribute("media",r),T=i.appendChild(o),X.ie&&X.win&&typeof M.styleSheets!=L&&M.styleSheets.length>0&&(T=M.styleSheets[M.styleSheets.length-1]),I=r}X.ie&&X.win?T&&typeof T.addRule==k&&T.addRule(e,t):T&&typeof M.createTextNode!=L&&T.appendChild(M.createTextNode(e+" {"+t+"}"))}}}function b(e,t){if(U){var n=t?"visible":"hidden";G&&y(e)?y(e).style.visibility=n:w("#"+e,"visibility:"+n)}}function C(e){var t=/[\\\"<>\.;]/,n=null!=t.exec(e);return n&&typeof encodeURIComponent!=L?encodeURIComponent(e):e}{var E,S,A,N,T,I,L="undefined",k="object",j="Shockwave Flash",B="ShockwaveFlash.ShockwaveFlash",O="application/x-shockwave-flash",F="SWFObjectExprInst",$="onreadystatechange",x=window,M=document,V=navigator,P=!1,R=[a],D=[],W=[],H=[],G=!1,J=!1,U=!0,X=function(){var e=typeof M.getElementById!=L&&typeof M.getElementsByTagName!=L&&typeof M.createElement!=L,t=V.userAgent.toLowerCase(),n=V.platform.toLowerCase(),a=/win/.test(n?n:t),i=/mac/.test(n?n:t),r=/webkit/.test(t)?parseFloat(t.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,o=!1,s=[0,0,0],l=null;if(typeof V.plugins!=L&&typeof V.plugins[j]==k)l=V.plugins[j].description,!l||typeof V.mimeTypes!=L&&V.mimeTypes[O]&&!V.mimeTypes[O].enabledPlugin||(P=!0,o=!1,l=l.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),s[0]=parseInt(l.replace(/^(.*)\..*$/,"$1"),10),s[1]=parseInt(l.replace(/^.*\.(.*)\s.*$/,"$1"),10),s[2]=/[a-zA-Z]/.test(l)?parseInt(l.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof x.ActiveXObject!=L)try{var c=new ActiveXObject(B);c&&(l=c.GetVariable("$version"),l&&(o=!0,l=l.split(" ")[1].split(","),s=[parseInt(l[0],10),parseInt(l[1],10),parseInt(l[2],10)]))}catch(f){}return{w3:e,pv:s,wk:r,ie:o,win:a,mac:i}}();!function(){X.w3&&((typeof M.readyState!=L&&"complete"==M.readyState||typeof M.readyState==L&&(M.getElementsByTagName("body")[0]||M.body))&&e(),G||(typeof M.addEventListener!=L&&M.addEventListener("DOMContentLoaded",e,!1),X.ie&&X.win&&(M.attachEvent($,function(){"complete"==M.readyState&&(M.detachEvent($,arguments.callee),e())}),x==top&&!function(){if(!G){try{M.documentElement.doScroll("left")}catch(t){return void setTimeout(arguments.callee,0)}e()}}()),X.wk&&!function(){return G?void 0:/loaded|complete/.test(M.readyState)?void e():void setTimeout(arguments.callee,0)}(),n(e)))}(),function(){X.ie&&X.win&&window.attachEvent("onunload",function(){for(var e=H.length,t=0;e>t;t++)H[t][0].detachEvent(H[t][1],H[t][2]);for(var n=W.length,a=0;n>a;a++)p(W[a]);for(var i in X)X[i]=null;X=null;for(var r in swfobject)swfobject[r]=null;swfobject=null})}()}return{registerObject:function(e,t,n,a){if(X.w3&&e&&t){var i={};i.id=e,i.swfVersion=t,i.expressInstall=n,i.callbackFn=a,D[D.length]=i,b(e,!1)}else a&&a({success:!1,id:e})},getObjectById:function(e){return X.w3?o(e):void 0},embedSWF:function(e,n,a,i,r,o,c,f,u,p){var v={success:!1,id:n};X.w3&&!(X.wk&&X.wk<312)&&e&&n&&a&&i&&r?(b(n,!1),t(function(){a+="",i+="";var t={};if(u&&typeof u===k)for(var y in u)t[y]=u[y];t.data=e,t.width=a,t.height=i;var h={};if(f&&typeof f===k)for(var m in f)h[m]=f[m];if(c&&typeof c===k)for(var w in c)typeof h.flashvars!=L?h.flashvars+="&"+w+"="+c[w]:h.flashvars=w+"="+c[w];if(g(r)){var C=d(t,h,n);t.id==n&&b(n,!0),v.success=!0,v.ref=C}else{if(o&&s())return t.data=o,void l(t,h,n,p);b(n,!0)}p&&p(v)})):p&&p(v)},switchOffAutoHideShow:function(){U=!1},ua:X,getFlashPlayerVersion:function(){return{major:X.pv[0],minor:X.pv[1],release:X.pv[2]}},hasFlashPlayerVersion:g,createSWF:function(e,t,n){return X.w3?d(e,t,n):void 0},showExpressInstall:function(e,t,n,a){X.w3&&s()&&l(e,t,n,a)},removeSWF:function(e){X.w3&&p(e)},createCSS:function(e,t,n,a){X.w3&&w(e,t,n,a)},addDomLoadEvent:t,addLoadEvent:n,getQueryParamValue:function(e){var t=M.location.search||M.location.hash;if(t){if(/\?/.test(t)&&(t=t.split("?")[1]),null==e)return C(t);for(var n=t.split("&"),a=0;ar;r++)if(!h(t,e[r]))return!1;return!0}var n=a(e);for(r=0,s=t.length;s>r;r++)if("RegExp"===n){if("string"==typeof t[r]&&t[r].match(e))return!0}else if(t[r]===e)return!0;return!1}function u(t,e){if(!o(t)||!o(e)||t.length!==e.length)return!1;t.sort(),e.sort();for(var r=0,s=t.length;s>r;r++)if(t[r]!==e[r])return!1;return!0}function p(t){return escape(t)}function c(t){return encodeURIComponent(t).replace(/[!'()*]/g,p).replace(/\*/g,"%2A")}var l=s&&s.URI;n.version="1.12.1";var d=n.prototype,f=Object.prototype.hasOwnProperty;n._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:n.duplicateQueryParameters,escapeQuerySpace:n.escapeQuerySpace}},n.duplicateQueryParameters=!1,n.escapeQuerySpace=!0,n.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,n.idn_expression=/[^a-z0-9\.-]/i,n.punycode_expression=/(xn--)/i,n.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,n.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,n.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/gi,n.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/},n.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},n.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,n.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src"},n.getDomAttribute=function(t){if(t&&t.nodeName){var e=t.nodeName.toLowerCase();return"input"===e&&"image"!==t.type?void 0:n.domAttributes[e]}},n.encode=c,n.decode=decodeURIComponent,n.iso8859=function(){n.encode=escape,n.decode=unescape},n.unicode=function(){n.encode=c,n.decode=decodeURIComponent},n.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}}},n.encodeQuery=function(t,e){var r=n.encode(t+"");return void 0===e&&(e=n.escapeQuerySpace),e?r.replace(/%20/g,"+"):r},n.decodeQuery=function(t,e){t+="",void 0===e&&(e=n.escapeQuerySpace);try{return n.decode(e?t.replace(/\+/g,"%20"):t)}catch(r){return t}},n.recodePath=function(t){t=(t+"").split("/");for(var e=0,r=t.length;r>e;e++)t[e]=n.encodePathSegment(n.decode(t[e]));return t.join("/")},n.decodePath=function(t){t=(t+"").split("/");for(var e=0,r=t.length;r>e;e++)t[e]=n.decodePathSegment(t[e]);return t.join("/")};var m,_={encode:"encode",decode:"decode"},g=function(t,e){return function(r){return n[e](r+"").replace(n.characters[t][e].expression,function(r){return n.characters[t][e].map[r]})}};for(m in _)n[m+"PathSegment"]=g("pathname",_[m]);n.encodeReserved=g("reserved","encode"),n.parse=function(t,e){var r;return e||(e={}),r=t.indexOf("#"),r>-1&&(e.fragment=t.substring(r+1)||null,t=t.substring(0,r)),r=t.indexOf("?"),r>-1&&(e.query=t.substring(r+1)||null,t=t.substring(0,r)),"//"===t.substring(0,2)?(e.protocol=null,t=t.substring(2),t=n.parseAuthority(t,e)):(r=t.indexOf(":"),r>-1&&(e.protocol=t.substring(0,r)||null,e.protocol&&!e.protocol.match(n.protocol_expression)?e.protocol=void 0:"file"===e.protocol?t=t.substring(r+3):"//"===t.substring(r+1,r+3)?(t=t.substring(r+3),t=n.parseAuthority(t,e)):(t=t.substring(r+1),e.urn=!0))),e.path=t,e},n.parseHost=function(t,e){var r,s=t.indexOf("/");return-1===s&&(s=t.length),"["===t.charAt(0)?(r=t.indexOf("]"),e.hostname=t.substring(1,r)||null,e.port=t.substring(r+2,s)||null):t.indexOf(":")!==t.lastIndexOf(":")?(e.hostname=t.substring(0,s)||null,e.port=null):(r=t.substring(0,s).split(":"),e.hostname=r[0]||null,e.port=r[1]||null),e.hostname&&"/"!==t.substring(s).charAt(0)&&(s++,t="/"+t),t.substring(s)||"/"},n.parseAuthority=function(t,e){return t=n.parseUserinfo(t,e),n.parseHost(t,e)},n.parseUserinfo=function(t,e){var r=t.indexOf("/"),s=r>-1?t.lastIndexOf("@",r):t.indexOf("@");return s>-1&&(-1===r||r>s)?(r=t.substring(0,s).split(":"),e.username=r[0]?n.decode(r[0]):null,r.shift(),e.password=r[0]?n.decode(r.join(":")):null,t=t.substring(s+1)):(e.username=null,e.password=null),t},n.parseQuery=function(t,e){if(!t)return{};if(t=t.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!t)return{};for(var r,s,i={},a=t.split("&"),o=a.length,h=0;o>h;h++)r=a[h].split("="),s=n.decodeQuery(r.shift(),e),r=r.length?n.decodeQuery(r.join("="),e):null,i[s]?("string"==typeof i[s]&&(i[s]=[i[s]]),i[s].push(r)):i[s]=r;return i},n.build=function(t){var e="";return t.protocol&&(e+=t.protocol+":"),t.urn||!e&&!t.hostname||(e+="//"),e+=n.buildAuthority(t)||"","string"==typeof t.path&&("/"!==t.path.charAt(0)&&"string"==typeof t.hostname&&(e+="/"),e+=t.path),"string"==typeof t.query&&t.query&&(e+="?"+t.query),"string"==typeof t.fragment&&t.fragment&&(e+="#"+t.fragment),e},n.buildHost=function(t){var e="";return t.hostname?(n.ip6_expression.test(t.hostname)?e=t.port?e+("["+t.hostname+"]:"+t.port):e+t.hostname:(e+=t.hostname,t.port&&(e+=":"+t.port)),e):""},n.buildAuthority=function(t){return n.buildUserinfo(t)+n.buildHost(t)},n.buildUserinfo=function(t){var e="";return t.username&&(e+=n.encode(t.username),t.password&&(e+=":"+n.encode(t.password)),e+="@"),e},n.buildQuery=function(t,e,r){var s,i,a,h,u="";for(i in t)if(f.call(t,i)&&i)if(o(t[i]))for(s={},a=0,h=t[i].length;h>a;a++)void 0!==t[i][a]&&void 0===s[t[i][a]+""]&&(u+="&"+n.buildQueryParameter(i,t[i][a],r),!0!==e&&(s[t[i][a]+""]=!0));else void 0!==t[i]&&(u+="&"+n.buildQueryParameter(i,t[i],r));return u.substring(1)},n.buildQueryParameter=function(t,e,r){return n.encodeQuery(t,r)+(null!==e?"="+n.encodeQuery(e,r):"")},n.addQuery=function(t,e,r){if("object"==typeof e)for(var s in e)f.call(e,s)&&n.addQuery(t,s,e[s]);else{if("string"!=typeof e)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");void 0===t[e]?t[e]=r:("string"==typeof t[e]&&(t[e]=[t[e]]),o(r)||(r=[r]),t[e]=t[e].concat(r))}},n.removeQuery=function(t,e,r){var s;if(o(e))for(r=0,s=e.length;s>r;r++)t[e[r]]=void 0;else if("object"==typeof e)for(s in e)f.call(e,s)&&n.removeQuery(t,s,e[s]);else{if("string"!=typeof e)throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");if(void 0!==r){if(t[e]===r)t[e]=void 0;else if(o(t[e])){s=t[e];var i,a,h={};if(o(r))for(i=0,a=r.length;a>i;i++)h[r[i]]=!0;else h[r]=!0;for(i=0,a=s.length;a>i;i++)void 0!==h[s[i]]&&(s.splice(i,1),a--,i--);t[e]=s}}else t[e]=void 0}},n.hasQuery=function(t,e,r,s){if("object"==typeof e){for(var i in e)if(f.call(e,i)&&!n.hasQuery(t,i,e[i]))return!1;return!0}if("string"!=typeof e)throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter");switch(a(r)){case"Undefined":return e in t;case"Boolean":return t=Boolean(o(t[e])?t[e].length:t[e]),r===t;case"Function":return!!r(t[e],e,t);case"Array":return o(t[e])?(s?h:u)(t[e],r):!1;case"RegExp":return o(t[e])?s?h(t[e],r):!1:Boolean(t[e]&&t[e].match(r));case"Number":r=String(r);case"String":return o(t[e])?s?h(t[e],r):!1:t[e]===r;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},n.commonPath=function(t,e){var r,s=Math.min(t.length,e.length);for(r=0;s>r;r++)if(t.charAt(r)!==e.charAt(r)){r--;break}return 1>r?t.charAt(0)===e.charAt(0)&&"/"===t.charAt(0)?"/":"":(("/"!==t.charAt(r)||"/"!==e.charAt(r))&&(r=t.substring(0,r).lastIndexOf("/")),t.substring(0,r+1))},n.withinString=function(t,e,r){r||(r={});var s=r.start||n.findUri.start,i=r.end||n.findUri.end,a=r.trim||n.findUri.trim,o=/[a-z0-9-]=["']?$/i;for(s.lastIndex=0;;){var h=s.exec(t);if(!h)break;if(h=h.index,r.ignoreHtml){var u=t.slice(Math.max(h-3,0),h);if(u&&o.test(u))continue}var u=h+t.slice(h).search(i),p=t.slice(h,u).replace(a,"");r.ignore&&r.ignore.test(p)||(u=h+p.length,p=e(p,h,u,t),t=t.slice(0,h)+p+t.slice(u),s.lastIndex=h+p.length)}return s.lastIndex=0,t},n.ensureValidHostname=function(e){if(e.match(n.invalid_hostname_characters)){if(!t)throw new TypeError("Hostname '"+e+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(t.toASCII(e).match(n.invalid_hostname_characters))throw new TypeError("Hostname '"+e+"' contains characters other than [A-Z0-9.-]")}},n.noConflict=function(t){return t?(t={URI:this.noConflict()},URITemplate&&"function"==typeof URITemplate.noConflict&&(t.URITemplate=URITemplate.noConflict()),e&&"function"==typeof e.noConflict&&(t.IPv6=e.noConflict()),SecondLevelDomains&&"function"==typeof SecondLevelDomains.noConflict&&(t.SecondLevelDomains=SecondLevelDomains.noConflict()),t):(s.URI===this&&(s.URI=l),this)},d.build=function(t){return!0===t?this._deferred_build=!0:(void 0===t||this._deferred_build)&&(this._string=n.build(this._parts),this._deferred_build=!1),this},d.clone=function(){return new n(this)},d.valueOf=d.toString=function(){return this.build(!1)._string},_={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"},g=function(t){return function(e,r){return void 0===e?this._parts[t]||"":(this._parts[t]=e||null,this.build(!r),this)}};for(m in _)d[m]=g(_[m]);_={query:"?",fragment:"#"},g=function(t,e){return function(r,s){return void 0===r?this._parts[t]||"":(null!==r&&(r+="",r.charAt(0)===e&&(r=r.substring(1))),this._parts[t]=r,this.build(!s),this)}};for(m in _)d[m]=g(m,_[m]);_={search:["?","query"],hash:["#","fragment"]},g=function(t,e){return function(r,s){var n=this[t](r,s);return"string"==typeof n&&n.length?e+n:n}};for(m in _)d[m]=g(_[m][1],_[m][0]);d.pathname=function(t,e){if(void 0===t||!0===t){var r=this._parts.path||(this._parts.hostname?"/":"");return t?n.decodePath(r):r}return this._parts.path=t?n.recodePath(t):"/",this.build(!e),this},d.path=d.pathname,d.href=function(t,e){var r;if(void 0===t)return this.toString();this._string="",this._parts=n._parts();var s=t instanceof n,i="object"==typeof t&&(t.hostname||t.path||t.pathname);if(t.nodeName&&(i=n.getDomAttribute(t),t=t[i]||"",i=!1),!s&&i&&void 0!==t.pathname&&(t=t.toString()),"string"==typeof t)this._parts=n.parse(t,this._parts);else{if(!s&&!i)throw new TypeError("invalid input");for(r in s=s?t._parts:t)f.call(this._parts,r)&&(this._parts[r]=s[r])}return this.build(!e),this},d.is=function(t){var e=!1,s=!1,i=!1,a=!1,o=!1,h=!1,u=!1,p=!this._parts.urn;switch(this._parts.hostname&&(p=!1,s=n.ip4_expression.test(this._parts.hostname),i=n.ip6_expression.test(this._parts.hostname),e=s||i,o=(a=!e)&&r&&r.has(this._parts.hostname),h=a&&n.idn_expression.test(this._parts.hostname),u=a&&n.punycode_expression.test(this._parts.hostname)),t.toLowerCase()){case"relative":return p;case"absolute":return!p;case"domain":case"name":return a;case"sld":return o;case"ip":return e;case"ip4":case"ipv4":case"inet4":return s;case"ip6":case"ipv6":case"inet6":return i;case"idn":return h;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return u}return null};var y=d.protocol,v=d.port,b=d.hostname;d.protocol=function(t,e){if(void 0!==t&&t&&(t=t.replace(/:(\/\/)?$/,""),!t.match(n.protocol_expression)))throw new TypeError("Protocol '"+t+"' contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return y.call(this,t,e)},d.scheme=d.protocol,d.port=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t&&(0===t&&(t=null),t&&(t+="",":"===t.charAt(0)&&(t=t.substring(1)),t.match(/[^0-9]/))))throw new TypeError("Port '"+t+"' contains characters other than [0-9]");return v.call(this,t,e)},d.hostname=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t){var r={};n.parseHost(t,r),t=r.hostname}return b.call(this,t,e)},d.host=function(t,e){return this._parts.urn?void 0===t?"":this:void 0===t?this._parts.hostname?n.buildHost(this._parts):"":(n.parseHost(t,this._parts),this.build(!e),this)},d.authority=function(t,e){return this._parts.urn?void 0===t?"":this:void 0===t?this._parts.hostname?n.buildAuthority(this._parts):"":(n.parseAuthority(t,this._parts),this.build(!e),this)},d.userinfo=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){if(!this._parts.username)return"";var r=n.buildUserinfo(this._parts);return r.substring(0,r.length-1)}return"@"!==t[t.length-1]&&(t+="@"),n.parseUserinfo(t,this._parts),this.build(!e),this},d.resource=function(t,e){var r;return void 0===t?this.path()+this.search()+this.hash():(r=n.parse(t),this._parts.path=r.path,this._parts.query=r.query,this._parts.fragment=r.fragment,this.build(!e),this)},d.subdomain=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var r=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,r)||""}return r=this._parts.hostname.length-this.domain().length,r=this._parts.hostname.substring(0,r),r=RegExp("^"+i(r)),t&&"."!==t.charAt(t.length-1)&&(t+="."),t&&n.ensureValidHostname(t),this._parts.hostname=this._parts.hostname.replace(r,t),this.build(!e),this},d.domain=function(t,e){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(e=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var r=this._parts.hostname.match(/\./g);return r&&2>r.length?this._parts.hostname:(r=this._parts.hostname.length-this.tld(e).length-1,r=this._parts.hostname.lastIndexOf(".",r-1)+1,this._parts.hostname.substring(r)||"")}if(!t)throw new TypeError("cannot set domain empty");return n.ensureValidHostname(t),!this._parts.hostname||this.is("IP")?this._parts.hostname=t:(r=RegExp(i(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(r,t)),this.build(!e),this},d.tld=function(t,e){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(e=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var s=this._parts.hostname.lastIndexOf("."),s=this._parts.hostname.substring(s+1);return!0!==e&&r&&r.list[s.toLowerCase()]?r.get(this._parts.hostname)||s:s}if(!t)throw new TypeError("cannot set TLD empty");if(t.match(/[^a-zA-Z0-9-]/)){if(!r||!r.is(t))throw new TypeError("TLD '"+t+"' contains characters other than [A-Z0-9]");s=RegExp(i(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(s,t)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");s=RegExp(i(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(s,t)}return this.build(!e),this},d.directory=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||!0===t){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var r=this._parts.path.length-this.filename().length-1,r=this._parts.path.substring(0,r)||(this._parts.hostname?"/":"");return t?n.decodePath(r):r}return r=this._parts.path.length-this.filename().length,r=this._parts.path.substring(0,r),r=RegExp("^"+i(r)),this.is("relative")||(t||(t="/"),"/"!==t.charAt(0)&&(t="/"+t)),t&&"/"!==t.charAt(t.length-1)&&(t+="/"),t=n.recodePath(t),this._parts.path=this._parts.path.replace(r,t),this.build(!e),this},d.filename=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||!0===t){if(!this._parts.path||"/"===this._parts.path)return"";var r=this._parts.path.lastIndexOf("/"),r=this._parts.path.substring(r+1);return t?n.decodePathSegment(r):r}r=!1,"/"===t.charAt(0)&&(t=t.substring(1)),t.match(/\.?\//)&&(r=!0);var s=RegExp(i(this.filename())+"$");return t=n.recodePath(t),this._parts.path=this._parts.path.replace(s,t),r?this.normalizePath(e):this.build(!e),this},d.suffix=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||!0===t){if(!this._parts.path||"/"===this._parts.path)return"";var r=this.filename(),s=r.lastIndexOf(".");return-1===s?"":(r=r.substring(s+1),r=/^[a-z0-9%]+$/i.test(r)?r:"",t?n.decodePathSegment(r):r)}if("."===t.charAt(0)&&(t=t.substring(1)),r=this.suffix())s=RegExp(t?i(r)+"$":i("."+r)+"$");else{if(!t)return this;this._parts.path+="."+n.recodePath(t)}return s&&(t=n.recodePath(t),this._parts.path=this._parts.path.replace(s,t)),this.build(!e),this},d.segment=function(t,e,r){var s=this._parts.urn?":":"/",n=this.path(),i="/"===n.substring(0,1),n=n.split(s);if(void 0!==t&&"number"!=typeof t&&(r=e,e=t,t=void 0),void 0!==t&&"number"!=typeof t)throw Error("Bad segment '"+t+"', must be 0-based integer");if(i&&n.shift(),0>t&&(t=Math.max(n.length+t,0)),void 0===e)return void 0===t?n:n[t];if(null===t||void 0===n[t])if(o(e)){n=[],t=0;for(var a=e.length;a>t;t++)(e[t].length||n.length&&n[n.length-1].length)&&(n.length&&!n[n.length-1].length&&n.pop(),n.push(e[t]))}else(e||"string"==typeof e)&&(""===n[n.length-1]?n[n.length-1]=e:n.push(e));else e||"string"==typeof e&&e.length?n[t]=e:n.splice(t,1);return i&&n.unshift(""),this.path(n.join(s),r)},d.segmentCoded=function(t,e,r){var s,i;if("number"!=typeof t&&(r=e,e=t,t=void 0),void 0===e){if(t=this.segment(t,e,r),o(t))for(s=0,i=t.length;i>s;s++)t[s]=n.decode(t[s]);else t=void 0!==t?n.decode(t):void 0;return t}if(o(e))for(s=0,i=e.length;i>s;s++)e[s]=n.decode(e[s]);else e="string"==typeof e?n.encode(e):e;return this.segment(t,e,r)};var Q=d.query;return d.query=function(t,e){if(!0===t)return n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof t){var r=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace),s=t.call(this,r);return this._parts.query=n.buildQuery(s||r,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!e),this}return void 0!==t&&"string"!=typeof t?(this._parts.query=n.buildQuery(t,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!e),this):Q.call(this,t,e)},d.setQuery=function(t,e,r){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("object"==typeof t)for(var i in t)f.call(t,i)&&(s[i]=t[i]);else{if("string"!=typeof t)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");s[t]=void 0!==e?e:null}return this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},d.addQuery=function(t,e,r){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.addQuery(s,t,void 0===e?null:e),this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},d.removeQuery=function(t,e,r){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.removeQuery(s,t,e),this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},d.hasQuery=function(t,e,r){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.hasQuery(s,t,e,r)},d.setSearch=d.setQuery,d.addSearch=d.addQuery,d.removeSearch=d.removeQuery,d.hasSearch=d.hasQuery,d.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},d.normalizeProtocol=function(t){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!t)),this},d.normalizeHostname=function(r){return this._parts.hostname&&(this.is("IDN")&&t?this._parts.hostname=t.toASCII(this._parts.hostname):this.is("IPv6")&&e&&(this._parts.hostname=e.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!r)),this},d.normalizePort=function(t){return"string"==typeof this._parts.protocol&&this._parts.port===n.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!t)),this},d.normalizePath=function(t){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this;var e,r,s,i=this._parts.path,a="";for("/"!==i.charAt(0)&&(e=!0,i="/"+i),i=i.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),e&&(a=i.substring(1).match(/^(\.\.\/)+/)||"")&&(a=a[0]);r=i.indexOf("/.."),-1!==r;)0!==r?(s=i.substring(0,r).lastIndexOf("/"),-1===s&&(s=r),i=i.substring(0,s)+i.substring(r+3)):i=i.substring(3);return e&&this.is("relative")&&(i=a+i.substring(1)),i=n.recodePath(i),this._parts.path=i,this.build(!t),this},d.normalizePathname=d.normalizePath,d.normalizeQuery=function(t){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(n.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!t)),this},d.normalizeFragment=function(t){return this._parts.fragment||(this._parts.fragment=null,this.build(!t)),this},d.normalizeSearch=d.normalizeQuery,d.normalizeHash=d.normalizeFragment,d.iso8859=function(){var t=n.encode,e=n.decode;return n.encode=escape,n.decode=decodeURIComponent,this.normalize(),n.encode=t,n.decode=e,this},d.unicode=function(){var t=n.encode,e=n.decode;return n.encode=c,n.decode=unescape,this.normalize(),n.encode=t,n.decode=e,this},d.readable=function(){var e=this.clone();e.username("").password("").normalize();var r="";if(e._parts.protocol&&(r+=e._parts.protocol+"://"),e._parts.hostname&&(e.is("punycode")&&t?(r+=t.toUnicode(e._parts.hostname),e._parts.port&&(r+=":"+e._parts.port)):r+=e.host()),e._parts.hostname&&e._parts.path&&"/"!==e._parts.path.charAt(0)&&(r+="/"),r+=e.path(!0),e._parts.query){for(var s="",i=0,a=e._parts.query.split("&"),o=a.length;o>i;i++){var h=(a[i]||"").split("="),s=s+("&"+n.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"));void 0!==h[1]&&(s+="="+n.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}r+="?"+s.substring(1)}return r+=n.decodeQuery(e.hash(),!0)},d.absoluteTo=function(t){var e,r,s=this.clone(),i=["protocol","username","password","hostname","port"];if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");if(t instanceof n||(t=new n(t)),s._parts.protocol||(s._parts.protocol=t._parts.protocol),this._parts.hostname)return s;for(e=0;r=i[e];e++)s._parts[r]=t._parts[r];return s._parts.path?".."===s._parts.path.substring(-2)&&(s._parts.path+="/"):(s._parts.path=t._parts.path,s._parts.query||(s._parts.query=t._parts.query)),"/"!==s.path().charAt(0)&&(t=t.directory(),s._parts.path=(t?t+"/":"")+s._parts.path,s.normalizePath()),s.build(),s},d.relativeTo=function(t){var e,r,s,i,a=this.clone().normalize();if(a._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");if(t=new n(t).normalize(),e=a._parts,r=t._parts,s=a.path(),i=t.path(),"/"!==s.charAt(0))throw Error("URI is already relative");if("/"!==i.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");return e.protocol===r.protocol&&(e.protocol=null),e.username!==r.username||e.password!==r.password||null!==e.protocol||null!==e.username||null!==e.password||e.hostname!==r.hostname||e.port!==r.port?a.build():(e.hostname=null,e.port=null,s===i?(e.path="",a.build()):(t=n.commonPath(a.path(),t.path()))?(r=r.path.substring(t.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../"),e.path=r+e.path.substring(t.length),a.build()):a.build())},d.equals=function(t){var e=this.clone();t=new n(t);var r,s={},i={},a={};if(e.normalize(),t.normalize(),e.toString()===t.toString())return!0;if(s=e.query(),i=t.query(),e.query(""),t.query(""),e.toString()!==t.toString()||s.length!==i.length)return!1;s=n.parseQuery(s,this._parts.escapeQuerySpace),i=n.parseQuery(i,this._parts.escapeQuerySpace);for(r in s)if(f.call(s,r)){if(o(s[r])){if(!u(s[r],i[r]))return!1}else if(s[r]!==i[r])return!1;a[r]=!0}for(r in i)if(f.call(i,r)&&!a[r])return!1;return!0},d.duplicateQueryParameters=function(t){return this._parts.duplicateQueryParameters=!!t,this},d.escapeQuerySpace=function(t){return this._parts.escapeQuerySpace=!!t,this},n}); \ No newline at end of file