@streamlayer/react 1.22.3 → 1.23.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.
Files changed (122) hide show
  1. package/lib/app/pause-ad.d.ts +2 -4
  2. package/lib/app/polymarket.d.ts +7 -0
  3. package/lib/cjs/Question.js +1 -1
  4. package/lib/cjs/advertisement.js +44 -40
  5. package/lib/cjs/analytics.js +1 -1
  6. package/lib/cjs/auth.js +1 -1
  7. package/lib/cjs/bet-pack.js +1 -1
  8. package/lib/cjs/feature.js +1 -0
  9. package/lib/cjs/hooks-WfHlJH12.js +1 -0
  10. package/lib/cjs/index-eShKGO10.js +5 -0
  11. package/lib/cjs/index.js +1 -1
  12. package/lib/cjs/index10.js +1 -1
  13. package/lib/cjs/index16.js +2 -2
  14. package/lib/cjs/index2.js +1 -1
  15. package/lib/cjs/index3.js +1 -1
  16. package/lib/cjs/index4.js +1 -1
  17. package/lib/cjs/index7.js +1 -5
  18. package/lib/cjs/insight.js +1 -1
  19. package/lib/cjs/masters.js +1 -1
  20. package/lib/cjs/masters2.js +5 -5
  21. package/lib/cjs/notification.js +1 -1
  22. package/lib/cjs/pause-ad.js +1 -1
  23. package/lib/cjs/points.js +1 -1
  24. package/lib/cjs/polymarket.js +19 -0
  25. package/lib/cjs/useStreamLayerApp2.js +17 -17
  26. package/lib/classic/app/pause-ad.d.ts +2 -4
  27. package/lib/classic/app/polymarket.d.ts +7 -0
  28. package/lib/classic/cjs/Question.js +1 -1
  29. package/lib/classic/cjs/advertisement.js +44 -40
  30. package/lib/classic/cjs/analytics.js +1 -1
  31. package/lib/classic/cjs/auth.js +1 -1
  32. package/lib/classic/cjs/bet-pack.js +3 -3
  33. package/lib/classic/cjs/feature.js +1 -0
  34. package/lib/classic/cjs/hooks-WfHlJH12.js +1 -0
  35. package/lib/classic/cjs/index-eShKGO10.js +5 -0
  36. package/lib/classic/cjs/index.js +1 -1
  37. package/lib/classic/cjs/index10.js +1 -1
  38. package/lib/classic/cjs/index11.js +1 -1
  39. package/lib/classic/cjs/index12.js +1 -1
  40. package/lib/classic/cjs/index13.js +1 -1
  41. package/lib/classic/cjs/index2.js +2 -2
  42. package/lib/classic/cjs/index3.js +1 -1
  43. package/lib/classic/cjs/index4.js +1 -1
  44. package/lib/classic/cjs/index5.js +1 -1
  45. package/lib/classic/cjs/index6.js +1 -5
  46. package/lib/classic/cjs/index9.js +1 -1
  47. package/lib/classic/cjs/insight.js +1 -1
  48. package/lib/classic/cjs/notification.js +1 -1
  49. package/lib/classic/cjs/notification2.js +1 -1
  50. package/lib/classic/cjs/pause-ad.js +1 -1
  51. package/lib/classic/cjs/points.js +1 -1
  52. package/lib/classic/cjs/polymarket.js +19 -0
  53. package/lib/classic/cjs/useStreamLayerApp2.js +17 -17
  54. package/lib/classic/es/Question.js +50 -50
  55. package/lib/classic/es/advertisement.js +15547 -10742
  56. package/lib/classic/es/analytics.js +74 -18
  57. package/lib/classic/es/auth.js +1 -1
  58. package/lib/classic/es/bet-pack.js +19 -18
  59. package/lib/classic/es/feature.js +63 -0
  60. package/lib/classic/es/hooks-WfHlJH12.js +98 -0
  61. package/lib/classic/es/index-eShKGO10.js +3757 -0
  62. package/lib/classic/es/index.js +1 -1
  63. package/lib/classic/es/index10.js +1 -1
  64. package/lib/classic/es/index11.js +767 -755
  65. package/lib/classic/es/index12.js +1 -1
  66. package/lib/classic/es/index13.js +2 -2
  67. package/lib/classic/es/index2.js +125 -125
  68. package/lib/classic/es/index3.js +16 -61
  69. package/lib/classic/es/index4.js +282 -16
  70. package/lib/classic/es/index5.js +4 -283
  71. package/lib/classic/es/index6.js +5 -3758
  72. package/lib/classic/es/index9.js +1 -1
  73. package/lib/classic/es/insight.js +1 -1
  74. package/lib/classic/es/notification.js +1 -1
  75. package/lib/classic/es/notification2.js +476 -451
  76. package/lib/classic/es/pause-ad.js +174 -208
  77. package/lib/classic/es/points.js +16 -15
  78. package/lib/classic/es/polymarket.js +6670 -0
  79. package/lib/classic/es/useStreamLayerApp2.js +5088 -4030
  80. package/lib/dist/cjs/index-eShKGO10.js +5 -0
  81. package/lib/dist/cjs/masters.js +36 -36
  82. package/lib/dist/es/index-eShKGO10.js +3757 -0
  83. package/lib/dist/es/masters.js +9243 -8192
  84. package/lib/dist/index.d.ts +30 -7
  85. package/lib/dist/style.css +1 -1
  86. package/lib/es/Question.js +3 -3
  87. package/lib/es/advertisement.js +15547 -10742
  88. package/lib/es/analytics.js +74 -18
  89. package/lib/es/auth.js +1 -1
  90. package/lib/es/bet-pack.js +1 -1
  91. package/lib/es/feature.js +63 -0
  92. package/lib/es/hooks-WfHlJH12.js +98 -0
  93. package/lib/es/index-eShKGO10.js +3757 -0
  94. package/lib/es/index.js +1 -1
  95. package/lib/es/index10.js +9 -9
  96. package/lib/es/index16.js +2 -2
  97. package/lib/es/index2.js +118 -118
  98. package/lib/es/index3.js +3 -61
  99. package/lib/es/index4.js +1 -1
  100. package/lib/es/index7.js +5 -3758
  101. package/lib/es/insight.js +1 -1
  102. package/lib/es/masters.js +1 -1
  103. package/lib/es/masters2.js +23 -23
  104. package/lib/es/notification.js +450 -425
  105. package/lib/es/pause-ad.js +174 -208
  106. package/lib/es/points.js +5 -4
  107. package/lib/es/polymarket.js +6670 -0
  108. package/lib/es/useStreamLayerApp2.js +5088 -4030
  109. package/lib/style.css +1 -1
  110. package/package.json +27 -17
  111. package/lib/cjs/hooks-B0Qttldg.js +0 -1
  112. package/lib/cjs/index-DSi8Qgfs.js +0 -1
  113. package/lib/cjs/vast-client.min.js +0 -1
  114. package/lib/classic/cjs/hooks-B0Qttldg.js +0 -1
  115. package/lib/classic/cjs/index-DSi8Qgfs.js +0 -1
  116. package/lib/classic/cjs/vast-client.min.js +0 -1
  117. package/lib/classic/es/hooks-B0Qttldg.js +0 -98
  118. package/lib/classic/es/index-DSi8Qgfs.js +0 -65
  119. package/lib/classic/es/vast-client.min.js +0 -1060
  120. package/lib/es/hooks-B0Qttldg.js +0 -98
  121. package/lib/es/index-DSi8Qgfs.js +0 -65
  122. package/lib/es/vast-client.min.js +0 -1060
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/react",
3
- "version": "1.22.3",
3
+ "version": "1.23.1",
4
4
  "author": "StreamLayer, Inc (https://streamlayer.io)",
