@glomex/vast-ima-player
Version:
Convenience wrapper for advertising video/audio content with Google IMA
3 lines (2 loc) • 21.6 kB
JavaScript
var t=null,i=function(){t=null};function e(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}function s(){return s=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},s.apply(this,arguments)}function h(t,i){t.prototype=Object.create(i.prototype),t.prototype.constructor=t,o(t,i)}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function o(t,i){return o=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},o(t,i)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function u(t,i,e){return u=a()?Reflect.construct:function(t,i,e){var n=[null];n.push.apply(n,i);var s=new(Function.bind.apply(t,n));return e&&o(s,e.prototype),s},u.apply(null,arguments)}function c(t){var i="function"==typeof Map?new Map:void 0;return c=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,e)}function e(){return u(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)},c(t)}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,i){(null==i||i>t.length)&&(i=t.length);for(var e=0,n=new Array(i);e<i;e++)n[e]=t[e];return n}var f=0;function v(t){return"__private_"+f+++"_"+t}function b(t,i){if(!Object.prototype.hasOwnProperty.call(t,i))throw new TypeError("attempted to use private field on non-instance");return t}var w={};w.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(t){return i[t]=new i("").constructor[t],i;function i(t,i){i||(i={});var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!!i.bubbles,!!i.cancelable,i.detail),e}}("prototype");var m,p,y=w.CustomEvent,O=v("mediaElement"),j=v("currentTime"),g=v("enabled"),A=function(){function t(t){Object.defineProperty(this,O,{writable:!0,value:void 0}),Object.defineProperty(this,j,{writable:!0,value:void 0}),Object.defineProperty(this,g,{writable:!0,value:void 0}),this.seeking=void 0,b(this,O)[O]=t,b(this,j)[j]=0,b(this,g)[g]=!1,this.seeking=!1,this.t=this.t.bind(this),this.i=this.i.bind(this),this.h=this.h.bind(this),this.enable()}var i=t.prototype;return i.i=function(){this.seeking=!0},i.h=function(){this.seeking=!1},i.t=function(){var t,i;this.seeking||null!=(t=b(this,O)[O])&&t.paused||(b(this,j)[j]=null==(i=b(this,O)[O])?void 0:i.currentTime)},i.enable=function(){var t,i,e;b(this,g)[g]||(null==(t=b(this,O)[O])||t.addEventListener("seeking",this.i),null==(i=b(this,O)[O])||i.addEventListener("seeked",this.h),null==(e=b(this,O)[O])||e.addEventListener("timeupdate",this.t),b(this,g)[g]=!0)},i.disable=function(){var t,i,e;b(this,g)[g]&&(null==(t=b(this,O)[O])||t.removeEventListener("seeking",this.i),null==(i=b(this,O)[O])||i.removeEventListener("seeked",this.h),null==(e=b(this,O)[O])||e.removeEventListener("timeupdate",this.t),b(this,g)[g]=!1)},i.play=function(){var t=this;return new Promise(function(i){var e;i(null==(e=b(t,O)[O])?void 0:e.play())})},i.pause=function(){var t;null==(t=b(this,O)[O])||t.pause()},i.reset=function(){b(this,j)[j]=0,b(this,g)[g]=!1,this.seeking=!1,this.enable()},i.destroy=function(){b(this,j)[j]=0,b(this,g)[g]=!1,this.seeking=!1,this.disable(),b(this,O)[O]=void 0},n(t,[{key:"enabled",get:function(){return b(this,g)[g]}},{key:"currentTime",get:function(){return b(this,j)[j]}},{key:"duration",get:function(){var t;return null==(t=b(this,O)[O])?void 0:t.duration}},{key:"muted",get:function(){var t;return null==(t=b(this,O)[O])?void 0:t.muted}},{key:"volume",get:function(){var t;return null==(t=b(this,O)[O])?void 0:t.volume}}]),t}(),k=function(){function t(){this.delegate=document.createDocumentFragment()}var i=t.prototype;return i.addEventListener=function(){this.delegate.addEventListener.apply(this.delegate,[].slice.call(arguments))},i.dispatchEvent=function(){return this.delegate.dispatchEvent.apply(this.delegate,[].slice.call(arguments))},i.removeEventListener=function(){return this.delegate.removeEventListener.apply(this.delegate,[].slice.call(arguments))},t}(),C=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"];!function(t){t.MEDIA_START="MediaStart",t.MEDIA_IMPRESSION="MediaImpression",t.MEDIA_STOP="MediaStop",t.MEDIA_CUE_POINTS_CHANGE="MediaCuePointsChange",t.MEDIA_RESUMED="MediaResumed"}(m||(m={})),function(t){t.AD_ERROR="AdError",t.AD_BUFFERING="AdBuffering",t.LOADED="AdLoaded",t.IMPRESSION="AdImpression",t.STARTED="AdStarted",t.FIRST_QUARTILE="AdFirstQuartile",t.MIDPOINT="AdMidpoint",t.THIRD_QUARTILE="AdThirdQuartile",t.AD_PROGRESS="AdProgress",t.COMPLETE="AdComplete",t.CLICK="AdClick",t.PAUSED="AdPaused",t.RESUMED="AdResumed",t.SKIPPED="AdSkipped",t.SKIPPABLE_STATE_CHANGED="AdSkippableStateChanged",t.VOLUME_CHANGED="AdVolumeChanged",t.VOLUME_MUTED="AdMuted",t.AD_METADATA="AdMetadata",t.AD_BREAK_READY="AdBreakReady",t.CONTENT_PAUSE_REQUESTED="AdContentPauseRequested",t.CONTENT_RESUME_REQUESTED="AdContentResumeRequested",t.ALL_ADS_COMPLETED="AdAllAdsCompleted",t.DURATION_CHANGE="AdDurationChange",t.INTERACTION="AdInteraction",t.LINEAR_CHANGED="AdLinearChanged",t.LOG="AdLog",t.USER_CLOSE="AdUserClose",t.AD_CAN_PLAY="AdCanPlay",t.EXPANDED_CHANGED="AdExpandedChanged",t.VIEWABLE_IMPRESSION="AdViewableImpression"}(p||(p={}));var P=s({},p,m),R=function(){this.disableCustomPlaybackForIOS10Plus=!1,this.autoResize=!0,this.clickTrackingElement=void 0},E=function(t){function i(){var i;return(i=t.call.apply(t,[this].concat([].slice.call(arguments)))||this).errorCode=void 0,i.innerError=void 0,i.type=void 0,i.vastErrorCode=void 0,i}return h(i,t),i}(c(Error));E.ERROR_CODE_ADS_MANAGER_LOADED_TIMEOUT=9e3,E.ERROR_CODE_REQUEST_ADS_TIMEOUT=9001;var T=v("mediaElement"),S=v("adElement"),M=v("customPlayhead"),x=v("adsRenderingSettings"),I=v("ima"),B=v("adDisplayContainer"),L=v("adsManager"),D=v("width"),W=v("height"),_=v("adsLoader"),q=v("playerOptions"),F=v("resizeObserver"),N=v("currentAd"),V=v("loadedAd"),G=v("mediaStartTriggered"),Q=v("mediaImpressionTriggered"),U=v("mediaInActivation"),z=v("customPlaybackTimeAdjustedOnEnded"),Z=v("cuePoints"),$=v("adCurrentTime"),H=v("adDuration"),J=v("startAdCallback"),K=v("adsManagerLoadedTimeout"),X=v("requestAdsTimeout"),Y=v("wasExternallyPaused"),tt=v("lastNonZeroAdVolume"),it=v("activatePromise");exports.Player=function(t){function i(i,e,n,s,h){var r;void 0===s&&(s=new i.AdsRenderingSettings),void 0===h&&(h=new R),r=t.call(this)||this,Object.defineProperty(d(r),T,{writable:!0,value:void 0}),Object.defineProperty(d(r),S,{writable:!0,value:void 0}),Object.defineProperty(d(r),M,{writable:!0,value:void 0}),Object.defineProperty(d(r),x,{writable:!0,value:void 0}),Object.defineProperty(d(r),I,{writable:!0,value:void 0}),Object.defineProperty(d(r),B,{writable:!0,value:void 0}),Object.defineProperty(d(r),L,{writable:!0,value:void 0}),Object.defineProperty(d(r),D,{writable:!0,value:void 0}),Object.defineProperty(d(r),W,{writable:!0,value:void 0}),Object.defineProperty(d(r),_,{writable:!0,value:void 0}),Object.defineProperty(d(r),q,{writable:!0,value:void 0}),Object.defineProperty(d(r),F,{writable:!0,value:void 0}),Object.defineProperty(d(r),N,{writable:!0,value:void 0}),Object.defineProperty(d(r),V,{writable:!0,value:void 0}),Object.defineProperty(d(r),G,{writable:!0,value:!1}),Object.defineProperty(d(r),Q,{writable:!0,value:!1}),Object.defineProperty(d(r),U,{writable:!0,value:!1}),Object.defineProperty(d(r),z,{writable:!0,value:!1}),Object.defineProperty(d(r),Z,{writable:!0,value:[]}),Object.defineProperty(d(r),$,{writable:!0,value:void 0}),Object.defineProperty(d(r),H,{writable:!0,value:void 0}),Object.defineProperty(d(r),J,{writable:!0,value:void 0}),Object.defineProperty(d(r),K,{writable:!0,value:void 0}),Object.defineProperty(d(r),X,{writable:!0,value:void 0}),Object.defineProperty(d(r),Y,{writable:!0,value:!1}),Object.defineProperty(d(r),tt,{writable:!0,value:1}),Object.defineProperty(d(r),it,{writable:!0,value:Promise.resolve()}),b(d(r),T)[T]=e,b(d(r),S)[S]=n,b(d(r),I)[I]=i,b(d(r),q)[q]=h,b(d(r),x)[x]=s,b(d(r),x)[x].restoreCustomPlaybackStateOnAdBreakComplete=!0,h.disableCustomPlaybackForIOS10Plus&&!b(d(r),T)[T].hasAttribute("playsinline")&&b(d(r),T)[T].setAttribute("playsinline",""),b(d(r),I)[I].settings.setDisableCustomPlaybackForIOS10Plus(h.disableCustomPlaybackForIOS10Plus),b(d(r),M)[M]=new A(b(d(r),T)[T]),r.o=r.o.bind(d(r)),C.forEach(function(t){b(d(r),T)[T].addEventListener(t,r.o)}),r.u=r.u.bind(d(r)),r.l=r.l.bind(d(r));var o=b(d(r),T)[T],a=o.offsetHeight,u=o.offsetWidth;return b(d(r),D)[D]=u,b(d(r),W)[W]=a,h.autoResize&&window.ResizeObserver&&(b(d(r),F)[F]=new window.ResizeObserver(function(t){return r.v(t)}),b(d(r),F)[F].observe(b(d(r),T)[T])),r}h(i,t);var e=i.prototype;return e.activate=function(){var t=this;if(!b(this,G)[G]&&!b(this,U)[U]&&(b(this,U)[U]=!0,b(this,T)[T].paused)){var i=function(){return b(t,T)[T].pause(),new Promise(function(i){setTimeout(function(){b(t,U)[U]=!1,i()},1)})};b(this,it)[it]=new Promise(function(i){return i(b(t,T)[T].play())}).then(i).catch(i)}},e.playAds=function(t){this.m(t)},e.loadAds=function(t,i){this.m(t,!1,i)},e.p=function(){var t=this;return b(this,it)[it].then(function(){return new Promise(function(i){return i(b(t,T)[T].play())})})},e.m=function(t,i,e){var n=this;void 0===i&&(i=!0),this.reset(),this.O(),b(this,I)[I].settings.setAutoPlayAdBreaks(i),b(this,T)[T].ended&&(b(this,M)[M].reset(),b(this,T)[T].currentTime=0),b(this,J)[J]=e,t.linearAdSlotWidth=b(this,D)[D],t.linearAdSlotHeight=b(this,W)[W],t.nonLinearAdSlotWidth=b(this,D)[D],t.nonLinearAdSlotHeight=b(this,W)[W],null==t.contentDuration&&(t.contentDuration=-3),b(this,K)[K]=window.setTimeout(function(){var t=new E("No adsManagerLoadedEvent within 5000ms.");t.errorCode=E.ERROR_CODE_ADS_MANAGER_LOADED_TIMEOUT,n.j(t)},5e3),b(this,X)[X]=window.setTimeout(function(){var t=new E("No response for ads-request within 10000ms.");t.errorCode=E.ERROR_CODE_REQUEST_ADS_TIMEOUT,n.j(t)},1e4),b(this,_)[_].requestAds(t)},e.O=function(){b(this,B)[B]=new(b(this,I)[I].AdDisplayContainer)(b(this,S)[S],b(this,q)[q].disableCustomPlaybackForIOS10Plus?void 0:b(this,T)[T],b(this,q)[q].clickTrackingElement),b(this,_)[_]=new(b(this,I)[I].AdsLoader)(b(this,B)[B]),b(this,_)[_].addEventListener(b(this,I)[I].AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.u,!1),b(this,_)[_].addEventListener(b(this,I)[I].AdErrorEvent.Type.AD_ERROR,this.l,!1)},e.skipAd=function(){b(this,L)[L]&&b(this,L)[L].skip()},e.discardAdBreak=function(){b(this,L)[L]&&b(this,L)[L].discardAdBreak()},e.play=function(){var t=this;b(this,Y)[Y]=!1,!b(this,M)[M].enabled&&b(this,L)[L]?b(this,L)[L].resume():b(this,K)[K]||this.p().then(function(){}).catch(function(){t.dispatchEvent(new y("pause"))})},e.pause=function(){b(this,Y)[Y]=!0,!b(this,M)[M].enabled&&b(this,L)[L]?b(this,L)[L].pause():b(this,T)[T].pause()},e.g=function(t){b(this,Z)[Z]=[].concat(t),this.dispatchEvent(new y(P.MEDIA_CUE_POINTS_CHANGE,{detail:{cuePoints:[].concat(b(this,Z)[Z])}}))},e.A=function(t){var i=this.cuePoints.indexOf(t);i>-1&&(b(this,Z)[Z].splice(i,1),this.g(b(this,Z)[Z]))},e.resizeAd=function(t,i){b(this,D)[D]=t,b(this,W)[W]=i,b(this,L)[L]&&b(this,L)[L].resize(t,i,this.k()),b(this,S)[S].style.width=t+"px",b(this,S)[S].style.height=i+"px"},e.reset=function(t){void 0===t&&(t=!1),t&&(b(this,Q)[Q]=!1,b(this,G)[G]=!1,b(this,z)[z]=!1),this.C(),b(this,Z)[Z]=[],b(this,Y)[Y]=!1,b(this,J)[J]=void 0,b(this,L)[L]&&b(this,L)[L].destroy(),b(this,L)[L]=void 0,b(this,I)[I].settings.setAutoPlayAdBreaks(!0),t&&this.P(),b(this,S)[S].style.display="none"},e.P=function(){b(this,_)[_]&&(b(this,_)[_].removeEventListener(b(this,I)[I].AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.u,!1),b(this,_)[_].removeEventListener(b(this,I)[I].AdErrorEvent.Type.AD_ERROR,this.l,!1),b(this,_)[_].destroy()),b(this,B)[B]&&b(this,B)[B].destroy()},e.destroy=function(){var t,i,e,n,s=this;this.reset(!0),b(this,M)[M].destroy(),C.forEach(function(t){b(s,T)[T].removeEventListener(t,s.o)}),null==(t=b(this,_)[_])||t.removeEventListener(b(this,I)[I].AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.u,!1),null==(i=b(this,B)[B])||i.destroy(),null==(e=b(this,_)[_])||e.destroy(),b(this,Q)[Q]=!1,b(this,z)[z]=!1,b(this,G)[G]=!1,null==(n=b(this,F)[F])||n.disconnect()},e.isCustomPlaybackUsed=function(){return!1===b(this,I)[I].settings.getDisableCustomPlaybackForIOS10Plus()&&!b(this,S)[S].querySelector("video")},e.C=function(){window.clearTimeout(b(this,K)[K]),window.clearTimeout(b(this,X)[X]),b(this,K)[K]=void 0,b(this,X)[X]=void 0,b(this,N)[N]=void 0,b(this,$)[$]=void 0,b(this,H)[H]=void 0,b(this,S)[S].style.display="none",b(this,S)[S].classList.remove("nonlinear"),b(this,L)[L]&&this.R()},e.o=function(t){var i=this;if(b(this,M)[M].enabled||"volumechange"===t.type){if("timeupdate"===t.type){if(b(this,L)[L]){var e=b(this,L)[L].getCuePoints().filter(function(t){return t>=0&&t<b(i,M)[M].currentTime}).pop();this.A(e)}!b(this,Q)[Q]&&b(this,G)[G]&&b(this,T)[T].currentTime>=.5&&(this.dispatchEvent(new y(P.MEDIA_IMPRESSION)),b(this,Q)[Q]=!0)}if("play"!==t.type||b(this,G)[G]||b(this,U)[U]||(this.dispatchEvent(new y(P.MEDIA_START)),b(this,G)[G]=!0),"ended"===t.type&&(this.isCustomPlaybackUsed()&&b(this,T)[T].currentTime===b(this,T)[T].duration&&b(this,Z)[Z].indexOf(-1)>-1&&(b(this,T)[T].currentTime=b(this,T)[T].duration-1e-5,b(this,z)[z]=!0),b(this,_)[_].contentComplete(),b(this,L)[L]||this.T()),!window.ResizeObserver&&b(this,q)[q].autoResize&&"loadedmetadata"===t.type){var n=b(this,T)[T],s=n.offsetHeight,h=n.offsetWidth;b(this,D)[D]=h,b(this,W)[W]=s,this.R()}b(this,U)[U]&&"volumechange"!==t.type||this.dispatchEvent(new y(t.type))}},e.S=function(t){var i=this,e=b(this,I)[I].AdEvent;switch(t.type){case e.Type.LOADED:var n=t.getAd();b(this,J)[J]&&0===b(this,Z)[Z].length?b(this,J)[J]({ad:n,start:function(){i.M(),b(i,J)[J]=void 0},startWithoutReset:function(){i.M()}}):b(this,V)[V]=n;break;case e.Type.AD_BREAK_READY:this.C(),b(this,J)[J]?(b(this,J)[J]({ad:b(this,V)[V],adBreakTime:t.getAdData().adBreakTime,start:function(){i.M(),b(i,J)[J]=void 0},startWithoutReset:function(){i.M()}}),b(this,V)[V]=void 0):this.M();break;case e.Type.STARTED:var s=b(this,N)[N]=t.getAd();s.getAdPodInfo().getAdPosition()>1&&b(this,L)[L].setVolume(b(this,L)[L].getVolume()),b(this,S)[S].classList.remove("nonlinear"),this.R(),s.isLinear()?(b(this,M)[M].disable(),b(this,H)[H]=s.getDuration(),b(this,$)[$]=0):(b(this,S)[S].classList.add("nonlinear"),this.I()),b(this,S)[S].style.display="",b(this,Y)[Y]&&(b(this,Y)[Y]=!1,b(this,L)[L].pause());break;case e.Type.ALL_ADS_COMPLETED:if(b(this,z)[z])return;this.isCustomPlaybackUsed()&&Boolean(b(this,N)[N])&&-1!==b(this,N)[N].getAdPodInfo().getTimeOffset()&&this.I(),this.reset();break;case e.Type.CONTENT_PAUSE_REQUESTED:this.C(),b(this,N)[N]=t.getAd(),b(this,S)[S].style.display="",b(this,T)[T].pause(),this.R(),b(this,N)[N]&&this.A(b(this,N)[N].getAdPodInfo().getTimeOffset()),b(this,L)[L].setVolume(b(this,T)[T].muted?0:b(this,T)[T].volume),b(this,M)[M].disable(),b(this,H)[H]=b(this,N)[N].getDuration(),b(this,$)[$]=0;break;case e.Type.CONTENT_RESUME_REQUESTED:var h=Boolean(b(this,N)[N]);if(h){var r=b(this,L)[L].getVolume();b(this,T)[T].muted=0===r,b(this,T)[T].volume=b(this,tt)[tt]}b(this,z)[z]&&(b(this,T)[T].currentTime=b(this,T)[T].duration+1,b(this,z)[z]=!1),b(this,T)[T].ended?(this.reset(),this.T()):this.C(),h&&(b(this,Y)[Y]=!1,this.I());break;case e.Type.AD_METADATA:this.g(b(this,L)[L].getCuePoints()),-1===b(this,Z)[Z].indexOf(0)&&(b(this,J)[J]?b(this,J)[J]({start:function(){i.I(),b(i,J)[J]=void 0},startWithoutReset:function(){i.I()}}):this.I());break;case e.Type.AD_PROGRESS:var o=t.getAdData();b(this,$)[$]=o.currentTime,b(this,H)[H]=o.duration;break;case e.Type.LOG:var a=t.getAdData();b(this,J)[J]?b(this,J)[J]({start:function(){i.I(),b(i,J)[J]=void 0},startWithoutReset:function(){i.I()}}):a.adError&&!b(this,N)[N]&&this.I();break;case e.Type.VOLUME_CHANGED:var u=b(this,L)[L].getVolume();u>0&&(b(this,tt)[tt]=u)}},e.l=function(t){this.j(this.B(t))},e.u=function(t){var i=this,e=b(this,I)[I],n=e.AdEvent,s=e.AdErrorEvent.Type.AD_ERROR;window.clearTimeout(b(this,K)[K]);var h=b(this,L)[L]=t.getAdsManager(b(this,M)[M],b(this,x)[x]);Object.keys(n.Type).forEach(function(t){h.addEventListener(n.Type[t],function(e){if(i.S(e),P[t]){var n=["LOG","AD_PROGRESS"].indexOf(t)>-1;i.dispatchEvent(new y(P[t],{detail:{ad:e.getAd()||b(i,N)[N],adData:n?e.getAdData():{}}}))}})}),h.addEventListener(s,function(t){return i.j(i.B(t))});try{var r;h.init(b(this,D)[D],b(this,W)[W],this.k()),h.setVolume(b(this,T)[T].muted?0:b(this,T)[T].volume),null==(r=b(this,B)[B])||r.initialize(),b(this,J)[J]||this.M()}catch(t){this.j(new E(t.message))}},e.M=function(){if(b(this,G)[G]||(this.dispatchEvent(new y(P.MEDIA_START)),b(this,G)[G]=!0),b(this,L)[L])try{b(this,L)[L].start()}catch(t){this.j(new E(t.message))}else this.I()},e.T=function(){var t=this;setTimeout(function(){b(t,Q)[Q]=!1,b(t,G)[G]=!1,b(t,z)[z]=!1,t.dispatchEvent(new y(P.MEDIA_STOP))},1)},e.v=function(t){for(var i,e=function(t,i){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,i){if(t){if("string"==typeof t)return l(t,i);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?l(t,i):void 0}}(t))){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(i=e()).done;){var n=i.value;n.contentBoxSize&&1===n.contentBoxSize.length?(b(this,D)[D]=n.contentBoxSize[0].inlineSize,b(this,W)[W]=n.contentBoxSize[0].blockSize):n.contentBoxSize&&n.contentBoxSize.inlineSize?(b(this,D)[D]=n.contentBoxSize.inlineSize,b(this,W)[W]=n.contentBoxSize.blockSize):(b(this,D)[D]=n.contentRect.width,b(this,W)[W]=n.contentRect.height)}this.R()},e.R=function(){if(b(this,q)[q].autoResize&&b(this,L)[L]){var t=b(this,N)[N],i=this.k();t&&!t.isLinear()?t&&(t.getWidth()>b(this,D)[D]||t.getHeight()>b(this,W)[W]?this.resizeAd(b(this,D)[D],b(this,W)[W]):(b(this,L)[L].resize(t.getWidth(),t.getHeight()+20,i),b(this,S)[S].style.width=t.getWidth()+"px",b(this,S)[S].style.height=t.getHeight()+20+"px")):this.resizeAd(b(this,D)[D],b(this,W)[W])}},e.k=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||b(this,T)[T].webkitDisplayingFullscreen?b(this,I)[I].ViewMode.FULLSCREEN:b(this,I)[I].ViewMode.NORMAL},e.I=function(){var t=this;b(this,S)[S].style.display="none",b(this,T)[T].ended||(b(this,M)[M].enable(),b(this,Y)[Y]?(b(this,T)[T].pause(),this.dispatchEvent(new y("pause"))):(this.p().then(function(){}).catch(function(){t.dispatchEvent(new y("pause"))}),this.dispatchEvent(new y("play")),this.dispatchEvent(new y(P.MEDIA_RESUMED))),b(this,Y)[Y]=!1)},e.B=function(t){var i=t.getError(),e=new E(i.getMessage());return e.type=i.getType(),e.errorCode=i.getErrorCode(),e.vastErrorCode=i.getVastErrorCode&&i.getVastErrorCode(),e.innerError=i.getInnerError(),e},e.j=function(t){var i=this;this.dispatchEvent(new y(P.AD_ERROR,{detail:{error:t}})),this.C(),b(this,J)[J]?b(this,J)[J]({start:function(){i.I(),b(i,J)[J]=void 0},startWithoutReset:function(){i.I()}}):this.I()},n(i,[{key:"volume",get:function(){return!b(this,M)[M].enabled&&b(this,L)[L]?b(this,L)[L].getVolume():b(this,T)[T].volume},set:function(t){!b(this,M)[M].enabled&&b(this,L)[L]&&b(this,L)[L].setVolume(t),b(this,T)[T].volume=t}},{key:"muted",get:function(){return!b(this,M)[M].enabled&&b(this,L)[L]?0===b(this,L)[L].getVolume():b(this,T)[T].muted},set:function(t){!b(this,M)[M].enabled&&b(this,L)[L]&&b(this,L)[L].setVolume(t?0:b(this,tt)[tt]),b(this,T)[T].muted=t}},{key:"currentTime",get:function(){return void 0!==b(this,$)[$]?b(this,$)[$]:b(this,T)[T].currentTime},set:function(t){b(this,M)[M].enabled&&(b(this,T)[T].currentTime=t)}},{key:"duration",get:function(){return void 0!==b(this,H)[H]?b(this,H)[H]:b(this,T)[T].duration}},{key:"cuePoints",get:function(){return[].concat(b(this,Z)[Z])}}]),i}(k),exports.PlayerError=E,exports.PlayerEvent=P,exports.PlayerOptions=R,exports.loadImaSdk=function(){var e=window;return e.google&&e.google.ima?Promise.resolve(e.google.ima):t||((t=new Promise(function(t,i){var e=document.createElement("script");e.async=!0,e.src="https://imasdk.googleapis.com/js/sdkloader/ima3.js",e.onload=t,e.onerror=i,document.body.appendChild(e)}).then(function(){return e.google.ima})).then(i).catch(i),t)};
//# sourceMappingURL=vast-ima-player.js.map