@hopeplayer/core 1.0.10 → 1.0.12

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 (56) hide show
  1. package/dist/HopePlayerElement.d.ts +44 -0
  2. package/dist/HopePlayerElement.d.ts.map +1 -1
  3. package/dist/chunks/index-Br_RybXV.js +835 -0
  4. package/dist/chunks/index-Br_RybXV.js.map +1 -0
  5. package/dist/chunks/{index-DJZjHaLs.js → index-C3s21eZa.js} +2 -2
  6. package/dist/chunks/{index-DJZjHaLs.js.map → index-C3s21eZa.js.map} +1 -1
  7. package/dist/chunks/{index-Bqs23yk7.js → index-D2aXO0eh.js} +744 -399
  8. package/dist/chunks/index-D2aXO0eh.js.map +1 -0
  9. package/dist/chunks/{index-BJxXxr0g.js → index-DBwvWiuK.js} +2 -2
  10. package/dist/chunks/{index-BJxXxr0g.js.map → index-DBwvWiuK.js.map} +1 -1
  11. package/dist/chunks/index-DCXX1ZJG.js +108 -0
  12. package/dist/chunks/index-DCXX1ZJG.js.map +1 -0
  13. package/dist/chunks/{index-CJ3wYSlU.js → index-_-pYIxvh.js} +2 -2
  14. package/dist/chunks/{index-CJ3wYSlU.js.map → index-_-pYIxvh.js.map} +1 -1
  15. package/dist/chunks/{index-DN077Bbe.js → index-adiWYyto.js} +2 -2
  16. package/dist/chunks/{index-DN077Bbe.js.map → index-adiWYyto.js.map} +1 -1
  17. package/dist/chunks/{index-i8eKCN8V.js → index-nvfNBIM_.js} +2 -2
  18. package/dist/chunks/{index-i8eKCN8V.js.map → index-nvfNBIM_.js.map} +1 -1
  19. package/dist/controls/ControlBar.d.ts +28 -0
  20. package/dist/controls/ControlBar.d.ts.map +1 -1
  21. package/dist/controls/VolumePanel.d.ts +0 -2
  22. package/dist/controls/VolumePanel.d.ts.map +1 -1
  23. package/dist/debug/ErrorLog.d.ts +29 -0
  24. package/dist/debug/ErrorLog.d.ts.map +1 -0
  25. package/dist/hls/SourceManager.d.ts +9 -0
  26. package/dist/hls/SourceManager.d.ts.map +1 -1
  27. package/dist/hope-player.js +1 -1
  28. package/dist/i18n/locales/en.d.ts.map +1 -1
  29. package/dist/i18n/locales/tr.d.ts.map +1 -1
  30. package/dist/i18n/types.d.ts +17 -0
  31. package/dist/i18n/types.d.ts.map +1 -1
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/keyboard/KeyboardController.d.ts +2 -0
  35. package/dist/keyboard/KeyboardController.d.ts.map +1 -1
  36. package/dist/plugins/ads/AdSurfaceGuard.d.ts +39 -0
  37. package/dist/plugins/ads/AdSurfaceGuard.d.ts.map +1 -0
  38. package/dist/plugins/ads/AdsController.d.ts +101 -1
  39. package/dist/plugins/ads/AdsController.d.ts.map +1 -1
  40. package/dist/plugins/ads/PrerollGate.d.ts +51 -0
  41. package/dist/plugins/ads/PrerollGate.d.ts.map +1 -0
  42. package/dist/plugins/ads/preconnect.d.ts +2 -0
  43. package/dist/plugins/ads/preconnect.d.ts.map +1 -0
  44. package/dist/plugins/debug/DebugPanel.d.ts +37 -0
  45. package/dist/plugins/debug/DebugPanel.d.ts.map +1 -0
  46. package/dist/plugins/debug/index.d.ts +5 -0
  47. package/dist/plugins/debug/index.d.ts.map +1 -0
  48. package/dist/subtitles/CaptionRenderer.d.ts +6 -0
  49. package/dist/subtitles/CaptionRenderer.d.ts.map +1 -1
  50. package/dist/subtitles/attachTracks.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +50 -1
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunks/index-Bqs23yk7.js.map +0 -1
  55. package/dist/chunks/index-glxDu2eJ.js +0 -531
  56. package/dist/chunks/index-glxDu2eJ.js.map +0 -1
