@brndts/brndts-ads 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -18615,14 +18615,13 @@ var Reporter = /*#__PURE__*/ function() {
18615
18615
  replaysOnErrorSampleRate: 1
18616
18616
  });
18617
18617
  this.scope = new Scope();
18618
- this.scope.setClient(this.client);
18619
18618
  this.client.init();
18620
18619
  }
18621
18620
  _create_class(Reporter, [
18622
18621
  {
18623
18622
  key: "capture",
18624
18623
  value: function capture(error) {
18625
- return this.scope.captureException(error);
18624
+ return this.client.captureException(error, {}, this.scope);
18626
18625
  }
18627
18626
  }
18628
18627
  ]);
@@ -18733,6 +18732,36 @@ function _getGeneralInfo() {
18733
18732
  });
18734
18733
  return _getGeneralInfo.apply(this, arguments);
18735
18734
  }
18735
+ // src/Common/utils/Changeable.ts
18736
+ var Changeable = /*#__PURE__*/ function() {
18737
+ "use strict";
18738
+ function Changeable(value2) {
18739
+ _class_call_check(this, Changeable);
18740
+ this.listeners = [];
18741
+ this._value = value2;
18742
+ }
18743
+ _create_class(Changeable, [
18744
+ {
18745
+ key: "value",
18746
+ get: function get() {
18747
+ return this._value;
18748
+ },
18749
+ set: function set(value2) {
18750
+ this._value = value2;
18751
+ for(var index = 0; index < this.listeners.length; index++){
18752
+ this.listeners[index](this._value);
18753
+ }
18754
+ }
18755
+ },
18756
+ {
18757
+ key: "onUpdate",
18758
+ value: function onUpdate(listener3) {
18759
+ this.listeners.push(listener3);
18760
+ }
18761
+ }
18762
+ ]);
18763
+ return Changeable;
18764
+ }();
18736
18765
  // src/Common/utils/is.ts
