(function(){'use strict';var e;function g(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var k=g(this),l="function"==typeof Object.create?Object.create:function(a){function b(){}b.prototype=a;return new b},m;
if("function"==typeof Object.setPrototypeOf)m=Object.setPrototypeOf;else{var n;a:{var p={a:!0},q={};try{q.__proto__=p;n=q.a;break a}catch(a){}n=!1}m=n?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null}var r=m;var t="abort canplay canplaythrough durationchange emptied ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),u={".avi":1,".m4v":1,".mp4":1,".mpeg":1,".mpg":1,".ogg":1,".ogv":1,".qt":1,".webm":1,".wmv":1};function v(a,b){window.setTimeout(a,b)};function w(a){if(!a.gwdIsLoaded()){var b=x(a);b?b.gwdIsLoaded()&&a.gwdLoad():a.gwdLoad()}}function y(a){if(!a.gwdIsActive()){var b=x(a);b?b.gwdIsActive()&&a.gwdActivate():a.gwdActivate()}}function z(a){return"gwd-page"==a.tagName.toLowerCase()||"gwd-page"==a.getAttribute("is")}function x(a){if(z(a))return a;for(;a&&9!=a.nodeType;)if((a=a.parentElement)&&z(a))return a;return null}function A(a){for(var b=[];a;)b.unshift(a),a=a.parentNode;return b}
function B(a,b,c){a.hasAttribute(b)?(a=a.getAttribute(b),c.setAttribute(b,a)):c.removeAttribute(b)};function C(a,b,c){c=void 0===c?null:c;var d=document.createEvent("CustomEvent");d.initCustomEvent(a,!0,!0,c);b.dispatchEvent(d)}function D(a,b){function c(d){a.removeEventListener("playing",c);b(d)}a.addEventListener("playing",c)};var E={I:"fullscreenchange",M:"mozfullscreenchange",N:"webkitfullscreenchange"},F={I:"fullscreenElement",M:"mozFullScreenElement",N:"webkitFullscreenElement"};function G(a){for(var b,c=Object.keys(F),d=0;d<c.length&&(b=a[F[c[d]]],void 0===b);d++);return b||null}function H(a){this.g=document;this.h=a;this.i=this.j.bind(this)}
H.prototype.j=function(){var a=G(this.g);if(a)if(this.h==a){var b=this.g;for(a=this.h;a&&a!=b;a=a.parentNode)a.classList.add("has-fullscreen-gwd-video")}else if(a.classList.contains("has-fullscreen-gwd-video")){b=A(this.h);a=A(a);for(var c=0,d=b[0],f=a[0],h=null;d&&f&&d==f;)h=d,c++,d=b[c],f=a[c];I(this,h)}else I(this);else I(this)};function I(a,b){b=(void 0===b?null:b)||a.g;for(a=a.h;a&&a!=b;a=a.parentNode)a.classList.remove("has-fullscreen-gwd-video")}
H.prototype.install=function(){for(var a=Object.keys(E),b=0;b<a.length;b++)this.g.addEventListener(E[a[b]],this.i)};var J=Object.keys(HTMLMediaElement.prototype).concat(Object.keys(HTMLVideoElement.prototype)).concat(["sources"]);
function K(){var a=HTMLElement.call(this)||this;a.g=a.ownerDocument.createElement("video");a.g.setAttribute("webkit-playsinline","");a.g.setAttribute("playsinline","");a.g.setAttribute("x-webkit-airplay","allow");a.A=function(b){C(b.type,a,b.detail)};a.H=a.O.bind(a);a.B=new H(a.g);a.h=!1;a.i=null;a.l=null;a.interactiveVideoComponents=[];a.J=function(){for(var b=0;b<a.interactiveVideoComponents.length;b++)a.interactiveVideoComponents[b].handleVideoTimeUpdate()};a.G=function(){a.i||(a.i=window.setInterval(a.J,
33))};a.j=function(){a.i&&(window.clearInterval(a.i),a.i=null)};a.F=null;a.D=null;a.u=function(){if(a.parentElement){var b=a.getBoundingClientRect();if(b.width!=a.F||b.height!=a.D)for(a.F=b.width,a.D=b.height,b=0;b<a.interactiveVideoComponents.length;b++)a.interactiveVideoComponents[b].resizeHandlerNeeded&&a.interactiveVideoComponents[b].resize()}};a.K=function(){a.l||(a.l=window.setInterval(a.u,250))};a.L=function(){a.l&&window.clearInterval(a.l)};a.o=!1;a.m=!1;a.C=!1;a.v=1;a.s=!1;return a}
var L=HTMLElement;K.prototype=l(L.prototype);K.prototype.constructor=K;if(r)r(K,L);else for(var M in L)if("prototype"!=M)if(Object.defineProperties){var N=Object.getOwnPropertyDescriptor(L,M);N&&Object.defineProperty(K,M,N)}else K[M]=L[M];e=K.prototype;
e.connectedCallback=function(){var a=this;if(!this.C){for(var b=0;b<this.children.length;b++){var c=this.children[b];if(c.classList.contains("intermediate-element")){this.removeChild(c);break}}this.h=this.muted&&-1!=(window.navigator.userAgent||"").indexOf("Android");b=this.ownerDocument.createElement("div");b.classList.add("intermediate-element");b.appendChild(this.g);this.appendChild(b);this.C=!0}w(this);y(this);this.h&&D(this.g,function(){a.h&&(a.g.volume=0)});this.g.addEventListener("volumechange",
this.H,!1);for(b=0;b<t.length;b++)this.g.addEventListener(t[b],this.A,!1);this.B.install();this.g.addEventListener("play",this.G,!1);this.g.addEventListener("pause",this.j,!1);this.g.addEventListener("ended",this.j,!1)};
e.disconnectedCallback=function(){for(var a=this.B,b=Object.keys(E),c=0;c<b.length;c++)a.g.removeEventListener(E[b[c]],a.i);b=G(a.g);a.h==b&&I(a);this.h&&(this.g.volume=1);this.g.removeEventListener("volumechange",this.H,!1);for(a=0;a<t.length;a++)this.g.removeEventListener(t[a],this.A,!1);this.j();this.g.removeEventListener("play",this.G,!1);this.g.removeEventListener("pause",this.j,!1);this.g.removeEventListener("ended",this.j,!1)};
e.setResizeObserver=function(){for(var a=!1,b=0;b<this.interactiveVideoComponents.length;b++)if(this.interactiveVideoComponents[b].resizeHandlerNeeded){a=!0;break}a?(this.K(),window.addEventListener("resize",this.u,!1)):(this.L(),window.removeEventListener("resize",this.u,!1))};
e.attributeChangedCallback=function(a){var b=this;if("sources"==a){if(this.o){var c=this.g.paused,d=this.muted;O(this);this.g.load();v(function(){b.muted=d;c?b.pause():b.play()},1)}}else"muted"==a&&(this.g.muted=this.muted);B(this,a,this.g)};e.gwdActivate=function(){var a=this;this.autoplay&&this.g.paused&&v(function(){if(2<=a.g.readyState)a.play();else{var b=function(){2<=a.g.readyState&&(a.g.removeEventListener("loadeddata",b),a.play())};a.g.addEventListener("loadeddata",b)}},200);this.m=!0};
e.gwdDeactivate=function(){this.hasAttribute("resumable")||this.seek(0);this.pause();this.m=!1};e.gwdIsActive=function(){return this.m};e.gwdLoad=function(){O(this);this.o=!0;C("ready",this)};e.gwdIsLoaded=function(){return this.o};e.play=function(){this.g.play()};e.pause=function(){this.g.pause()};e.mute=function(){this.h&&(this.g.volume=1);this.h=!1;this.muted=!this.muted};e.replay=function(){this.seek(0);this.play()};e.seek=function(a){this.currentTime!=a&&(this.currentTime=a)};
e.O=function(){0==this.s&&1==this.muted&&0==this.v&&(this.g.volume=1,this.muted=!1);this.v=this.g.volume;this.s=this.muted};e.setVolume=function(a){this.muted=0<a?!1:!0;this.g.volume=a/100;this.v=this.g.volume;this.s=this.muted};e.setSources=function(a){this.setAttribute("sources",a)};
function O(a){var b=a.getAttribute("sources");b=P(b);for(var c=a.g.children,d=c.length-1;0<=d;d--){var f=c[d];"source"==f.tagName.toLowerCase()&&a.g.removeChild(f)}for(c=0;c<b.length;c++)d=a.ownerDocument.createElement("source"),f=b[c],f=f.trim(),f=window.Enabler?window.Enabler.getUrl(f):f,d.src=f,a.g.appendChild(d)}
function P(a){var b=[];if(!a)return b;a=a.split(",").map(function(Q){return Q.trim()});for(var c="",d=0;d<a.length;d++){var f=a[d];c+=f;var h=f.lastIndexOf(".");-1!=h?u[f.substring(h).toLowerCase()]?(b.push(c),c=""):c+=",":c+=","}c&&b.push(c.substring(0,c.length-1));return b}
k.Object.defineProperties(K.prototype,{nativeElement:{configurable:!0,enumerable:!0,get:function(){return this.g}},autoplay:{configurable:!0,enumerable:!0,get:function(){return this.g.autoplay},set:function(a){a?this.setAttribute("autoplay",""):this.removeAttribute("autoplay")}},loop:{configurable:!0,enumerable:!0,get:function(){return this.g.loop},set:function(a){a?this.setAttribute("loop",""):this.removeAttribute("loop")}},muted:{configurable:!0,enumerable:!0,get:function(){return this.hasAttribute("muted")},
set:function(a){a?this.setAttribute("muted",""):this.removeAttribute("muted")}},controls:{configurable:!0,enumerable:!0,get:function(){return this.g.controls},set:function(a){a?this.setAttribute("controls",""):this.removeAttribute("controls")}},poster:{configurable:!0,enumerable:!0,get:function(){return this.g.poster},set:function(a){a?this.setAttribute("poster",a):this.removeAttribute("poster")}},paused:{configurable:!0,enumerable:!0,get:function(){return this.g.paused}},volume:{configurable:!0,
enumerable:!0,get:function(){return this.g.volume},set:function(a){this.g.volume=a}},currentTime:{configurable:!0,enumerable:!0,get:function(){return this.g.currentTime},set:function(a){this.g.currentTime=a}},duration:{configurable:!0,enumerable:!0,get:function(){return this.g.duration}},width:{configurable:!0,enumerable:!0,get:function(){return this.g.width},set:function(a){a&&(this.g.width=a)}},height:{configurable:!0,enumerable:!0,get:function(){return this.g.height},set:function(a){a&&(this.g.height=
a)}},videoWidth:{configurable:!0,enumerable:!0,get:function(){return this.g.videoWidth}},videoHeight:{configurable:!0,enumerable:!0,get:function(){return this.g.videoHeight}}});k.Object.defineProperties(K,{observedAttributes:{configurable:!0,enumerable:!0,get:function(){return J}}});customElements.define("gwd-video",K);}).call(this);
