Path: blob/main/misc/vex4/cdn.jsdelivr.net/npm/@orange-games/[email protected]/build/phaser-ads.min.js
49384 views
/*!1* phaser-ads - version 2.2.72* A Phaser plugin for providing nice ads integration in your phaser.io game3*4* OrangeGames5* Build at 07-08-20186* Released under MIT License7*/89var __extends = this && this.__extends || function() {10var a = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(a, b) { a.__proto__ = b } || function(a, b) { for (var c in b) b.hasOwnProperty(c) && (a[c] = b[c]) };11return function(b, c) {12function d() { this.constructor = b } a(b, c), b.prototype = null === c ? Object.create(c) : (d.prototype = c.prototype, new d)13}14}(),15PhaserAds;16! function(a) {17var b;18! function(a) { a[a.start = 0] = "start", a[a.firstQuartile = 1] = "firstQuartile", a[a.midPoint = 2] = "midPoint", a[a.thirdQuartile = 3] = "thirdQuartile", a[a.complete = 4] = "complete" }(b = a.AdEvent || (a.AdEvent = {}));19var c;20! function(a) { a[a.interstitial = 0] = "interstitial", a[a.rewarded = 1] = "rewarded", a[a.banner = 2] = "banner", a[a.video = 3] = "video" }(c = a.AdType || (a.AdType = {}));21var d = function(a) {22function b(b, c) { var d = a.call(this, b, c) || this; return d.onContentPaused = new Phaser.Signal, d.onContentResumed = new Phaser.Signal, d.onAdProgression = new Phaser.Signal, d.onAdsDisabled = new Phaser.Signal, d.onAdClicked = new Phaser.Signal, d.onAdRewardGranted = new Phaser.Signal, d.onBannerShown = new Phaser.Signal, d.onBannerHidden = new Phaser.Signal, d.bannerActive = !1, d.provider = null, d.wasMuted = !1, Object.defineProperty(b, "ads", { value: d }), d }23return __extends(b, a), b.prototype.setAdProvider = function(a) { this.provider = a, this.provider.setManager(this) }, b.prototype.showAd = function() {24for (var a = [], b = 0; b < arguments.length; b++) a[b] = arguments[b];25if (null === this.provider) throw new Error("Can not request an ad without an provider, please attach an ad provider!");26a[0] !== c.banner && (this.wasMuted = this.game.sound.mute, this.game.sound.mute = !0), this.provider.showAd.apply(this.provider, a)27}, b.prototype.preloadAd = function() {28for (var a = [], b = 0; b < arguments.length; b++) a[b] = arguments[b];29if (null === this.provider) throw new Error("Can not preload an ad without an provider, please attach an ad provider!");30this.provider.preloadAd.apply(this.provider, a)31}, b.prototype.destroyAd = function() {32for (var a = [], b = 0; b < arguments.length; b++) a[b] = arguments[b];33if (null === this.provider) throw new Error("Can not destroy an ad without an provider, please attach an ad provider!");34this.provider.destroyAd.apply(this.provider, a)35}, b.prototype.hideAd = function() {36for (var a = [], b = 0; b < arguments.length; b++) a[b] = arguments[b];37if (null === this.provider) throw new Error("Can not hide an ad without an provider, please attach an ad provider!");38this.unMuteAfterAd(), this.provider.hideAd.apply(this.provider, a)39}, b.prototype.adsEnabled = function() { return this.provider.adsEnabled }, b.prototype.unMuteAfterAd = function() { this.wasMuted || (this.game.sound.mute = !1) }, b40}(Phaser.Plugin);41a.AdManager = d42}(PhaserAds || (PhaserAds = {}));43var PhaserAds;44! function(a) {45var b;46! function(b) {47var c;48! function(a) { a[a.AdMob = 0] = "AdMob", a[a.MoPub = 1] = "MoPub", a[a.Chartboost = 2] = "Chartboost", a[a.Heyzap = 3] = "Heyzap" }(c = b.CocoonProvider || (b.CocoonProvider = {}));49var d = function() {50function b(a, b, d) {51if (this.adsEnabled = !1, this.banner = null, this.bannerShowable = !1, this.interstitial = null, this.interstitialShowable = !1, this.rewarded = null, this.rewardedShowable = !1, (a.device.cordova || a.device.crosswalk) && Cocoon && Cocoon.Ad) {52switch (this.adsEnabled = !0, b) {53default:54case c.AdMob:55this.cocoonProvider = Cocoon.Ad.AdMob;56break;57case c.Chartboost:58this.cocoonProvider = Cocoon.Ad.Chartboost;59break;60case c.Heyzap:61this.cocoonProvider = Cocoon.Ad.Heyzap;62break;63case c.MoPub:64this.cocoonProvider = Cocoon.Ad.MoPub65}66this.cocoonProvider.configure(d)67}68}69return b.prototype.setManager = function(a) { this.adManager = a }, b.prototype.showAd = function(b) {70if (!this.adsEnabled) return this.adManager.unMuteAfterAd(), void(b !== a.AdType.banner && this.adManager.onContentResumed.dispatch());71if (b === a.AdType.banner) {72if (!this.bannerShowable || null === this.banner) return void this.adManager.unMuteAfterAd();73this.adManager.onBannerShown.dispatch(this.banner.width, this.banner.height), this.adManager.bannerActive = !0, this.banner.show()74}75if (b === a.AdType.interstitial) {76if (!this.interstitialShowable || null === this.interstitial) return this.adManager.unMuteAfterAd(), void this.adManager.onContentResumed.dispatch(a.AdType.interstitial);77this.interstitial.show()78}79if (b === a.AdType.rewarded) {80if (!this.rewardedShowable || null === this.rewarded) return this.adManager.unMuteAfterAd(), void this.adManager.onContentResumed.dispatch(a.AdType.rewarded);81this.rewarded.show()82}83}, b.prototype.preloadAd = function(b, c, d) {84var e = this;85this.adsEnabled && (this.destroyAd(b), b === a.AdType.banner && (this.banner = this.cocoonProvider.createBanner(c), d && this.banner.setLayout(d), this.banner.on("load", function() { e.bannerShowable = !0 }), this.banner.on("fail", function() { e.bannerShowable = !1, e.banner = null }), this.banner.on("click", function() { e.adManager.onAdClicked.dispatch(a.AdType.banner) }), this.banner.on("show", function() {}), this.banner.on("dismiss", function() {}), this.banner.load()), b === a.AdType.interstitial && (this.interstitial = this.cocoonProvider.createInterstitial(c), this.interstitial.on("load", function() { e.interstitialShowable = !0 }), this.interstitial.on("fail", function() { e.interstitialShowable = !1, e.interstitial = null }), this.interstitial.on("click", function() { e.adManager.onAdClicked.dispatch(a.AdType.interstitial) }), this.interstitial.on("show", function() { e.adManager.onContentPaused.dispatch(a.AdType.interstitial) }), this.interstitial.on("dismiss", function() { e.adManager.unMuteAfterAd(), e.adManager.onContentResumed.dispatch(a.AdType.interstitial), e.interstitialShowable = !1, e.interstitial = null }), this.interstitial.load()), b === a.AdType.rewarded && (this.rewarded = this.cocoonProvider.createRewardedVideo(c), this.rewarded.on("load", function() { e.rewardedShowable = !0 }), this.rewarded.on("fail", function() { e.rewardedShowable = !1, e.rewarded = null }), this.rewarded.on("click", function() { e.adManager.onAdClicked.dispatch(a.AdType.rewarded) }), this.rewarded.on("show", function() { e.adManager.onContentPaused.dispatch(a.AdType.rewarded) }), this.rewarded.on("dismiss", function() { e.adManager.unMuteAfterAd(), e.adManager.onContentResumed.dispatch(a.AdType.rewarded), e.rewardedShowable = !1, e.rewarded = null }), this.rewarded.on("reward", function() { e.adManager.unMuteAfterAd(), e.adManager.onAdRewardGranted.dispatch(a.AdType.rewarded), e.rewardedShowable = !1, e.rewarded = null }), this.rewarded.load()))86}, b.prototype.destroyAd = function(b) { if (this.adsEnabled) { if (b === a.AdType.banner && null !== this.banner) { try { this.cocoonProvider.releaseBanner(this.banner) } catch (a) {} this.banner = null, this.bannerShowable = !1 } b === a.AdType.interstitial && null !== this.interstitial && (this.cocoonProvider.releaseInterstitial(this.interstitial), this.interstitial = null, this.interstitialShowable = !1) } }, b.prototype.hideAd = function(b) { this.adsEnabled && (b === a.AdType.interstitial && null !== this.interstitial && this.interstitial.hide(), b === a.AdType.banner && null !== this.banner && (this.adManager.bannerActive && (this.adManager.bannerActive = !1, this.adManager.onBannerHidden.dispatch(this.banner.width, this.banner.height)), this.banner.hide()), b === a.AdType.rewarded && null !== this.rewarded && this.rewarded.hide()) }, b87}();88b.CocoonAds = d89}(b = a.AdProvider || (a.AdProvider = {}))90}(PhaserAds || (PhaserAds = {}));91var PhaserAds;92! function(a) {93var b;94! function(a) {95var b = function() {96function a(a, b, c, d) { void 0 === d && (d = !1), this.adsEnabled = !1, void 0 === cordova.plugins || void 0 !== cordova.plugins && void 0 === cordova.plugins.gdApi || (d && cordova.plugins.gdApi.enableTestAds(), this.setAdListeners(), cordova.plugins.gdApi.init([b, c], function(a) {}, function(a) {})) }97return a.prototype.setAdListeners = function() {98var a = this;99cordova.plugins.gdApi.setAdListener(function(b) {100switch (b.event) {101case "BANNER_STARTED":102a.adManager.onContentPaused.dispatch();103break;104case "API_IS_READY":105a.adsEnabled = !0;106break;107case "API_ALREADY_INITIALIZED":108break;109case "BANNER_CLOSED":110case "API_NOT_READY":111case "BANNER_FAILED":112a.adManager.onContentResumed.dispatch()113}114}, function(b) { a.adsEnabled = !1 })115}, a.prototype.setManager = function(a) { this.adManager = a }, a.prototype.showAd = function(a) {116var b = this;117this.adsEnabled ? cordova.plugins.gdApi.showBanner(function(a) {}, function(a) { b.adManager.onContentResumed.dispatch() }) : this.adManager.onContentResumed.dispatch()118}, a.prototype.preloadAd = function() {}, a.prototype.destroyAd = function() {}, a.prototype.hideAd = function() {}, a119}();120a.CordovaGameDistribution = b121}(b = a.AdProvider || (a.AdProvider = {}))122}(PhaserAds || (PhaserAds = {}));123var PhaserAds;124! function(a) {125var b;126! function(a) {127var b;128! function(a) { a[a.Interstitial = 0] = "Interstitial", a[a.Video = 1] = "Video", a[a.Rewarded = 2] = "Rewarded", a[a.Banner = 3] = "Banner" }(b = a.HeyzapAdTypes || (a.HeyzapAdTypes = {}));129var c = function() {130function a(a, b) {131var c = this;132this.adsEnabled = !1, (a.device.cordova || a.device.crosswalk) && (this.adsEnabled = !0, HeyzapAds.start(b).then(function() {}, function(a) { c.adsEnabled = !1 }))133}134return a.prototype.setManager = function(a) { this.adManager = a }, a.prototype.showAd = function(a, c) {135var d = this;136switch (this.adsEnabled || (this.adManager.unMuteAfterAd(), this.adManager.onContentResumed.dispatch()), a) {137case b.Interstitial:138HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.HIDE, function() { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch(HeyzapAds.InterstitialAd.Events.HIDE) }), HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.SHOW_FAILED, function() { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch(HeyzapAds.InterstitialAd.Events.SHOW_FAILED) }), HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.CLICKED, function() { d.adManager.onAdClicked.dispatch(HeyzapAds.InterstitialAd.Events.CLICKED) }), HeyzapAds.InterstitialAd.show().then(function() { d.adManager.onContentPaused.dispatch() }, function(a) { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch() });139break;140case b.Video:141HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.HIDE, function() { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch(HeyzapAds.VideoAd.Events.HIDE) }), HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.SHOW_FAILED, function() { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch(HeyzapAds.VideoAd.Events.SHOW_FAILED) }), HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.CLICKED, function() { d.adManager.onAdClicked.dispatch(HeyzapAds.VideoAd.Events.CLICKED) }), HeyzapAds.VideoAd.show().then(function() { d.adManager.onContentPaused.dispatch() }, function(a) { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch() });142break;143case b.Rewarded:144HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.HIDE, function() { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch(HeyzapAds.IncentivizedAd.Events.HIDE) }), HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.SHOW_FAILED, function() { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch(HeyzapAds.IncentivizedAd.Events.SHOW_FAILED) }), HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.CLICKED, function() { d.adManager.onAdClicked.dispatch(HeyzapAds.IncentivizedAd.Events.CLICKED) }), HeyzapAds.IncentivizedAd.show().then(function() { d.adManager.onContentPaused.dispatch() }, function(a) { d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch() });145break;146case b.Banner:147HeyzapAds.BannerAd.show(c).then(function() {}, function(a) {})148}149}, a.prototype.preloadAd = function(a) { this.adsEnabled && a === b.Rewarded && HeyzapAds.IncentivizedAd.fetch().then(function() {}, function(a) {}) }, a.prototype.destroyAd = function(a) { this.adsEnabled && a === b.Banner && HeyzapAds.BannerAd.destroy().then(function() {}, function(a) {}) }, a.prototype.hideAd = function(a) { this.adsEnabled && a === b.Banner && HeyzapAds.BannerAd.hide().then(function() {}, function(a) {}) }, a150}();151a.CordovaHeyzap = c152}(b = a.AdProvider || (a.AdProvider = {}))153}(PhaserAds || (PhaserAds = {}));154var PhaserAds;155! function(a) {156var b;157! function(a) {158var b;159! function(a) { a[a.preroll = 0] = "preroll", a[a.midroll = 1] = "midroll" }(b = a.GameDistributionAdType || (a.GameDistributionAdType = {}));160var c = function() {161function a(a, b, c) {162void 0 === c && (c = "");163var d = this;164this.adsEnabled = !0, this.areAdsEnabled(), GD_OPTIONS = {165gameId: b,166userId: c,167advertisementSettings: { autoplay: !1 },168onEvent: function(a) {169switch (a.name) {170case "SDK_GAME_START":171"undefined" != typeof gdApi && gdApi.play(), d.adManager.unMuteAfterAd(), d.adManager.onContentResumed.dispatch();172break;173case "SDK_GAME_PAUSE":174d.adManager.onContentPaused.dispatch();175break;176case "SDK_READY":177break;178case "SDK_ERROR":179}180}181},182function(a, b, c) {183var d, e = a.getElementsByTagName(b)[0];184a.getElementById(c) || (d = a.createElement(b), d.id = c, d.src = "//htmi.api.gamedistribution.com/main.min.js", e.parentNode.insertBefore(d, e))185}(document, "script", "gamedistribution-jssdk")186}187return a.prototype.setManager = function(a) { this.adManager = a }, a.prototype.showAd = function() {188if (this.adsEnabled) {189if ("undefined" == typeof gdApi || gdApi && "undefined" == typeof gdApi.showBanner) return this.adsEnabled = !1, this.adManager.unMuteAfterAd(), void this.adManager.onContentResumed.dispatch();190gdApi.showBanner()191}192else this.adManager.unMuteAfterAd(), this.adManager.onContentResumed.dispatch()193}, a.prototype.preloadAd = function() {}, a.prototype.destroyAd = function() {}, a.prototype.hideAd = function() {}, a.prototype.areAdsEnabled = function() {194var a = this,195b = document.createElement("div");196b.innerHTML = " ", b.className = "adsbox", b.style.position = "absolute", b.style.fontSize = "10px", document.body.appendChild(b);197var c = function() { var a = !0; return 0 === b.offsetHeight && (a = !1), b.parentNode.removeChild(b), a };198window.setTimeout(function() { a.adsEnabled = c() }, 100)199}, a200}();201a.GameDistributionAds = c202}(b = a.AdProvider || (a.AdProvider = {}))203}(PhaserAds || (PhaserAds = {}));204var PhaserAds;205! function(a) {206var b;207! function(b) {208var c = function() {209function b(a, b) { this.adsManager = null, this.googleEnabled = !1, this.adsEnabled = !0, this.adTagUrl = "", this.adRequested = !1, this.adManager = null, this.resizeListener = null, this.areAdsEnabled(), "undefined" != typeof google && (this.googleEnabled = !0, this.gameContent = "string" == typeof a.parent ? document.getElementById(a.parent) : a.parent, this.gameContent.style.position = "absolute", this.gameContent.style.width = "100%", this.adContent = this.gameContent.parentNode.appendChild(document.createElement("div")), this.adContent.id = "phaser-ad-container", this.adContent.style.position = "absolute", this.adContent.style.zIndex = "9999", this.adContent.style.display = "none", this.adContent.style.top = "0", this.adContent.style.left = "0", this.adContent.style.width = "100%", this.adContent.style.height = "100%", this.adContent.style.overflow = "hidden", this.adTagUrl = b, this.game = a, this.adDisplay = new google.ima.AdDisplayContainer(this.adContent), google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED), google.ima.settings.setLocale("nl"), this.adLoader = new google.ima.AdsLoader(this.adDisplay), this.adLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, this.onAdManagerLoader, !1, this), this.adLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, this.onAdError, !1, this)) }210return b.prototype.setManager = function(a) { this.adManager = a }, b.prototype.showAd = function(a) {211if (!this.adRequested) {212if (this.adsEnabled || this.adManager.onAdsDisabled.dispatch(!0), !this.googleEnabled) return void this.onContentResumeRequested();213this.adDisplay.initialize();214var b = new google.ima.AdsRequest;215b.adTagUrl = this.adTagUrl + this.parseCustomParams(a);216var c = window.innerWidth,217d = window.innerHeight;218this.game.scale.isFullScreen && document.body.clientHeight < window.innerHeight && (d = document.body.clientHeight, c = document.body.clientWidth), b.linearAdSlotWidth = c, b.linearAdSlotHeight = d, b.nonLinearAdSlotWidth = c, b.nonLinearAdSlotHeight = d, b.forceNonLinearFullSlot = !0;219try { this.adRequested = !0, this.adLoader.requestAds(b) }220catch (a) { this.onContentResumeRequested() }221}222}, b.prototype.preloadAd = function() {}, b.prototype.destroyAd = function() {}, b.prototype.hideAd = function() {}, b.prototype.onAdManagerLoader = function(a) {223var b = this,224c = new google.ima.AdsRenderingSettings;225c.restoreCustomPlaybackStateOnAdBreakComplete = !0;226var d = a.getAdsManager(this.gameContent, c);227this.adsManager = d, d.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED, this.onContentPauseRequested, !1, this), d.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED, this.onContentResumeRequested, !1, this), d.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, this.onAdError, !1, this), [google.ima.AdEvent.Type.ALL_ADS_COMPLETED, google.ima.AdEvent.Type.CLICK, google.ima.AdEvent.Type.COMPLETE, google.ima.AdEvent.Type.FIRST_QUARTILE, google.ima.AdEvent.Type.LOADED, google.ima.AdEvent.Type.MIDPOINT, google.ima.AdEvent.Type.PAUSED, google.ima.AdEvent.Type.STARTED, google.ima.AdEvent.Type.THIRD_QUARTILE].forEach(function(a) { d.addEventListener(a, b.onAdEvent, !1, b) });228try {229this.adContent.style.display = "block";230var e = window.innerWidth,231f = window.innerHeight;232this.adsManager.init(e, f, google.ima.ViewMode.NORMAL), this.adsManager.start(), this.resizeListener = function() { null !== b.adsManager && b.adsManager.resize(window.innerWidth, window.innerHeight, google.ima.ViewMode.NORMAL) }, window.addEventListener("resize", this.resizeListener)233}234catch (a) { this.onAdError(a) }235}, b.prototype.onAdEvent = function(b) {236switch (b.type) {237case google.ima.AdEvent.Type.CLICK:238this.adManager.onAdClicked.dispatch();239break;240case google.ima.AdEvent.Type.LOADED:241this.adRequested = !1;242var c = b.getAd();243c.isLinear() || this.onContentResumeRequested();244break;245case google.ima.AdEvent.Type.STARTED:246this.adManager.onAdProgression.dispatch(a.AdEvent.start);247break;248case google.ima.AdEvent.Type.FIRST_QUARTILE:249this.adManager.onAdProgression.dispatch(a.AdEvent.firstQuartile);250break;251case google.ima.AdEvent.Type.MIDPOINT:252this.adManager.onAdProgression.dispatch(a.AdEvent.midPoint);253break;254case google.ima.AdEvent.Type.THIRD_QUARTILE:255this.adManager.onAdProgression.dispatch(a.AdEvent.thirdQuartile);256break;257case google.ima.AdEvent.Type.COMPLETE:258this.adManager.onAdProgression.dispatch(a.AdEvent.complete);259break;260case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:261this.onContentResumeRequested()262}263}, b.prototype.onAdError = function(a) { null !== this.adsManager && (this.adsManager.destroy(), this.adsManager = null, null !== this.resizeListener && (window.removeEventListener("resize", this.resizeListener), this.resizeListener = null)), this.adRequested && (this.adRequested = !1), this.onContentResumeRequested() }, b.prototype.onContentPauseRequested = function() { this.adManager.onContentPaused.dispatch() }, b.prototype.onContentResumeRequested = function() { return "undefined" == typeof google ? (this.adManager.unMuteAfterAd(), void this.adManager.onContentResumed.dispatch()) : (this.adContent.style.display = "none", this.adManager.unMuteAfterAd(), void this.adManager.onContentResumed.dispatch()) }, b.prototype.parseCustomParams = function(a) {264if (void 0 !== a) {265var b = "";266for (var c in a)267if (a.hasOwnProperty(c)) {268b.length > 0 && (b += "&");269var d = Array.isArray(a[c]) ? a[c].join(",") : a[c];270b += c + "=" + d271}272return "&cust_params=" + encodeURIComponent(b)273}274return ""275}, b.prototype.areAdsEnabled = function() {276var a = this,277b = document.createElement("div");278b.innerHTML = " ", b.className = "adsbox", b.style.position = "absolute", b.style.fontSize = "10px", document.body.appendChild(b);279var c = function() { var a = !0; return 0 === b.offsetHeight && (a = !1), b.parentNode.removeChild(b), a };280window.setTimeout(function() { a.adsEnabled = c() }, 100)281}, b282}();283b.Ima3 = c284}(b = a.AdProvider || (a.AdProvider = {}))285}(PhaserAds || (PhaserAds = {}));286287288