18737
18766
  var getConstructor = function(input) {
18738
18767
  return input !== null && typeof input !== "undefined" ? input.constructor : null;
@@ -18865,7 +18894,7 @@ var defaults = {
18865
18894
  host: "http://localhost:8001"
18866
18895
  },
18867
18896
  controls: {
18868
- default: "none"
18897
+ default: "brndts_fs"
18869
18898
  },
18870
18899
  playback: {},
18871
18900
  volume: {
@@ -18875,8 +18904,8 @@ var defaults = {
18875
18904
  enabled: true,
18876
18905
  useLocalCache: false,
18877
18906
  presentation: {
18878
- duration: 5,
18879
- cooldown: 60
18907
+ duration: 2,
18908
+ cooldown: 10
18880
18909
  },
18881
18910
  regions: {
18882
18911
  useCache: true,
@@ -19085,7 +19114,7 @@ var Logger = /*#__PURE__*/ function() {
19085
19114
  {
19086
19115
  key: "error",
19087
19116
  get: function get() {
19088
- return this.enabled ? Function.prototype.bind.call(console.error, console) : noop;
19117
+ return Function.prototype.bind.call(console.error, console);
19089
19118
  }
19090
19119
  }
19091
19120
  ]);
@@ -19125,7 +19154,7 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
19125
19154
  var nextFrameInfo;
19126
19155
  var missingIntervals = {};
19127
19156
  if (this.timestampList.length === 0) {
19128
- missingIntervals[0] = {
19157
+ missingIntervals["0"] = {
19129
19158
  timestamp_start: 0,
19130
19159
  timestamp_end: this.totalLengthSeconds
19131
19160
  };
@@ -19196,9 +19225,6 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
19196
19225
  {
19197
19226
  key: "isValidRegionForTimestamp",
19198
19227
  value: function isValidRegionForTimestamp(region, timestamp) {
19199
- if (!region) {
19200
- return false;
19201
- }
19202
19228
  if (region.timestamp_start < timestamp && region.timestamp_end > timestamp) {
19203
19229
  return true;
19204
19230
  }
@@ -19237,14 +19263,6 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
19237
19263
  right = mid - 1;
19238
19264
  }
19239
19265
  }
19240
- leftInterval = this.frameInfo[this.timestampList[left]];
19241
- rightInterval = this.frameInfo[this.timestampList[right]];
19242
- if (this.isValidRegionForTimestamp(leftInterval, target)) {
19243
- return leftInterval;
19244
- }
19245
- if (this.isValidRegionForTimestamp(rightInterval, target)) {
19246
- return rightInterval;
19247
- }
19248
19266
  return null;
19249
19267
  }
19250
19268
  },
@@ -19389,7 +19407,11 @@ var VideoRegionsDataManager = /*#__PURE__*/ function() {
19389
19407
  },
19390
19408
  {
19391
19409
  key: "destroy",
19392
- value: function destroy() {}
19410
+ value: function destroy() {
19411
+ this.service.removeListener("result", this.handlePredictionResult);
19412
+ this.service.removeListener("completed", this.handlePredictionConpleted);
19413
+ this.service.removeListener("aborted", this.handlePredictionAborted);
19414
+ }
19393
19415
  }
19394
19416
  ]);
19395
19417
  return VideoRegionsDataManager;
@@ -19579,6 +19601,7 @@ var RegionBox = /*#__PURE__*/ function() {
19579
19601
  var Region = /*#__PURE__*/ function() {
19580
19602
  "use strict";
19581
19603
  function Region(id, regionDescriptor, planeDescriptor, deps) {
19604
+ var _this = this;
19582
19605
  _class_call_check(this, Region);
19583
19606
  this.visible = false;
19584
19607
  this.id = id;
@@ -19604,6 +19627,16 @@ var Region = /*#__PURE__*/ function() {
19604
19627
  this.container.addEventListener("click", this.handleClick);
19605
19628
  this.container.addEventListener("mouseenter", this.handleMouseEnter);
19606
19629
  this.container.addEventListener("mouseleave", this.handleMouseLeave);
19630
+ if (this.deps.provider) {
19631
+ this.deps.provider.onRefreshContents(function(contents) {
19632
+ var _this_deps_recorder;
19633
+ _this.boxView.innerHTML = "";
19634
+ for(var index = 0; index < contents.length; index++){
19635
+ _this.boxView.appendChild(contents[index]);
19636
+ }
19637
+ (_this_deps_recorder = _this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(_this);
19638
+ });
19639
+ }
19607
19640
  this.render(regionDescriptor.contours, regionDescriptor.box);
19608
19641
  if (this.boxArea > 0) {
19609
19642
  this.requestContent();
@@ -19613,19 +19646,7 @@ var Region = /*#__PURE__*/ function() {
19613
19646
  {
19614
19647
  key: "requestContent",
19615
19648
  value: function requestContent() {
19616
- var _this = this;
19617
- var _this_deps;
19618
- if ((_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : _this_deps.provider) {
19619
- this.deps.provider.onRefreshContents(function(contents) {
19620
- _this.boxView.innerHTML = "";
19621
- for(var index = 0; index < contents.length; index++){
19622
- _this.boxView.appendChild(contents[index]);
19623
- }
19624
- });
19625
- var content = this.deps.provider.contents();
19626
- for(var index = 0; index < content.length; index++){
19627
- this.boxView.appendChild(content[index]);
19628
- }
19649
+ if (this.deps.provider) {
19629
19650
  this.deps.provider.request({
19630
19651
  size: {
19631
19652
  width: this.boxWidth,
@@ -19641,22 +19662,22 @@ var Region = /*#__PURE__*/ function() {
19641
19662
  {
19642
19663
  key: "handleClick",
19643
19664
  value: function handleClick() {
19644
- var _this_deps_recorder, _this_deps;
19645
- this.isPresented && ((_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : (_this_deps_recorder = _this_deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseClick(this));
19665
+ var _this_deps_recorder;
19666
+ this.isPresented && ((_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseClick(this));
19646
19667
  }
19647
19668
  },
19648
19669
  {
19649
19670
  key: "handleMouseEnter",
19650
19671
  value: function handleMouseEnter() {
19651
- var _this_deps_recorder, _this_deps;
19652
- this.isPresented && ((_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : (_this_deps_recorder = _this_deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseEnter(this));
19672
+ var _this_deps_recorder;
19673
+ this.isPresented && ((_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseEnter(this));
19653
19674
  }
19654
19675
  },
19655
19676
  {
19656
19677
  key: "handleMouseLeave",
19657
19678
  value: function handleMouseLeave() {
19658
- var _this_deps_recorder, _this_deps;
19659
- this.isPresented && ((_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : (_this_deps_recorder = _this_deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseLeave(this));
19679
+ var _this_deps_recorder;
19680
+ this.isPresented && ((_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseLeave(this));
19660
19681
  }
19661
19682
  },
19662
19683
  {
@@ -19756,20 +19777,26 @@ var Region = /*#__PURE__*/ function() {
19756
19777
  return this.visible;
19757
19778
  }
19758
19779
  },
19780
+ {
19781
+ key: "hasContent",
19782
+ get: function get() {
19783
+ return this.boxView.children.length > 0;
19784
+ }
19785
+ },
19759
19786
  {
19760
19787
  key: "updateVisibility",
19761
19788
  value: function updateVisibility(value2) {
19762
- var _this_deps_recorder, _this_deps;
19789
+ var _this_deps_recorder;
19763
19790
  this.visible = value2;
19764
- (_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : (_this_deps_recorder = _this_deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.displayStateChanged(this);
19791
+ (_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.displayStateChanged(this);
19765
19792
  }
19766
19793
  },
19767
19794
  {
19768
19795
  key: "render",
19769
19796
  value: function render(contours, box) {
19770
19797
  var _this = this;
19771
- var _this_deps_recorder, _this_deps;
19772
- this.contours = contours || [];
19798
+ var _this_deps_recorder;
19799
+ this.contours = contours;
19773
19800
  var newBox = new RegionBox(box);
19774
19801
  if (!this.box.isEqual(newBox.coords) && newBox.area(this.plane.size) > 0) {
19775
19802
  this.box = newBox;
@@ -19783,7 +19810,6 @@ var Region = /*#__PURE__*/ function() {
19783
19810
  this.boxView.style.width = "".concat(Math.floor(this.boxWidth), "px");
19784
19811
  this.boxView.style.height = "".concat(Math.floor(this.boxHeight), "px");
19785
19812
  if (this.maskLayer) {
19786
- var _this_maskLayer;
19787
19813
  this.maskLayer.width = this.boxWidth;
19788
19814
  this.maskLayer.style.width = "".concat(this.boxWidth, "px");
19789
19815
  this.maskLayer.height = this.boxHeight;
@@ -19811,12 +19837,12 @@ var Region = /*#__PURE__*/ function() {
19811
19837
  ctx.fillStyle = "black";
19812
19838
  ctx.fill();
19813
19839
  }
19814
- var maskUrl = "url(" + ((_this_maskLayer = this.maskLayer) === null || _this_maskLayer === void 0 ? void 0 : _this_maskLayer.toDataURL()) + ")";
19840
+ var maskUrl = "url(" + this.maskLayer.toDataURL() + ")";
19815
19841
  if (this.boxView) {
19816
19842
  this.boxView.style.maskImage = maskUrl;
19817
19843
  }
19818
19844
  }
19819
- (_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : (_this_deps_recorder = _this_deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this);
19845
+ (_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this);
19820
19846
  }
19821
19847
  },
19822
19848
  {
@@ -20370,7 +20396,7 @@ var ContentProvider = /*#__PURE__*/ function() {
20370
20396
  ]);
20371
20397
  return ContentProvider;
20372
20398
  }();
20373
- // src/Ads/Providers/AdsTerraProvider.ts
20399
+ // src/Ads/Providers/AdsTerra/AdsTerraProvider.ts
20374
20400
  var ADSTERRA_BANNER_KEY = "f5024dbe632a4ccafec26462f39acaf8";
20375
20401
  var AdsTerraProvider = /*#__PURE__*/ function(ContentProvider) {
20376
20402
  "use strict";
@@ -20390,7 +20416,7 @@ var AdsTerraProvider = /*#__PURE__*/ function(ContentProvider) {
20390
20416
  var conf = document.createElement("script");
20391
20417
  var script = document.createElement("script");
20392
20418
  script.type = "text/javascript";
20393
- script.src = "//www.highperformancedformats.com/".concat(atOptions.key, "/invoke.js");
20419
+ script.src = "http://www.highperformancedformats.com/".concat(atOptions.key, "/invoke.js");
20394
20420
  conf.innerHTML = "atOptions = ".concat(JSON.stringify(atOptions));
20395
20421
  _this.content.push(conf);
20396
20422
  _this.content.push(script);
@@ -20458,7 +20484,7 @@ var BRNDTSDefaultProvider = /*#__PURE__*/ function(ContentProvider) {
20458
20484
  ]);
20459
20485
  return BRNDTSDefaultProvider;
20460
20486
  }(ContentProvider);
20461
- // src/Ads/Providers/KevelProvider.ts
20487
+ // src/Ads/Providers/Kevel/KevelSDK.ts
20462
20488
  var KevelSDK = /*#__PURE__*/ function() {
20463
20489
  "use strict";
20464
20490
  function KevelSDK(networkId, siteId) {
@@ -20512,6 +20538,7 @@ var KevelSDK = /*#__PURE__*/ function() {
20512
20538
  ]);
20513
20539
  return KevelSDK;
20514
20540
  }();
20541
+ // src/Ads/Providers/Kevel/KevelProvider.ts
20515
20542
  var KevelProvider = /*#__PURE__*/ function(ContentProvider) {
20516
20543
  "use strict";
20517
20544
  _inherits(KevelProvider, ContentProvider);
@@ -20581,6 +20608,32 @@ var KevelProvider = /*#__PURE__*/ function(ContentProvider) {
20581
20608
  return KevelProvider;
20582
20609
  }(ContentProvider);
20583
20610
  // src/Ads/Providers/SmartyAds/SmartyAdsSDK.ts
20611
+ import { TCModel, TCString, GVL } from "@iabtcf/core";
20612
+ GVL.baseUrl = "https://vendor-list.consensu.org/v3/";
20613
+ var PARAMS = [
20614
+ "res",
20615
+ "m",
20616
+ "ua",
20617
+ "ip",
20618
+ "w",
20619
+ "h",
20620
+ "gdpr",
20621
+ "gdpr_consent",
20622
+ "gpp",
20623
+ "gpp_sid",
20624
+ "coppa",
20625
+ "page",
20626
+ "domain",
20627
+ "secure",
20628
+ "lmt",
20629
+ "dnt",
20630
+ "ad_width",
20631
+ "ad_height",
20632
+ "language",
20633
+ "cattax",
20634
+ "keywords",
20635
+ "placementId"
20636
+ ];
20584
20637
  var SmartyadsSDK = /*#__PURE__*/ function() {
20585
20638
  "use strict";
20586
20639
  function SmartyadsSDK() {
@@ -20588,45 +20641,119 @@ var SmartyadsSDK = /*#__PURE__*/ function() {
20588
20641
  }
20589
20642
  _create_class(SmartyadsSDK, [
20590
20643
  {
20591
- /**
20644
+ key: "generateTCString",
20645
+ value: function generateTCString() {
20646
+ var _this = this;
20647
+ return _async_to_generator(function() {
20648
+ var tcModel;
20649
+ return _ts_generator(this, function(_state) {
20650
+ switch(_state.label){
20651
+ case 0:
20652
+ if (!!_this.gdprConsent) return [
20653
+ 3,
20654
+ 2
20655
+ ];
20656
+ tcModel = new TCModel(new GVL());
20657
+ tcModel.vendorConsents.set(534);
20658
+ return [
20659
+ 4,
20660
+ tcModel.gvl.readyPromise
20661
+ ];
20662
+ case 1:
20663
+ _state.sent();
20664
+ _this.gdprConsent = TCString.encode(tcModel);
20665
+ console.log(_this.gdprConsent);
20666
+ _state.label = 2;
20667
+ case 2:
20668
+ return [
20669
+ 2,
20670
+ _this.gdprConsent
20671
+ ];
20672
+ }
20673
+ });
20674
+ })();
20675
+ }
20676
+ },
20677
+ {
20678
+ key: "buildQueryParams",
20679
+ value: /**
20592
20680
  * Converts an object into a URL query string.
20593
20681
  *
20594
20682
  * @param params - The object to be converted into query parameters.
20595
20683
  * @returns The query string with URL encoding.
20596
- */ key: "buildQueryParams",
20597
- value: function buildQueryParams(params) {
20598
- var queryKeys = Object.keys(params);
20599
- var queryString = queryKeys.map(function(key) {
20600
- var value2 = params[key];
20601
- if (value2 === null || value2 === void 0) {
20602
- return "";
20603
- }
20604
- if (Array.isArray(value2)) {
20605
- return value2.map(function(item) {
20606
- return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(item));
20607
- }).join("&");
20608
- }
20609
- return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value2));
20610
- }).filter(function(part) {
20611
- return part.length > 0;
20612
- }).join("&");
20613
- return queryString;
20684
+ */ function buildQueryParams(params) {
20685
+ var _this = this;
20686
+ return _async_to_generator(function() {
20687
+ var queryString;
20688
+ return _ts_generator(this, function(_state) {
20689
+ switch(_state.label){
20690
+ case 0:
20691
+ if (!(params.gdpr === void 0)) return [
20692
+ 3,
20693
+ 2
20694
+ ];
20695
+ params.gdpr = 1;
20696
+ return [
20697
+ 4,
20698
+ _this.generateTCString()
20699
+ ];
20700
+ case 1:
20701
+ params.gdpr_consent = _state.sent();
20702
+ _state.label = 2;
20703
+ case 2:
20704
+ queryString = PARAMS.map(function(key) {
20705
+ var value2 = params[key];
20706
+ if (value2 === null || value2 === void 0) {
20707
+ return "";
20708
+ }
20709
+ return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value2));
20710
+ }).filter(function(part) {
20711
+ return part.length > 0;
20712
+ }).join("&");
20713
+ return [
20714
+ 2,
20715
+ queryString
20716
+ ];
20717
+ }
20718
+ });
20719
+ })();
20614
20720
  }
20615
20721
  },
20616
20722
  {
20617
20723
  key: "request",
20618
20724
  value: function request(params) {
20619
- var url2 = "https://n1.smartyads.com/?c=b&".concat(this.buildQueryParams(params));
20620
- return fetch("https://n1.smartyads.com/?c=b&".concat(this.buildQueryParams(params))).then(function(response) {
20621
- if (!response.ok) {
20622
- throw new InternalError("Network response was not ok");
20623
- }
20624
- return response.json();
20625
- }).then(function(data) {
20626
- return data;
20627
- }).catch(function(error) {
20628
- throw error;
20629
- });
20725
+ var _this = this;
20726
+ return _async_to_generator(function() {
20727
+ var _, _1;
20728
+ return _ts_generator(this, function(_state) {
20729
+ switch(_state.label){
20730
+ case 0:
20731
+ _1 = (_ = "https://n1.smartyads.com/?c=b&").concat;
20732
+ return [
20733
+ 4,
20734
+ _this.buildQueryParams(params)
20735
+ ];
20736
+ case 1:
20737
+ return [
20738
+ 2,
20739
+ fetch.apply(void 0, [
20740
+ _1.apply(_, [
20741
+ _state.sent()
20742
+ ])
20743
+ ]).then(function(response) {
20744
+ if (!response.ok) {
20745
+ throw new InternalError("Network response was not ok");
20746
+ }
20747
+ return response.json();
20748
+ }).then(function(data) {
20749
+ return data;
20750
+ }).catch(function(error) {
20751
+ throw error;
20752
+ })
20753
+ ];
20754
+ }
20755
+ });
20756
+ })();
20630
20757
  }
20631
20758
  }
20632
20759
  ]);
@@ -20641,7 +20768,7 @@ var SmartyadsProvider = /*#__PURE__*/ function(ContentProvider) {
20641
20768
  _class_call_check(this, SmartyadsProvider);
20642
20769
  var _this;
20643
20770
  _this = _super.call(this, context, options);
20644
- _this.placements = options.placements;
20771
+ _this.placements = options.placements || {};
20645
20772
  _this.smartyads = new SmartyadsSDK();
20646
20773
  return _this;
20647
20774
  }
@@ -20650,13 +20777,21 @@ var SmartyadsProvider = /*#__PURE__*/ function(ContentProvider) {
20650
20777
  key: "getPlacement",
20651
20778
  value: function getPlacement(regionId) {
20652
20779
  var availablePlacements = Object.keys(this.placements).map(parseInt);
20653
- if (!availablePlacements) {
20780
+ if (!availablePlacements.length) {
20654
20781
  throw new Error("No available placements!");
20655
20782
  }
20783
+ var foundPlacement;
20656
20784
  if (!regionId) {
20657
- return this.placements[availablePlacements[0]];
20785
+ foundPlacement = this.placements[availablePlacements[0]];
20786
+ } else {
20787
+ foundPlacement = this.placements[regionId];
20658
20788
  }
20659
- return this.placements[regionId];
20789
+ if (typeof foundPlacement === "number") {
20790
+ return {
20791
+ id: foundPlacement
20792
+ };
20793
+ }
20794
+ return foundPlacement;
20660
20795
  }
20661
20796
  },
20662
20797
  {
@@ -20664,18 +20799,19 @@ var SmartyadsProvider = /*#__PURE__*/ function(ContentProvider) {
20664
20799
  value: function request(params) {
20665
20800
  var _this = this;
20666
20801
  return _async_to_generator(function() {
20667
- var _params_params, smartyadsContent, div, index;
20802
+ var _params_params, placementInfo, smartyadsContent, div, index;
20668
20803
  return _ts_generator(this, function(_state) {
20669
20804
  switch(_state.label){
20670
20805
  case 0:
20671
20806
  if (!params || params.size.width === void 0 || params.size.width === 0 || params.size.height === void 0 || params.size.height === 0) {
20672
20807
  throw new InternalError("No Params!");
20673
20808
  }
20809
+ placementInfo = _this.getPlacement((_params_params = params.params) === null || _params_params === void 0 ? void 0 : _params_params.regionId);
20674
20810
  return [
20675
20811
  4,
20676
20812
  _this.smartyads.request(_object_spread_props(_object_spread({}, _this.options), {
20677
- ad_width: params.size.width,
20678
- ad_height: params.size.height,
20813
+ ad_width: placementInfo.w || params.size.width,
20814
+ ad_height: placementInfo.h || params.size.height,
20679
20815
  m: "api",
20680
20816
  ua: _this.context.info.ua || navigator.userAgent,
20681
20817
  w: window.innerWidth,
@@ -20683,7 +20819,7 @@ var SmartyadsProvider = /*#__PURE__*/ function(ContentProvider) {
20683
20819
  domain: _this.context.info.domain || window.location.hostname,
20684
20820
  page: window.location.href,
20685
20821
  ip: _this.context.info.ip,
20686
- placementId: _this.getPlacement((_params_params = params.params) === null || _params_params === void 0 ? void 0 : _params_params.regionId)
20822
+ placementId: placementInfo.id
20687
20823
  }))
20688
20824
  ];
20689
20825
  case 1:
@@ -20746,6 +20882,147 @@ var StaticImageProvider = /*#__PURE__*/ function(ContentProvider) {
20746
20882
  ]);
20747
20883
  return StaticImageProvider;
20748
20884
  }(ContentProvider);
20885
+ // src/Ads/Providers/Prebidjs/PrebidjsProvider.ts
20886
+ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider) {
20887
+ "use strict";
20888
+ _inherits(PrebidjsProvider, ContentProvider);
20889
+ var _super = _create_super(PrebidjsProvider);
20890
+ function PrebidjsProvider(context, options) {
20891
+ _class_call_check(this, PrebidjsProvider);
20892
+ var _this;
20893
+ _this = _super.call(this, context, options);
20894
+ _this.ready = false;
20895
+ _this.processBids = _this.processBids.bind(_assert_this_initialized(_this));
20896
+ _this.loadPrebidJS().then(function() {
20897
+ _this.configurePrebidJS();
20898
+ _this.defineAdUnits();
20899
+ });
20900
+ return _this;
20901
+ }
20902
+ _create_class(PrebidjsProvider, [
20903
+ {
20904
+ key: "loadPrebidJS",
20905
+ value: function loadPrebidJS() {
20906
+ var _this = this;
20907
+ return new Promise(function(resolve, reject) {
20908
+ if (window.pbjs) {
20909
+ _this.ready = true;
20910
+ _this.prebidjs = window.pbjs;
20911
+ _this.context.logger.log("Prebid.js already loaded!");
20912
+ resolve();
20913
+ return;
20914
+ }
20915
+ var script = document.createElement("script");
20916
+ script.src = "https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js";
20917
+ script.onload = function() {
20918
+ _this.ready = true;
20919
+ _this.prebidjs = window.pbjs;
20920
+ _this.context.logger.log("Prebid.js loaded!");
20921
+ resolve();
20922
+ };
20923
+ script.onerror = function() {
20924
+ reject(new Error("Failed to load Prebid.js"));
20925
+ };
20926
+ document.head.appendChild(script);
20927
+ });
20928
+ }
20929
+ },
20930
+ {
20931
+ key: "configurePrebidJS",
20932
+ value: function configurePrebidJS() {
20933
+ var _this = this;
20934
+ if (!this.prebidjs) {
20935
+ return;
20936
+ }
20937
+ this.prebidjs.que.push(function() {
20938
+ if (_this.prebidjs) {
20939
+ _this.prebidjs.setConfig({
20940
+ debug: true,
20941
+ priceGranularity: "high",
20942
+ enableSendAllBids: true
20943
+ });
20944
+ }
20945
+ });
20946
+ }
20947
+ },
20948
+ {
20949
+ key: "defineAdUnits",
20950
+ value: function defineAdUnits() {
20951
+ var _this = this;
20952
+ if (!this.ready) {
20953
+ throw new Error("Prebid.js is not loaded");
20954
+ }
20955
+ if (!this.prebidjs) {
20956
+ return;
20957
+ }
20958
+ this.prebidjs.que.push(function() {
20959
+ if (_this.prebidjs) {
20960
+ _this.prebidjs.addAdUnits(_this.options.units);
20961
+ }
20962
+ });
20963
+ }
20964
+ },
20965
+ {
20966
+ key: "processBid",
20967
+ value: function processBid(bid) {
20968
+ var _iframe_sandbox, _iframe_contentWindow;
20969
+ var iframe = document.createElement("iframe");
20970
+ iframe.name = "prebid_ads_iframe_".concat(bid.adUnitCode);
20971
+ iframe.title = "3rd party ad content";
20972
+ (_iframe_sandbox = iframe.sandbox) === null || _iframe_sandbox === void 0 ? void 0 : _iframe_sandbox.add("allow-forms", "allow-popups", "allow-popups-to-escape-sandbox", "allow-same-origin", "allow-scripts", "allow-top-navigation-by-user-activation");
20973
+ iframe.setAttribute("aria-label", "Advertisment");
20974
+ iframe.style.setProperty("border", "0");
20975
+ iframe.style.setProperty("margin", "0");
20976
+ iframe.style.setProperty("overflow", "hidden");
20977
+ var iframeDoc = (_iframe_contentWindow = iframe.contentWindow) === null || _iframe_contentWindow === void 0 ? void 0 : _iframe_contentWindow.document;
20978
+ if (!iframeDoc) {
20979
+ return;
20980
+ }
20981
+ if (this.prebidjs) {
20982
+ this.prebidjs.renderAd(iframeDoc, bid.adId);
20983
+ }
20984
+ var normalizeCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */button,hr,input{overflow:visible}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}";
20985
+ var iframeStyle = iframeDoc.createElement("style");
20986
+ iframeStyle.appendChild(iframeDoc.createTextNode(normalizeCss));
20987
+ iframeDoc.head.appendChild(iframeStyle);
20988
+ this.content = [
20989
+ iframe
20990
+ ];
20991
+ this.notify();
20992
+ }
20993
+ },
20994
+ {
20995
+ key: "processBids",
20996
+ value: function processBids(bids, timedOut, auctionId) {
20997
+ var _this_prebidjs;
20998
+ this.context.logger.log("Bids:", bids);
20999
+ var winners = ((_this_prebidjs = this.prebidjs) === null || _this_prebidjs === void 0 ? void 0 : _this_prebidjs.getHighestCpmBids()) || [];
21000
+ for(var i2 = 0; i2 < winners.length; i2++){
21001
+ this.processBid(winners[i2]);
21002
+ }
21003
+ }
21004
+ },
21005
+ {
21006
+ key: "request",
21007
+ value: function request(params) {
21008
+ var _this = this;
21009
+ if (!this.prebidjs) {
21010
+ return Promise.resolve();
21011
+ }
21012
+ this.prebidjs.que.push(function() {
21013
+ if (_this.prebidjs) {
21014
+ _this.prebidjs.requestBids({
21015
+ timeout: 1e3,
21016
+ bidsBackHandler: _this.processBids
21017
+ });
21018
+ }
21019
+ });
21020
+ return Promise.resolve();
21021
+ }
21022
+ }
21023
+ ]);
21024
+ return PrebidjsProvider;
21025
+ }(ContentProvider);
20749
21026
  // src/Ads/Providers/ProviderFactory.ts
20750
21027
  var ContentProviderFactory = /*#__PURE__*/ function() {
20751
21028
  "use strict";
@@ -20771,8 +21048,11 @@ var ContentProviderFactory = /*#__PURE__*/ function() {
20771
21048
  if (options.params.code === "smartyads") {
20772
21049
  return new SmartyadsProvider(context, options.params);
20773
21050
  }
21051
+ if (options.params.code === "prebid") {
21052
+ return new PrebidjsProvider(context, options.params);
21053
+ }
20774
21054
  }
20775
- throw new InternalError("No provider found for type");
21055
+ throw new InternalError("No provider found for type: ".concat(options.type));
20776
21056
  }
20777
21057
  }
20778
21058
  ]);
@@ -20881,16 +21161,29 @@ var Ads = /*#__PURE__*/ function() {
20881
21161
  key: "mediaIsReady",
20882
21162
  value: function mediaIsReady() {
20883
21163
  this.videoRegions.fetch();
21164
+ console.log("media is ready");
20884
21165
  if (this.regionsRenderer) {
20885
21166
  return;
20886
21167
  }
20887
- this.regionsRenderer = new RegionRenderer(this.context.media.viewWidth, this.context.media.viewHeight, {
20888
- debug: this.context.config.get("debug"),
20889
- recorder: this.context.recorder,
20890
- provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
20891
- });
21168
+ console.log("creating regions renderer");
21169
+ try {
21170
+ this.regionsRenderer = new RegionRenderer(this.context.media.viewWidth, this.context.media.viewHeight, {
21171
+ debug: this.context.config.get("debug"),
21172
+ recorder: this.context.recorder,
21173
+ provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
21174
+ });
21175
+ } catch (e2) {
21176
+ if (_instanceof(e2, Error)) {
21177
+ var error = new InternalError(e2.message);
21178
+ error.stack = e2.stack;
21179
+ this.context.logger.error(e2);
21180
+ ErrorHandler.handle(error);
21181
+ }
21182
+ }
21183
+ console.log("attaching regions renderer", this.context.elements.container);
20892
21184
  if (this.context.elements.container) {
20893
- this.regionsRenderer.attach(this.context.elements.container);
21185
+ var _this_regionsRenderer;
21186
+ (_this_regionsRenderer = this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.attach(this.context.elements.container);
20894
21187
  }
20895
21188
  }
20896
21189
  },
@@ -20898,6 +21191,7 @@ var Ads = /*#__PURE__*/ function() {
20898
21191
  key: "handleState",
20899
21192
  value: function handleState() {
20900
21193
  var state = this.context.store.getState();
21194
+ console.log("state", state);
20901
21195
  if (state.ready) {
20902
21196
  this.mediaIsReady();
20903
21197
  }
@@ -20953,6 +21247,7 @@ var Ads = /*#__PURE__*/ function() {
20953
21247
  (_this_context_media = this.context.media) === null || _this_context_media === void 0 ? void 0 : _this_context_media.on("SEEKED", function() {
20954
21248
  _this.videoRegions.seek(_this.context.media.currentTime);
20955
21249
  });
21250
+ console.log("ads started");
20956
21251
  this.handleState();
20957
21252
  }
20958
21253
  },
@@ -24485,6 +24780,7 @@ var ImpressionModel = /*#__PURE__*/ function() {
24485
24780
  _class_call_check(this, ImpressionModel);
24486
24781
  this.service = service;
24487
24782
  this.currentImpression = {
24783
+ datetime: /* @__PURE__ */ new Date().toISOString(),
24488
24784
  type: "impression",
24489
24785
  session: sessionInfo,
24490
24786
  video: video,
@@ -24499,11 +24795,10 @@ var ImpressionModel = /*#__PURE__*/ function() {
24499
24795
  value: function insertNewHit(newHit) {
24500
24796
  var _this = this;
24501
24797
  return _async_to_generator(function() {
24502
- var _this_currentImpression_extra, result;
24798
+ var result;
24503
24799
  return _ts_generator(this, function(_state) {
24504
24800
  if (_this.currentImpression.type === "impression") {
24505
- ;
24506
- (_this_currentImpression_extra = _this.currentImpression.extra) === null || _this_currentImpression_extra === void 0 ? void 0 : _this_currentImpression_extra.hits.push(newHit);
24801
+ _this.currentImpression.extra.hits.push(newHit);
24507
24802
  if (!_this.currentImpression.id) {
24508
24803
  if (_this.currentImpression.video) {
24509
24804
  _this.currentImpression.video.ts = newHit.start;
@@ -24525,41 +24820,59 @@ var ImpressionModel = /*#__PURE__*/ function() {
24525
24820
  })();
24526
24821
  }
24527
24822
  },
24823
+ {
24824
+ key: "startNewImpressionHit",
24825
+ value: function startNewImpressionHit(region, ts) {
24826
+ this.inProgressHit = {
24827
+ ts_start: ts,
24828
+ dt_start: /* @__PURE__ */ new Date(),
24829
+ totalDisplayingTime: 0,
24830
+ area: region.polygonArea
24831
+ };
24832
+ if (region.isVisible) {
24833
+ this.inProgressHit.displayingStart = this.inProgressHit.dt_start;
24834
+ }
24835
+ }
24836
+ },
24837
+ {
24838
+ key: "finishInProgressHit",
24839
+ value: function finishInProgressHit(ts) {
24840
+ if (!this.inProgressHit) {
24841
+ return;
24842
+ }
24843
+ this.inProgressHit.ts_end = ts;
24844
+ this.inProgressHit.dt_end = /* @__PURE__ */ new Date();
24845
+ if (this.inProgressHit.displayingStart !== void 0) {
24846
+ this.inProgressHit.displayingEnd = /* @__PURE__ */ new Date();
24847
+ this.inProgressHit.totalDisplayingTime += (this.inProgressHit.displayingEnd.getTime() - this.inProgressHit.displayingStart.getTime()) / 1e3;
24848
+ this.inProgressHit.displayingStart = void 0;
24849
+ this.inProgressHit.displayingEnd = void 0;
24850
+ }
24851
+ var inProgress = this.inProgressHit;
24852
+ var presentationTime = // @ts-expect-error
24853
+ (inProgress.dt_end.getTime() - inProgress.dt_start.getTime()) / 1e3;
24854
+ this.inProgressHit = void 0;
24855
+ this.insertNewHit({
24856
+ presentation_time: presentationTime,
24857
+ display_time: inProgress.totalDisplayingTime,
24858
+ start: inProgress.ts_start,
24859
+ // @ts-expect-error
24860
+ end: inProgress.ts_end,
24861
+ area: inProgress.area || 0
24862
+ });
24863
+ }
24864
+ },
24528
24865
  {
24529
24866
  key: "presentationChanged",
24530
24867
  value: function presentationChanged(region, ts) {
24531
- if (region.isPresented && this.inProgressHit) {
24532
- return;
24533
- } else if (region.isPresented && !this.inProgressHit) {
24534
- this.inProgressHit = {
24535
- ts_start: ts,
24536
- dt_start: /* @__PURE__ */ new Date(),
24537
- totalDisplayingTime: 0,
24538
- area: region.polygonArea
24539
- };
24540
- if (region.isVisible) {
24541
- this.inProgressHit.displayingStart = this.inProgressHit.dt_start;
24868
+ if (!this.inProgressHit) {
24869
+ if (region.isPresented && region.hasContent) {
24870
+ this.startNewImpressionHit(region, ts);
24542
24871
  }
24543
- } else if (!region.isPresented && this.inProgressHit) {
24544
- var _inProgress_dt_end;
24545
- this.inProgressHit.ts_end = ts;
24546
- this.inProgressHit.dt_end = /* @__PURE__ */ new Date();
24547
- if (this.inProgressHit.displayingStart !== void 0) {
24548
- this.inProgressHit.displayingEnd = /* @__PURE__ */ new Date();
24549
- this.inProgressHit.totalDisplayingTime += (this.inProgressHit.displayingEnd.getTime() - this.inProgressHit.displayingStart.getTime()) / 1e3;
24550
- this.inProgressHit.displayingStart = void 0;
24551
- this.inProgressHit.displayingEnd = void 0;
24872
+ } else {
24873
+ if (!region.isPresented || !region.hasContent) {
24874
+ this.finishInProgressHit(ts);
24552
24875
  }
24553
- var inProgress = this.inProgressHit;
24554
- var presentationTime = ((((_inProgress_dt_end = inProgress.dt_end) === null || _inProgress_dt_end === void 0 ? void 0 : _inProgress_dt_end.getTime()) || 0) - inProgress.dt_start.getTime()) / 1e3;
24555
- this.inProgressHit = void 0;
24556
- this.insertNewHit({
24557
- presentation_time: presentationTime,
24558
- display_time: inProgress.totalDisplayingTime,
24559
- start: inProgress.ts_start,
24560
- end: inProgress.ts_end || inProgress.ts_start,
24561
- area: inProgress.area || 0
24562
- });
24563
24876
  }
24564
24877
  }
24565
24878
  },
@@ -24585,7 +24898,6 @@ var ImpressionModel = /*#__PURE__*/ function() {
24585
24898
  key: "destroy",
24586
24899
  value: function destroy() {
24587
24900
  if (this.inProgressHit) {
24588
- var _inProgress_dt_end;
24589
24901
  this.inProgressHit.dt_end = /* @__PURE__ */ new Date();
24590
24902
  if (this.inProgressHit.displayingStart !== void 0) {
24591
24903
  this.inProgressHit.displayingEnd = /* @__PURE__ */ new Date();
@@ -24594,7 +24906,8 @@ var ImpressionModel = /*#__PURE__*/ function() {
24594
24906
  this.inProgressHit.displayingEnd = void 0;
24595
24907
  }
24596
24908
  var inProgress = this.inProgressHit;
24597
- var presentationTime = ((((_inProgress_dt_end = inProgress.dt_end) === null || _inProgress_dt_end === void 0 ? void 0 : _inProgress_dt_end.getTime()) || 0) - inProgress.dt_start.getTime()) / 1e3;
24909
+ var presentationTime = // @ts-expect-error
24910
+ (inProgress.dt_end.getTime() - inProgress.dt_start.getTime()) / 1e3;
24598
24911
  this.inProgressHit = void 0;
24599
24912
  this.insertNewHit({
24600
24913
  presentation_time: presentationTime,
@@ -28638,35 +28951,6 @@ Object.assign(lookup2, {
28638
28951
  connect: lookup2
28639
28952
  });
28640
28953
  // src/BRNDTSService.ts
28641
- var Changeable = /*#__PURE__*/ function() {
28642
- "use strict";
28643
- function Changeable(value2) {
28644
- _class_call_check(this, Changeable);
28645
- this.listeners = [];
28646
- this._value = value2;
28647
- }
28648
- _create_class(Changeable, [
28649
- {
28650
- key: "value",
28651
- get: function get() {
28652
- return this._value;
28653
- },
28654
- set: function set(value2) {
28655
- this._value = value2;
28656
- for(var index = 0; index < this.listeners.length; index++){
28657
- this.listeners[index](this._value);
28658
- }
28659
- }
28660
- },
28661
- {
28662
- key: "onUpdate",
28663
- value: function onUpdate(listener3) {
28664
- this.listeners.push(listener3);
28665
- }
28666
- }
28667
- ]);
28668
- return Changeable;
28669
- }();
28670
28954
  var BRNDTSService = /*#__PURE__*/ function(_import_events4_default) {
28671
28955
  "use strict";
28672
28956
  _inherits(BRNDTSService, _import_events4_default);
@@ -28734,8 +29018,7 @@ var BRNDTSService = /*#__PURE__*/ function(_import_events4_default) {
28734
29018
  payload[_key - 1] = arguments[_key];
28735
29019
  }
28736
29020
  var _this_socket;
28737
- var _this_socket1;
28738
- return (_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : (_this_socket = _this_socket1).emit.apply(_this_socket, [
29021
+ return (_this_socket = this.socket).emit.apply(_this_socket, [
28739
29022
  event
28740
29023
  ].concat(_to_consumable_array(payload)));
28741
29024
  }
@@ -28743,16 +29026,14 @@ var BRNDTSService = /*#__PURE__*/ function(_import_events4_default) {
28743
29026
  {
28744
29027
  key: "handle",
28745
29028
  value: function handle(event, handler) {
28746
- var _this_socket;
28747
- return (_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.on(event, handler);
29029
+ return this.socket.on(event, handler);
28748
29030
  }
28749
29031
  },
28750
29032
  {
28751
29033
  key: "destroy",
28752
29034
  value: function destroy() {
28753
- var _this_socket, _this_socket1;
28754
- (_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.emit("stop");
28755
- (_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.close();
29035
+ this.socket.emit("stop");
29036
+ this.socket.close();
28756
29037
  }
28757
29038
  }
28758
29039
  ]);
@@ -29124,6 +29405,7 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
29124
29405
  var container = elements_default.createElement("div", {
29125
29406
  id: id
29126
29407
  });
29408
+ this.context.elements.original = media;
29127
29409
  media = elements_default.replaceElement(container, media);
29128
29410
  var ytPlayer = new window.YT.Player(media, {
29129
29411
  videoId: videoId || void 0,
@@ -29287,13 +29569,13 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
29287
29569
  {
29288
29570
  key: "disableNativeControls",
29289
29571
  value: function disableNativeControls() {
29290
- throw new InternalError("Method not implemented.");
29572
+ this.context.logger.log("Disabling native controls");
29291
29573
  }
29292
29574
  },
29293
29575
  {
29294
29576
  key: "enableNativeControls",
29295
29577
  value: function enableNativeControls() {
29296
- throw new InternalError("Method not implemented.");
29578
+ this.context.logger.log("Enabling native controls");
29297
29579
  }
29298
29580
  },
29299
29581
  {
@@ -29373,6 +29655,85 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
29373
29655
  ]);
29374
29656
  return YoutubeMediaElement;
29375
29657
  }(GenericMediaElement);
29658
+ // src/Common/utils/videoColor.ts
29659
+ function getAverageRGB(imgEl, block) {
29660
+ var blockSize = block;
29661
+ var defaultRGB = {
29662
+ r: 0,
29663
+ g: 0,
29664
+ b: 0
29665
+ };
29666
+ var canvas = document.createElement("canvas");
29667
+ var context = canvas.getContext && canvas.getContext("2d");
29668
+ var data;
29669
+ var width;
29670
+ var height;
29671
+ var i2 = -4;
29672
+ var length2;
29673
+ var rgb = {
29674
+ r: 0,
29675
+ g: 0,
29676
+ b: 0
29677
+ };
29678
+ var count = 0;
29679
+ if (!block) {
29680
+ blockSize = 5;
29681
+ }
29682
+ if (!context) {
29683
+ return defaultRGB;
29684
+ }
29685
+ height = canvas.height = imgEl.offsetHeight || imgEl.height;
29686
+ width = canvas.width = imgEl.offsetWidth || imgEl.width;
29687
+ context.drawImage(imgEl, 0, 0);
29688
+ try {
29689
+ data = context.getImageData(0, 0, width, height);
29690
+ } catch (e2) {
29691
+ return defaultRGB;
29692
+ }
29693
+ length2 = data.data.length;
29694
+ while((i2 += blockSize * 4) < length2){
29695
+ ++count;
29696
+ rgb.r += data.data[i2];
29697
+ rgb.g += data.data[i2 + 1];
29698
+ rgb.b += data.data[i2 + 2];
29699
+ }
29700
+ rgb.r = ~~(rgb.r / count);
29701
+ rgb.g = ~~(rgb.g / count);
29702
+ rgb.b = ~~(rgb.b / count);
29703
+ return rgb;
29704
+ }
29705
+ function getVideoAverageColor(video) {
29706
+ var defaultRGB = {
29707
+ r: 0,
29708
+ g: 0,
29709
+ b: 0
29710
+ };
29711
+ var canvas = document.createElement("canvas");
29712
+ canvas.width = video.offsetWidth;
29713
+ canvas.height = video.offsetHeight;
29714
+ var context = canvas.getContext("2d");
29715
+ if (!context) {
29716
+ return defaultRGB;
29717
+ }
29718
+ context.drawImage(video, 0, 0, canvas.width, canvas.height);
29719
+ return getAverageRGB(canvas, 5);
29720
+ }
29721
+ function getVideoDominantColor(video) {
29722
+ var defaultRGB = {
29723
+ r: 0,
29724
+ g: 0,
29725
+ b: 0
29726
+ };
29727
+ var canvas = document.createElement("canvas");
29728
+ canvas.width = 1;
29729
+ canvas.height = 1;
29730
+ var context = canvas.getContext("2d");
29731
+ if (!context) {
29732
+ return defaultRGB;
29733
+ }
29734
+ context.drawImage(video, 0, 0, 1, 1);
29735
+ return getAverageRGB(canvas, 1);
29736
+ }
29376
29737
  // src/Media/NativeMediaElement.ts
29377
29738
  var DEFAULT_SEEK_INTERVAL2 = 10;
29378
29739
  var EVENT_LIST_TO_HANDLE = [
@@ -29726,6 +30087,18 @@ var NativeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
29726
30087
  value: function resetSize() {
29727
30088
  return this.setSize(this.context.dimensions.w, this.context.dimensions.h);
29728
30089
  }
30090
+ },
30091
+ {
30092
+ key: "getAverageColor",
30093
+ value: function getAverageColor() {
30094
+ return getVideoAverageColor(this.media);
30095
+ }
30096
+ },
30097
+ {
30098
+ key: "getVideoDominantColor",
30099
+ value: function getVideoDominantColor1() {
30100
+ return getVideoDominantColor(this.media);
30101
+ }
29729
30102
  }
29730
30103
  ]);
29731
30104
  return NativeMediaElement;
@@ -29866,6 +30239,10 @@ var BrndtsAds = /*#__PURE__*/ function() {
29866
30239
  }
29867
30240
  };
29868
30241
  try {
30242
+ if (!this.context.config.get("enabled")) {
30243
+ this.context.logger.error("Setup failed: disabled by config");
30244
+ return;
30245
+ }
29869
30246
  this.context.media = MediaElementFactory.getMediaElement(this.context);
29870
30247
  this.context.media.on("ERROR", function(error) {
29871
30248
  ErrorHandler.handle(error);
@@ -29888,16 +30265,13 @@ var BrndtsAds = /*#__PURE__*/ function() {
29888
30265
  key: "initialize",
29889
30266
  value: function initialize() {
29890
30267
  var _this = this;
30268
+ console.log("initialize");
29891
30269
  try {
29892
30270
  this.context.recorder = new InteractionLog(this.context);
29893
30271
  this.context.media.on("RESIZED", function() {
29894
30272
  var _this_context_ads;
29895
30273
  (_this_context_ads = _this.context.ads) === null || _this_context_ads === void 0 ? void 0 : _this_context_ads.updateSize();
29896
30274
  });
29897
- if (!this.context.config.get("enabled")) {
29898
- this.context.logger.error("Setup failed: disabled by config");
29899
- return;
29900
- }
29901
30275
  this.context.interface = new Interface(this.context);
29902
30276
  if (this.context.media.view.brndts) {
29903
30277
  this.context.logger.error("Setup failed: target already setup");
@@ -29911,6 +30285,7 @@ var BrndtsAds = /*#__PURE__*/ function() {
29911
30285
  if (this.context.config.get("debug")) {
29912
30286
  window.brndts = this;
29913
30287
  }
30288
+ console.log("start ads", this.context.config.get("ads"));
29914
30289
  if (this.context.config.get("ads").enabled) {
29915
30290
  this.context.ads = new Ads_default(this.context);
29916
30291
  this.context.ads.start();
@@ -29947,6 +30322,7 @@ var BrndtsAds = /*#__PURE__*/ function() {
29947
30322
  });
29948
30323
  });
29949
30324
  this.context.service.handle("info", function(data) {
30325
+ console.log("info", data);
29950
30326
  if (!data.video) {
29951
30327
  ErrorHandler.handle(new InternalError("Setup failed: no video identifier"));
29952
30328
  return;