@@ -0,0 +1,835 @@
1
+ var T = Object.defineProperty;
2
+ var P = (l, e, t) => e in l ? T(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var r = (l, e, t) => P(l, typeof e != "symbol" ? e + "" : e, t);
4
+ class k {
5
+ constructor(e) {
6
+ /** Reklam yüzünden çıkılan yüzey — reklam bitince geri dönüş butonu için. */
7
+ r(this, "exited", null);
8
+ r(this, "button", null);
9
+ r(this, "hideTimer", null);
10
+ this.ctx = e;
11
+ }
12
+ get video() {
13
+ return this.ctx.videoEl;
14
+ }
15
+ /** Şu an reklamın görünmeyeceği bir yüzeyde miyiz? */
16
+ current() {
17
+ const e = this.video;
18
+ return e.webkitDisplayingFullscreen ? "fullscreen" : document.pictureInPictureElement === e || e.webkitPresentationMode === "picture-in-picture" ? "pip" : null;
19
+ }
20
+ /** Lineer reklam arası başlıyor: görünmeyen yüzeyden çık (içerik zaten duraklatıldı). */
21
+ onBreakStart() {
22
+ var i, s;
23
+ this.hideButton();
24
+ const e = this.current();
25
+ if (!e) return;
26
+ this.exited = e;
27
+ const t = this.video;
28
+ try {
29
+ e === "fullscreen" ? (i = t.webkitExitFullscreen) == null || i.call(t) : document.pictureInPictureElement === t ? document.exitPictureInPicture().catch(() => {
30
+ }) : (s = t.webkitSetPresentationMode) == null || s.call(t, "inline");
31
+ } catch {
32
+ }
33
+ }
34
+ /** Lineer reklam arası bitti. Postroll'dan sonra içerik bitmiştir — geri dönüş önerilmez. */
35
+ onBreakEnd(e) {
36
+ const t = this.exited;
37
+ this.exited = null, t && e && this.showButton(t);
38
+ }
39
+ showButton(e) {
40
+ this.hideButton();
41
+ const t = this.ctx.labels(), i = document.createElement("button");
42
+ i.type = "button", i.className = "hp-ad-return", i.setAttribute("part", "ad-return"), i.textContent = e === "fullscreen" ? t.adReturnFullscreen : t.adReturnPip, i.addEventListener("click", (s) => {
43
+ s.stopPropagation(), this.hideButton(), e === "fullscreen" ? this.ctx.enterFullscreen() : this.enterPip();
44
+ }), i.addEventListener("pointerdown", (s) => s.stopPropagation()), this.ctx.containerEl.appendChild(i), this.button = i, this.hideTimer = setTimeout(() => this.hideButton(), 8e3);
45
+ }
46
+ enterPip() {
47
+ var t, i;
48
+ const e = this.video;
49
+ e.requestPictureInPicture && document.pictureInPictureEnabled ? e.requestPictureInPicture().catch(() => {
50
+ }) : (t = e.webkitSupportsPresentationMode) != null && t.call(e, "picture-in-picture") && ((i = e.webkitSetPresentationMode) == null || i.call(e, "picture-in-picture"));
51
+ }
52
+ hideButton() {
53
+ var e;
54
+ this.hideTimer && clearTimeout(this.hideTimer), this.hideTimer = null, (e = this.button) == null || e.remove(), this.button = null;
55
+ }
56
+ destroy() {
57
+ this.hideButton(), this.exited = null;
58
+ }
59
+ }
60
+ const M = "https://imasdk.googleapis.com/js/sdkloader/ima3.js";
61
+ let g = null;
62
+ function L() {
63
+ var l;
64
+ return (l = window.google) != null && l.ima ? Promise.resolve(window.google.ima) : g || (g = new Promise((e, t) => {
65
+ const i = document.createElement("script");
66
+ i.src = M, i.async = !0, i.onload = () => {
67
+ var s;
68
+ (s = window.google) != null && s.ima ? e(window.google.ima) : t(new Error("IMA SDK yüklendi ama window.google.ima yok"));
69
+ }, i.onerror = () => t(new Error("IMA SDK yüklenemedi (reklam engelleyici olabilir)")), document.head.appendChild(i);
70
+ }), g);
71
+ }
72
+ function C() {
73
+ var i;
74
+ const e = (i = window.adTaxonomy) == null ? void 0 : i.keyValues;
75
+ if (!e || typeof e != "object") return "";
76
+ const t = [];
77
+ for (const [s, a] of Object.entries(e))
78
+ a == null || a === "" || t.push(`${s}=${a}`);
79
+ return t.join("&");
80
+ }
81
+ function x(l, e = {}) {
82
+ const t = encodeURIComponent(document.referrer || window.location.href), i = encodeURIComponent(window.location.href), s = Date.now();
83
+ let a = l;
84
+ const o = {
85
+ referrer_url: t,
86
+ description_url: i,
87
+ timestamp: s
88
+ };
89
+ for (const [n, c] of Object.entries(o)) {
90
+ const h = `[${n}]`;
91
+ if (a.includes(h))
92
+ a = a.replace(h, String(c));
93
+ else if (!new URLSearchParams(a.split("?")[1]).has(n)) {
94
+ const d = a.includes("?") ? "&" : "?";
95
+ a += `${d}${n}=${c}`;
96
+ }
97
+ }
98
+ try {
99
+ const n = new URL(a);
100
+ if (n.pathname.includes("/vmap/")) return l;
101
+ const h = [];
102
+ e.includeRefreshCount && h.push(`adrefreshCount=${e.adRefreshCount ?? 0}`);
103
+ const d = C();
104
+ if (d && h.push(d), h.length) {
105
+ const u = n.searchParams.get("cust_params");
106
+ n.searchParams.set("cust_params", u ? `${u}&${h.join("&")}` : h.join("&"));
107
+ }
108
+ return n.toString();
109
+ } catch {
110
+ return a;
111
+ }
112
+ }
113
+ class b {
114
+ constructor(e) {
115
+ r(this, "adRetryCount", 0);
116
+ r(this, "chain", {});
117
+ r(this, "retryTimer", null);
118
+ this.config = e;
119
+ }
120
+ get isPending() {
121
+ return this.retryTimer !== null;
122
+ }
123
+ reset() {
124
+ this.adRetryCount = 0, this.chain = {}, this.cancelPending();
125
+ }
126
+ cancelPending() {
127
+ this.retryTimer && (clearTimeout(this.retryTimer), this.retryTimer = null);
128
+ }
129
+ /** Devre dışı/kapsam dışı/limit dolduysa onGiveUp; aksi halde (jitter'lı) gecikmeden sonra onRetry. */
130
+ retry(e, t, i, s) {
131
+ if (!this.config.enabled) {
132
+ s("retry-disabled");
133
+ return;
134
+ }
135
+ if ((this.config.retryScope ?? "preroll") === "preroll" && e !== "Preroll") {
136
+ s("retry-disabled");
137
+ return;
138
+ }
139
+ const o = this.resolveMaxRetry();
140
+ if (this.adRetryCount >= o) {
141
+ this.reset(), s("retry-limit");
142
+ return;
143
+ }
144
+ this.cancelPending(), this.adRetryCount++;
145
+ const n = this.getChainState(e, t);
146
+ n.attemptsOnCurrent++;
147
+ const c = this.config.maxAttemptsPerTag ?? 1 / 0;
148
+ n.attemptsOnCurrent > c && n.index < n.tags.length - 1 && (n.index++, n.attemptsOnCurrent = 1);
149
+ const h = n.tags[n.index], d = this.adRetryCount;
150
+ this.retryTimer = setTimeout(() => {
151
+ this.retryTimer = null, i(h, d);
152
+ }, this.applyJitter(this.resolveRetryDelay()));
153
+ }
154
+ getChainState(e, t) {
155
+ const i = this.chain[e];
156
+ if (i) return i;
157
+ const s = (Array.isArray(t) ? t : [t]).filter((o) => !!o), a = { tags: s.length ? s : [t], index: 0, attemptsOnCurrent: 0 };
158
+ return this.chain[e] = a, a;
159
+ }
160
+ resolveRetryDelay() {
161
+ const e = this.config.retryDelayPattern;
162
+ if (!Array.isArray(e) || e.length === 0) return this.config.retryDelay ?? 800;
163
+ for (const t of e) {
164
+ const [i, s] = this.normalizeEntry(t);
165
+ if (this.adRetryCount <= i) return s;
166
+ }
167
+ return this.normalizeEntry(e[e.length - 1])[1];
168
+ }
169
+ resolveMaxRetry() {
170
+ const e = this.config.retryDelayPattern;
171
+ return Array.isArray(e) && e.length > 0 ? this.normalizeEntry(e[e.length - 1])[0] : this.config.maxRetry ?? 10;
172
+ }
173
+ normalizeEntry(e) {
174
+ return Array.isArray(e) ? e : [e.upTo, e.delay];
175
+ }
176
+ applyJitter(e) {
177
+ const t = this.config.jitter ?? 0;
178
+ if (!t) return e;
179
+ const i = 1 + (Math.random() * 2 - 1) * t;
180
+ return Math.max(0, Math.round(e * i));
181
+ }
182
+ }
183
+ function E(l, e) {
184
+ var t;
185
+ try {
186
+ (t = l == null ? void 0 : l.settings) != null && t.setPrivacySettings && (l.settings.setPrivacySettings({ nonPersonalizedAds: !0 }), console.warn(`[HopePlayer consent] non-personalized ads zorlandı (${e})`));
187
+ } catch (i) {
188
+ console.warn("[HopePlayer consent] setPrivacySettings hatası:", i);
189
+ }
190
+ }
191
+ function S(l, e) {
192
+ if (l.consentAware) {
193
+ try {
194
+ typeof window.__uspapi == "function" && window.__uspapi("getUSPData", 1, (t, i) => {
195
+ !i || !(t != null && t.uspString) || t.uspString.charAt(2) === "Y" && E(e, "USP/CCPA opt-out");
196
+ });
197
+ } catch (t) {
198
+ console.warn("[HopePlayer consent] __uspapi okuma hatası:", t);
199
+ }
200
+ try {
201
+ typeof window.__tcfapi == "function" && window.__tcfapi("getTCData", 2, (t, i) => {
202
+ var o, n, c, h;
203
+ if (!i || !t || t.gdprApplies !== !0) return;
204
+ const s = (n = (o = t.vendor) == null ? void 0 : o.consents) == null ? void 0 : n[755], a = (h = (c = t.purpose) == null ? void 0 : c.consents) == null ? void 0 : h[1];
205
+ (s === !1 || a === !1) && E(e, "TCF yetersiz onay");
206
+ });
207
+ } catch (t) {
208
+ console.warn("[HopePlayer consent] __tcfapi okuma hatası:", t);
209
+ }
210
+ }
211
+ }
212
+ function R(l) {
213
+ try {
214
+ const e = atob(l), t = new Uint8Array(e.length);
215
+ for (let d = 0; d < e.length; d++) t[d] = e.charCodeAt(d);
216
+ if (t[0] !== 252 || t[13] !== 5) return null;
217
+ const s = (t[14] << 24 | t[15] << 16 | t[16] << 8 | t[17]) >>> 0;
218
+ if (t[18] >> 7 & 1) return { type: "cancel", spliceEventId: s };
219
+ const o = t[19] >> 7 & 1, n = t[19] >> 6 & 1, c = t[19] >> 5 & 1;
220
+ let h = null;
221
+ if (n) {
222
+ let d = 20;
223
+ const u = t[d] >> 7 & 1;
224
+ if (d += u ? 5 : 1, c) {
225
+ const p = t[d] >> 7 & 1, f = (t[d] & 1) * Math.pow(2, 32) + t[d + 1] * Math.pow(2, 24) + t[d + 2] * Math.pow(2, 16) + t[d + 3] * Math.pow(2, 8) + t[d + 4];
226
+ h = { autoReturn: p, seconds: f / 9e4 };
227
+ }
228
+ }
229
+ return { type: o ? "out" : "in", spliceEventId: s, breakDuration: h, programSplice: !!n };
230
+ } catch {
231
+ return null;
232
+ }
233
+ }
234
+ function w(l, e) {
235
+ if (l === "EXT-X-CUE-OUT")
236
+ return { type: "out", duration: parseFloat(e) || null };
237
+ if (l === "EXT-X-CUE-IN")
238
+ return { type: "in" };
239
+ if (l === "EXT-X-DATERANGE") {
240
+ const t = e.match(/SCTE35-OUT=0x([0-9A-Fa-f]+)/), i = e.match(/SCTE35-IN=0x([0-9A-Fa-f]+)/), s = e.match(/PLANNED-DURATION=([\d.]+)/), a = e.match(/CLASS="([^"]+)"/);
241
+ if (t)
242
+ return { type: "out", duration: s ? parseFloat(s[1]) : null, class: a ? a[1] : null, raw: t[1] };
243
+ if (i) return { type: "in", raw: i[1] };
244
+ }
245
+ return l === "EXT-OATCLS-SCTE35" ? R(e) : null;
246
+ }
247
+ class B {
248
+ constructor(e, t) {
249
+ r(this, "inAdBreak", !1);
250
+ r(this, "adBreakTimer", null);
251
+ r(this, "processedEventIds", /* @__PURE__ */ new Set());
252
+ r(this, "trackListeners", /* @__PURE__ */ new Map());
253
+ r(this, "onAddTrack", (e) => {
254
+ e.track instanceof TextTrack && this.listenTrack(e.track);
255
+ });
256
+ this.videoEl = e, this.callbacks = t, this.attachExistingTracks(), e.textTracks.addEventListener("addtrack", this.onAddTrack);
257
+ }
258
+ destroy() {
259
+ this.videoEl.textTracks.removeEventListener("addtrack", this.onAddTrack);
260
+ for (const [e, t] of this.trackListeners)
261
+ e.removeEventListener("cuechange", t);
262
+ this.trackListeners.clear(), this.adBreakTimer && clearTimeout(this.adBreakTimer), this.processedEventIds.clear();
263
+ }
264
+ attachExistingTracks() {
265
+ for (let e = 0; e < this.videoEl.textTracks.length; e++)
266
+ this.listenTrack(this.videoEl.textTracks[e]);
267
+ }
268
+ listenTrack(e) {
269
+ if (e.kind !== "metadata" || this.trackListeners.has(e)) return;
270
+ e.mode = "hidden";
271
+ const t = () => {
272
+ const i = e.activeCues;
273
+ if (i)
274
+ for (let s = 0; s < i.length; s++) this.processCue(i[s]);
275
+ };
276
+ e.addEventListener("cuechange", t), this.trackListeners.set(e, t);
277
+ }
278
+ processCue(e) {
279
+ const t = e;
280
+ let i = null, s = "";
281
+ if (t.value && typeof t.value == "object")
282
+ i = t.value.key ?? null, s = t.value.data ?? t.value.value ?? "";
283
+ else if (typeof t.text == "string") {
284
+ const o = t.text.match(/^(EXT[^:]+):?(.*)$/);
285
+ o && (i = o[1], s = o[2] ?? "");
286
+ }
287
+ if (!i) return;
288
+ const a = w(i, s);
289
+ a && this.handleSignal(a);
290
+ }
291
+ handleSignal(e) {
292
+ var t;
293
+ if (e.spliceEventId !== void 0) {
294
+ if (this.processedEventIds.has(e.spliceEventId)) return;
295
+ this.processedEventIds.add(e.spliceEventId), setTimeout(() => this.processedEventIds.delete(e.spliceEventId), 300 * 1e3);
296
+ }
297
+ if (e.type === "cancel") {
298
+ this.endAdBreak(!0);
299
+ return;
300
+ }
301
+ e.type === "out" && !this.inAdBreak ? this.startAdBreak(((t = e.breakDuration) == null ? void 0 : t.seconds) ?? e.duration ?? null) : e.type === "in" && this.inAdBreak && this.endAdBreak(!1);
302
+ }
303
+ startAdBreak(e) {
304
+ this.inAdBreak || (this.inAdBreak = !0, this.callbacks.onAdBreakStart(e), e && e > 0 && (this.adBreakTimer = setTimeout(() => {
305
+ this.inAdBreak && this.endAdBreak(!0);
306
+ }, (e + 5) * 1e3)));
307
+ }
308
+ endAdBreak(e = !1) {
309
+ this.inAdBreak && (this.inAdBreak = !1, this.adBreakTimer && (clearTimeout(this.adBreakTimer), this.adBreakTimer = null), this.callbacks.onAdBreakEnd());
310
+ }
311
+ }
312
+ const I = 250, O = 300 * 1e3, q = "100% 0px 100% 0px";
313
+ function V(l, e) {
314
+ return e === "Preroll" ? l.adTagPreroll : e === "Midroll" ? l.adTagMidroll : l.adTagPostroll;
315
+ }
316
+ class U {
317
+ constructor(e, t) {
318
+ r(this, "ima", null);
319
+ r(this, "adDisplayContainer", null);
320
+ r(this, "adsLoader", null);
321
+ r(this, "adsManager", null);
322
+ r(this, "retry");
323
+ r(this, "currentBreakType", "Preroll");
324
+ r(this, "vmapRequested", !1);
325
+ r(this, "postrollPending", !1);
326
+ r(this, "postrollShown", !1);
327
+ r(this, "lastMidrollTime", 0);
328
+ r(this, "displayContainerInitialized", !1);
329
+ /**
330
+ * Reklam sırasında toolbar oynat/duraklat + ses buraya yönlenir (IMA reklamı ayrı bir video'da oynatır).
331
+ * Durum hem bizim çağrılarımızdan hem IMA'nın kendi PAUSED/RESUMED event'lerinden senkron tutulur.
332
+ */
333
+ r(this, "adPaused", !1);
334
+ r(this, "adVolumeBeforeMute", 1);
335
+ r(this, "prebidIdSuffix");
336
+ r(this, "prebidInstances", {});
337
+ r(this, "scte35Manager", null);
338
+ r(this, "scte35BreakActive", !1);
339
+ r(this, "scte35BreakTimeout", null);
340
+ /**
341
+ * Preroll yüklendi ama içerik henüz oynatılmak istenmedi — init() + start() oynatma isteğine kadar bekler.
342
+ * init() de ertelenir: VMAP'te IMA, start() beklemeden init() anında 0 noktasındaki preroll'u kendiliğinden
343
+ * oynatıyor (autoPlayAdBreaks: false bile durdurmuyor); init edilmemiş bir AdsManager hiçbir şey oynatamaz.
344
+ */
345
+ r(this, "prerollStartPending", !1);
346
+ /** İlk preroll/VMAP isteği atıldı mı (requestWhen'e göre zamanlanır). */
347
+ r(this, "initialRequestFired", !1);
348
+ /** İlk preroll/VMAP isteğinin zamanı — bayatlama kontrolü için. */
349
+ r(this, "prerollRequestedAt", 0);
350
+ /** requestWhen: 'visible' — player ekrana yaklaşınca isteği tetikler. */
351
+ r(this, "visibilityObserver", null);
352
+ /** Bir lineer reklam arası başladı ve henüz bitmedi (CONTENT_PAUSE_REQUESTED → CONTENT_RESUME_REQUESTED). */
353
+ r(this, "linearBreakActive", !1);
354
+ /** Ekranda bir overlay (non-linear) reklam var — reklam katmanı içerikle birlikte görünür. */
355
+ r(this, "nonLinearActive", !1);
356
+ /** Son IMA hatası — vazgeçilince hp:aderror bununla gönderilir. */
357
+ r(this, "lastAdError", null);
358
+ /** Reklam geri sayımı zamanlayıcısı (lineer reklam oynarken). */
359
+ r(this, "progressTimer", null);
360
+ r(this, "podPosition", 1);
361
+ r(this, "podTotal", 1);
362
+ /** Son istek ham bir VMAP mı — VMAP'te aranın tipi isteğin tipinden değil, IMA'nın verdiği konumdan okunur. */
363
+ r(this, "lastRequestIsVmap", !1);
364
+ /** Şu an oynayan / son oynayan reklam arasının tipi (hp:adstart / hp:adend ve sonrasındaki içerik kararı). */
365
+ r(this, "activeBreak", "preroll");
366
+ /** Preroll zaman aşımına uğradı — geç gelen cevap gösterilmez (içerik çoktan başladı). */
367
+ r(this, "prerollAbandoned", !1);
368
+ r(this, "surfaceGuard");
369
+ /** Player boyutu değişince (tam ekran, pencere, yön) IMA'ya bildirmek için — IMA boyutu kendisi izlemiyor. */
370
+ r(this, "resizeObserver", null);
371
+ r(this, "resizeFrame", 0);
372
+ /** Açık overlay creative'inin yüksekliği — yeniden boyutlandırmada şerit yüksekliği için. */
373
+ r(this, "nonLinearCreativeHeight", 0);
374
+ /**
375
+ * initialize() yalnızca 'play'e değil, player'a ilk dokunuşa da bağlı: preroll kullanıcı oynatmadan
376
+ * adsManager.start()'a ulaşabiliyor ve initialize() önce çağrılmazsa IMA AdError 400 veriyor.
377
+ */
378
+ r(this, "initializeDisplayContainerOnce", () => {
379
+ var e;
380
+ this.displayContainerInitialized || (this.displayContainerInitialized = !0, (e = this.adDisplayContainer) == null || e.initialize());
381
+ });
382
+ r(this, "onTimeUpdateForMidroll", () => {
383
+ var i;
384
+ const e = this.options.midrollIntervalSeconds ?? 0;
385
+ if (e <= 0 || !this.options.adTagMidroll || this.options.iosFullscreen === "defer" && ((i = this.surfaceGuard) != null && i.current())) return;
386
+ const t = this.ctx.videoEl.currentTime;
387
+ t > 60 && t - this.lastMidrollTime >= e && (this.lastMidrollTime = t, this.requestAd("Midroll", this.options.adTagMidroll));
388
+ });
389
+ r(this, "onContentEnded", () => {
390
+ var e;
391
+ if (!this.postrollShown) {
392
+ if (this.options.adTagVmap) {
393
+ this.postrollShown = !0, (e = this.adsLoader) == null || e.contentComplete();
394
+ return;
395
+ }
396
+ this.options.adTagPostroll && (this.postrollPending = !0, this.postrollShown = !0, this.requestAd("Postroll", this.options.adTagPostroll));
397
+ }
398
+ });
399
+ r(this, "onAdsManagerLoaded", (e) => {
400
+ var a, o;
401
+ if (!this.ima) return;
402
+ const t = this.currentBreakType === "Preroll";
403
+ if (t && this.prerollAbandoned) {
404
+ e.getAdsManager(this.ctx.videoEl).destroy();
405
+ return;
406
+ }
407
+ this.adsManager = e.getAdsManager(this.ctx.videoEl, {
408
+ restoreCustomPlaybackStateOnAdBreakComplete: !0,
409
+ // VAST çözüldükten sonra creative'in yüklenmesi için üst sınır.
410
+ loadVideoTimeout: this.options.loadVideoTimeoutMs ?? 1e4,
411
+ enablePreloading: !0,
412
+ // false: IMA'nın KENDİ styled linear ad UI'ı (skip/sayaç
413
+ // kutusu) yerine bizim ControlBar'ımız (ad mode) kullanılıyor —
414
+ // ikisi üst üste binmesin diye.
415
+ useStyledLinearAds: !1,
416
+ useStyledNonLinearAds: !0
417
+ });
418
+ const i = this.ima.AdEvent;
419
+ this.adsManager.addEventListener(i.Type.CONTENT_PAUSE_REQUESTED, this.onContentPauseRequested), this.adsManager.addEventListener(i.Type.CONTENT_RESUME_REQUESTED, this.onContentResumeRequested), this.adsManager.addEventListener(i.Type.ALL_ADS_COMPLETED, this.onAllAdsCompleted), this.adsManager.addEventListener(i.Type.LOADED, this.onAdLoaded), this.adsManager.addEventListener(i.Type.STARTED, this.onAdStarted), this.adsManager.addEventListener(i.Type.COMPLETE, this.stopAdProgress), this.adsManager.addEventListener(i.Type.SKIPPED, this.stopAdProgress), i.Type.USER_CLOSE && this.adsManager.addEventListener(i.Type.USER_CLOSE, this.endNonLinear), this.adsManager.addEventListener(this.ima.AdErrorEvent.Type.AD_ERROR, this.onAdsManagerError), this.adsManager.addEventListener(i.Type.PAUSED, this.onAdPaused), this.adsManager.addEventListener(i.Type.RESUMED, this.onAdResumed);
420
+ const s = this.ctx.prerollGate;
421
+ if (t && (s != null && s.isArmed)) {
422
+ const n = ((o = (a = this.adsManager).getCuePoints) == null ? void 0 : o.call(a)) ?? [];
423
+ if (n.length > 0 && !n.includes(0)) {
424
+ s.release(!0), this.startAdsManager();
425
+ return;
426
+ }
427
+ if (!s.hasPlayIntent) {
428
+ this.prerollStartPending = !0;
429
+ return;
430
+ }
431
+ }
432
+ this.startAdsManager();
433
+ });
434
+ /** Preroll kapısında ilk oynatma isteği: IMA'yı kullanıcı jestiyle hazırla, hazır bekleyen preroll'u başlat. */
435
+ r(this, "onPrerollPlayIntent", () => {
436
+ var e;
437
+ if (this.initializeDisplayContainerOnce(), !this.initialRequestFired) {
438
+ this.fireInitialRequest();
439
+ return;
440
+ }
441
+ if (this.prerollStartPending) {
442
+ if (this.prerollStartPending = !1, Date.now() - this.prerollRequestedAt > O) {
443
+ (e = this.adsManager) == null || e.destroy(), this.adsManager = null, this.initialRequestFired = !1, this.vmapRequested = !1, this.fireInitialRequest();
444
+ return;
445
+ }
446
+ this.startAdsManager();
447
+ }
448
+ });
449
+ /** Preroll süresinde gelmedi: bekleyen istekleri bırak, içerik reklamsız başlasın (kapı kendisi açılır). */
450
+ r(this, "onPrerollTimeout", () => {
451
+ var t, i, s;
452
+ this.prerollAbandoned = !0, this.prerollStartPending = !1, this.retry.cancelPending(), this.currentBreakType === "Preroll" && ((t = this.adsManager) == null || t.destroy(), this.adsManager = null);
453
+ const e = this.options.prerollTimeoutMs ?? 8e3;
454
+ (s = (i = this.ctx).log) == null || s.call(i, { message: `Preroll did not arrive within ${e} ms — content started without it`, details: { prerollTimeoutMs: e } }), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:aderror", { detail: { message: "preroll-timeout", breakType: "preroll" } })), this.maybeRequestVmapAfterPreroll();
455
+ });
456
+ r(this, "onAdPaused", () => {
457
+ var e, t;
458
+ this.adPaused = !0, (t = (e = this.ctx).onAdPlayStateChange) == null || t.call(e);
459
+ });
460
+ r(this, "onAdResumed", () => {
461
+ var e, t;
462
+ this.adPaused = !1, (t = (e = this.ctx).onAdPlayStateChange) == null || t.call(e);
463
+ });
464
+ r(this, "onContentPauseRequested", (e) => {
465
+ var t, i;
466
+ this.linearBreakActive = !0, this.activeBreak = this.breakTypeOf(e), this.activeBreak === "preroll" && ((t = this.ctx.prerollGate) == null || t.release(!1)), this.ctx.videoEl.pause(), this.adPaused = !1, this.ctx.hideChrome(), this.ctx.adLayerEl.classList.remove("hp:hidden"), this.ctx.adLayerEl.classList.add("hp:block"), this.retry.reset(), this.scte35BreakActive && this.scte35BreakTimeout && (clearTimeout(this.scte35BreakTimeout), this.scte35BreakTimeout = null), (i = this.surfaceGuard) == null || i.onBreakStart(), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:adstart", { detail: { type: this.activeBreak } }));
467
+ });
468
+ r(this, "onContentResumeRequested", () => {
469
+ var t;
470
+ this.stopAdProgress(), this.hideAdLayer();
471
+ const e = this.activeBreak;
472
+ this.linearBreakActive && (this.linearBreakActive = !1, (t = this.surfaceGuard) == null || t.onBreakEnd(e !== "postroll"), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:adend", { detail: { type: e } }))), this.scte35BreakActive = !1, e === "preroll" && this.maybeRequestVmapAfterPreroll(), e !== "postroll" && this.ctx.videoEl.play().catch(() => {
473
+ });
474
+ });
475
+ r(this, "onAllAdsCompleted", () => {
476
+ var e;
477
+ this.stopAdProgress(), this.endNonLinear(), (e = this.adsManager) == null || e.destroy(), this.adsManager = null;
478
+ });
479
+ /**
480
+ * Overlay (non-linear) reklam yüklendi: içeriği DURDURMAZ (CONTENT_PAUSE_REQUESTED gelmez) — preroll kapısı onu
481
+ * beklerse içerik zaman aşımına kadar bekliyor, overlay de hiç gösterilmiyordu. Kapı hemen açılır, içerik başlar;
482
+ * reklam katmanı içerikle birlikte görünür, kontrol çubuğunun üstünde durur ve yalnızca overlay tıklanabilir.
483
+ */
484
+ r(this, "onAdLoaded", (e) => {
485
+ var s, a, o;
486
+ const t = (s = e == null ? void 0 : e.getAd) == null ? void 0 : s.call(e);
487
+ if (!t || typeof t.isLinear != "function" || t.isLinear()) return;
488
+ this.nonLinearActive = !0;
489
+ const i = this.ctx.adLayerEl;
490
+ this.nonLinearCreativeHeight = ((a = t.getHeight) == null ? void 0 : a.call(t)) || 0, i.setAttribute("data-nonlinear", ""), i.classList.remove("hp:hidden"), i.classList.add("hp:block"), this.resizeAd(), this.currentBreakType === "Preroll" && ((o = this.ctx.prerollGate) == null || o.release(!0)), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:adstart", { detail: { type: this.breakTypeOf(e), linear: !1 } }));
491
+ });
492
+ /** Boyut değişimleri (ResizeObserver) kare başına bire indirilir — pencere sürüklenirken IMA'yı boğmasın. */
493
+ r(this, "scheduleResize", () => {
494
+ cancelAnimationFrame(this.resizeFrame), this.resizeFrame = requestAnimationFrame(() => this.resizeAd());
495
+ });
496
+ /** Overlay kapandı (kullanıcı kapattı / süresi doldu): katman gizlenir. */
497
+ r(this, "endNonLinear", () => {
498
+ this.nonLinearActive && (this.nonLinearActive = !1, this.ctx.adLayerEl.removeAttribute("data-nonlinear"), this.ctx.adLayerEl.style.removeProperty("--hp-nonlinear-ad-height"), this.ctx.adLayerEl.classList.add("hp:hidden"), this.ctx.adLayerEl.classList.remove("hp:block"), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:adend", { detail: { type: this.activeBreak, linear: !1 } })));
499
+ });
500
+ r(this, "onAdsLoaderError", (e) => {
501
+ var t;
502
+ if ((t = this.adsManager) == null || t.destroy(), this.adsManager = null, this.scte35BreakActive) {
503
+ this.endScte35Break();
504
+ return;
505
+ }
506
+ this.giveUpOrRetry(this.currentBreakType, this.recordAdError(e));
507
+ });
508
+ r(this, "onAdsManagerError", (e) => {
509
+ var t;
510
+ if (this.stopAdProgress(), (t = this.adsManager) == null || t.destroy(), this.adsManager = null, this.scte35BreakActive) {
511
+ this.endScte35Break();
512
+ return;
513
+ }
514
+ this.giveUpOrRetry(this.currentBreakType, this.recordAdError(e));
515
+ });
516
+ /** Lineer reklam başladı: pod bilgisi + kalan süre toolbar'a (geri sayım). */
517
+ r(this, "onAdStarted", (e) => {
518
+ var i;
519
+ const t = (i = e == null ? void 0 : e.getAd) == null ? void 0 : i.call(e);
520
+ if (!(!t || typeof t.isLinear == "function" && !t.isLinear())) {
521
+ try {
522
+ const s = t.getAdPodInfo();
523
+ this.podPosition = s.getAdPosition() || 1, this.podTotal = s.getTotalAds() || 1;
524
+ } catch {
525
+ this.podPosition = 1, this.podTotal = 1;
526
+ }
527
+ this.stopAdProgress(), this.reportAdProgress(), this.progressTimer = setInterval(this.reportAdProgress, I);
528
+ }
529
+ });
530
+ r(this, "reportAdProgress", () => {
531
+ var t, i, s;
532
+ const e = ((t = this.adsManager) == null ? void 0 : t.getRemainingTime()) ?? -1;
533
+ (s = (i = this.ctx).onAdProgress) == null || s.call(i, { remaining: e, position: this.podPosition, total: this.podTotal });
534
+ });
535
+ r(this, "stopAdProgress", () => {
536
+ var e, t;
537
+ this.progressTimer && clearInterval(this.progressTimer), this.progressTimer = null, (t = (e = this.ctx).onAdProgress) == null || t.call(e, null);
538
+ });
539
+ this.ctx = e, this.options = t, this.retry = new b(t.retry ?? {}), this.prebidIdSuffix = e.hostEl.id || Math.random().toString(36).slice(2, 8), this.surfaceGuard = e.surface ? new k(e.surface) : null;
540
+ }
541
+ async install() {
542
+ var s, a, o, n;
543
+ let e;
544
+ const t = this.ctx.prerollGate;
545
+ t && (t.onPlayIntent = this.onPrerollPlayIntent, t.onTimeout = this.onPrerollTimeout);
546
+ try {
547
+ e = await L();
548
+ } catch (c) {
549
+ t == null || t.release(!0), (a = (s = this.ctx).log) == null || a.call(s, { message: `IMA SDK failed to load: ${String(c)}`, details: { hint: "ad blocker / network" } }), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:aderror", { detail: { message: String(c), errorType: "sdkLoadError" } }));
550
+ return;
551
+ }
552
+ this.ima = e;
553
+ try {
554
+ e.settings.setLocale(this.ctx.locale);
555
+ } catch {
556
+ }
557
+ try {
558
+ e.settings.setNumRedirects(this.options.numRedirects ?? 15);
559
+ } catch {
560
+ }
561
+ try {
562
+ e.settings.setDisableCustomPlaybackForIOS10Plus(!0);
563
+ } catch {
564
+ }
565
+ try {
566
+ (o = e.ImaSdkSettings) != null && o.VpaidMode && e.settings.setVpaidMode(e.ImaSdkSettings.VpaidMode.INSECURE);
567
+ } catch {
568
+ }
569
+ S(this.options, this.ima), this.adDisplayContainer = new e.AdDisplayContainer(this.ctx.adLayerEl, this.ctx.videoEl), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(this.scheduleResize), this.resizeObserver.observe(this.ctx.videoEl)), this.adsLoader = new e.AdsLoader(this.adDisplayContainer), this.adsLoader.addEventListener(e.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, this.onAdsManagerLoaded), this.adsLoader.addEventListener(e.AdErrorEvent.Type.AD_ERROR, this.onAdsLoaderError), this.ctx.videoEl.addEventListener("play", this.initializeDisplayContainerOnce);
570
+ const i = typeof navigator < "u" && "userActivation" in navigator && navigator.userActivation.hasBeenActive;
571
+ (!this.ctx.videoEl.paused || i || t != null && t.hasPlayIntent) && this.initializeDisplayContainerOnce(), this.ctx.videoEl.addEventListener("ended", this.onContentEnded), this.options.adTagMidroll && !this.options.adTagVmap && this.options.midrollIntervalSeconds && this.ctx.videoEl.addEventListener("timeupdate", this.onTimeUpdateForMidroll), this.requestInitialPrerollOrVmap(), (n = this.options.live) != null && n.scte35 && this.options.live.adTagLive && (this.scte35Manager = new B(this.ctx.videoEl, {
572
+ onAdBreakStart: (c) => this.onScte35AdBreakStart(c),
573
+ onAdBreakEnd: () => this.onScte35AdBreakEnd()
574
+ }));
575
+ }
576
+ /**
577
+ * İlk preroll/VMAP isteğinin zamanı (requestWhen):
578
+ * - 'visible' (varsayılan): player ekrana yaklaşınca — uzun bir makalenin sonundaki player için, oraya hiç inmeyen
579
+ * ziyaretçi adına boşa istek atılmaz (raporlarda istek/gösterim oranı düşmez, teklifler bayatlamaz); kullanıcı
580
+ * player'a ulaştığında reklam çoğunlukla hazırdır.
581
+ * - 'load': hemen. - 'play': oynatma isteğinde (en geç; bekleme istek süresi kadar uzar).
582
+ * Hangi moddan olursa olsun oynatma isteği geldiğinde istek hâlâ atılmadıysa hemen atılır.
583
+ */
584
+ requestInitialPrerollOrVmap() {
585
+ if (!this.options.adTagPreroll && !this.options.adTagVmap) return;
586
+ const e = this.options.requestWhen ?? (this.options.requestOnPlay ? "play" : "visible");
587
+ if (e === "load" || !this.ctx.videoEl.paused) {
588
+ this.fireInitialRequest();
589
+ return;
590
+ }
591
+ if (e === "visible" && typeof IntersectionObserver < "u") {
592
+ this.visibilityObserver = new IntersectionObserver(
593
+ (t) => {
594
+ t.some((i) => i.isIntersecting) && this.fireInitialRequest();
595
+ },
596
+ { rootMargin: q }
597
+ ), this.visibilityObserver.observe(this.ctx.hostEl);
598
+ return;
599
+ }
600
+ if (e === "visible") {
601
+ this.fireInitialRequest();
602
+ return;
603
+ }
604
+ this.ctx.prerollGate || this.ctx.videoEl.addEventListener("play", () => this.fireInitialRequest(), { once: !0 });
605
+ }
606
+ fireInitialRequest() {
607
+ var e;
608
+ (e = this.visibilityObserver) == null || e.disconnect(), this.visibilityObserver = null, !this.initialRequestFired && (this.initialRequestFired = !0, this.prerollRequestedAt = Date.now(), this.options.adTagPreroll ? this.requestAd("Preroll", this.options.adTagPreroll) : this.options.adTagVmap && (this.vmapRequested = !0, this.requestAd("Preroll", this.options.adTagVmap, 0, !0)));
609
+ }
610
+ /** Playlist/story item değişiminde: önceki item'ın reklam durumunu sıfırla. */
611
+ resetForNewItem(e) {
612
+ this.retry.reset(), this.vmapRequested = !1, this.postrollShown = !1, this.postrollPending = !1, this.lastMidrollTime = 0, this.prerollAbandoned = !1, this.prerollStartPending = !1, e !== void 0 && (this.options.adTagPreroll = e), this.initialRequestFired = !0, this.prerollRequestedAt = Date.now(), this.options.adTagPreroll ? this.requestAd("Preroll", this.options.adTagPreroll) : this.options.adTagVmap && (this.vmapRequested = !0, this.requestAd("Preroll", this.options.adTagVmap, 0, !0));
613
+ }
614
+ destroy() {
615
+ var e, t, i, s, a, o, n;
616
+ this.ctx.prerollGate && (this.ctx.prerollGate.onPlayIntent = null, this.ctx.prerollGate.onTimeout = null, this.ctx.prerollGate.release(!1)), (e = this.visibilityObserver) == null || e.disconnect(), this.visibilityObserver = null, this.stopAdProgress(), this.ctx.videoEl.removeEventListener("play", this.initializeDisplayContainerOnce), this.ctx.videoEl.removeEventListener("ended", this.onContentEnded), this.ctx.videoEl.removeEventListener("timeupdate", this.onTimeUpdateForMidroll), (t = this.surfaceGuard) == null || t.destroy(), (i = this.resizeObserver) == null || i.disconnect(), this.resizeObserver = null, cancelAnimationFrame(this.resizeFrame), this.retry.cancelPending(), (s = this.adsManager) == null || s.destroy(), (a = this.adsLoader) == null || a.destroy(), (o = this.adDisplayContainer) == null || o.destroy(), (n = this.scte35Manager) == null || n.destroy(), this.scte35BreakTimeout && clearTimeout(this.scte35BreakTimeout);
617
+ }
618
+ /** SCTE-35 OUT sinyali: IMA'ya reklam iste (normal midroll gibi) + IMA cevap vermezse N ms sonra vazgeç. */
619
+ onScte35AdBreakStart(e) {
620
+ var i;
621
+ this.scte35BreakActive = !0, this.requestAd("Midroll", this.options.live.adTagLive);
622
+ const t = ((i = this.options.live) == null ? void 0 : i.breakTimeoutMs) ?? 1e4;
623
+ this.scte35BreakTimeout && clearTimeout(this.scte35BreakTimeout), this.scte35BreakTimeout = setTimeout(() => {
624
+ this.endScte35Break();
625
+ }, t);
626
+ }
627
+ /** SCTE-35 IN sinyali: yayıncının sinyaline güvenilir — reklam hâlâ oynuyor olsa bile içeriğe dönülür. */
628
+ onScte35AdBreakEnd() {
629
+ this.endScte35Break();
630
+ }
631
+ endScte35Break() {
632
+ var e;
633
+ this.scte35BreakActive && (this.scte35BreakActive = !1, this.scte35BreakTimeout && (clearTimeout(this.scte35BreakTimeout), this.scte35BreakTimeout = null), (e = this.adsManager) == null || e.destroy(), this.adsManager = null, this.hideAdLayer(), this.ctx.videoEl.paused && this.ctx.videoEl.play().catch(() => {
634
+ }));
635
+ }
636
+ /** Preroll: options.prebid, Midroll: options.prebid.midroll. Postroll'da prebid yok. */
637
+ getPrebidConfigFor(e) {
638
+ var i;
639
+ const t = this.options.prebid;
640
+ return t ? e === "Preroll" ? t.enabled ? t : null : e === "Midroll" && (i = t.midroll) != null && i.enabled ? { ...t, ...t.midroll } : null : null;
641
+ }
642
+ async getOrCreatePrebidInstance(e, t) {
643
+ var n;
644
+ const i = this.prebidInstances[e];
645
+ if (i) return i;
646
+ const { VideoPrebid: s } = await import("./VideoPrebid-CpckFzSq.js"), a = e === "Midroll" ? "hope-video-midroll" : "hope-video-preroll", o = new s({
647
+ ...t,
648
+ adUnitCode: `${t.adUnitCode || a}-${this.prebidIdSuffix}`,
649
+ consentManagement: (n = this.options.prebid) == null ? void 0 : n.consentManagement
650
+ });
651
+ return this.prebidInstances[e] = o, o;
652
+ }
653
+ async requestAd(e, t, i = 0, s = !1) {
654
+ var h, d, u, p, y, f, A;
655
+ if (!this.adsLoader || !this.ima) return;
656
+ this.currentBreakType = e, this.lastRequestIsVmap = s;
657
+ const a = Array.isArray(t) ? t[0] : t;
658
+ let o = s ? a : x(a, { includeRefreshCount: !!((h = this.options.retry) != null && h.enabled), adRefreshCount: i });
659
+ if (!s && i === 0) {
660
+ const m = this.getPrebidConfigFor(e);
661
+ if (m) {
662
+ const v = await this.getOrCreatePrebidInstance(e, m);
663
+ v.isAvailable() && (o = await v.runAuction(o));
664
+ }
665
+ }
666
+ if (!this.adsLoader || !this.ima) return;
667
+ const n = new this.ima.AdsRequest();
668
+ n.adTagUrl = o, n.linearAdSlotWidth = this.ctx.videoEl.clientWidth || 640, n.linearAdSlotHeight = this.ctx.videoEl.clientHeight || 360, n.nonLinearAdSlotWidth = this.ctx.videoEl.clientWidth || 640, n.nonLinearAdSlotHeight = Math.round((this.ctx.videoEl.clientHeight || 360) / 3), n.vastLoadTimeout = this.options.vastLoadTimeoutMs ?? 1e4;
669
+ try {
670
+ (u = n.setAdWillAutoPlay) == null || u.call(n, this.ctx.videoEl.autoplay || !!((d = this.ctx.prerollGate) != null && d.hasPlayIntent) || !this.ctx.videoEl.paused), (p = n.setAdWillPlayMuted) == null || p.call(n, this.ctx.videoEl.muted), (A = n.setContinuousPlayback) == null || A.call(n, !!((f = (y = this.ctx).isContinuousPlayback) != null && f.call(y)));
671
+ } catch {
672
+ }
673
+ const c = this.omidRules();
674
+ c && (n.omidAccessModeRules = c);
675
+ try {
676
+ this.adsLoader.requestAds(n);
677
+ } catch (m) {
678
+ this.giveUpOrRetry(e, String(m));
679
+ }
680
+ }
681
+ /**
682
+ * Open Measurement erişim kuralları: her ölçüm firması için mod (varsayılan 'full').
683
+ * IMA'nın enum'ları yoksa (eski SDK) hiçbir şey ayarlanmaz — IMA kendi varsayılanını kullanır.
684
+ */
685
+ omidRules() {
686
+ var c, h;
687
+ const e = (c = this.ima) == null ? void 0 : c.OmidVerificationVendor, t = (h = this.ima) == null ? void 0 : h.OmidAccessMode;
688
+ if (!e || !t) return null;
689
+ const i = this.options.omidAccessMode ?? "full", s = (d) => d === "full" ? t.FULL : d === "domain" ? t.DOMAIN : d === "limited" ? t.LIMITED : void 0, a = typeof i == "string" ? {} : i, o = s(typeof i == "string" ? i : i.default ?? "full") ?? t.FULL, n = {};
690
+ for (const [d, u] of Object.entries(e))
691
+ typeof u == "number" && (n[u] = s(a[d]) ?? o);
692
+ return n;
693
+ }
694
+ startAdsManager() {
695
+ if (!(!this.adsManager || !this.ima))
696
+ try {
697
+ this.adsManager.init(this.ctx.videoEl.clientWidth || 640, this.ctx.videoEl.clientHeight || 360, this.viewMode()), this.adsManager.start();
698
+ } catch (e) {
699
+ this.giveUpOrRetry(this.currentBreakType, String(e));
700
+ }
701
+ }
702
+ /** Toolbar'daki oynat/duraklat butonunun (reklam modunda) hedefi — content videoEl yerine bu çağrılır. */
703
+ toggleAdPlayPause() {
704
+ this.adsManager && (this.adPaused ? this.adsManager.resume() : this.adsManager.pause(), this.adPaused = !this.adPaused);
705
+ }
706
+ isAdPaused() {
707
+ return this.adPaused;
708
+ }
709
+ getAdVolume() {
710
+ var e;
711
+ return ((e = this.adsManager) == null ? void 0 : e.getVolume()) ?? 1;
712
+ }
713
+ setAdVolume(e) {
714
+ var t;
715
+ (t = this.adsManager) == null || t.setVolume(Math.min(1, Math.max(0, e)));
716
+ }
717
+ isAdMuted() {
718
+ return this.getAdVolume() === 0;
719
+ }
720
+ /** VolumePanel'deki `onToggleMute` ile AYNI desen: 0 ↔ son bilinen (ya da varsayılan 0.5) ses seviyesi arasında geçiş. */
721
+ toggleAdMute() {
722
+ if (!this.adsManager) return;
723
+ const e = this.adsManager.getVolume();
724
+ e > 0 ? (this.adVolumeBeforeMute = e, this.adsManager.setVolume(0)) : this.adsManager.setVolume(this.adVolumeBeforeMute > 0 ? this.adVolumeBeforeMute : 0.5);
725
+ }
726
+ viewMode() {
727
+ const e = document, t = this.ctx.hostEl;
728
+ return document.fullscreenElement === t || e.webkitFullscreenElement === t ? this.ima.ViewMode.FULLSCREEN : this.ima.ViewMode.NORMAL;
729
+ }
730
+ /**
731
+ * Reklamı player'ın şimdiki boyutuna getirir: tam ekrana giriş/çıkış, pencere küçültme, cihaz döndürme.
732
+ * IMA boyutu yalnızca init()'te alır; resize() çağrılmazsa reklam eski boyutunda kalıyordu.
733
+ */
734
+ resizeAd() {
735
+ if (!this.adsManager || !this.ima) return;
736
+ const e = this.ctx.videoEl;
737
+ if (!(!e.clientWidth || !e.clientHeight))
738
+ try {
739
+ if (this.nonLinearActive) {
740
+ const t = this.ctx.adLayerEl, i = Math.round(e.clientHeight / 3), s = this.nonLinearCreativeHeight || i;
741
+ t.style.setProperty("--hp-nonlinear-ad-height", `${Math.min(i + 40, s + 24)}px`), this.adsManager.resize(t.clientWidth || e.clientWidth, t.clientHeight || i, this.viewMode());
742
+ } else
743
+ this.adsManager.resize(e.clientWidth, e.clientHeight, this.viewMode());
744
+ } catch {
745
+ }
746
+ }
747
+ /** IMA hatasının kodlarını çıkarır, hata kaydına yazar (yeniden denenecek olsa da) ve mesajı döndürür. */
748
+ recordAdError(e) {
749
+ var s, a, o, n, c, h, d;
750
+ const t = (s = e.getError) == null ? void 0 : s.call(e), i = {
751
+ message: ((a = t == null ? void 0 : t.getMessage) == null ? void 0 : a.call(t)) ?? "ad-error",
752
+ code: (o = t == null ? void 0 : t.getErrorCode) == null ? void 0 : o.call(t),
753
+ vastCode: (n = t == null ? void 0 : t.getVastErrorCode) == null ? void 0 : n.call(t),
754
+ errorType: (c = t == null ? void 0 : t.getType) == null ? void 0 : c.call(t)
755
+ };
756
+ return i.vastCode !== void 0 && i.vastCode <= 0 && (i.vastCode = void 0), this.lastAdError = i, (d = (h = this.ctx).log) == null || d.call(h, {
757
+ message: i.message,
758
+ details: { code: i.code, vastCode: i.vastCode, errorType: i.errorType, break: this.breakTypeLower() }
759
+ }), i.message;
760
+ }
761
+ giveUpOrRetry(e, t) {
762
+ if (e === "Preroll" && this.prerollAbandoned) return;
763
+ if (this.scte35BreakActive) {
764
+ this.endScte35Break();
765
+ return;
766
+ }
767
+ const i = V(this.options, e);
768
+ if (!i) {
769
+ this.resumeContentAfterGiveUp(e, t);
770
+ return;
771
+ }
772
+ this.retry.retry(
773
+ e,
774
+ i,
775
+ (s, a) => this.requestAd(e, s, a),
776
+ () => this.resumeContentAfterGiveUp(e, t)
777
+ );
778
+ }
779
+ resumeContentAfterGiveUp(e, t) {
780
+ this.hideAdLayer();
781
+ const i = this.lastAdError;
782
+ this.lastAdError = null, this.ctx.hostEl.dispatchEvent(
783
+ new CustomEvent("hp:aderror", {
784
+ detail: {
785
+ message: t ?? (i == null ? void 0 : i.message) ?? "ad-error",
786
+ code: i == null ? void 0 : i.code,
787
+ vastCode: i == null ? void 0 : i.vastCode,
788
+ errorType: i == null ? void 0 : i.errorType,
789
+ breakType: e.toLowerCase()
790
+ }
791
+ })
792
+ ), e === "Preroll" && this.maybeRequestVmapAfterPreroll();
793
+ const s = this.ctx.prerollGate;
794
+ if (e === "Preroll" && (s != null && s.isArmed)) {
795
+ s.release(!0);
796
+ return;
797
+ }
798
+ e !== "Postroll" && this.ctx.videoEl.paused && this.ctx.videoEl.play().catch(() => {
799
+ });
800
+ }
801
+ /** VMAP split: preroll (başarılı ya da vazgeçilerek) bitince, VMAP TAM OLARAK BİR KEZ, değiştirilmeden istenir. */
802
+ maybeRequestVmapAfterPreroll() {
803
+ this.vmapRequested || !this.options.adTagVmap || (this.vmapRequested = !0, this.requestAd("Midroll", this.options.adTagVmap, 0, !0));
804
+ }
805
+ hideAdLayer() {
806
+ this.nonLinearActive || (this.ctx.adLayerEl.classList.add("hp:hidden"), this.ctx.adLayerEl.classList.remove("hp:block")), this.ctx.showChrome();
807
+ }
808
+ /**
809
+ * Başlayan aranın gerçek tipi. VMAP tek istekle preroll + midroll + postroll getirir; isteğin tipi (currentBreakType)
810
+ * yalnızca ilk arayı anlatır — midroll'lar "preroll" diye bildiriliyor, VMAP postroll'undan sonra video baştan
811
+ * başlıyordu. IMA reklamın arasındaki konumu verir: 0 preroll, -1 postroll, diğerleri midroll.
812
+ */
813
+ breakTypeOf(e) {
814
+ var t, i, s, a, o;
815
+ if (!this.lastRequestIsVmap) return this.breakTypeLower();
816
+ try {
817
+ const n = (o = (a = (s = (i = (t = e == null ? void 0 : e.getAd) == null ? void 0 : t.call(e)) == null ? void 0 : i.getAdPodInfo) == null ? void 0 : s.call(i)) == null ? void 0 : a.getTimeOffset) == null ? void 0 : o.call(a);
818
+ if (typeof n == "number") return n === 0 ? "preroll" : n < 0 ? "postroll" : "midroll";
819
+ } catch {
820
+ }
821
+ return this.breakTypeLower();
822
+ }
823
+ breakTypeLower() {
824
+ return this.currentBreakType.toLowerCase();
825
+ }
826
+ }
827
+ async function D(l, e) {
828
+ const t = new U(l, e);
829
+ return await t.install(), t;
830
+ }
831
+ export {
832
+ U as AdsController,
833
+ D as installAds
834
+ };
835
+ //# sourceMappingURL=index-Br_RybXV.js.map