5
5
  "maintainers": [
6
6
  {
@@ -31,6 +31,11 @@
31
31
  "require": "./lib/classic/cjs/points.js",
32
32
  "types": "./lib/classic/app/points.d.ts"
33
33
  },
34
+ "./classic/polymarket": {
35
+ "module": "./lib/classic/es/polymarket.js",
36
+ "require": "./lib/classic/cjs/polymarket.js",
37
+ "types": "./lib/classic/app/polymarket.d.ts"
38
+ },
34
39
  "./classic/advertisement": {
35
40
  "module": "./lib/classic/es/advertisement.js",
36
41
  "require": "./lib/classic/cjs/advertisement.js",
@@ -76,6 +81,11 @@
76
81
  "require": "./lib/cjs/points.js",
77
82
  "types": "./lib/app/points.d.ts"
78
83
  },
84
+ "./polymarket": {
85
+ "module": "./lib/es/polymarket.js",
86
+ "require": "./lib/cjs/polymarket.js",
87
+ "types": "./lib/app/polymarket.d.ts"
88
+ },
79
89
  "./advertisement": {
80
90
  "module": "./lib/es/advertisement.js",
81
91
  "require": "./lib/cjs/advertisement.js",
@@ -133,30 +143,30 @@
133
143
  ],
134
144
  "dependencies": {
135
145
  "@bufbuild/protobuf": "^2.2.2",
136
- "@streamlayer/sl-eslib": "^5.225.0",
146
+ "@streamlayer/sl-eslib": "^5.228.0",
137
147
  "@connectrpc/connect": "^2.0.0",
138
148
  "@connectrpc/connect-web": "^2.0.0",
139
- "@streamlayer/feature-gamification": "^1.23.8",
140
- "@streamlayer/react-polyfills": "^0.1.53",
141
- "@streamlayer/sdk-web": "^1.16.8",
142
- "@streamlayer/sdk-web-analytics": "^1.14.3",
143
- "@streamlayer/sdk-web-api": "^1.14.8",
144
- "@streamlayer/sdk-web-features": "^1.0.93",
145
- "@streamlayer/sdk-web-core": "^1.18.3",
146
- "@streamlayer/sdk-web-interfaces": "^1.8.8",
147
- "@streamlayer/sdk-web-logger": "^1.0.93",
148
- "@streamlayer/sdk-web-storage": "^1.0.93",
149
- "@streamlayer/sdk-web-types": "^1.16.8",
150
- "@streamlayer/sdk-web-notifications": "^1.3.55",
151
- "@streamlayer/react-ui": "^1.33.3"
149
+ "@streamlayer/feature-gamification": "^1.24.6",
150
+ "@streamlayer/react-polyfills": "^0.2.6",
151
+ "@streamlayer/sdk-web": "^1.17.6",
152
+ "@streamlayer/sdk-web-analytics": "^1.15.6",
153
+ "@streamlayer/sdk-web-api": "^1.15.6",
154
+ "@streamlayer/sdk-web-core": "^1.20.3",
155
+ "@streamlayer/sdk-web-features": "^1.0.100",
156
+ "@streamlayer/sdk-web-interfaces": "^1.9.6",
157
+ "@streamlayer/sdk-web-logger": "^1.0.100",
158
+ "@streamlayer/sdk-web-notifications": "^1.3.62",
159
+ "@streamlayer/sdk-web-storage": "^1.0.100",
160
+ "@streamlayer/sdk-web-types": "^1.16.15",
161
+ "@streamlayer/react-ui": "^1.35.3"
152
162
  },
153
163
  "peerDependencies": {
154
164
  "@fastify/deepmerge": "^2.0.0",
155
165
  "@lottiefiles/react-lottie-player": "^3.5.4",
156
- "@nanostores/query": "^0.2.10",
166
+ "@nanostores/query": "^0.3.4",
157
167
  "@types/lodash.throttle": "^4.1.9",
158
168
  "lodash.throttle": "^4.1.1",
159
- "nanostores": "^0.11.4",
169
+ "nanostores": "^1.1.0",
160
170
  "pino": "^9.4.0",
161
171
  "react": "18.3.1",
162
172
  "react-auth-code-input": "^3.2.1",
@@ -1 +0,0 @@
1
- "use strict";const n=require("react"),E=require("react/jsx-runtime"),w=require("./useStreamLayerApp2.js"),f=({event:e,internal:r})=>{const o=m(),s=L();return n.useEffect(()=>(o&&(e&&(o.createEventSession(e,r),s&&(s.current=e)),!e&&s!=null&&s.current&&(o.createEventSession("",r),s.current="")),()=>{o&&o.disableApp()}),[e,r,s,o]),null};var h=(e=>(e[e.UNSET=0]="UNSET",e[e.CONNECTED=1]="CONNECTED",e[e.READY=2]="READY",e))(h||{});const x={status:0,sdk:null},i=n.createContext(x),N=({sdkKey:e,theme:r,themeMode:o,plugins:s,children:u,event:p,production:y=!0,autoEnable:C=!0,withAdNotification:S,withAd:A=!0,betPack:a=!1,hideFriends:D,skipOnboarding:c,friendsTab:v="enabled",onDeepLinkHandled:l,videoPlayerController:d,onContentActivate:K,containerId:b,webOS:P})=>{const t=w.$({sdkKey:e,plugins:s,production:y,autoEnable:C,onDeepLinkHandled:l,videoPlayerController:d,onContentActivate:K,hideFriends:D,skipOnboarding:c,withAdNotification:S,withAd:A,friendsTab:v,betPack:a,webOS:P}),k=n.useRef(""),g=n.useMemo(()=>t?{sdk:t,status:2,event:k}:{status:1,sdk:null,event:k},[t]);return n.useEffect(()=>{t&&(t.options.setKey("friendsTab",v),t.options.setKey("theme",r),t.options.setKey("themeMode",o),t.options.setKey("skipOnboarding",c),t.options.setKey("betPack",a),t.options.setKey("containerId",b))},[t,v,r,o,c,a,b]),n.useEffect(()=>()=>{l&&(t==null||t.removeDeepLinkHandler(l)),d&&(t==null||t.removeVideoPlayerController(d))},[t]),n.useEffect(()=>{localStorage.getItem("SL_DEBUG")&&console.log("StreamLayerProvider mounted with props:",{sdkKey:!!e,onDeepLinkHandled:!!l,videoPlayerController:!!d})},[e,l,d]),E.jsxs(i.Provider,{value:g,children:[p!==void 0&&E.jsx(f,{event:p}),u]})},m=()=>{const{sdk:e}=n.useContext(i);return e},L=()=>{const{event:e}=n.useContext(i);return e},O=()=>{const{sdk:e}=n.useContext(i),[r,o]=n.useState({});return n.useEffect(()=>{var s;return e!=null&&e.options?(s=e==null?void 0:e.options)==null?void 0:s.subscribe(u=>{o({theme:u.theme,themeMode:u.themeMode})}):()=>{}},[e==null?void 0:e.options]),r},T=()=>{const{sdk:e}=n.useContext(i),[r,o]=n.useState({});return n.useEffect(()=>e!=null&&e.uiState?e==null?void 0:e.uiState.subscribe(s=>{o({...s})}):()=>{},[e==null?void 0:e.uiState]),r};exports.B=m;exports.F=T;exports.Y=h;exports.c=i;exports.j=f;exports.q=N;exports.z=O;
@@ -1 +0,0 @@
1
- "use strict";let n=[],i=0;const r=4;let s=o=>{let l=[],e={get(){return e.lc||e.listen(()=>{})(),e.value},lc:0,listen(t){return e.lc=l.push(t),()=>{for(let f=i+r;f<n.length;)n[f]===t?n.splice(f,r):f+=r;let u=l.indexOf(t);~u&&(l.splice(u,1),--e.lc||e.off())}},notify(t,u){let f=!n.length;for(let v of l)n.push(v,e.value,t,u);if(f){for(i=0;i<n.length;i+=r)n[i](n[i+1],n[i+2],n[i+3]);n.length=0}},off(){},set(t){let u=e.value;u!==t&&(e.value=t,e.notify(u))},subscribe(t){let u=e.listen(t);return t(e.value),u},value:o};return e},a=(o={})=>{let l=s(o);return l.setKey=function(e,t){let u=l.value;typeof t>"u"&&e in l.value?(l.value={...l.value},delete l.value[e],l.notify(u,e)):l.value[e]!==t&&(l.value={...l.value,[e]:t},l.notify(u,e))},l};exports.a=s;exports.i=a;
@@ -1 +0,0 @@
1
- "use strict";function N(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:i.id||null,adId:i.adId||null,sequence:i.sequence||null,apiFramework:i.apiFramework||null,universalAdIds:[],creativeExtensions:[]}}const G=["ADCATEGORIES","ADCOUNT","ADPLAYHEAD","ADSERVINGID","ADTYPE","APIFRAMEWORKS","APPBUNDLE","ASSETURI","BLOCKEDADCATEGORIES","BREAKMAXADLENGTH","BREAKMAXADS","BREAKMAXDURATION","BREAKMINADLENGTH","BREAKMINDURATION","BREAKPOSITION","CLICKPOS","CLICKTYPE","CLIENTUA","CONTENTID","CONTENTPLAYHEAD","CONTENTURI","DEVICEIP","DEVICEUA","DOMAIN","EXTENSIONS","GDPRCONSENT","IFA","IFATYPE","INVENTORYSTATE","LATLONG","LIMITADTRACKING","MEDIAMIME","MEDIAPLAYHEAD","OMIDPARTNER","PAGEURL","PLACEMENTTYPE","PLAYERCAPABILITIES","PLAYERSIZE","PLAYERSTATE","PODSEQUENCE","REGULATIONS","SERVERSIDE","SERVERUA","TRANSACTIONID","UNIVERSALADID","VASTVERSIONS","VERIFICATIONVENDORS"];function w(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=[],a=M(i);!e.ERRORCODE||t.isCustomCode||/^[0-9]{3}$/.test(e.ERRORCODE)||(e.ERRORCODE=900),e.CACHEBUSTING=q(Math.round(1e8*Math.random())),e.TIMESTAMP=new Date().toISOString(),e.RANDOM=e.random=e.CACHEBUSTING;for(const s in e)e[s]=j(e[s]);for(const s in a){const o=a[s];typeof o=="string"&&r.push(B(o,e))}return r}function B(i,e){const t=(i=L(i,e)).match(/[^[\]]+(?=])/g);if(!t)return i;let r=t.filter(a=>G.indexOf(a)>-1);return r.length===0?i:(r=r.reduce((a,s)=>(a[s]=-1,a),{}),L(i,r))}function L(i,e){let t=i;for(const r in e){const a=e[r];t=t.replace(new RegExp("(?:\\[|%%)(".concat(r,")(?:\\]|%%)"),"g"),a)}return t}function M(i){return Array.isArray(i)?i.map(e=>e&&e.hasOwnProperty("url")?e.url:e):i}function C(i){return/^(https?:\/\/|\/\/)/.test(i)}function U(i,e){for(let t=0;t<e.length;t++)if(W(e[t],i))return!0;return!1}function W(i,e){if(i&&e){const t=Object.getOwnPropertyNames(i),r=Object.getOwnPropertyNames(e);return t.length===r.length&&i.id===e.id&&i.url===e.url}return!1}function j(i){return encodeURIComponent(i).replace(/[!'()*]/g,e=>"%".concat(e.charCodeAt(0).toString(16)))}function q(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8;return i.toString().padStart(e,"0")}const f={track:function(i,e,t){w(i,e,t).forEach(r=>{typeof window<"u"&&window!==null&&(new Image().src=r)})},resolveURLTemplates:w,extractURLsFromTemplates:M,filterUrlTemplates:function(i){return i.reduce((e,t)=>{const r=t.url||t;return C(r)?e.validUrls.push(r):e.invalidUrls.push(r),e},{validUrls:[],invalidUrls:[]})},containsTemplateObject:U,isTemplateObjectEqual:W,encodeURIComponentRFC3986:j,replaceUrlMacros:B,isNumeric:function(i){return!isNaN(parseFloat(i))&&isFinite(i)},flatten:function i(e){return e.reduce((t,r)=>t.concat(Array.isArray(r)?i(r):r),[])},joinArrayOfUniqueTemplateObjs:function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];const t=Array.isArray(i)?i:[],r=Array.isArray(e)?e:[];return t.concat(r).reduce((a,s)=>(U(s,a)||a.push(s),a),[])},isValidTimeValue:function(i){return Number.isFinite(i)&&i>=-2},addLeadingZeros:q,isValidUrl:C,isBrowserEnvironment:function(){return typeof window<"u"},formatMacrosValues:function(i){return typeof i!="object"?i:JSON.stringify(i)}};function I(i){return["true","TRUE","True","1"].includes(i)}function Y(i){if(i==null)return-1;if(f.isNumeric(i))return parseInt(i);const e=i.split(":");if(e.length!==3)return-1;const t=e[2].split(".");let r=parseInt(t[0]);t.length===2&&(r+=parseFloat("0.".concat(t[1])));const a=parseInt(60*e[1]),s=parseInt(60*e[0]*60);return isNaN(s)||isNaN(a)||isNaN(r)||a>3600||r>60?-1:s+a+r}const l={childByName:function(i,e){return Array.from(i.childNodes).find(t=>t.nodeName===e)},childrenByName:function(i,e){return Array.from(i.childNodes).filter(t=>t.nodeName===e)},resolveVastAdTagURI:function(i,e){if(!e)return i;if(i.startsWith("//")){const{protocol:t}=location;return"".concat(t).concat(i)}if(!i.includes("://")){const t=e.slice(0,e.lastIndexOf("/"));return"".concat(t,"/").concat(i)}return i},parseBoolean:I,parseNodeText:function(i){return i&&(i.textContent||i.text||"").trim()},copyNodeAttribute:function(i,e,t){const r=e.getAttribute(i);r&&t.setAttribute(i,r)},parseAttributes:function(i){return Array.from(i.attributes).reduce((e,t)=>(e[t.nodeName]=t.nodeValue,e),{})},parseDuration:Y,getStandAloneAds:function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).filter(i=>!parseInt(i.sequence,10))},getSortedAdPods:function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).filter(i=>parseInt(i.sequence,10)).sort((i,e)=>i.sequence-e.sequence)},assignAttributes:function(i,e){i&&Array.from(i).forEach(t=>{let{nodeName:r,nodeValue:a}=t;if(r&&a&&e.hasOwnProperty(r)){let s=a;typeof e[r]=="boolean"&&(s=I(s)),e[r]=s}})},mergeWrapperAdData:function(i,e){var t;i.errorURLTemplates=e.errorURLTemplates.concat(i.errorURLTemplates),i.impressionURLTemplates=e.impressionURLTemplates.concat(i.impressionURLTemplates),i.extensions=e.extensions.concat(i.extensions),e.viewableImpression.length>0&&(i.viewableImpression=[...i.viewableImpression,...e.viewableImpression]),i.followAdditionalWrappers=e.followAdditionalWrappers,i.allowMultipleAds=e.allowMultipleAds,i.fallbackOnNoAd=e.fallbackOnNoAd;const r=(e.creatives||[]).filter(n=>n&&n.type==="companion"),a=r.reduce((n,c)=>((c.variations||[]).forEach(u=>{(u.companionClickTrackingURLTemplates||[]).forEach(d=>{f.containsTemplateObject(d,n)||n.push(d)})}),n),[]);i.creatives=r.concat(i.creatives);const s=e.videoClickTrackingURLTemplates&&e.videoClickTrackingURLTemplates.length,o=e.videoCustomClickURLTemplates&&e.videoCustomClickURLTemplates.length;if(i.creatives.forEach(n=>{if(e.trackingEvents&&e.trackingEvents[n.type])for(const c in e.trackingEvents[n.type]){const u=e.trackingEvents[n.type][c];Array.isArray(n.trackingEvents[c])||(n.trackingEvents[c]=[]),n.trackingEvents[c]=n.trackingEvents[c].concat(u)}n.type==="linear"&&(s&&(n.videoClickTrackingURLTemplates=n.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates)),o&&(n.videoCustomClickURLTemplates=n.videoCustomClickURLTemplates.concat(e.videoCustomClickURLTemplates)),!e.videoClickThroughURLTemplate||n.videoClickThroughURLTemplate!==null&&n.videoClickThroughURLTemplate!==void 0||(n.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate)),n.type==="companion"&&a.length&&(n.variations||[]).forEach(c=>{c.companionClickTrackingURLTemplates=f.joinArrayOfUniqueTemplateObjs(c.companionClickTrackingURLTemplates,a)})}),e.adVerifications&&(i.adVerifications=i.adVerifications.concat(e.adVerifications)),e.blockedAdCategories&&(i.blockedAdCategories=i.blockedAdCategories.concat(e.blockedAdCategories)),(t=e.creatives)!==null&&t!==void 0&&t.length){const n=e.creatives.filter(c=>{var u;return((u=c.icons)===null||u===void 0?void 0:u.length)&&!c.mediaFiles.length});n.length&&(i.creatives=i.creatives.concat(n))}}};function Q(i,e){const t=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:a,adId:s,sequence:o,apiFramework:n}=N(r);return{id:a,adId:s,sequence:o,apiFramework:n,type:"companion",required:null,variations:[]}}(e);return t.required=i.getAttribute("required")||null,t.variations=l.childrenByName(i,"Companion").map(r=>{const a=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:n.id||null,adType:"companionAd",width:n.width||0,height:n.height||0,assetWidth:n.assetWidth||null,assetHeight:n.assetHeight||null,expandedWidth:n.expandedWidth||null,expandedHeight:n.expandedHeight||null,apiFramework:n.apiFramework||null,adSlotId:n.adSlotId||null,pxratio:n.pxratio||"1",renderingMode:n.renderingMode||"default",staticResources:[],htmlResources:[],iframeResources:[],adParameters:null,altText:null,companionClickThroughURLTemplate:null,companionClickTrackingURLTemplates:[],trackingEvents:{}}}(l.parseAttributes(r));a.htmlResources=l.childrenByName(r,"HTMLResource").reduce((n,c)=>{const u=l.parseNodeText(c);return u?n.concat(u):n},[]),a.iframeResources=l.childrenByName(r,"IFrameResource").reduce((n,c)=>{const u=l.parseNodeText(c);return u?n.concat(u):n},[]),a.staticResources=l.childrenByName(r,"StaticResource").reduce((n,c)=>{const u=l.parseNodeText(c);return u?n.concat({url:u,creativeType:c.getAttribute("creativeType")||null}):n},[]),a.altText=l.parseNodeText(l.childByName(r,"AltText"))||null;const s=l.childByName(r,"TrackingEvents");s&&l.childrenByName(s,"Tracking").forEach(n=>{const c=n.getAttribute("event"),u=l.parseNodeText(n);c&&u&&(Array.isArray(a.trackingEvents[c])||(a.trackingEvents[c]=[]),a.trackingEvents[c].push(u))}),a.companionClickTrackingURLTemplates=l.childrenByName(r,"CompanionClickTracking").map(n=>({id:n.getAttribute("id")||null,url:l.parseNodeText(n)})),a.companionClickThroughURLTemplate=l.parseNodeText(l.childByName(r,"CompanionClickThrough"))||null;const o=l.childByName(r,"AdParameters");return o&&(a.adParameters={value:l.parseNodeText(o),xmlEncoded:o.getAttribute("xmlEncoded")||null}),a}),t}function X(i,e){let t;const r=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:u,adId:d,sequence:g,apiFramework:m}=N(c);return{id:u,adId:d,sequence:g,apiFramework:m,type:"linear",duration:0,skipDelay:null,mediaFiles:[],mezzanine:null,interactiveCreativeFile:null,closedCaptionFiles:[],videoClickThroughURLTemplate:null,videoClickTrackingURLTemplates:[],videoCustomClickURLTemplates:[],adParameters:null,icons:[],trackingEvents:{}}}(e);r.duration=l.parseDuration(l.parseNodeText(l.childByName(i,"Duration")));const a=i.getAttribute("skipoffset");if(a==null)r.skipDelay=null;else if(a.charAt(a.length-1)==="%"&&r.duration!==-1){const c=parseInt(a,10);r.skipDelay=r.duration*(c/100)}else r.skipDelay=l.parseDuration(a);const s=l.childByName(i,"VideoClicks");if(s){const c=l.childByName(s,"ClickThrough");r.videoClickThroughURLTemplate=c?{id:c.getAttribute("id")||null,url:l.parseNodeText(c)}:null,l.childrenByName(s,"ClickTracking").forEach(u=>{r.videoClickTrackingURLTemplates.push({id:u.getAttribute("id")||null,url:l.parseNodeText(u)})}),l.childrenByName(s,"CustomClick").forEach(u=>{r.videoCustomClickURLTemplates.push({id:u.getAttribute("id")||null,url:l.parseNodeText(u)})})}const o=l.childByName(i,"AdParameters");o&&(r.adParameters={value:l.parseNodeText(o),xmlEncoded:o.getAttribute("xmlEncoded")||null}),l.childrenByName(i,"TrackingEvents").forEach(c=>{l.childrenByName(c,"Tracking").forEach(u=>{let d=u.getAttribute("event");const g=l.parseNodeText(u);if(d&&g){if(d==="progress"){if(t=u.getAttribute("offset"),!t)return;d=t.charAt(t.length-1)==="%"?"progress-".concat(t):"progress-".concat(l.parseDuration(t))}Array.isArray(r.trackingEvents[d])||(r.trackingEvents[d]=[]),r.trackingEvents[d].push(g)}})}),l.childrenByName(i,"MediaFiles").forEach(c=>{l.childrenByName(c,"MediaFile").forEach(h=>{r.mediaFiles.push(function(p){const v={id:null,fileURL:null,fileSize:0,deliveryType:"progressive",mimeType:null,mediaType:null,codec:null,bitrate:0,minBitrate:0,maxBitrate:0,width:0,height:0,apiFramework:null,scalable:null,maintainAspectRatio:null};v.id=p.getAttribute("id"),v.fileURL=l.parseNodeText(p),v.deliveryType=p.getAttribute("delivery"),v.codec=p.getAttribute("codec"),v.mimeType=p.getAttribute("type"),v.mediaType=p.getAttribute("mediaType")||"2D",v.apiFramework=p.getAttribute("apiFramework"),v.fileSize=parseInt(p.getAttribute("fileSize")||0),v.bitrate=parseInt(p.getAttribute("bitrate")||0),v.minBitrate=parseInt(p.getAttribute("minBitrate")||0),v.maxBitrate=parseInt(p.getAttribute("maxBitrate")||0),v.width=parseInt(p.getAttribute("width")||0),v.height=parseInt(p.getAttribute("height")||0);const R=p.getAttribute("scalable");R&&typeof R=="string"&&(v.scalable=l.parseBoolean(R));const A=p.getAttribute("maintainAspectRatio");return A&&typeof A=="string"&&(v.maintainAspectRatio=l.parseBoolean(A)),v}(h))});const u=l.childByName(c,"InteractiveCreativeFile");u&&(r.interactiveCreativeFile=function(h){const p=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{type:v.type||null,apiFramework:v.apiFramework||null,variableDuration:l.parseBoolean(v.variableDuration),fileURL:null}}(l.parseAttributes(h));return p.fileURL=l.parseNodeText(h),p}(u));const d=l.childByName(c,"ClosedCaptionFiles");d&&l.childrenByName(d,"ClosedCaptionFile").forEach(h=>{const p=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{type:v.type||null,language:v.language||null,fileURL:null}}(l.parseAttributes(h));p.fileURL=l.parseNodeText(h),r.closedCaptionFiles.push(p)});const g=l.childByName(c,"Mezzanine"),m=function(h,p){const v={};let R=!1;return p.forEach(A=>{h&&h.getAttribute(A)?v[A]=h.getAttribute(A):R=!0}),R?null:v}(g,["delivery","type","width","height"]);if(m){const h={id:null,fileURL:null,delivery:null,codec:null,type:null,width:0,height:0,fileSize:0,mediaType:"2D"};h.id=g.getAttribute("id"),h.fileURL=l.parseNodeText(g),h.delivery=m.delivery,h.codec=g.getAttribute("codec"),h.type=m.type,h.width=parseInt(m.width,10),h.height=parseInt(m.height,10),h.fileSize=parseInt(g.getAttribute("fileSize"),10),h.mediaType=g.getAttribute("mediaType")||"2D",r.mezzanine=h}});const n=l.childByName(i,"Icons");return n&&l.childrenByName(n,"Icon").forEach(c=>{r.icons.push(function(u){const d={program:null,height:0,width:0,xPosition:0,yPosition:0,apiFramework:null,offset:null,duration:0,type:null,staticResource:null,htmlResource:null,iframeResource:null,pxratio:"1",iconClickThroughURLTemplate:null,iconClickTrackingURLTemplates:[],iconViewTrackingURLTemplate:null,iconClickFallbackImages:[],altText:null,hoverText:null};d.program=u.getAttribute("program"),d.height=parseInt(u.getAttribute("height")||0),d.width=parseInt(u.getAttribute("width")||0),d.xPosition=function(m){return["left","right"].indexOf(m)!==-1?m:parseInt(m||0)}(u.getAttribute("xPosition")),d.yPosition=function(m){return["top","bottom"].indexOf(m)!==-1?m:parseInt(m||0)}(u.getAttribute("yPosition")),d.apiFramework=u.getAttribute("apiFramework"),d.pxratio=u.getAttribute("pxratio")||"1",d.offset=l.parseDuration(u.getAttribute("offset")),d.duration=l.parseDuration(u.getAttribute("duration")),d.altText=u.getAttribute("altText"),d.hoverText=u.getAttribute("hoverText"),l.childrenByName(u,"HTMLResource").forEach(m=>{d.type=m.getAttribute("creativeType")||"text/html",d.htmlResource=l.parseNodeText(m)}),l.childrenByName(u,"IFrameResource").forEach(m=>{d.type=m.getAttribute("creativeType")||0,d.iframeResource=l.parseNodeText(m)}),l.childrenByName(u,"StaticResource").forEach(m=>{d.type=m.getAttribute("creativeType")||0,d.staticResource=l.parseNodeText(m)});const g=l.childByName(u,"IconClicks");if(g){d.iconClickThroughURLTemplate=l.parseNodeText(l.childByName(g,"IconClickThrough")),l.childrenByName(g,"IconClickTracking").forEach(h=>{d.iconClickTrackingURLTemplates.push({id:h.getAttribute("id")||null,url:l.parseNodeText(h)})});const m=l.childByName(g,"IconClickFallbackImages");m&&l.childrenByName(m,"IconClickFallbackImage").forEach(h=>{d.iconClickFallbackImages.push({url:l.parseNodeText(h)||null,width:h.getAttribute("width")||null,height:h.getAttribute("height")||null})})}return d.iconViewTrackingURLTemplate=l.parseNodeText(l.childByName(u,"IconViewTracking")),d}(c))}),r}function Z(i,e){const t=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:a,adId:s,sequence:o,apiFramework:n}=N(r);return{id:a,adId:s,sequence:o,apiFramework:n,type:"nonlinear",variations:[],trackingEvents:{}}}(e);return l.childrenByName(i,"TrackingEvents").forEach(r=>{let a,s;l.childrenByName(r,"Tracking").forEach(o=>{a=o.getAttribute("event"),s=l.parseNodeText(o),a&&s&&(Array.isArray(t.trackingEvents[a])||(t.trackingEvents[a]=[]),t.trackingEvents[a].push(s))})}),l.childrenByName(i,"NonLinear").forEach(r=>{const a={id:null,width:0,height:0,expandedWidth:0,expandedHeight:0,scalable:!0,maintainAspectRatio:!0,minSuggestedDuration:0,apiFramework:"static",adType:"nonLinearAd",type:null,staticResource:null,htmlResource:null,iframeResource:null,nonlinearClickThroughURLTemplate:null,nonlinearClickTrackingURLTemplates:[],adParameters:null};a.id=r.getAttribute("id")||null,a.width=r.getAttribute("width"),a.height=r.getAttribute("height"),a.expandedWidth=r.getAttribute("expandedWidth"),a.expandedHeight=r.getAttribute("expandedHeight"),a.scalable=l.parseBoolean(r.getAttribute("scalable")),a.maintainAspectRatio=l.parseBoolean(r.getAttribute("maintainAspectRatio")),a.minSuggestedDuration=l.parseDuration(r.getAttribute("minSuggestedDuration")),a.apiFramework=r.getAttribute("apiFramework"),l.childrenByName(r,"HTMLResource").forEach(o=>{a.type=o.getAttribute("creativeType")||"text/html",a.htmlResource=l.parseNodeText(o)}),l.childrenByName(r,"IFrameResource").forEach(o=>{a.type=o.getAttribute("creativeType")||0,a.iframeResource=l.parseNodeText(o)}),l.childrenByName(r,"StaticResource").forEach(o=>{a.type=o.getAttribute("creativeType")||0,a.staticResource=l.parseNodeText(o)});const s=l.childByName(r,"AdParameters");s&&(a.adParameters={value:l.parseNodeText(s),xmlEncoded:s.getAttribute("xmlEncoded")||null}),a.nonlinearClickThroughURLTemplate=l.parseNodeText(l.childByName(r,"NonLinearClickThrough")),l.childrenByName(r,"NonLinearClickTracking").forEach(o=>{a.nonlinearClickTrackingURLTemplates.push({id:o.getAttribute("id")||null,url:l.parseNodeText(o)})}),t.variations.push(a)}),t}function x(i){const e=[];return i.forEach(t=>{const r=K(t);r&&e.push(r)}),e}function K(i){if(i.nodeName==="#comment")return null;const e={name:null,value:null,attributes:{},children:[]},t=i.attributes,r=i.childNodes;if(e.name=i.nodeName,i.attributes){for(const s in t)if(t.hasOwnProperty(s)){const o=t[s];o.nodeName&&o.nodeValue&&(e.attributes[o.nodeName]=o.nodeValue)}}for(const s in r)if(r.hasOwnProperty(s)){const o=K(r[s]);o&&e.children.push(o)}if(e.children.length===0||e.children.length===1&&["#cdata-section","#text"].indexOf(e.children[0].name)>=0){const s=l.parseNodeText(i);s!==""&&(e.value=s),e.children=[]}return(a=e).value===null&&Object.keys(a.attributes).length===0&&a.children.length===0?null:e;var a}function J(i){return i.getAttribute("AdID")||i.getAttribute("adID")||i.getAttribute("adId")||null}const y={Wrapper:{subElements:["VASTAdTagURI","Impression"]},BlockedAdCategories:{attributes:["authority"]},InLine:{subElements:["AdSystem","AdTitle","Impression","AdServingId","Creatives"]},Category:{attributes:["authority"]},Pricing:{attributes:["model","currency"]},Verification:{oneOfinLineResources:["JavaScriptResource","ExecutableResource"],attributes:["vendor"]},UniversalAdId:{attributes:["idRegistry"]},JavaScriptResource:{attributes:["apiFramework","browserOptional"]},ExecutableResource:{attributes:["apiFramework","type"]},Tracking:{attributes:["event"]},Creatives:{subElements:["Creative"]},Creative:{subElements:["UniversalAdId"]},Linear:{subElements:["MediaFiles","Duration"]},MediaFiles:{subElements:["MediaFile"]},MediaFile:{attributes:["delivery","type","width","height"]},Mezzanine:{attributes:["delivery","type","width","height"]},NonLinear:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},Companion:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},StaticResource:{attributes:["creativeType"]},Icons:{subElements:["Icon"]},Icon:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"]}};function S(i,e){if(!y[i.nodeName]||!y[i.nodeName].attributes)return;const t=y[i.nodeName].attributes.filter(r=>!i.getAttribute(r));t.length>0&&k({name:i.nodeName,parentName:i.parentNode.nodeName,attributes:t},e)}function V(i,e,t){const r=y[i.nodeName],a=!t&&i.nodeName!=="Wrapper";if(!(!r||a)){if(r.subElements){const s=r.subElements.filter(o=>!l.childByName(i,o));s.length>0&&k({name:i.nodeName,parentName:i.parentNode.nodeName,subElements:s},e)}!t||!r.oneOfinLineResources||r.oneOfinLineResources.some(s=>l.childByName(i,s))||k({name:i.nodeName,parentName:i.parentNode.nodeName,oneOfResources:r.oneOfinLineResources},e)}}function D(i){return i.children&&i.children.length!==0}function k(i,e){let{name:t,parentName:r,attributes:a,subElements:s,oneOfResources:o}=i,n="Element '".concat(t,"'");n+=a?" missing required attribute(s) '".concat(a.join(", "),"' "):s?" missing required sub element(s) '".concat(s.join(", "),"' "):o?" must provide one of the following '".concat(o.join(", "),"' "):" is empty",e("VAST-warning",{message:n,parentElement:r,specVersion:4.1})}const $={verifyRequiredValues:function i(e,t,r){if(e&&e.nodeName)if(e.nodeName==="InLine"&&(r=!0),S(e,t),D(e)){V(e,t,r);for(let a=0;a<e.children.length;a++)i(e.children[a],t,r)}else l.parseNodeText(e).length===0&&k({name:e.nodeName,parentName:e.parentNode.nodeName},t)},hasSubElements:D,emitMissingValueWarning:k,verifyRequiredAttributes:S,verifyRequiredSubElements:V};function ee(i,e){let{allowMultipleAds:t,followAdditionalWrappers:r}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const a=Array.from(i.childNodes).filter(s=>{const o=s.nodeName.toLowerCase();return o==="inline"||r!==!1&&o==="wrapper"});for(const s of a){if(l.copyNodeAttribute("id",i,s),l.copyNodeAttribute("sequence",i,s),l.copyNodeAttribute("adType",i,s),s.nodeName==="Wrapper")return{ad:re(s,e),type:"WRAPPER"};if(s.nodeName==="InLine")return{ad:te(s,e,{allowMultipleAds:t}),type:"INLINE"};const o=s.nodeName.toLowerCase();e("VAST-warning",{message:"<".concat(s.nodeName,o==="inline"?"> must be written <InLine>":"> must be written <Wrapper>"),wrongNode:s})}}function te(i,e){let{allowMultipleAds:t}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return t===!1&&i.getAttribute("sequence")?null:H(i,e)}function H(i,e){let t=[];e&&$.verifyRequiredValues(i,e);const r=Array.from(i.childNodes),a=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:s.id||null,sequence:s.sequence||null,adType:s.adType||null,adServingId:null,categories:[],expires:null,viewableImpression:[],system:null,title:null,description:null,advertiser:null,pricing:null,survey:null,errorURLTemplates:[],impressionURLTemplates:[],creatives:[],extensions:[],adVerifications:[],blockedAdCategories:[],followAdditionalWrappers:!0,allowMultipleAds:!1,fallbackOnNoAd:null}}(l.parseAttributes(i));return r.forEach(s=>{switch(s.nodeName){case"Error":a.errorURLTemplates.push(l.parseNodeText(s));break;case"Impression":a.impressionURLTemplates.push({id:s.getAttribute("id")||null,url:l.parseNodeText(s)});break;case"Creatives":a.creatives=function(o){const n=[];return o.forEach(c=>{const u={id:c.getAttribute("id")||null,adId:J(c),sequence:c.getAttribute("sequence")||null,apiFramework:c.getAttribute("apiFramework")||null},d=[];let g;l.childrenByName(c,"UniversalAdId").forEach(h=>{const p={idRegistry:h.getAttribute("idRegistry")||"unknown",value:l.parseNodeText(h)};d.push(p)});const m=l.childByName(c,"CreativeExtensions");m&&(g=x(l.childrenByName(m,"CreativeExtension")));for(const h in c.childNodes){const p=c.childNodes[h];let v;switch(p.nodeName){case"Linear":v=X(p,u);break;case"NonLinearAds":v=Z(p,u);break;case"CompanionAds":v=Q(p,u)}v&&(d&&(v.universalAdIds=d),g&&(v.creativeExtensions=g),n.push(v))}}),n}(l.childrenByName(s,"Creative"));break;case"Extensions":{const o=l.childrenByName(s,"Extension");a.extensions=x(o),a.adVerifications.length||(t=function(n){let c=null,u=[];return n.some(d=>c=l.childByName(d,"AdVerifications")),c&&(u=O(l.childrenByName(c,"Verification"))),u}(o));break}case"AdVerifications":a.adVerifications=O(l.childrenByName(s,"Verification"));break;case"AdSystem":a.system={value:l.parseNodeText(s),version:s.getAttribute("version")||null};break;case"AdTitle":a.title=l.parseNodeText(s);break;case"AdServingId":a.adServingId=l.parseNodeText(s);break;case"Category":a.categories.push({authority:s.getAttribute("authority")||null,value:l.parseNodeText(s)});break;case"Expires":a.expires=parseInt(l.parseNodeText(s),10);break;case"ViewableImpression":a.viewableImpression.push(function(o){const n=(c,u)=>{const d=l.parseNodeText(u);return d&&c.push(d),c};return{id:o.getAttribute("id")||null,viewable:l.childrenByName(o,"Viewable").reduce(n,[]),notViewable:l.childrenByName(o,"NotViewable").reduce(n,[]),viewUndetermined:l.childrenByName(o,"ViewUndetermined").reduce(n,[])}}(s));break;case"Description":a.description=l.parseNodeText(s);break;case"Advertiser":a.advertiser={id:s.getAttribute("id")||null,value:l.parseNodeText(s)};break;case"Pricing":a.pricing={value:l.parseNodeText(s),model:s.getAttribute("model")||null,currency:s.getAttribute("currency")||null};break;case"Survey":a.survey={value:l.parseNodeText(s),type:s.getAttribute("type")||null};break;case"BlockedAdCategories":a.blockedAdCategories.push({authority:s.getAttribute("authority")||null,value:l.parseNodeText(s)})}}),t.length&&(a.adVerifications=a.adVerifications.concat(t)),a}function re(i,e){const t=H(i,e),r=i.getAttribute("followAdditionalWrappers"),a=i.getAttribute("allowMultipleAds"),s=i.getAttribute("fallbackOnNoAd");t.followAdditionalWrappers=!r||l.parseBoolean(r),t.allowMultipleAds=!!a&&l.parseBoolean(a),t.fallbackOnNoAd=s?l.parseBoolean(s):null;let o=l.childByName(i,"VASTAdTagURI");if(o?t.nextWrapperURL=l.parseNodeText(o):(o=l.childByName(i,"VASTAdTagURL"),o&&(t.nextWrapperURL=l.parseNodeText(l.childByName(o,"URL")))),t.creatives.forEach(n=>{if(["linear","nonlinear"].includes(n.type)){if(n.trackingEvents){t.trackingEvents||(t.trackingEvents={}),t.trackingEvents[n.type]||(t.trackingEvents[n.type]={});for(const c in n.trackingEvents){const u=n.trackingEvents[c];Array.isArray(t.trackingEvents[n.type][c])||(t.trackingEvents[n.type][c]=[]),u.forEach(d=>{t.trackingEvents[n.type][c].push(d)})}}n.videoClickTrackingURLTemplates&&(Array.isArray(t.videoClickTrackingURLTemplates)||(t.videoClickTrackingURLTemplates=[]),n.videoClickTrackingURLTemplates.forEach(c=>{t.videoClickTrackingURLTemplates.push(c)})),n.videoClickThroughURLTemplate&&(t.videoClickThroughURLTemplate=n.videoClickThroughURLTemplate),n.videoCustomClickURLTemplates&&(Array.isArray(t.videoCustomClickURLTemplates)||(t.videoCustomClickURLTemplates=[]),n.videoCustomClickURLTemplates.forEach(c=>{t.videoCustomClickURLTemplates.push(c)}))}}),t.nextWrapperURL)return t}function O(i){const e=[];return i.forEach(t=>{const r={resource:null,vendor:null,browserOptional:!1,apiFramework:null,type:null,parameters:null,trackingEvents:{}},a=Array.from(t.childNodes);l.assignAttributes(t.attributes,r),a.forEach(o=>{let{nodeName:n,textContent:c,attributes:u}=o;switch(n){case"JavaScriptResource":case"ExecutableResource":r.resource=c.trim(),l.assignAttributes(u,r);break;case"VerificationParameters":r.parameters=c.trim()}});const s=l.childByName(t,"TrackingEvents");s&&l.childrenByName(s,"Tracking").forEach(o=>{const n=o.getAttribute("event"),c=l.parseNodeText(o);n&&c&&(Array.isArray(r.trackingEvents[n])||(r.trackingEvents[n]=[]),r.trackingEvents[n].push(c))}),e.push(r)}),e}class _{constructor(){this._handlers=[]}on(e,t){if(typeof t!="function")throw new TypeError("The handler argument must be of type Function. Received type ".concat(typeof t));if(!e)throw new TypeError("The event argument must be of type String. Received type ".concat(typeof e));return this._handlers.push({event:e,handler:t}),this}once(e,t){return this.on(e,function(r,a,s){const o={fired:!1,wrapFn:void 0};function n(){o.fired||(r.off(a,o.wrapFn),o.fired=!0,s.bind(r)(...arguments))}return o.wrapFn=n,n}(this,e,t))}off(e,t){return this._handlers=this._handlers.filter(r=>r.event!==e||r.handler!==t),this}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];let s=!1;return this._handlers.forEach(o=>{o.event==="*"&&(s=!0,o.handler(e,...r)),o.event===e&&(s=!0,o.handler(...r))}),s}removeAllListeners(e){return e?(this._handlers=this._handlers.filter(t=>t.event!==e),this):(this._handlers=[],this)}listenerCount(e){return this._handlers.filter(t=>t.event===e).length}listeners(e){return this._handlers.reduce((t,r)=>(r.event===e&&t.push(r.handler),t),[])}eventNames(){return this._handlers.map(e=>e.event)}}let F=0,E=0;const z=(i,e)=>{!i||!e||i<=0||e<=0||(E=(E*F+8*i/e)/++F)},ie={ERRORCODE:900,extensions:[]},P="VAST response version not supported";class ae extends _{constructor(){let{fetcher:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.maxWrapperDepth=null,this.rootErrorURLTemplates=[],this.errorURLTemplates=[],this.remainingAds=[],this.parsingOptions={},this.fetcher=e||null,this.keepFailedAdPod=!1}trackVastError(e,t){for(var r=arguments.length,a=new Array(r>2?r-2:0),s=2;s<r;s++)a[s-2]=arguments[s];this.emit("VAST-error",Object.assign({},ie,t,...a)),f.track(e,t)}getErrorURLTemplates(){return this.rootErrorURLTemplates.concat(this.errorURLTemplates)}getEstimatedBitrate(){return E}initParsingStatus(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.maxWrapperDepth=e.wrapperLimit||10,this.parsingOptions={allowMultipleAds:e.allowMultipleAds},this.keepFailedAdPod=e.keepFailedAdPod||!1,this.rootURL="",this.resetParsingStatus(),z(e.byteLength,e.requestDuration)}resetParsingStatus(){this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.vastVersion=null}getRemainingAds(e){if(this.remainingAds.length===0)return Promise.reject(new Error("No more ads are available for the given VAST"));const t=e?this.remainingAds:[this.remainingAds.shift()];return this.errorURLTemplates=[],this.resolveAds(t,{wrapperDepth:0,url:this.rootURL}).then(r=>this.buildVASTResponse(r))}parseVAST(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.initParsingStatus(t),t.isRootVAST=!0,this.parse(e,t).then(r=>this.buildVASTResponse(r))}buildVASTResponse(e){const t=function(r){let{ads:a,errorURLTemplates:s,version:o}=r;return{ads:a||[],errorURLTemplates:s||[],version:o||null}}({ads:e,errorURLTemplates:this.getErrorURLTemplates(),version:this.vastVersion});return this.completeWrapperResolving(t),t}parseVastXml(e,t){let{isRootVAST:r=!1,url:a=null,wrapperDepth:s=0,allowMultipleAds:o,followAdditionalWrappers:n}=t;if(!e||!e.documentElement||e.documentElement.nodeName!=="VAST"){var c;this.emit("VAST-ad-parsed",{type:"ERROR",url:a,wrapperDepth:s});const m=(e==null||(c=e.documentElement)===null||c===void 0?void 0:c.nodeName)==="VideoAdServingTemplate";throw new Error(m?P:"Invalid VAST XMLDocument")}const u=[],d=e.documentElement.childNodes,g=e.documentElement.getAttribute("version");r&&g&&(this.vastVersion=g);for(const m in d){const h=d[m];if(h.nodeName==="Error"){const p=l.parseNodeText(h);r?this.rootErrorURLTemplates.push(p):this.errorURLTemplates.push(p)}else if(h.nodeName==="Ad"){if(this.vastVersion&&parseFloat(this.vastVersion)<3)o=!0;else if(o===!1&&u.length>1)break;const p=ee(h,this.emit.bind(this),{allowMultipleAds:o,followAdditionalWrappers:n});p.ad?(u.push(p.ad),this.emit("VAST-ad-parsed",{type:p.type,url:a,wrapperDepth:s,adIndex:u.length-1,vastVersion:g})):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}return u}parse(e){let{url:t=null,resolveAll:r=!0,wrapperSequence:a=null,previousUrl:s=null,wrapperDepth:o=0,isRootVAST:n=!1,followAdditionalWrappers:c,allowMultipleAds:u}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=[];this.vastVersion&&parseFloat(this.vastVersion)<3&&n&&(u=!0);try{d=this.parseVastXml(e,{isRootVAST:n,url:t,wrapperDepth:o,allowMultipleAds:u,followAdditionalWrappers:c})}catch(g){return Promise.reject(g)}if(d.length===1&&a!=null&&(d[0].sequence=a),r===!1){const g=l.getSortedAdPods(d),m=l.getStandAloneAds(d);g.length?d=g:m.length&&(d=[m.shift()]),this.remainingAds=m}return this.resolveAds(d,{wrapperDepth:o,previousUrl:s,url:t})}resolveAds(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],{wrapperDepth:t,previousUrl:r,url:a}=arguments.length>1?arguments[1]:void 0;const s=[];return r=a,e.forEach(o=>{const n=this.resolveWrappers(o,t,r);s.push(n)}),Promise.all(s).then(o=>f.flatten(o))}resolveWrappers(e,t,r){const a={...e};return new Promise(s=>{var o;if(t++,!a.nextWrapperURL)return delete a.nextWrapperURL,s(a);if(!this.fetcher)return a.VASTAdTagURI=a.nextWrapperURL,delete a.nextWrapperURL,s(a);if(t>=this.maxWrapperDepth)return a.errorCode=302,delete a.nextWrapperURL,s(a);a.nextWrapperURL=l.resolveVastAdTagURI(a.nextWrapperURL,r);const n=(o=this.parsingOptions.allowMultipleAds)!==null&&o!==void 0?o:a.allowMultipleAds,c=a.sequence;this.fetcher.fetchVAST({url:a.nextWrapperURL,emitter:this.emit.bind(this),maxWrapperDepth:this.maxWrapperDepth}).then(u=>this.parse(u,{url:a.nextWrapperURL,previousUrl:r,wrapperSequence:c,wrapperDepth:t,followAdditionalWrappers:a.followAdditionalWrappers,allowMultipleAds:n}).then(d=>{if(delete a.nextWrapperURL,d.length===0)return a.creatives=[],s(a);d.forEach(g=>{g&&l.mergeWrapperAdData(g,a)}),s(d)})).catch(u=>{a.errorCode=u.message===P?102:301,a.errorMessage=u.message,s(a)})})}completeWrapperResolving(e){if(e.ads.length===0)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(let t=e.ads.length-1;t>=0;t--){const r=e.ads[t],a=!r.creatives.some(s=>{var o,n;return((o=s.mediaFiles)===null||o===void 0?void 0:o.length)>0||((n=s.variations)===null||n===void 0?void 0:n.length)>0});!r.errorCode&&!a||r.VASTAdTagURI||(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),this.keepFailedAdPod&&r.sequence?r.hasFailed=!0:e.ads.splice(t,1))}}}let T=null;const se={data:{},length:0,getItem(i){return this.data[i]},setItem(i,e){this.data[i]=e,this.length=Object.keys(this.data).length},removeItem(i){delete this.data[i],this.length=Object.keys(this.data).length},clear(){this.data={},this.length=0}};class ne{constructor(){this.storage=this.initStorage()}initStorage(){if(T)return T;try{T=typeof window<"u"&&window!==null?window.localStorage||window.sessionStorage:null}catch{T=null}return T&&!this.isStorageDisabled(T)||(T=se,T.clear()),T}isStorageDisabled(e){const t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch{return!0}return e.removeItem(t),!1}getItem(e){return this.storage.getItem(e)}setItem(e,t){return this.storage.setItem(e,t)}removeItem(e){return this.storage.removeItem(e)}clear(){return this.storage.clear()}}const b=12e4,oe={get:async function(i,e){try{const t=new AbortController,r=setTimeout(()=>{throw t.abort(),new Error("URLHandler: Request timed out after ".concat(e.timeout||b," ms (408)"))},e.timeout||b),a=await fetch(i,{...e,signal:t.signal,credentials:e.withCredentials?"include":"omit"}).finally(()=>{clearTimeout(r)}),s=function(o){return f.isBrowserEnvironment()&&window.location.protocol==="https:"&&o.url.includes("http://")?"URLHandler: Cannot go from HTTPS to HTTP.":o.status===200&&o.ok?null:"URLHandler: ".concat(o.statusText," (").concat(o.status,")")}(a);return s?{error:new Error(s),statusCode:a.status}:async function(o){const n=await o.text();let c;return c=f.isBrowserEnvironment()?new DOMParser:new(await Promise.resolve().then(()=>require("./index7.js")).then(u=>u.index)).DOMParser,{xml:c.parseFromString(n,"text/xml"),details:{byteLength:n.length,statusCode:o.status,rawXml:n}}}(a)}catch(t){return{error:t,statusCode:t.name==="AbortError"?408:null}}}};class le{constructor(){this.URLTemplateFilters=[]}setOptions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.urlHandler=e.urlHandler||e.urlhandler||oe,this.fetchingOptions={...e.fetchOptions,timeout:e.timeout||b,withCredentials:!!e.withCredentials}}addURLTemplateFilter(e){typeof e=="function"&&this.URLTemplateFilters.push(e)}removeLastURLTemplateFilter(){this.URLTemplateFilters.pop()}countURLTemplateFilters(){return this.URLTemplateFilters.length}clearURLTemplateFilters(){this.URLTemplateFilters=[]}async fetchVAST(e){var t;let{url:r,maxWrapperDepth:a,emitter:s,wrapperDepth:o=0,previousUrl:n=null,wrapperAd:c=null}=e;const u=Date.now();this.URLTemplateFilters.forEach(m=>{r=m(r)}),s("VAST-resolving",{url:r,previousUrl:n,wrapperDepth:o,maxWrapperDepth:a,timeout:this.fetchingOptions.timeout,wrapperAd:c});const d=await this.urlHandler.get(r,this.fetchingOptions),g=Math.round(Date.now()-u);if(s("VAST-resolved",{url:r,previousUrl:n,wrapperDepth:o,error:(d==null?void 0:d.error)||null,duration:g,statusCode:(d==null?void 0:d.statusCode)||null,...d==null?void 0:d.details}),z(d==null||(t=d.details)===null||t===void 0?void 0:t.byteLength,g),d.error)throw new Error(d.error);return d.xml}}class ce{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new ne;this.cappingFreeLunch=e,this.cappingMinimumTimeInterval=t,this.fetcher=new le,this.vastParser=new ae({fetcher:this.fetcher}),this.storage=r,this.lastSuccessfulAd===void 0&&(this.lastSuccessfulAd=0),this.totalCalls===void 0&&(this.totalCalls=0),this.totalCallsTimeout===void 0&&(this.totalCallsTimeout=0)}addURLTemplateFilter(e){this.fetcher.addURLTemplateFilter(e)}removeLastURLTemplateFilter(){this.fetcher.removeLastURLTemplateFilter()}countURLTemplateFilters(){return this.fetcher.countURLTemplateFilters()}clearURLTemplateFilters(){this.fetcher.clearURLTemplateFilters()}getParser(){return this.vastParser}get lastSuccessfulAd(){return this.storage.getItem("vast-client-last-successful-ad")}set lastSuccessfulAd(e){this.storage.setItem("vast-client-last-successful-ad",e)}get totalCalls(){return this.storage.getItem("vast-client-total-calls")}set totalCalls(e){this.storage.setItem("vast-client-total-calls",e)}get totalCallsTimeout(){return this.storage.getItem("vast-client-total-calls-timeout")}set totalCallsTimeout(e){this.storage.setItem("vast-client-total-calls-timeout",e)}hasRemainingAds(){return this.vastParser.remainingAds.length>0}getNextAds(e){return this.vastParser.getRemainingAds(e)}parseVAST(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.fetcher.setOptions(t),this.vastParser.parseVAST(e,t)}get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=Date.now();return t.hasOwnProperty("resolveAll")||(t.resolveAll=!1),this.totalCallsTimeout<r?(this.totalCalls=1,this.totalCallsTimeout=r+36e5):this.totalCalls++,new Promise((a,s)=>{if(this.cappingFreeLunch>=this.totalCalls)return s(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(this.totalCalls,"/").concat(this.cappingFreeLunch)));const o=r-this.lastSuccessfulAd;if(o<0)this.lastSuccessfulAd=0;else if(o<this.cappingMinimumTimeInterval)return s(new Error("VAST call canceled – (".concat(this.cappingMinimumTimeInterval,")ms minimum interval reached")));this.vastParser.initParsingStatus(t),this.fetcher.setOptions(t),this.vastParser.rootURL=e,this.fetcher.fetchVAST({url:e,emitter:this.vastParser.emit.bind(this.vastParser),maxWrapperDepth:this.vastParser.maxWrapperDepth}).then(n=>(t.previousUrl=e,t.isRootVAST=!0,t.url=e,this.vastParser.parse(n,t).then(c=>{const u=this.vastParser.buildVASTResponse(c);a(u)}))).catch(n=>s(n))})}}class ue extends _{constructor(e,t,r){var a;let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,o=arguments.length>4&&arguments[4]!==void 0&&arguments[4];super(),this.ad=t,this.creative=r,this.variation=s,this.muted=o,this.impressed=!1,this.skippable=!1,this.trackingEvents={},this.trackedProgressEvents=[],this.lastPercentage=0,this._alreadyTriggeredQuartiles={},this.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"];for(const n in this.creative.trackingEvents){const c=this.creative.trackingEvents[n];this.trackingEvents[n]=c.slice(0)}this.viewableImpressionTrackers=((a=this.ad.viewableImpression)===null||a===void 0?void 0:a.reduce((n,c)=>(n.notViewable.push(...c.notViewable),n.viewUndetermined.push(...c.viewUndetermined),n.viewable.push(...c.viewable),n),{notViewable:[],viewUndetermined:[],viewable:[]}))||{},Object.entries(this.viewableImpressionTrackers).forEach(n=>{let[c,u]=n;u.length&&(this.trackingEvents[c]=u)}),function(n){return n.type==="linear"}(this.creative)?this._initLinearTracking():this._initVariationTracking(),e&&this.on("start",()=>{e.lastSuccessfulAd=Date.now()})}_initLinearTracking(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}_initVariationTracking(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(const e in this.variation.trackingEvents){const t=this.variation.trackingEvents[e];this.trackingEvents[e]?this.trackingEvents[e]=this.trackingEvents[e].concat(t.slice(0)):this.trackingEvents[e]=t.slice(0)}this.variation.adType==="nonLinearAd"?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):function(e){return e.adType==="companionAd"}(this.variation)&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}setDuration(e){f.isValidTimeValue(e)?(this.assetDuration=e,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}):this.emit("TRACKER-error",{message:"the duration provided is not valid. duration: ".concat(e)})}setProgress(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(!f.isValidTimeValue(e)||typeof t!="object")return void this.emit("TRACKER-error",{message:"One given setProgress parameter has the wrong type. progress: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))});const a=this.skipDelay||-1;if(a===-1||this.skippable||(a>e?this.emit("skip-countdown",a-e):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){const s=Math.round(e/this.assetDuration*100),o=[];if(e>0){o.push("start");for(let n=this.lastPercentage;n<s;n++)o.push("progress-".concat(n+1,"%"));o.push("progress-".concat(e));for(const n in this.quartiles)this.isQuartileReached(n,this.quartiles[n],e)&&(o.push(n),this._alreadyTriggeredQuartiles[n]=!0);this.lastPercentage=s}o.forEach(n=>{this.track(n,{macros:t,once:r})}),e<this.progress&&(this.track("rewind",{macros:t}),this.trackedProgressEvents&&this.trackedProgressEvents.splice(0))}this.progress=e}isQuartileReached(e,t,r){let a=!1;return t<=r&&!this._alreadyTriggeredQuartiles[e]&&(a=!0),a}setMuted(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="boolean"&&typeof t=="object"?(this.muted!==e&&this.track(e?"mute":"unmute",{macros:t}),this.muted=e):this.emit("TRACKER-error",{message:"One given setMuted parameter has the wrong type. muted: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}setPaused(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="boolean"&&typeof t=="object"?(this.paused!==e&&this.track(e?"pause":"resume",{macros:t}),this.paused=e):this.emit("TRACKER-error",{message:"One given setPaused parameter has the wrong type. paused: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}setFullscreen(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="boolean"&&typeof t=="object"?(this.fullscreen!==e&&this.track(e?"fullscreen":"exitFullscreen",{macros:t}),this.fullscreen=e):this.emit("TRACKER-error",{message:"One given setFullScreen parameter has the wrong type. fullscreen: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}setExpand(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="boolean"&&typeof t=="object"?(this.expanded!==e&&(this.track(e?"expand":"collapse",{macros:t}),this.track(e?"playerExpand":"playerCollapse",{macros:t})),this.expanded=e):this.emit("TRACKER-error",{message:"One given setExpand parameter has the wrong type. expanded: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}setSkipDelay(e){f.isValidTimeValue(e)?this.skipDelay=e:this.emit("TRACKER-error",{message:"setSkipDelay parameter does not have a valid value. duration: ".concat(e)})}trackImpression(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.impressed||(this.impressed=!0,this.trackURLs(this.ad.impressionURLTemplates,e),this.track("creativeView",{macros:e})):this.emit("TRACKER-error",{message:"trackImpression parameter has the wrong type. macros: ".concat(e)})}trackViewableImpression(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="object"?this.track("viewable",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackViewableImpression given macros has the wrong type. macros: ".concat(e)})}trackNotViewableImpression(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="object"?this.track("notViewable",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackNotViewableImpression given macros has the wrong type. macros: ".concat(e)})}trackUndeterminedImpression(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="object"?this.track("viewUndetermined",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackUndeterminedImpression given macros has the wrong type. macros: ".concat(e)})}error(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="object"&&typeof t=="boolean"?this.trackURLs(this.ad.errorURLTemplates,e,{isCustomCode:t}):this.emit("TRACKER-error",{message:"One given error parameter has the wrong type. macros: ".concat(f.formatMacrosValues(e),", isCustomCode: ").concat(t)})}errorWithCode(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="string"&&typeof t=="boolean"?(this.error({ERRORCODE:e},t),console.log("The method errorWithCode is deprecated, please use vast tracker error method instead")):this.emit("TRACKER-error",{message:"One given errorWithCode parameter has the wrong type. errorCode: ".concat(e,", isCustomCode: ").concat(t)})}complete(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("complete",{macros:e}):this.emit("TRACKER-error",{message:"complete given macros has the wrong type. macros: ".concat(e)})}notUsed(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?(this.track("notUsed",{macros:e}),this.trackingEvents=[]):this.emit("TRACKER-error",{message:"notUsed given macros has the wrong type. macros: ".concat(e)})}otherAdInteraction(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("otherAdInteraction",{macros:e}):this.emit("TRACKER-error",{message:"otherAdInteraction given macros has the wrong type. macros: ".concat(e)})}acceptInvitation(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("acceptInvitation",{macros:e}):this.emit("TRACKER-error",{message:"acceptInvitation given macros has the wrong type. macros: ".concat(e)})}adExpand(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("adExpand",{macros:e}):this.emit("TRACKER-error",{message:"adExpand given macros has the wrong type. macros: ".concat(e)})}adCollapse(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("adCollapse",{macros:e}):this.emit("TRACKER-error",{message:"adCollapse given macros has the wrong type. macros: ".concat(e)})}minimize(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("minimize",{macros:e}):this.emit("TRACKER-error",{message:"minimize given macros has the wrong type. macros: ".concat(e)})}verificationNotExecuted(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof e!="string"||typeof t!="object")return void this.emit("TRACKER-error",{message:"One given verificationNotExecuted parameter has to wrong type. vendor: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))});if(!this.ad||!this.ad.adVerifications||!this.ad.adVerifications.length)throw new Error("No adVerifications provided");if(!e)throw new Error("No vendor provided, unable to find associated verificationNotExecuted");const r=this.ad.adVerifications.find(s=>s.vendor===e);if(!r)throw new Error("No associated verification element found for vendor: ".concat(e));const a=r.trackingEvents;if(a&&a.verificationNotExecuted){const s=a.verificationNotExecuted;this.trackURLs(s,t),this.emit("verificationNotExecuted",{trackingURLTemplates:s})}}overlayViewDuration(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="string"&&typeof t=="object"?(t.ADPLAYHEAD=e,this.track("overlayViewDuration",{macros:t})):this.emit("TRACKER-error",{message:"One given overlayViewDuration parameters has the wrong type. formattedDuration: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}close(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track(this.linear?"closeLinear":"close",{macros:e}):this.emit("TRACKER-error",{message:"close given macros has the wrong type. macros: ".concat(e)})}skip(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("skip",{macros:e}):this.emit("TRACKER-error",{message:"skip given macros has the wrong type. macros: ".concat(e)})}load(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("loaded",{macros:e}):this.emit("TRACKER-error",{message:"load given macros has the wrong type. macros: ".concat(e)})}click(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==null&&typeof e!="string"||typeof t!="object")return void this.emit("TRACKER-error",{message:"One given click parameter has the wrong type. fallbackClickThroughURL: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))});this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates,t);const r=this.clickThroughURLTemplate||e,a={...t};if(r){this.progress&&(a.ADPLAYHEAD=this.progressFormatted());const s=f.resolveURLTemplates([r],a)[0];this.emit("clickthrough",s)}}trackProgressEvents(e,t,r){const a=parseFloat(e.split("-")[1]);Object.entries(this.trackingEvents).filter(s=>{let[o]=s;return o.startsWith("progress-")}).map(s=>{let[o,n]=s;return{name:o,time:parseFloat(o.split("-")[1]),urls:n}}).filter(s=>{let{time:o}=s;return o<=a&&o>this.progress}).forEach(s=>{let{name:o,urls:n}=s;!r&&this.trackedProgressEvents.includes(o)||(this.emit(o,{trackingURLTemplates:n}),this.trackURLs(n,t),r?delete this.trackingEvents[o]:this.trackedProgressEvents.push(o))})}track(e){let{macros:t={},once:r=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof t!="object")return void this.emit("TRACKER-error",{message:"track given macros has the wrong type. macros: ".concat(t)});e==="closeLinear"&&!this.trackingEvents[e]&&this.trackingEvents.close&&(e="close"),e.startsWith("progress-")&&!e.endsWith("%")&&this.trackProgressEvents(e,t,r);const a=this.trackingEvents[e],s=this.emitAlwaysEvents.indexOf(e)>-1;a?(this.emit(e,{trackingURLTemplates:a}),this.trackURLs(a,t)):s&&this.emit(e,null),r&&(delete this.trackingEvents[e],s&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e),1))}trackURLs(e){var t;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const{validUrls:s,invalidUrls:o}=f.filterUrlTemplates(e);o.length&&this.emit("TRACKER-error",{message:"Provided urls are malformed. url: ".concat(o)});const n={...r};this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(n.ASSETURI=this.creative.mediaFiles[0].fileURL),this.progress&&(n.ADPLAYHEAD=this.progressFormatted())),(t=this.creative)!==null&&t!==void 0&&(t=t.universalAdIds)!==null&&t!==void 0&&t.length&&(n.UNIVERSALADID=this.creative.universalAdIds.map(c=>c.idRegistry.concat(" ",c.value)).join(",")),this.ad&&(this.ad.sequence&&(n.PODSEQUENCE=this.ad.sequence),this.ad.adType&&(n.ADTYPE=this.ad.adType),this.ad.adServingId&&(n.ADSERVINGID=this.ad.adServingId),this.ad.categories&&this.ad.categories.length&&(n.ADCATEGORIES=this.ad.categories.map(c=>c.value).join(",")),this.ad.blockedAdCategories&&this.ad.blockedAdCategories.length&&(n.BLOCKEDADCATEGORIES=this.ad.blockedAdCategories.map(c=>c.value).join(","))),f.track(s,n,a)}convertToTimecode(e){if(!f.isValidTimeValue(e))return"";const t=1e3*e,r=Math.floor(t/36e5),a=Math.floor(t/6e4%60),s=Math.floor(t/1e3%60),o=Math.floor(t%1e3);return"".concat(f.addLeadingZeros(r,2),":").concat(f.addLeadingZeros(a,2),":").concat(f.addLeadingZeros(s,2),".").concat(f.addLeadingZeros(o,3))}progressFormatted(){return this.convertToTimecode(this.progress)}}exports._=ce;exports.z=ue;
@@ -1 +0,0 @@
1
- "use strict";const n=require("react"),E=require("react/jsx-runtime"),w=require("./useStreamLayerApp2.js"),f=({event:e,internal:r})=>{const o=m(),s=L();return n.useEffect(()=>(o&&(e&&(o.createEventSession(e,r),s&&(s.current=e)),!e&&s!=null&&s.current&&(o.createEventSession("",r),s.current="")),()=>{o&&o.disableApp()}),[e,r,s,o]),null};var h=(e=>(e[e.UNSET=0]="UNSET",e[e.CONNECTED=1]="CONNECTED",e[e.READY=2]="READY",e))(h||{});const x={status:0,sdk:null},i=n.createContext(x),N=({sdkKey:e,theme:r,themeMode:o,plugins:s,children:u,event:p,production:y=!0,autoEnable:C=!0,withAdNotification:S,withAd:A=!0,betPack:a=!1,hideFriends:D,skipOnboarding:c,friendsTab:v="enabled",onDeepLinkHandled:l,videoPlayerController:d,onContentActivate:K,containerId:b,webOS:P})=>{const t=w.$({sdkKey:e,plugins:s,production:y,autoEnable:C,onDeepLinkHandled:l,videoPlayerController:d,onContentActivate:K,hideFriends:D,skipOnboarding:c,withAdNotification:S,withAd:A,friendsTab:v,betPack:a,webOS:P}),k=n.useRef(""),g=n.useMemo(()=>t?{sdk:t,status:2,event:k}:{status:1,sdk:null,event:k},[t]);return n.useEffect(()=>{t&&(t.options.setKey("friendsTab",v),t.options.setKey("theme",r),t.options.setKey("themeMode",o),t.options.setKey("skipOnboarding",c),t.options.setKey("betPack",a),t.options.setKey("containerId",b))},[t,v,r,o,c,a,b]),n.useEffect(()=>()=>{l&&(t==null||t.removeDeepLinkHandler(l)),d&&(t==null||t.removeVideoPlayerController(d))},[t]),n.useEffect(()=>{localStorage.getItem("SL_DEBUG")&&console.log("StreamLayerProvider mounted with props:",{sdkKey:!!e,onDeepLinkHandled:!!l,videoPlayerController:!!d})},[e,l,d]),E.jsxs(i.Provider,{value:g,children:[p!==void 0&&E.jsx(f,{event:p}),u]})},m=()=>{const{sdk:e}=n.useContext(i);return e},L=()=>{const{event:e}=n.useContext(i);return e},O=()=>{const{sdk:e}=n.useContext(i),[r,o]=n.useState({});return n.useEffect(()=>{var s;return e!=null&&e.options?(s=e==null?void 0:e.options)==null?void 0:s.subscribe(u=>{o({theme:u.theme,themeMode:u.themeMode})}):()=>{}},[e==null?void 0:e.options]),r},T=()=>{const{sdk:e}=n.useContext(i),[r,o]=n.useState({});return n.useEffect(()=>e!=null&&e.uiState?e==null?void 0:e.uiState.subscribe(s=>{o({...s})}):()=>{},[e==null?void 0:e.uiState]),r};exports.B=m;exports.F=T;exports.Y=h;exports.c=i;exports.j=f;exports.q=N;exports.z=O;
@@ -1 +0,0 @@
1
- "use strict";let n=[],i=0;const r=4;let s=o=>{let l=[],e={get(){return e.lc||e.listen(()=>{})(),e.value},lc:0,listen(t){return e.lc=l.push(t),()=>{for(let f=i+r;f<n.length;)n[f]===t?n.splice(f,r):f+=r;let u=l.indexOf(t);~u&&(l.splice(u,1),--e.lc||e.off())}},notify(t,u){let f=!n.length;for(let v of l)n.push(v,e.value,t,u);if(f){for(i=0;i<n.length;i+=r)n[i](n[i+1],n[i+2],n[i+3]);n.length=0}},off(){},set(t){let u=e.value;u!==t&&(e.value=t,e.notify(u))},subscribe(t){let u=e.listen(t);return t(e.value),u},value:o};return e},a=(o={})=>{let l=s(o);return l.setKey=function(e,t){let u=l.value;typeof t>"u"&&e in l.value?(l.value={...l.value},delete l.value[e],l.notify(u,e)):l.value[e]!==t&&(l.value={...l.value,[e]:t},l.notify(u,e))},l};exports.a=s;exports.i=a;
@@ -1 +0,0 @@
1
- "use strict";function N(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:i.id||null,adId:i.adId||null,sequence:i.sequence||null,apiFramework:i.apiFramework||null,universalAdIds:[],creativeExtensions:[]}}const G=["ADCATEGORIES","ADCOUNT","ADPLAYHEAD","ADSERVINGID","ADTYPE","APIFRAMEWORKS","APPBUNDLE","ASSETURI","BLOCKEDADCATEGORIES","BREAKMAXADLENGTH","BREAKMAXADS","BREAKMAXDURATION","BREAKMINADLENGTH","BREAKMINDURATION","BREAKPOSITION","CLICKPOS","CLICKTYPE","CLIENTUA","CONTENTID","CONTENTPLAYHEAD","CONTENTURI","DEVICEIP","DEVICEUA","DOMAIN","EXTENSIONS","GDPRCONSENT","IFA","IFATYPE","INVENTORYSTATE","LATLONG","LIMITADTRACKING","MEDIAMIME","MEDIAPLAYHEAD","OMIDPARTNER","PAGEURL","PLACEMENTTYPE","PLAYERCAPABILITIES","PLAYERSIZE","PLAYERSTATE","PODSEQUENCE","REGULATIONS","SERVERSIDE","SERVERUA","TRANSACTIONID","UNIVERSALADID","VASTVERSIONS","VERIFICATIONVENDORS"];function w(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=[],a=M(i);!e.ERRORCODE||t.isCustomCode||/^[0-9]{3}$/.test(e.ERRORCODE)||(e.ERRORCODE=900),e.CACHEBUSTING=q(Math.round(1e8*Math.random())),e.TIMESTAMP=new Date().toISOString(),e.RANDOM=e.random=e.CACHEBUSTING;for(const s in e)e[s]=j(e[s]);for(const s in a){const o=a[s];typeof o=="string"&&r.push(B(o,e))}return r}function B(i,e){const t=(i=L(i,e)).match(/[^[\]]+(?=])/g);if(!t)return i;let r=t.filter(a=>G.indexOf(a)>-1);return r.length===0?i:(r=r.reduce((a,s)=>(a[s]=-1,a),{}),L(i,r))}function L(i,e){let t=i;for(const r in e){const a=e[r];t=t.replace(new RegExp("(?:\\[|%%)(".concat(r,")(?:\\]|%%)"),"g"),a)}return t}function M(i){return Array.isArray(i)?i.map(e=>e&&e.hasOwnProperty("url")?e.url:e):i}function C(i){return/^(https?:\/\/|\/\/)/.test(i)}function U(i,e){for(let t=0;t<e.length;t++)if(W(e[t],i))return!0;return!1}function W(i,e){if(i&&e){const t=Object.getOwnPropertyNames(i),r=Object.getOwnPropertyNames(e);return t.length===r.length&&i.id===e.id&&i.url===e.url}return!1}function j(i){return encodeURIComponent(i).replace(/[!'()*]/g,e=>"%".concat(e.charCodeAt(0).toString(16)))}function q(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8;return i.toString().padStart(e,"0")}const f={track:function(i,e,t){w(i,e,t).forEach(r=>{typeof window<"u"&&window!==null&&(new Image().src=r)})},resolveURLTemplates:w,extractURLsFromTemplates:M,filterUrlTemplates:function(i){return i.reduce((e,t)=>{const r=t.url||t;return C(r)?e.validUrls.push(r):e.invalidUrls.push(r),e},{validUrls:[],invalidUrls:[]})},containsTemplateObject:U,isTemplateObjectEqual:W,encodeURIComponentRFC3986:j,replaceUrlMacros:B,isNumeric:function(i){return!isNaN(parseFloat(i))&&isFinite(i)},flatten:function i(e){return e.reduce((t,r)=>t.concat(Array.isArray(r)?i(r):r),[])},joinArrayOfUniqueTemplateObjs:function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];const t=Array.isArray(i)?i:[],r=Array.isArray(e)?e:[];return t.concat(r).reduce((a,s)=>(U(s,a)||a.push(s),a),[])},isValidTimeValue:function(i){return Number.isFinite(i)&&i>=-2},addLeadingZeros:q,isValidUrl:C,isBrowserEnvironment:function(){return typeof window<"u"},formatMacrosValues:function(i){return typeof i!="object"?i:JSON.stringify(i)}};function I(i){return["true","TRUE","True","1"].includes(i)}function Y(i){if(i==null)return-1;if(f.isNumeric(i))return parseInt(i);const e=i.split(":");if(e.length!==3)return-1;const t=e[2].split(".");let r=parseInt(t[0]);t.length===2&&(r+=parseFloat("0.".concat(t[1])));const a=parseInt(60*e[1]),s=parseInt(60*e[0]*60);return isNaN(s)||isNaN(a)||isNaN(r)||a>3600||r>60?-1:s+a+r}const l={childByName:function(i,e){return Array.from(i.childNodes).find(t=>t.nodeName===e)},childrenByName:function(i,e){return Array.from(i.childNodes).filter(t=>t.nodeName===e)},resolveVastAdTagURI:function(i,e){if(!e)return i;if(i.startsWith("//")){const{protocol:t}=location;return"".concat(t).concat(i)}if(!i.includes("://")){const t=e.slice(0,e.lastIndexOf("/"));return"".concat(t,"/").concat(i)}return i},parseBoolean:I,parseNodeText:function(i){return i&&(i.textContent||i.text||"").trim()},copyNodeAttribute:function(i,e,t){const r=e.getAttribute(i);r&&t.setAttribute(i,r)},parseAttributes:function(i){return Array.from(i.attributes).reduce((e,t)=>(e[t.nodeName]=t.nodeValue,e),{})},parseDuration:Y,getStandAloneAds:function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).filter(i=>!parseInt(i.sequence,10))},getSortedAdPods:function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).filter(i=>parseInt(i.sequence,10)).sort((i,e)=>i.sequence-e.sequence)},assignAttributes:function(i,e){i&&Array.from(i).forEach(t=>{let{nodeName:r,nodeValue:a}=t;if(r&&a&&e.hasOwnProperty(r)){let s=a;typeof e[r]=="boolean"&&(s=I(s)),e[r]=s}})},mergeWrapperAdData:function(i,e){var t;i.errorURLTemplates=e.errorURLTemplates.concat(i.errorURLTemplates),i.impressionURLTemplates=e.impressionURLTemplates.concat(i.impressionURLTemplates),i.extensions=e.extensions.concat(i.extensions),e.viewableImpression.length>0&&(i.viewableImpression=[...i.viewableImpression,...e.viewableImpression]),i.followAdditionalWrappers=e.followAdditionalWrappers,i.allowMultipleAds=e.allowMultipleAds,i.fallbackOnNoAd=e.fallbackOnNoAd;const r=(e.creatives||[]).filter(n=>n&&n.type==="companion"),a=r.reduce((n,c)=>((c.variations||[]).forEach(u=>{(u.companionClickTrackingURLTemplates||[]).forEach(d=>{f.containsTemplateObject(d,n)||n.push(d)})}),n),[]);i.creatives=r.concat(i.creatives);const s=e.videoClickTrackingURLTemplates&&e.videoClickTrackingURLTemplates.length,o=e.videoCustomClickURLTemplates&&e.videoCustomClickURLTemplates.length;if(i.creatives.forEach(n=>{if(e.trackingEvents&&e.trackingEvents[n.type])for(const c in e.trackingEvents[n.type]){const u=e.trackingEvents[n.type][c];Array.isArray(n.trackingEvents[c])||(n.trackingEvents[c]=[]),n.trackingEvents[c]=n.trackingEvents[c].concat(u)}n.type==="linear"&&(s&&(n.videoClickTrackingURLTemplates=n.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates)),o&&(n.videoCustomClickURLTemplates=n.videoCustomClickURLTemplates.concat(e.videoCustomClickURLTemplates)),!e.videoClickThroughURLTemplate||n.videoClickThroughURLTemplate!==null&&n.videoClickThroughURLTemplate!==void 0||(n.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate)),n.type==="companion"&&a.length&&(n.variations||[]).forEach(c=>{c.companionClickTrackingURLTemplates=f.joinArrayOfUniqueTemplateObjs(c.companionClickTrackingURLTemplates,a)})}),e.adVerifications&&(i.adVerifications=i.adVerifications.concat(e.adVerifications)),e.blockedAdCategories&&(i.blockedAdCategories=i.blockedAdCategories.concat(e.blockedAdCategories)),(t=e.creatives)!==null&&t!==void 0&&t.length){const n=e.creatives.filter(c=>{var u;return((u=c.icons)===null||u===void 0?void 0:u.length)&&!c.mediaFiles.length});n.length&&(i.creatives=i.creatives.concat(n))}}};function Q(i,e){const t=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:a,adId:s,sequence:o,apiFramework:n}=N(r);return{id:a,adId:s,sequence:o,apiFramework:n,type:"companion",required:null,variations:[]}}(e);return t.required=i.getAttribute("required")||null,t.variations=l.childrenByName(i,"Companion").map(r=>{const a=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:n.id||null,adType:"companionAd",width:n.width||0,height:n.height||0,assetWidth:n.assetWidth||null,assetHeight:n.assetHeight||null,expandedWidth:n.expandedWidth||null,expandedHeight:n.expandedHeight||null,apiFramework:n.apiFramework||null,adSlotId:n.adSlotId||null,pxratio:n.pxratio||"1",renderingMode:n.renderingMode||"default",staticResources:[],htmlResources:[],iframeResources:[],adParameters:null,altText:null,companionClickThroughURLTemplate:null,companionClickTrackingURLTemplates:[],trackingEvents:{}}}(l.parseAttributes(r));a.htmlResources=l.childrenByName(r,"HTMLResource").reduce((n,c)=>{const u=l.parseNodeText(c);return u?n.concat(u):n},[]),a.iframeResources=l.childrenByName(r,"IFrameResource").reduce((n,c)=>{const u=l.parseNodeText(c);return u?n.concat(u):n},[]),a.staticResources=l.childrenByName(r,"StaticResource").reduce((n,c)=>{const u=l.parseNodeText(c);return u?n.concat({url:u,creativeType:c.getAttribute("creativeType")||null}):n},[]),a.altText=l.parseNodeText(l.childByName(r,"AltText"))||null;const s=l.childByName(r,"TrackingEvents");s&&l.childrenByName(s,"Tracking").forEach(n=>{const c=n.getAttribute("event"),u=l.parseNodeText(n);c&&u&&(Array.isArray(a.trackingEvents[c])||(a.trackingEvents[c]=[]),a.trackingEvents[c].push(u))}),a.companionClickTrackingURLTemplates=l.childrenByName(r,"CompanionClickTracking").map(n=>({id:n.getAttribute("id")||null,url:l.parseNodeText(n)})),a.companionClickThroughURLTemplate=l.parseNodeText(l.childByName(r,"CompanionClickThrough"))||null;const o=l.childByName(r,"AdParameters");return o&&(a.adParameters={value:l.parseNodeText(o),xmlEncoded:o.getAttribute("xmlEncoded")||null}),a}),t}function X(i,e){let t;const r=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:u,adId:d,sequence:g,apiFramework:m}=N(c);return{id:u,adId:d,sequence:g,apiFramework:m,type:"linear",duration:0,skipDelay:null,mediaFiles:[],mezzanine:null,interactiveCreativeFile:null,closedCaptionFiles:[],videoClickThroughURLTemplate:null,videoClickTrackingURLTemplates:[],videoCustomClickURLTemplates:[],adParameters:null,icons:[],trackingEvents:{}}}(e);r.duration=l.parseDuration(l.parseNodeText(l.childByName(i,"Duration")));const a=i.getAttribute("skipoffset");if(a==null)r.skipDelay=null;else if(a.charAt(a.length-1)==="%"&&r.duration!==-1){const c=parseInt(a,10);r.skipDelay=r.duration*(c/100)}else r.skipDelay=l.parseDuration(a);const s=l.childByName(i,"VideoClicks");if(s){const c=l.childByName(s,"ClickThrough");r.videoClickThroughURLTemplate=c?{id:c.getAttribute("id")||null,url:l.parseNodeText(c)}:null,l.childrenByName(s,"ClickTracking").forEach(u=>{r.videoClickTrackingURLTemplates.push({id:u.getAttribute("id")||null,url:l.parseNodeText(u)})}),l.childrenByName(s,"CustomClick").forEach(u=>{r.videoCustomClickURLTemplates.push({id:u.getAttribute("id")||null,url:l.parseNodeText(u)})})}const o=l.childByName(i,"AdParameters");o&&(r.adParameters={value:l.parseNodeText(o),xmlEncoded:o.getAttribute("xmlEncoded")||null}),l.childrenByName(i,"TrackingEvents").forEach(c=>{l.childrenByName(c,"Tracking").forEach(u=>{let d=u.getAttribute("event");const g=l.parseNodeText(u);if(d&&g){if(d==="progress"){if(t=u.getAttribute("offset"),!t)return;d=t.charAt(t.length-1)==="%"?"progress-".concat(t):"progress-".concat(l.parseDuration(t))}Array.isArray(r.trackingEvents[d])||(r.trackingEvents[d]=[]),r.trackingEvents[d].push(g)}})}),l.childrenByName(i,"MediaFiles").forEach(c=>{l.childrenByName(c,"MediaFile").forEach(h=>{r.mediaFiles.push(function(p){const v={id:null,fileURL:null,fileSize:0,deliveryType:"progressive",mimeType:null,mediaType:null,codec:null,bitrate:0,minBitrate:0,maxBitrate:0,width:0,height:0,apiFramework:null,scalable:null,maintainAspectRatio:null};v.id=p.getAttribute("id"),v.fileURL=l.parseNodeText(p),v.deliveryType=p.getAttribute("delivery"),v.codec=p.getAttribute("codec"),v.mimeType=p.getAttribute("type"),v.mediaType=p.getAttribute("mediaType")||"2D",v.apiFramework=p.getAttribute("apiFramework"),v.fileSize=parseInt(p.getAttribute("fileSize")||0),v.bitrate=parseInt(p.getAttribute("bitrate")||0),v.minBitrate=parseInt(p.getAttribute("minBitrate")||0),v.maxBitrate=parseInt(p.getAttribute("maxBitrate")||0),v.width=parseInt(p.getAttribute("width")||0),v.height=parseInt(p.getAttribute("height")||0);const R=p.getAttribute("scalable");R&&typeof R=="string"&&(v.scalable=l.parseBoolean(R));const A=p.getAttribute("maintainAspectRatio");return A&&typeof A=="string"&&(v.maintainAspectRatio=l.parseBoolean(A)),v}(h))});const u=l.childByName(c,"InteractiveCreativeFile");u&&(r.interactiveCreativeFile=function(h){const p=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{type:v.type||null,apiFramework:v.apiFramework||null,variableDuration:l.parseBoolean(v.variableDuration),fileURL:null}}(l.parseAttributes(h));return p.fileURL=l.parseNodeText(h),p}(u));const d=l.childByName(c,"ClosedCaptionFiles");d&&l.childrenByName(d,"ClosedCaptionFile").forEach(h=>{const p=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{type:v.type||null,language:v.language||null,fileURL:null}}(l.parseAttributes(h));p.fileURL=l.parseNodeText(h),r.closedCaptionFiles.push(p)});const g=l.childByName(c,"Mezzanine"),m=function(h,p){const v={};let R=!1;return p.forEach(A=>{h&&h.getAttribute(A)?v[A]=h.getAttribute(A):R=!0}),R?null:v}(g,["delivery","type","width","height"]);if(m){const h={id:null,fileURL:null,delivery:null,codec:null,type:null,width:0,height:0,fileSize:0,mediaType:"2D"};h.id=g.getAttribute("id"),h.fileURL=l.parseNodeText(g),h.delivery=m.delivery,h.codec=g.getAttribute("codec"),h.type=m.type,h.width=parseInt(m.width,10),h.height=parseInt(m.height,10),h.fileSize=parseInt(g.getAttribute("fileSize"),10),h.mediaType=g.getAttribute("mediaType")||"2D",r.mezzanine=h}});const n=l.childByName(i,"Icons");return n&&l.childrenByName(n,"Icon").forEach(c=>{r.icons.push(function(u){const d={program:null,height:0,width:0,xPosition:0,yPosition:0,apiFramework:null,offset:null,duration:0,type:null,staticResource:null,htmlResource:null,iframeResource:null,pxratio:"1",iconClickThroughURLTemplate:null,iconClickTrackingURLTemplates:[],iconViewTrackingURLTemplate:null,iconClickFallbackImages:[],altText:null,hoverText:null};d.program=u.getAttribute("program"),d.height=parseInt(u.getAttribute("height")||0),d.width=parseInt(u.getAttribute("width")||0),d.xPosition=function(m){return["left","right"].indexOf(m)!==-1?m:parseInt(m||0)}(u.getAttribute("xPosition")),d.yPosition=function(m){return["top","bottom"].indexOf(m)!==-1?m:parseInt(m||0)}(u.getAttribute("yPosition")),d.apiFramework=u.getAttribute("apiFramework"),d.pxratio=u.getAttribute("pxratio")||"1",d.offset=l.parseDuration(u.getAttribute("offset")),d.duration=l.parseDuration(u.getAttribute("duration")),d.altText=u.getAttribute("altText"),d.hoverText=u.getAttribute("hoverText"),l.childrenByName(u,"HTMLResource").forEach(m=>{d.type=m.getAttribute("creativeType")||"text/html",d.htmlResource=l.parseNodeText(m)}),l.childrenByName(u,"IFrameResource").forEach(m=>{d.type=m.getAttribute("creativeType")||0,d.iframeResource=l.parseNodeText(m)}),l.childrenByName(u,"StaticResource").forEach(m=>{d.type=m.getAttribute("creativeType")||0,d.staticResource=l.parseNodeText(m)});const g=l.childByName(u,"IconClicks");if(g){d.iconClickThroughURLTemplate=l.parseNodeText(l.childByName(g,"IconClickThrough")),l.childrenByName(g,"IconClickTracking").forEach(h=>{d.iconClickTrackingURLTemplates.push({id:h.getAttribute("id")||null,url:l.parseNodeText(h)})});const m=l.childByName(g,"IconClickFallbackImages");m&&l.childrenByName(m,"IconClickFallbackImage").forEach(h=>{d.iconClickFallbackImages.push({url:l.parseNodeText(h)||null,width:h.getAttribute("width")||null,height:h.getAttribute("height")||null})})}return d.iconViewTrackingURLTemplate=l.parseNodeText(l.childByName(u,"IconViewTracking")),d}(c))}),r}function Z(i,e){const t=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:a,adId:s,sequence:o,apiFramework:n}=N(r);return{id:a,adId:s,sequence:o,apiFramework:n,type:"nonlinear",variations:[],trackingEvents:{}}}(e);return l.childrenByName(i,"TrackingEvents").forEach(r=>{let a,s;l.childrenByName(r,"Tracking").forEach(o=>{a=o.getAttribute("event"),s=l.parseNodeText(o),a&&s&&(Array.isArray(t.trackingEvents[a])||(t.trackingEvents[a]=[]),t.trackingEvents[a].push(s))})}),l.childrenByName(i,"NonLinear").forEach(r=>{const a={id:null,width:0,height:0,expandedWidth:0,expandedHeight:0,scalable:!0,maintainAspectRatio:!0,minSuggestedDuration:0,apiFramework:"static",adType:"nonLinearAd",type:null,staticResource:null,htmlResource:null,iframeResource:null,nonlinearClickThroughURLTemplate:null,nonlinearClickTrackingURLTemplates:[],adParameters:null};a.id=r.getAttribute("id")||null,a.width=r.getAttribute("width"),a.height=r.getAttribute("height"),a.expandedWidth=r.getAttribute("expandedWidth"),a.expandedHeight=r.getAttribute("expandedHeight"),a.scalable=l.parseBoolean(r.getAttribute("scalable")),a.maintainAspectRatio=l.parseBoolean(r.getAttribute("maintainAspectRatio")),a.minSuggestedDuration=l.parseDuration(r.getAttribute("minSuggestedDuration")),a.apiFramework=r.getAttribute("apiFramework"),l.childrenByName(r,"HTMLResource").forEach(o=>{a.type=o.getAttribute("creativeType")||"text/html",a.htmlResource=l.parseNodeText(o)}),l.childrenByName(r,"IFrameResource").forEach(o=>{a.type=o.getAttribute("creativeType")||0,a.iframeResource=l.parseNodeText(o)}),l.childrenByName(r,"StaticResource").forEach(o=>{a.type=o.getAttribute("creativeType")||0,a.staticResource=l.parseNodeText(o)});const s=l.childByName(r,"AdParameters");s&&(a.adParameters={value:l.parseNodeText(s),xmlEncoded:s.getAttribute("xmlEncoded")||null}),a.nonlinearClickThroughURLTemplate=l.parseNodeText(l.childByName(r,"NonLinearClickThrough")),l.childrenByName(r,"NonLinearClickTracking").forEach(o=>{a.nonlinearClickTrackingURLTemplates.push({id:o.getAttribute("id")||null,url:l.parseNodeText(o)})}),t.variations.push(a)}),t}function x(i){const e=[];return i.forEach(t=>{const r=K(t);r&&e.push(r)}),e}function K(i){if(i.nodeName==="#comment")return null;const e={name:null,value:null,attributes:{},children:[]},t=i.attributes,r=i.childNodes;if(e.name=i.nodeName,i.attributes){for(const s in t)if(t.hasOwnProperty(s)){const o=t[s];o.nodeName&&o.nodeValue&&(e.attributes[o.nodeName]=o.nodeValue)}}for(const s in r)if(r.hasOwnProperty(s)){const o=K(r[s]);o&&e.children.push(o)}if(e.children.length===0||e.children.length===1&&["#cdata-section","#text"].indexOf(e.children[0].name)>=0){const s=l.parseNodeText(i);s!==""&&(e.value=s),e.children=[]}return(a=e).value===null&&Object.keys(a.attributes).length===0&&a.children.length===0?null:e;var a}function J(i){return i.getAttribute("AdID")||i.getAttribute("adID")||i.getAttribute("adId")||null}const y={Wrapper:{subElements:["VASTAdTagURI","Impression"]},BlockedAdCategories:{attributes:["authority"]},InLine:{subElements:["AdSystem","AdTitle","Impression","AdServingId","Creatives"]},Category:{attributes:["authority"]},Pricing:{attributes:["model","currency"]},Verification:{oneOfinLineResources:["JavaScriptResource","ExecutableResource"],attributes:["vendor"]},UniversalAdId:{attributes:["idRegistry"]},JavaScriptResource:{attributes:["apiFramework","browserOptional"]},ExecutableResource:{attributes:["apiFramework","type"]},Tracking:{attributes:["event"]},Creatives:{subElements:["Creative"]},Creative:{subElements:["UniversalAdId"]},Linear:{subElements:["MediaFiles","Duration"]},MediaFiles:{subElements:["MediaFile"]},MediaFile:{attributes:["delivery","type","width","height"]},Mezzanine:{attributes:["delivery","type","width","height"]},NonLinear:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},Companion:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},StaticResource:{attributes:["creativeType"]},Icons:{subElements:["Icon"]},Icon:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"]}};function S(i,e){if(!y[i.nodeName]||!y[i.nodeName].attributes)return;const t=y[i.nodeName].attributes.filter(r=>!i.getAttribute(r));t.length>0&&k({name:i.nodeName,parentName:i.parentNode.nodeName,attributes:t},e)}function V(i,e,t){const r=y[i.nodeName],a=!t&&i.nodeName!=="Wrapper";if(!(!r||a)){if(r.subElements){const s=r.subElements.filter(o=>!l.childByName(i,o));s.length>0&&k({name:i.nodeName,parentName:i.parentNode.nodeName,subElements:s},e)}!t||!r.oneOfinLineResources||r.oneOfinLineResources.some(s=>l.childByName(i,s))||k({name:i.nodeName,parentName:i.parentNode.nodeName,oneOfResources:r.oneOfinLineResources},e)}}function D(i){return i.children&&i.children.length!==0}function k(i,e){let{name:t,parentName:r,attributes:a,subElements:s,oneOfResources:o}=i,n="Element '".concat(t,"'");n+=a?" missing required attribute(s) '".concat(a.join(", "),"' "):s?" missing required sub element(s) '".concat(s.join(", "),"' "):o?" must provide one of the following '".concat(o.join(", "),"' "):" is empty",e("VAST-warning",{message:n,parentElement:r,specVersion:4.1})}const $={verifyRequiredValues:function i(e,t,r){if(e&&e.nodeName)if(e.nodeName==="InLine"&&(r=!0),S(e,t),D(e)){V(e,t,r);for(let a=0;a<e.children.length;a++)i(e.children[a],t,r)}else l.parseNodeText(e).length===0&&k({name:e.nodeName,parentName:e.parentNode.nodeName},t)},hasSubElements:D,emitMissingValueWarning:k,verifyRequiredAttributes:S,verifyRequiredSubElements:V};function ee(i,e){let{allowMultipleAds:t,followAdditionalWrappers:r}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const a=Array.from(i.childNodes).filter(s=>{const o=s.nodeName.toLowerCase();return o==="inline"||r!==!1&&o==="wrapper"});for(const s of a){if(l.copyNodeAttribute("id",i,s),l.copyNodeAttribute("sequence",i,s),l.copyNodeAttribute("adType",i,s),s.nodeName==="Wrapper")return{ad:re(s,e),type:"WRAPPER"};if(s.nodeName==="InLine")return{ad:te(s,e,{allowMultipleAds:t}),type:"INLINE"};const o=s.nodeName.toLowerCase();e("VAST-warning",{message:"<".concat(s.nodeName,o==="inline"?"> must be written <InLine>":"> must be written <Wrapper>"),wrongNode:s})}}function te(i,e){let{allowMultipleAds:t}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return t===!1&&i.getAttribute("sequence")?null:H(i,e)}function H(i,e){let t=[];e&&$.verifyRequiredValues(i,e);const r=Array.from(i.childNodes),a=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:s.id||null,sequence:s.sequence||null,adType:s.adType||null,adServingId:null,categories:[],expires:null,viewableImpression:[],system:null,title:null,description:null,advertiser:null,pricing:null,survey:null,errorURLTemplates:[],impressionURLTemplates:[],creatives:[],extensions:[],adVerifications:[],blockedAdCategories:[],followAdditionalWrappers:!0,allowMultipleAds:!1,fallbackOnNoAd:null}}(l.parseAttributes(i));return r.forEach(s=>{switch(s.nodeName){case"Error":a.errorURLTemplates.push(l.parseNodeText(s));break;case"Impression":a.impressionURLTemplates.push({id:s.getAttribute("id")||null,url:l.parseNodeText(s)});break;case"Creatives":a.creatives=function(o){const n=[];return o.forEach(c=>{const u={id:c.getAttribute("id")||null,adId:J(c),sequence:c.getAttribute("sequence")||null,apiFramework:c.getAttribute("apiFramework")||null},d=[];let g;l.childrenByName(c,"UniversalAdId").forEach(h=>{const p={idRegistry:h.getAttribute("idRegistry")||"unknown",value:l.parseNodeText(h)};d.push(p)});const m=l.childByName(c,"CreativeExtensions");m&&(g=x(l.childrenByName(m,"CreativeExtension")));for(const h in c.childNodes){const p=c.childNodes[h];let v;switch(p.nodeName){case"Linear":v=X(p,u);break;case"NonLinearAds":v=Z(p,u);break;case"CompanionAds":v=Q(p,u)}v&&(d&&(v.universalAdIds=d),g&&(v.creativeExtensions=g),n.push(v))}}),n}(l.childrenByName(s,"Creative"));break;case"Extensions":{const o=l.childrenByName(s,"Extension");a.extensions=x(o),a.adVerifications.length||(t=function(n){let c=null,u=[];return n.some(d=>c=l.childByName(d,"AdVerifications")),c&&(u=O(l.childrenByName(c,"Verification"))),u}(o));break}case"AdVerifications":a.adVerifications=O(l.childrenByName(s,"Verification"));break;case"AdSystem":a.system={value:l.parseNodeText(s),version:s.getAttribute("version")||null};break;case"AdTitle":a.title=l.parseNodeText(s);break;case"AdServingId":a.adServingId=l.parseNodeText(s);break;case"Category":a.categories.push({authority:s.getAttribute("authority")||null,value:l.parseNodeText(s)});break;case"Expires":a.expires=parseInt(l.parseNodeText(s),10);break;case"ViewableImpression":a.viewableImpression.push(function(o){const n=(c,u)=>{const d=l.parseNodeText(u);return d&&c.push(d),c};return{id:o.getAttribute("id")||null,viewable:l.childrenByName(o,"Viewable").reduce(n,[]),notViewable:l.childrenByName(o,"NotViewable").reduce(n,[]),viewUndetermined:l.childrenByName(o,"ViewUndetermined").reduce(n,[])}}(s));break;case"Description":a.description=l.parseNodeText(s);break;case"Advertiser":a.advertiser={id:s.getAttribute("id")||null,value:l.parseNodeText(s)};break;case"Pricing":a.pricing={value:l.parseNodeText(s),model:s.getAttribute("model")||null,currency:s.getAttribute("currency")||null};break;case"Survey":a.survey={value:l.parseNodeText(s),type:s.getAttribute("type")||null};break;case"BlockedAdCategories":a.blockedAdCategories.push({authority:s.getAttribute("authority")||null,value:l.parseNodeText(s)})}}),t.length&&(a.adVerifications=a.adVerifications.concat(t)),a}function re(i,e){const t=H(i,e),r=i.getAttribute("followAdditionalWrappers"),a=i.getAttribute("allowMultipleAds"),s=i.getAttribute("fallbackOnNoAd");t.followAdditionalWrappers=!r||l.parseBoolean(r),t.allowMultipleAds=!!a&&l.parseBoolean(a),t.fallbackOnNoAd=s?l.parseBoolean(s):null;let o=l.childByName(i,"VASTAdTagURI");if(o?t.nextWrapperURL=l.parseNodeText(o):(o=l.childByName(i,"VASTAdTagURL"),o&&(t.nextWrapperURL=l.parseNodeText(l.childByName(o,"URL")))),t.creatives.forEach(n=>{if(["linear","nonlinear"].includes(n.type)){if(n.trackingEvents){t.trackingEvents||(t.trackingEvents={}),t.trackingEvents[n.type]||(t.trackingEvents[n.type]={});for(const c in n.trackingEvents){const u=n.trackingEvents[c];Array.isArray(t.trackingEvents[n.type][c])||(t.trackingEvents[n.type][c]=[]),u.forEach(d=>{t.trackingEvents[n.type][c].push(d)})}}n.videoClickTrackingURLTemplates&&(Array.isArray(t.videoClickTrackingURLTemplates)||(t.videoClickTrackingURLTemplates=[]),n.videoClickTrackingURLTemplates.forEach(c=>{t.videoClickTrackingURLTemplates.push(c)})),n.videoClickThroughURLTemplate&&(t.videoClickThroughURLTemplate=n.videoClickThroughURLTemplate),n.videoCustomClickURLTemplates&&(Array.isArray(t.videoCustomClickURLTemplates)||(t.videoCustomClickURLTemplates=[]),n.videoCustomClickURLTemplates.forEach(c=>{t.videoCustomClickURLTemplates.push(c)}))}}),t.nextWrapperURL)return t}function O(i){const e=[];return i.forEach(t=>{const r={resource:null,vendor:null,browserOptional:!1,apiFramework:null,type:null,parameters:null,trackingEvents:{}},a=Array.from(t.childNodes);l.assignAttributes(t.attributes,r),a.forEach(o=>{let{nodeName:n,textContent:c,attributes:u}=o;switch(n){case"JavaScriptResource":case"ExecutableResource":r.resource=c.trim(),l.assignAttributes(u,r);break;case"VerificationParameters":r.parameters=c.trim()}});const s=l.childByName(t,"TrackingEvents");s&&l.childrenByName(s,"Tracking").forEach(o=>{const n=o.getAttribute("event"),c=l.parseNodeText(o);n&&c&&(Array.isArray(r.trackingEvents[n])||(r.trackingEvents[n]=[]),r.trackingEvents[n].push(c))}),e.push(r)}),e}class _{constructor(){this._handlers=[]}on(e,t){if(typeof t!="function")throw new TypeError("The handler argument must be of type Function. Received type ".concat(typeof t));if(!e)throw new TypeError("The event argument must be of type String. Received type ".concat(typeof e));return this._handlers.push({event:e,handler:t}),this}once(e,t){return this.on(e,function(r,a,s){const o={fired:!1,wrapFn:void 0};function n(){o.fired||(r.off(a,o.wrapFn),o.fired=!0,s.bind(r)(...arguments))}return o.wrapFn=n,n}(this,e,t))}off(e,t){return this._handlers=this._handlers.filter(r=>r.event!==e||r.handler!==t),this}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];let s=!1;return this._handlers.forEach(o=>{o.event==="*"&&(s=!0,o.handler(e,...r)),o.event===e&&(s=!0,o.handler(...r))}),s}removeAllListeners(e){return e?(this._handlers=this._handlers.filter(t=>t.event!==e),this):(this._handlers=[],this)}listenerCount(e){return this._handlers.filter(t=>t.event===e).length}listeners(e){return this._handlers.reduce((t,r)=>(r.event===e&&t.push(r.handler),t),[])}eventNames(){return this._handlers.map(e=>e.event)}}let F=0,E=0;const z=(i,e)=>{!i||!e||i<=0||e<=0||(E=(E*F+8*i/e)/++F)},ie={ERRORCODE:900,extensions:[]},P="VAST response version not supported";class ae extends _{constructor(){let{fetcher:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.maxWrapperDepth=null,this.rootErrorURLTemplates=[],this.errorURLTemplates=[],this.remainingAds=[],this.parsingOptions={},this.fetcher=e||null,this.keepFailedAdPod=!1}trackVastError(e,t){for(var r=arguments.length,a=new Array(r>2?r-2:0),s=2;s<r;s++)a[s-2]=arguments[s];this.emit("VAST-error",Object.assign({},ie,t,...a)),f.track(e,t)}getErrorURLTemplates(){return this.rootErrorURLTemplates.concat(this.errorURLTemplates)}getEstimatedBitrate(){return E}initParsingStatus(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.maxWrapperDepth=e.wrapperLimit||10,this.parsingOptions={allowMultipleAds:e.allowMultipleAds},this.keepFailedAdPod=e.keepFailedAdPod||!1,this.rootURL="",this.resetParsingStatus(),z(e.byteLength,e.requestDuration)}resetParsingStatus(){this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.vastVersion=null}getRemainingAds(e){if(this.remainingAds.length===0)return Promise.reject(new Error("No more ads are available for the given VAST"));const t=e?this.remainingAds:[this.remainingAds.shift()];return this.errorURLTemplates=[],this.resolveAds(t,{wrapperDepth:0,url:this.rootURL}).then(r=>this.buildVASTResponse(r))}parseVAST(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.initParsingStatus(t),t.isRootVAST=!0,this.parse(e,t).then(r=>this.buildVASTResponse(r))}buildVASTResponse(e){const t=function(r){let{ads:a,errorURLTemplates:s,version:o}=r;return{ads:a||[],errorURLTemplates:s||[],version:o||null}}({ads:e,errorURLTemplates:this.getErrorURLTemplates(),version:this.vastVersion});return this.completeWrapperResolving(t),t}parseVastXml(e,t){let{isRootVAST:r=!1,url:a=null,wrapperDepth:s=0,allowMultipleAds:o,followAdditionalWrappers:n}=t;if(!e||!e.documentElement||e.documentElement.nodeName!=="VAST"){var c;this.emit("VAST-ad-parsed",{type:"ERROR",url:a,wrapperDepth:s});const m=(e==null||(c=e.documentElement)===null||c===void 0?void 0:c.nodeName)==="VideoAdServingTemplate";throw new Error(m?P:"Invalid VAST XMLDocument")}const u=[],d=e.documentElement.childNodes,g=e.documentElement.getAttribute("version");r&&g&&(this.vastVersion=g);for(const m in d){const h=d[m];if(h.nodeName==="Error"){const p=l.parseNodeText(h);r?this.rootErrorURLTemplates.push(p):this.errorURLTemplates.push(p)}else if(h.nodeName==="Ad"){if(this.vastVersion&&parseFloat(this.vastVersion)<3)o=!0;else if(o===!1&&u.length>1)break;const p=ee(h,this.emit.bind(this),{allowMultipleAds:o,followAdditionalWrappers:n});p.ad?(u.push(p.ad),this.emit("VAST-ad-parsed",{type:p.type,url:a,wrapperDepth:s,adIndex:u.length-1,vastVersion:g})):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}return u}parse(e){let{url:t=null,resolveAll:r=!0,wrapperSequence:a=null,previousUrl:s=null,wrapperDepth:o=0,isRootVAST:n=!1,followAdditionalWrappers:c,allowMultipleAds:u}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=[];this.vastVersion&&parseFloat(this.vastVersion)<3&&n&&(u=!0);try{d=this.parseVastXml(e,{isRootVAST:n,url:t,wrapperDepth:o,allowMultipleAds:u,followAdditionalWrappers:c})}catch(g){return Promise.reject(g)}if(d.length===1&&a!=null&&(d[0].sequence=a),r===!1){const g=l.getSortedAdPods(d),m=l.getStandAloneAds(d);g.length?d=g:m.length&&(d=[m.shift()]),this.remainingAds=m}return this.resolveAds(d,{wrapperDepth:o,previousUrl:s,url:t})}resolveAds(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],{wrapperDepth:t,previousUrl:r,url:a}=arguments.length>1?arguments[1]:void 0;const s=[];return r=a,e.forEach(o=>{const n=this.resolveWrappers(o,t,r);s.push(n)}),Promise.all(s).then(o=>f.flatten(o))}resolveWrappers(e,t,r){const a={...e};return new Promise(s=>{var o;if(t++,!a.nextWrapperURL)return delete a.nextWrapperURL,s(a);if(!this.fetcher)return a.VASTAdTagURI=a.nextWrapperURL,delete a.nextWrapperURL,s(a);if(t>=this.maxWrapperDepth)return a.errorCode=302,delete a.nextWrapperURL,s(a);a.nextWrapperURL=l.resolveVastAdTagURI(a.nextWrapperURL,r);const n=(o=this.parsingOptions.allowMultipleAds)!==null&&o!==void 0?o:a.allowMultipleAds,c=a.sequence;this.fetcher.fetchVAST({url:a.nextWrapperURL,emitter:this.emit.bind(this),maxWrapperDepth:this.maxWrapperDepth}).then(u=>this.parse(u,{url:a.nextWrapperURL,previousUrl:r,wrapperSequence:c,wrapperDepth:t,followAdditionalWrappers:a.followAdditionalWrappers,allowMultipleAds:n}).then(d=>{if(delete a.nextWrapperURL,d.length===0)return a.creatives=[],s(a);d.forEach(g=>{g&&l.mergeWrapperAdData(g,a)}),s(d)})).catch(u=>{a.errorCode=u.message===P?102:301,a.errorMessage=u.message,s(a)})})}completeWrapperResolving(e){if(e.ads.length===0)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(let t=e.ads.length-1;t>=0;t--){const r=e.ads[t],a=!r.creatives.some(s=>{var o,n;return((o=s.mediaFiles)===null||o===void 0?void 0:o.length)>0||((n=s.variations)===null||n===void 0?void 0:n.length)>0});!r.errorCode&&!a||r.VASTAdTagURI||(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),this.keepFailedAdPod&&r.sequence?r.hasFailed=!0:e.ads.splice(t,1))}}}let T=null;const se={data:{},length:0,getItem(i){return this.data[i]},setItem(i,e){this.data[i]=e,this.length=Object.keys(this.data).length},removeItem(i){delete this.data[i],this.length=Object.keys(this.data).length},clear(){this.data={},this.length=0}};class ne{constructor(){this.storage=this.initStorage()}initStorage(){if(T)return T;try{T=typeof window<"u"&&window!==null?window.localStorage||window.sessionStorage:null}catch{T=null}return T&&!this.isStorageDisabled(T)||(T=se,T.clear()),T}isStorageDisabled(e){const t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch{return!0}return e.removeItem(t),!1}getItem(e){return this.storage.getItem(e)}setItem(e,t){return this.storage.setItem(e,t)}removeItem(e){return this.storage.removeItem(e)}clear(){return this.storage.clear()}}const b=12e4,oe={get:async function(i,e){try{const t=new AbortController,r=setTimeout(()=>{throw t.abort(),new Error("URLHandler: Request timed out after ".concat(e.timeout||b," ms (408)"))},e.timeout||b),a=await fetch(i,{...e,signal:t.signal,credentials:e.withCredentials?"include":"omit"}).finally(()=>{clearTimeout(r)}),s=function(o){return f.isBrowserEnvironment()&&window.location.protocol==="https:"&&o.url.includes("http://")?"URLHandler: Cannot go from HTTPS to HTTP.":o.status===200&&o.ok?null:"URLHandler: ".concat(o.statusText," (").concat(o.status,")")}(a);return s?{error:new Error(s),statusCode:a.status}:async function(o){const n=await o.text();let c;return c=f.isBrowserEnvironment()?new DOMParser:new(await Promise.resolve().then(()=>require("./index6.js")).then(u=>u.index)).DOMParser,{xml:c.parseFromString(n,"text/xml"),details:{byteLength:n.length,statusCode:o.status,rawXml:n}}}(a)}catch(t){return{error:t,statusCode:t.name==="AbortError"?408:null}}}};class le{constructor(){this.URLTemplateFilters=[]}setOptions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.urlHandler=e.urlHandler||e.urlhandler||oe,this.fetchingOptions={...e.fetchOptions,timeout:e.timeout||b,withCredentials:!!e.withCredentials}}addURLTemplateFilter(e){typeof e=="function"&&this.URLTemplateFilters.push(e)}removeLastURLTemplateFilter(){this.URLTemplateFilters.pop()}countURLTemplateFilters(){return this.URLTemplateFilters.length}clearURLTemplateFilters(){this.URLTemplateFilters=[]}async fetchVAST(e){var t;let{url:r,maxWrapperDepth:a,emitter:s,wrapperDepth:o=0,previousUrl:n=null,wrapperAd:c=null}=e;const u=Date.now();this.URLTemplateFilters.forEach(m=>{r=m(r)}),s("VAST-resolving",{url:r,previousUrl:n,wrapperDepth:o,maxWrapperDepth:a,timeout:this.fetchingOptions.timeout,wrapperAd:c});const d=await this.urlHandler.get(r,this.fetchingOptions),g=Math.round(Date.now()-u);if(s("VAST-resolved",{url:r,previousUrl:n,wrapperDepth:o,error:(d==null?void 0:d.error)||null,duration:g,statusCode:(d==null?void 0:d.statusCode)||null,...d==null?void 0:d.details}),z(d==null||(t=d.details)===null||t===void 0?void 0:t.byteLength,g),d.error)throw new Error(d.error);return d.xml}}class ce{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new ne;this.cappingFreeLunch=e,this.cappingMinimumTimeInterval=t,this.fetcher=new le,this.vastParser=new ae({fetcher:this.fetcher}),this.storage=r,this.lastSuccessfulAd===void 0&&(this.lastSuccessfulAd=0),this.totalCalls===void 0&&(this.totalCalls=0),this.totalCallsTimeout===void 0&&(this.totalCallsTimeout=0)}addURLTemplateFilter(e){this.fetcher.addURLTemplateFilter(e)}removeLastURLTemplateFilter(){this.fetcher.removeLastURLTemplateFilter()}countURLTemplateFilters(){return this.fetcher.countURLTemplateFilters()}clearURLTemplateFilters(){this.fetcher.clearURLTemplateFilters()}getParser(){return this.vastParser}get lastSuccessfulAd(){return this.storage.getItem("vast-client-last-successful-ad")}set lastSuccessfulAd(e){this.storage.setItem("vast-client-last-successful-ad",e)}get totalCalls(){return this.storage.getItem("vast-client-total-calls")}set totalCalls(e){this.storage.setItem("vast-client-total-calls",e)}get totalCallsTimeout(){return this.storage.getItem("vast-client-total-calls-timeout")}set totalCallsTimeout(e){this.storage.setItem("vast-client-total-calls-timeout",e)}hasRemainingAds(){return this.vastParser.remainingAds.length>0}getNextAds(e){return this.vastParser.getRemainingAds(e)}parseVAST(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.fetcher.setOptions(t),this.vastParser.parseVAST(e,t)}get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=Date.now();return t.hasOwnProperty("resolveAll")||(t.resolveAll=!1),this.totalCallsTimeout<r?(this.totalCalls=1,this.totalCallsTimeout=r+36e5):this.totalCalls++,new Promise((a,s)=>{if(this.cappingFreeLunch>=this.totalCalls)return s(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(this.totalCalls,"/").concat(this.cappingFreeLunch)));const o=r-this.lastSuccessfulAd;if(o<0)this.lastSuccessfulAd=0;else if(o<this.cappingMinimumTimeInterval)return s(new Error("VAST call canceled – (".concat(this.cappingMinimumTimeInterval,")ms minimum interval reached")));this.vastParser.initParsingStatus(t),this.fetcher.setOptions(t),this.vastParser.rootURL=e,this.fetcher.fetchVAST({url:e,emitter:this.vastParser.emit.bind(this.vastParser),maxWrapperDepth:this.vastParser.maxWrapperDepth}).then(n=>(t.previousUrl=e,t.isRootVAST=!0,t.url=e,this.vastParser.parse(n,t).then(c=>{const u=this.vastParser.buildVASTResponse(c);a(u)}))).catch(n=>s(n))})}}class ue extends _{constructor(e,t,r){var a;let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,o=arguments.length>4&&arguments[4]!==void 0&&arguments[4];super(),this.ad=t,this.creative=r,this.variation=s,this.muted=o,this.impressed=!1,this.skippable=!1,this.trackingEvents={},this.trackedProgressEvents=[],this.lastPercentage=0,this._alreadyTriggeredQuartiles={},this.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"];for(const n in this.creative.trackingEvents){const c=this.creative.trackingEvents[n];this.trackingEvents[n]=c.slice(0)}this.viewableImpressionTrackers=((a=this.ad.viewableImpression)===null||a===void 0?void 0:a.reduce((n,c)=>(n.notViewable.push(...c.notViewable),n.viewUndetermined.push(...c.viewUndetermined),n.viewable.push(...c.viewable),n),{notViewable:[],viewUndetermined:[],viewable:[]}))||{},Object.entries(this.viewableImpressionTrackers).forEach(n=>{let[c,u]=n;u.length&&(this.trackingEvents[c]=u)}),function(n){return n.type==="linear"}(this.creative)?this._initLinearTracking():this._initVariationTracking(),e&&this.on("start",()=>{e.lastSuccessfulAd=Date.now()})}_initLinearTracking(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}_initVariationTracking(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(const e in this.variation.trackingEvents){const t=this.variation.trackingEvents[e];this.trackingEvents[e]?this.trackingEvents[e]=this.trackingEvents[e].concat(t.slice(0)):this.trackingEvents[e]=t.slice(0)}this.variation.adType==="nonLinearAd"?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):function(e){return e.adType==="companionAd"}(this.variation)&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}setDuration(e){f.isValidTimeValue(e)?(this.assetDuration=e,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}):this.emit("TRACKER-error",{message:"the duration provided is not valid. duration: ".concat(e)})}setProgress(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(!f.isValidTimeValue(e)||typeof t!="object")return void this.emit("TRACKER-error",{message:"One given setProgress parameter has the wrong type. progress: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))});const a=this.skipDelay||-1;if(a===-1||this.skippable||(a>e?this.emit("skip-countdown",a-e):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){const s=Math.round(e/this.assetDuration*100),o=[];if(e>0){o.push("start");for(let n=this.lastPercentage;n<s;n++)o.push("progress-".concat(n+1,"%"));o.push("progress-".concat(e));for(const n in this.quartiles)this.isQuartileReached(n,this.quartiles[n],e)&&(o.push(n),this._alreadyTriggeredQuartiles[n]=!0);this.lastPercentage=s}o.forEach(n=>{this.track(n,{macros:t,once:r})}),e<this.progress&&(this.track("rewind",{macros:t}),this.trackedProgressEvents&&this.trackedProgressEvents.splice(0))}this.progress=e}isQuartileReached(e,t,r){let a=!1;return t<=r&&!this._alreadyTriggeredQuartiles[e]&&(a=!0),a}setMuted(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="boolean"&&typeof t=="object"?(this.muted!==e&&this.track(e?"mute":"unmute",{macros:t}),this.muted=e):this.emit("TRACKER-error",{message:"One given setMuted parameter has the wrong type. muted: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}setPaused(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="boolean"&&typeof t=="object"?(this.paused!==e&&this.track(e?"pause":"resume",{macros:t}),this.paused=e):this.emit("TRACKER-error",{message:"One given setPaused parameter has the wrong type. paused: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}setFullscreen(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="boolean"&&typeof t=="object"?(this.fullscreen!==e&&this.track(e?"fullscreen":"exitFullscreen",{macros:t}),this.fullscreen=e):this.emit("TRACKER-error",{message:"One given setFullScreen parameter has the wrong type. fullscreen: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}setExpand(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="boolean"&&typeof t=="object"?(this.expanded!==e&&(this.track(e?"expand":"collapse",{macros:t}),this.track(e?"playerExpand":"playerCollapse",{macros:t})),this.expanded=e):this.emit("TRACKER-error",{message:"One given setExpand parameter has the wrong type. expanded: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}setSkipDelay(e){f.isValidTimeValue(e)?this.skipDelay=e:this.emit("TRACKER-error",{message:"setSkipDelay parameter does not have a valid value. duration: ".concat(e)})}trackImpression(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.impressed||(this.impressed=!0,this.trackURLs(this.ad.impressionURLTemplates,e),this.track("creativeView",{macros:e})):this.emit("TRACKER-error",{message:"trackImpression parameter has the wrong type. macros: ".concat(e)})}trackViewableImpression(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="object"?this.track("viewable",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackViewableImpression given macros has the wrong type. macros: ".concat(e)})}trackNotViewableImpression(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="object"?this.track("notViewable",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackNotViewableImpression given macros has the wrong type. macros: ".concat(e)})}trackUndeterminedImpression(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="object"?this.track("viewUndetermined",{macros:e,once:t}):this.emit("TRACKER-error",{message:"trackUndeterminedImpression given macros has the wrong type. macros: ".concat(e)})}error(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="object"&&typeof t=="boolean"?this.trackURLs(this.ad.errorURLTemplates,e,{isCustomCode:t}):this.emit("TRACKER-error",{message:"One given error parameter has the wrong type. macros: ".concat(f.formatMacrosValues(e),", isCustomCode: ").concat(t)})}errorWithCode(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];typeof e=="string"&&typeof t=="boolean"?(this.error({ERRORCODE:e},t),console.log("The method errorWithCode is deprecated, please use vast tracker error method instead")):this.emit("TRACKER-error",{message:"One given errorWithCode parameter has the wrong type. errorCode: ".concat(e,", isCustomCode: ").concat(t)})}complete(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("complete",{macros:e}):this.emit("TRACKER-error",{message:"complete given macros has the wrong type. macros: ".concat(e)})}notUsed(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?(this.track("notUsed",{macros:e}),this.trackingEvents=[]):this.emit("TRACKER-error",{message:"notUsed given macros has the wrong type. macros: ".concat(e)})}otherAdInteraction(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("otherAdInteraction",{macros:e}):this.emit("TRACKER-error",{message:"otherAdInteraction given macros has the wrong type. macros: ".concat(e)})}acceptInvitation(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("acceptInvitation",{macros:e}):this.emit("TRACKER-error",{message:"acceptInvitation given macros has the wrong type. macros: ".concat(e)})}adExpand(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("adExpand",{macros:e}):this.emit("TRACKER-error",{message:"adExpand given macros has the wrong type. macros: ".concat(e)})}adCollapse(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("adCollapse",{macros:e}):this.emit("TRACKER-error",{message:"adCollapse given macros has the wrong type. macros: ".concat(e)})}minimize(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("minimize",{macros:e}):this.emit("TRACKER-error",{message:"minimize given macros has the wrong type. macros: ".concat(e)})}verificationNotExecuted(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof e!="string"||typeof t!="object")return void this.emit("TRACKER-error",{message:"One given verificationNotExecuted parameter has to wrong type. vendor: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))});if(!this.ad||!this.ad.adVerifications||!this.ad.adVerifications.length)throw new Error("No adVerifications provided");if(!e)throw new Error("No vendor provided, unable to find associated verificationNotExecuted");const r=this.ad.adVerifications.find(s=>s.vendor===e);if(!r)throw new Error("No associated verification element found for vendor: ".concat(e));const a=r.trackingEvents;if(a&&a.verificationNotExecuted){const s=a.verificationNotExecuted;this.trackURLs(s,t),this.emit("verificationNotExecuted",{trackingURLTemplates:s})}}overlayViewDuration(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="string"&&typeof t=="object"?(t.ADPLAYHEAD=e,this.track("overlayViewDuration",{macros:t})):this.emit("TRACKER-error",{message:"One given overlayViewDuration parameters has the wrong type. formattedDuration: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))})}close(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track(this.linear?"closeLinear":"close",{macros:e}):this.emit("TRACKER-error",{message:"close given macros has the wrong type. macros: ".concat(e)})}skip(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("skip",{macros:e}):this.emit("TRACKER-error",{message:"skip given macros has the wrong type. macros: ".concat(e)})}load(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};typeof e=="object"?this.track("loaded",{macros:e}):this.emit("TRACKER-error",{message:"load given macros has the wrong type. macros: ".concat(e)})}click(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==null&&typeof e!="string"||typeof t!="object")return void this.emit("TRACKER-error",{message:"One given click parameter has the wrong type. fallbackClickThroughURL: ".concat(e,", macros: ").concat(f.formatMacrosValues(t))});this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates,t);const r=this.clickThroughURLTemplate||e,a={...t};if(r){this.progress&&(a.ADPLAYHEAD=this.progressFormatted());const s=f.resolveURLTemplates([r],a)[0];this.emit("clickthrough",s)}}trackProgressEvents(e,t,r){const a=parseFloat(e.split("-")[1]);Object.entries(this.trackingEvents).filter(s=>{let[o]=s;return o.startsWith("progress-")}).map(s=>{let[o,n]=s;return{name:o,time:parseFloat(o.split("-")[1]),urls:n}}).filter(s=>{let{time:o}=s;return o<=a&&o>this.progress}).forEach(s=>{let{name:o,urls:n}=s;!r&&this.trackedProgressEvents.includes(o)||(this.emit(o,{trackingURLTemplates:n}),this.trackURLs(n,t),r?delete this.trackingEvents[o]:this.trackedProgressEvents.push(o))})}track(e){let{macros:t={},once:r=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof t!="object")return void this.emit("TRACKER-error",{message:"track given macros has the wrong type. macros: ".concat(t)});e==="closeLinear"&&!this.trackingEvents[e]&&this.trackingEvents.close&&(e="close"),e.startsWith("progress-")&&!e.endsWith("%")&&this.trackProgressEvents(e,t,r);const a=this.trackingEvents[e],s=this.emitAlwaysEvents.indexOf(e)>-1;a?(this.emit(e,{trackingURLTemplates:a}),this.trackURLs(a,t)):s&&this.emit(e,null),r&&(delete this.trackingEvents[e],s&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e),1))}trackURLs(e){var t;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const{validUrls:s,invalidUrls:o}=f.filterUrlTemplates(e);o.length&&this.emit("TRACKER-error",{message:"Provided urls are malformed. url: ".concat(o)});const n={...r};this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(n.ASSETURI=this.creative.mediaFiles[0].fileURL),this.progress&&(n.ADPLAYHEAD=this.progressFormatted())),(t=this.creative)!==null&&t!==void 0&&(t=t.universalAdIds)!==null&&t!==void 0&&t.length&&(n.UNIVERSALADID=this.creative.universalAdIds.map(c=>c.idRegistry.concat(" ",c.value)).join(",")),this.ad&&(this.ad.sequence&&(n.PODSEQUENCE=this.ad.sequence),this.ad.adType&&(n.ADTYPE=this.ad.adType),this.ad.adServingId&&(n.ADSERVINGID=this.ad.adServingId),this.ad.categories&&this.ad.categories.length&&(n.ADCATEGORIES=this.ad.categories.map(c=>c.value).join(",")),this.ad.blockedAdCategories&&this.ad.blockedAdCategories.length&&(n.BLOCKEDADCATEGORIES=this.ad.blockedAdCategories.map(c=>c.value).join(","))),f.track(s,n,a)}convertToTimecode(e){if(!f.isValidTimeValue(e))return"";const t=1e3*e,r=Math.floor(t/36e5),a=Math.floor(t/6e4%60),s=Math.floor(t/1e3%60),o=Math.floor(t%1e3);return"".concat(f.addLeadingZeros(r,2),":").concat(f.addLeadingZeros(a,2),":").concat(f.addLeadingZeros(s,2),".").concat(f.addLeadingZeros(o,3))}progressFormatted(){return this.convertToTimecode(this.progress)}}exports._=ce;exports.z=ue;
@@ -1,98 +0,0 @@
1
- import { createContext as P, useEffect as s, useRef as g, useMemo as w, useContext as u, useState as h } from "react";
2
- import { jsxs as N, jsx as O } from "react/jsx-runtime";
3
- import { $ as T } from "./useStreamLayerApp2.js";
4
- const L = ({
5
- event: e,
6
- internal: r
7
- }) => {
8
- const n = H(), o = j();
9
- return s(() => (n && (e && (n.createEventSession(e, r), o && (o.current = e)), !e && o != null && o.current && (n.createEventSession("", r), o.current = "")), () => {
10
- n && n.disableApp();
11
- }), [e, r, o, n]), null;
12
- };
13
- var x = /* @__PURE__ */ ((e) => (e[e.UNSET = 0] = "UNSET", e[e.CONNECTED = 1] = "CONNECTED", e[e.READY = 2] = "READY", e))(x || {});
14
- const M = {
15
- status: 0,
16
- sdk: null
17
- }, d = P(M), U = ({
18
- sdkKey: e,
19
- theme: r,
20
- themeMode: n,
21
- plugins: o,
22
- children: a,
23
- event: m,
24
- production: y = !0,
25
- autoEnable: E = !0,
26
- withAdNotification: C,
27
- withAd: S = !0,
28
- betPack: c = !1,
29
- hideFriends: f,
30
- skipOnboarding: p,
31
- friendsTab: v = "enabled",
32
- onDeepLinkHandled: i,
33
- videoPlayerController: l,
34
- onContentActivate: A,
35
- containerId: b,
36
- webOS: D
37
- }) => {
38
- const t = T({
39
- sdkKey: e,
40
- plugins: o,
41
- production: y,
42
- autoEnable: E,
43
- onDeepLinkHandled: i,
44
- videoPlayerController: l,
45
- onContentActivate: A,
46
- hideFriends: f,
47
- skipOnboarding: p,
48
- withAdNotification: C,
49
- withAd: S,
50
- friendsTab: v,
51
- betPack: c,
52
- webOS: D
53
- }), k = g(""), K = w(() => t ? { sdk: t, status: 2, event: k } : { status: 1, sdk: null, event: k }, [t]);
54
- return s(() => {
55
- t && (t.options.setKey("friendsTab", v), t.options.setKey("theme", r), t.options.setKey("themeMode", n), t.options.setKey("skipOnboarding", p), t.options.setKey("betPack", c), t.options.setKey("containerId", b));
56
- }, [t, v, r, n, p, c, b]), s(() => () => {
57
- i && (t == null || t.removeDeepLinkHandler(i)), l && (t == null || t.removeVideoPlayerController(l));
58
- }, [t]), s(() => {
59
- localStorage.getItem("SL_DEBUG") && console.log("StreamLayerProvider mounted with props:", {
60
- sdkKey: !!e,
61
- onDeepLinkHandled: !!i,
62
- videoPlayerController: !!l
63
- });
64
- }, [e, i, l]), /* @__PURE__ */ N(d.Provider, { value: K, children: [
65
- m !== void 0 && /* @__PURE__ */ O(L, { event: m }),
66
- a
67
- ] });
68
- }, H = () => {
69
- const { sdk: e } = u(d);
70
- return e;
71
- }, j = () => {
72
- const { event: e } = u(d);
73
- return e;
74
- }, Y = () => {
75
- const { sdk: e } = u(d), [r, n] = h({});
76
- return s(() => {
77
- var o;
78
- return e != null && e.options ? (o = e == null ? void 0 : e.options) == null ? void 0 : o.subscribe((a) => {
79
- n({ theme: a.theme, themeMode: a.themeMode });
80
- }) : () => {
81
- };
82
- }, [e == null ? void 0 : e.options]), r;
83
- }, B = () => {
84
- const { sdk: e } = u(d), [r, n] = h({});
85
- return s(() => e != null && e.uiState ? e == null ? void 0 : e.uiState.subscribe((o) => {
86
- n({ ...o });
87
- }) : () => {
88
- }, [e == null ? void 0 : e.uiState]), r;
89
- };
90
- export {
91
- H as B,
92
- B as F,
93
- x as Y,
94
- d as c,
95
- L as j,
96
- U as q,
97
- Y as z
98
- };
@@ -1,65 +0,0 @@
1
- let n = [], f = 0;
2
- const r = 4;
3
- let s = (o) => {
4
- let l = [], e = {
5
- get() {
6
- return e.lc || e.listen(() => {
7
- })(), e.value;
8
- },
9
- lc: 0,
10
- listen(t) {
11
- return e.lc = l.push(t), () => {
12
- for (let i = f + r; i < n.length; )
13
- n[i] === t ? n.splice(i, r) : i += r;
14
- let u = l.indexOf(t);
15
- ~u && (l.splice(u, 1), --e.lc || e.off());
16
- };
17
- },
18
- notify(t, u) {
19
- let i = !n.length;
20
- for (let v of l)
21
- n.push(
22
- v,
23
- e.value,
24
- t,
25
- u
26
- );
27
- if (i) {
28
- for (f = 0; f < n.length; f += r)
29
- n[f](
30
- n[f + 1],
31
- n[f + 2],
32
- n[f + 3]
33
- );
34
- n.length = 0;
35
- }
36
- },
37
- /* It will be called on last listener unsubscribing.
38
- We will redefine it in onMount and onStop. */
39
- off() {
40
- },
41
- set(t) {
42
- let u = e.value;
43
- u !== t && (e.value = t, e.notify(u));
44
- },
45
- subscribe(t) {
46
- let u = e.listen(t);
47
- return t(e.value), u;
48
- },
49
- value: o
50
- };
51
- return e;
52
- }, a = (o = {}) => {
53
- let l = s(o);
54
- return l.setKey = function(e, t) {
55
- let u = l.value;
56
- typeof t > "u" && e in l.value ? (l.value = { ...l.value }, delete l.value[e], l.notify(u, e)) : l.value[e] !== t && (l.value = {
57
- ...l.value,
58
- [e]: t
59
- }, l.notify(u, e));
60
- }, l;
61
- };
62
- export {
63
- s as a,
64
- a as i
65
- };