@schibsted/advertory 2.60.1 → 2.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/aftenposten/es/index.css +1 -1
- package/core/aftenposten/es/index.d.ts +7 -1
- package/core/aftenposten/es/index.js +1 -1
- package/core/aftenposten/index.d.ts +7 -1
- package/core/aftenposten/index.js +1 -1
- package/core/{e24v2/es → aftenpostenv2}/index.d.ts +7 -1
- package/core/aftenpostenv2/index.js +1 -0
- package/{sites/e24v2/es → core/aftenpostenv2}/package.json +1 -1
- package/core/aftonbladet/es/index.css +1 -1
- package/core/aftonbladet/es/index.d.ts +7 -1
- package/core/aftonbladet/es/index.js +1 -1
- package/core/aftonbladet/index.d.ts +7 -1
- package/core/aftonbladet/index.js +1 -1
- package/core/aftonbladetv2/es/index.d.ts +7 -1
- package/core/aftonbladetv2/es/index.js +1 -1
- package/core/bt/es/index.css +1 -1
- package/core/bt/es/index.d.ts +7 -1
- package/core/bt/es/index.js +1 -1
- package/core/bt/index.d.ts +7 -1
- package/core/bt/index.js +1 -1
- package/core/e24/es/index.css +1 -1
- package/core/e24/es/index.d.ts +7 -1
- package/core/e24/es/index.js +1 -1
- package/core/e24/index.d.ts +7 -1
- package/core/e24/index.js +1 -1
- package/core/fotbollskanalen/es/index.css +1 -1
- package/core/fotbollskanalen/es/index.d.ts +7 -1
- package/core/fotbollskanalen/es/index.js +1 -1
- package/core/fotbollskanalen/index.d.ts +7 -1
- package/core/fotbollskanalen/index.js +1 -1
- package/core/godare/index.d.ts +7 -1
- package/core/godare/index.js +1 -1
- package/core/godt/index.d.ts +7 -1
- package/core/godt/index.js +1 -1
- package/core/klart/index.d.ts +7 -1
- package/core/klart/index.js +1 -1
- package/core/koket/es/index.css +1 -1
- package/core/koket/es/index.d.ts +7 -1
- package/core/koket/es/index.js +1 -1
- package/core/koket/index.d.ts +7 -1
- package/core/koket/index.js +1 -1
- package/core/kompakt/index.d.ts +7 -1
- package/core/kompakt/index.js +1 -1
- package/core/minmote/index.d.ts +7 -1
- package/core/minmote/index.js +1 -1
- package/core/pent/index.d.ts +7 -1
- package/core/pent/index.js +1 -1
- package/core/sa/es/index.css +1 -1
- package/core/sa/es/index.d.ts +7 -1
- package/core/sa/es/index.js +1 -1
- package/core/sa/index.d.ts +7 -1
- package/core/sa/index.js +1 -1
- package/core/svd/es/index.css +1 -1
- package/core/svd/es/index.d.ts +7 -1
- package/core/svd/es/index.js +1 -1
- package/core/svd/index.d.ts +7 -1
- package/core/svd/index.js +1 -1
- package/core/svdv2/es/index.css +1 -1
- package/core/svdv2/es/index.d.ts +7 -1
- package/core/svdv2/es/index.js +1 -1
- package/core/tek/index.d.ts +7 -1
- package/core/tek/index.js +1 -1
- package/core/tv4/es/index.d.ts +7 -1
- package/core/tv4/es/index.js +1 -1
- package/core/tv4/index.d.ts +7 -1
- package/core/tv4/index.js +1 -1
- package/core/tvnu/index.d.ts +7 -1
- package/core/tvnu/index.js +1 -1
- package/core/vg/es/index.css +1 -1
- package/core/vg/es/index.d.ts +7 -1
- package/core/vg/es/index.js +1 -1
- package/core/vg/index.d.ts +7 -1
- package/core/vg/index.js +1 -1
- package/core/vgv2/es/index.css +1 -1
- package/core/vgv2/es/index.d.ts +7 -1
- package/core/vgv2/es/index.js +1 -1
- package/features/ad-native/index.d.ts +7 -0
- package/features/dr-edition/es/index.d.ts +13 -4
- package/features/dr-edition/es/index.js +1 -1
- package/features/dr-edition/index.d.ts +13 -4
- package/features/dr-edition/index.js +1 -1
- package/features/tracker/index.d.ts +7 -0
- package/package.json +1 -1
- package/sites/aftenposten/es/index.css +1 -1
- package/sites/{e24v2/es → aftenpostenv2}/index.d.ts +6 -10
- package/sites/aftenpostenv2/index.js +1 -0
- package/{core/e24v2/es → sites/aftenpostenv2}/package.json +1 -1
- package/sites/aftonbladet/es/index.css +1 -1
- package/sites/aftonbladetv2/es/index.css +1 -1
- package/sites/bt/es/index.css +1 -1
- package/sites/e24/es/index.css +1 -1
- package/sites/e24/es/index.d.ts +5 -1
- package/sites/e24/es/index.js +1 -1
- package/sites/e24/index.d.ts +5 -1
- package/sites/e24/index.js +1 -1
- package/sites/fotbollskanalen/es/index.css +1 -1
- package/sites/koket/es/index.css +1 -1
- package/sites/sa/es/index.css +1 -1
- package/sites/svd/es/index.css +1 -1
- package/sites/svdv2/es/index.css +1 -1
- package/sites/vg/es/index.css +1 -1
- package/sites/vgv2/es/index.css +1 -1
- package/styles/aftenpostenv2/styles.css +1 -0
- package/styles/e24/styles.css +1 -1
- package/types/core/handlers/ad-server/placement.d.ts +2 -1
- package/types/core/interface/config.d.ts +7 -0
- package/types/features/ad-native/sites/aftenpostenv2/aftenposten-init.d.ts +4 -0
- package/types/features/ad-native/sites/aftenpostenv2/index.d.ts +6 -0
- package/types/features/ad-native/sites/aftenpostenv2/templates/content/index.d.ts +4 -0
- package/types/features/ad-native/sites/aftenpostenv2/templates/index.d.ts +3 -0
- package/types/features/ad-native/sites/aftenpostenv2/templates/recirc/index.d.ts +4 -0
- package/types/features/dr-edition/DrEdition.d.ts +1 -1
- package/types/features/dr-edition/types.d.ts +5 -3
- package/types/features/kilkaya/Kilkaya.d.ts +1 -1
- package/types/features/kilkaya/types.d.ts +5 -3
- package/types/features/widescreen-switching/constants.d.ts +3 -0
- package/types/features/widescreen-switching/query-widescreen.d.ts +3 -0
- package/types/features/widescreen-switching/query-widescreen.test.d.ts +1 -0
- package/types/interface/global.d.ts +0 -1
- package/types/sites/aftenpostenv2/formats/Netboard/index.d.ts +3 -0
- package/types/sites/{e24v2/formats/Brandboard → aftenpostenv2/formats/Skyscraper}/index.d.ts +1 -1
- package/types/sites/aftenpostenv2/formats/Wallpaper/index.d.ts +2 -0
- package/types/sites/aftenpostenv2/formats/helpers.d.ts +4 -0
- package/types/sites/{e24v2 → aftenpostenv2}/formats/index.d.ts +2 -5
- package/types/sites/aftenpostenv2/index.d.ts +4 -0
- package/types/sites/aftenpostenv2/prepare-page-options.test.d.ts +1 -0
- package/types/sites/aftenpostenv2/prepare-tag.d.ts +3 -0
- package/types/sites/aftenpostenv2/prepare-tag.test.d.ts +1 -0
- package/types/sites/e24/formats/Skyscraper/index.d.ts +3 -1
- package/types/sites/e24/formats/Wallpaper/index.d.ts +2 -1
- package/types/sites/e24/formats/index.d.ts +1 -0
- package/types/sites/e24/index.d.ts +2 -2
- package/core/e24v2/es/index.css +0 -1
- package/core/e24v2/es/index.js +0 -1
- package/sites/e24v2/es/index.css +0 -1
- package/sites/e24v2/es/index.js +0 -1
- package/styles/e24v2/styles.css +0 -1
- package/types/sites/e24/formats/helpers.d.ts +0 -4
- package/types/sites/e24v2/formats/Netboard/index.d.ts +0 -3
- package/types/sites/e24v2/formats/Skyscraper/index.d.ts +0 -5
- package/types/sites/e24v2/formats/Wallpaper/index.d.ts +0 -4
- package/types/sites/e24v2/index.d.ts +0 -2
- package/types/sites/tvnu/formats/Widescreen/helpers.d.ts +0 -1
- /package/styles/{e24v2 → aftenpostenv2}/index.js +0 -0
- /package/types/config/{e24v2.d.ts → aftenpostenv2.d.ts} +0 -0
- /package/types/{sites/aftonbladetv2/formats/Widescreen/helpers.d.ts → features/widescreen-switching/index.d.ts} +0 -0
- /package/types/{sites/e24v2/prepare-page-options.test.d.ts → features/widescreen-switching/index.test.d.ts} +0 -0
- /package/types/sites/{e24v2 → aftenpostenv2}/config.d.ts +0 -0
- /package/types/sites/{e24v2 → aftenpostenv2}/events.d.ts +0 -0
- /package/types/sites/{e24v2 → aftenpostenv2}/formats/Topboard/index.d.ts +0 -0
- /package/types/sites/{e24v2 → aftenpostenv2}/prepare-page-options.d.ts +0 -0
- /package/types/sites/{e24v2 → e24}/formats/Aksjelive/index.d.ts +0 -0
- /package/types/sites/{e24v2 → e24}/formats/Netboard/helpers.d.ts +0 -0
- /package/types/sites/{e24v2 → e24}/formats/Topboard/helpers.d.ts +0 -0
- /package/types/sites/{e24v2 → e24}/formats/Wallpaper/helpers.d.ts +0 -0
|
@@ -262,6 +262,7 @@ interface SiteConfig {
|
|
|
262
262
|
};
|
|
263
263
|
useAppTabletInvCode?: boolean;
|
|
264
264
|
adScaleConfig?: AdScaleConfig;
|
|
265
|
+
widescreenSwitching?: WidescreenSwitchingConfig;
|
|
265
266
|
}
|
|
266
267
|
interface NativeTrackingConfig {
|
|
267
268
|
nativeTrackingEnabled?: boolean;
|
|
@@ -271,6 +272,7 @@ interface SiteSpecificConfig {
|
|
|
271
272
|
publisherClassName?: Newsroom;
|
|
272
273
|
fullWidthFormatClassName?: 'netboard' | 'panorama';
|
|
273
274
|
classesToRemoveOnRefresh?: Array<string>;
|
|
275
|
+
mainColumnWidth?: number;
|
|
274
276
|
}
|
|
275
277
|
interface Placement {
|
|
276
278
|
id: string;
|
|
@@ -491,6 +493,11 @@ interface DevicePlacementBatches {
|
|
|
491
493
|
type PlacementBatchesConfig = {
|
|
492
494
|
[device in DeviceType]: DevicePlacementBatches;
|
|
493
495
|
};
|
|
496
|
+
interface WidescreenSwitchingConfig {
|
|
497
|
+
enabled: boolean;
|
|
498
|
+
rotationInterval?: number;
|
|
499
|
+
widescreenIdPrefix?: string;
|
|
500
|
+
}
|
|
494
501
|
|
|
495
502
|
interface AdComponentProps {
|
|
496
503
|
placementId: string;
|
|
@@ -265,6 +265,7 @@ interface SiteConfig {
|
|
|
265
265
|
};
|
|
266
266
|
useAppTabletInvCode?: boolean;
|
|
267
267
|
adScaleConfig?: AdScaleConfig;
|
|
268
|
+
widescreenSwitching?: WidescreenSwitchingConfig;
|
|
268
269
|
}
|
|
269
270
|
interface NativeTrackingConfig {
|
|
270
271
|
nativeTrackingEnabled?: boolean;
|
|
@@ -274,6 +275,7 @@ interface SiteSpecificConfig {
|
|
|
274
275
|
publisherClassName?: Newsroom;
|
|
275
276
|
fullWidthFormatClassName?: 'netboard' | 'panorama';
|
|
276
277
|
classesToRemoveOnRefresh?: Array<string>;
|
|
278
|
+
mainColumnWidth?: number;
|
|
277
279
|
}
|
|
278
280
|
interface Placement {
|
|
279
281
|
id: string;
|
|
@@ -494,6 +496,11 @@ interface DevicePlacementBatches {
|
|
|
494
496
|
type PlacementBatchesConfig = {
|
|
495
497
|
[device in DeviceType]: DevicePlacementBatches;
|
|
496
498
|
};
|
|
499
|
+
interface WidescreenSwitchingConfig {
|
|
500
|
+
enabled: boolean;
|
|
501
|
+
rotationInterval?: number;
|
|
502
|
+
widescreenIdPrefix?: string;
|
|
503
|
+
}
|
|
497
504
|
|
|
498
505
|
interface DrEditionParams {
|
|
499
506
|
editionName: string;
|
|
@@ -562,9 +569,11 @@ interface DrEditionComponentProps {
|
|
|
562
569
|
editionName: string;
|
|
563
570
|
children: ReactNode;
|
|
564
571
|
fallbackTargetId?: string;
|
|
565
|
-
pulseData?:
|
|
566
|
-
|
|
567
|
-
|
|
572
|
+
pulseData?: DrEditionHtmlAttributes;
|
|
573
|
+
htmlAttributes?: DrEditionHtmlAttributes;
|
|
574
|
+
}
|
|
575
|
+
interface DrEditionHtmlAttributes {
|
|
576
|
+
[key: string]: string | boolean | number;
|
|
568
577
|
}
|
|
569
578
|
type DrEditionObserverProperties = Pick<DrEditionObserverConfig, 'publisher' | 'pageType' | 'country'>;
|
|
570
579
|
|
|
@@ -600,7 +609,7 @@ declare class DrEditionManager {
|
|
|
600
609
|
|
|
601
610
|
declare const getDrEditionManager: (drEditionPageProperties: DrEditionObserverProperties, identityFacade: IdentityFacade, pulse?: PulseInstance) => DrEditionManager;
|
|
602
611
|
|
|
603
|
-
declare const DrEdition: ({ editionName, fallbackTargetId, children, pulseData }: DrEditionComponentProps) => ReactNode;
|
|
612
|
+
declare const DrEdition: ({ editionName, fallbackTargetId, children, pulseData, htmlAttributes }: DrEditionComponentProps) => ReactNode;
|
|
604
613
|
|
|
605
614
|
declare const handleDrEditionBackfill: (config: SiteConfig, adObj: AstAdObj) => Promise<void>;
|
|
606
615
|
declare const handleDrEdition: (siteConfig: SiteConfig) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";function n(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}d((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i={get:(e,t)=>n(void 0,void 0,void 0,function*(){const n=yield fetch(e,t);if(!n.ok)throw new Error(n.statusText);return yield n.json()}),post:(e,t,i)=>n(void 0,void 0,void 0,function*(){const n=JSON.stringify(i),r=yield fetch(e,{method:"POST",headers:t,body:n});if(!r.ok)throw new Error(r.statusText);return yield r.json()})},r=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},o=["netboard","board"];class s{constructor(e,t){this.identityFacade=e,this.tracker=t}buildUrl(e,t){var n,i;const{editionName:r}=e,o=(()=>{const e=window.location.href;return new URL(e).searchParams.get("dre_override_inv_code")||""})(),s=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),a=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return a.searchParams.append("editionName",r),o&&a.searchParams.append("urlData",o),s&&a.searchParams.append("excludedItems",s),l&&a.searchParams.append("spid",l),d&&a.searchParams.append("envid",d),a.toString()}fetchData(e){return n(this,void 0,void 0,function*(){var t,n;const o=yield this.identityFacade.getIdentityUser(),s=null!==(n=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==n?n:"",a=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:s,spid:a});try{r("Starting fetching DrEdition ad from URL:",d);const e={method:"GET"},t=yield i.get(d,e);return r("Fetch operation completed successfully."),t}catch(e){r("Error during fetch operation:",e)}return null})}}class a{getDrEditionUTMParams(e,t){var n;const{title:i="",clientName:r,creativeId:o}=null!==(n=null==e?void 0:e.pulseData)&&void 0!==n?n:{},{editionName:s}=t,a=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:s,utm_campaign:r,utm_medium:a},o&&{utm_id:`df-${o}`})}getUrlSearchParams(e,t,n){if(!e)return"";const i=this.getDrEditionUTMParams(t,n),r=new URLSearchParams(decodeURIComponent(e.search)),o=new URLSearchParams(e.search);return Object.entries(i).forEach(([e,t])=>{r.has(e)||o.set(e,null!=t?t:"")}),o.toString().replace(/\+/g,"%20")}getUrlWithParams(e,t){var n;const i=null===(n=null==e?void 0:e.pulseData)||void 0===n?void 0:n.url;if(!i)return"";const r=this.getDrEditionUTMParams(e,t),o=new URL(i);return Object.entries(r).forEach(([e,t])=>{o.searchParams.has(e)||o.searchParams.set(e,null!=t?t:"")}),o.toString()}handleVideo(e,t){return n(this,void 0,void 0,function*(){const{id:n,autoplay:i,mute:r,videoLoop:o,vendor:s}=t.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:n,vgtvVendor:s,vgtvAutoplay:i,vgtvMuted:r,vgtvLoop:!!o,vgtvNa:!0,vgtvRecommended:!1,vgtvPulseProvider:"vg",vgtvPulseProductTag:"partnerstudio"})})}getPulseObjectId(){return"sdrn:vg:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(){return"sdrn:vg:frontpage:front"}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];const{host:i,pathname:r}=new URL(n);if(!i.includes("www.vg.no")&&!r.includes("annonsorinnhold"))return[n];const o=r.split("/");return o.length?[...o.filter(Boolean).slice(1).map(e=>e),n]:[n]}}const d=e=>{if(window.location.href.includes("collapse_ad=0"))return;const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.setProperty("width","0","important"),t.style.setProperty("height","0","important"),t.style.setProperty("display","none","important"),n.style.setProperty("display","none","important"),e.includes("wallpaper")&&(()=>{const e=document.querySelector(".advertory-wallpaper-background");e&&e.remove()})())},l=e=>{const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("display"),n.style.removeProperty("display"))},c=e=>{const t=e.parentElement;t?t.classList.remove("dr-edition-lock-height"):r("Dr. Edition container does not have a parent element, cannot remove height lock.")};class u{constructor(e,t,n,i){this.drEditionService=e,this.rendererManager=t,this.videoManager=n,this.pulseManager=i,this.drEditionAds=[]}fetchAndRenderAd(e,t){return n(this,void 0,void 0,function*(){var n,i;const{drEditionConfig:{containerSelector:o},renderAsBackfill:s=!1}=t,a=e.querySelector(o);if(!a)return void r(`Container with selector "${o}" not found.`);const u=yield this.drEditionService.fetchData(t);return(null==u?void 0:u.itemId)||s?!(null==u?void 0:u.itemId)&&s?(r("No Dr. Edition ads available to render. Collapsing whole placement."),d(e.id),void c(a)):((null==u?void 0:u.itemId)&&s&&(r("Dr. Edition ad available to render as a Xandr backfill."),l(e.id)),void(u?(u.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(u.css,"style"),yield this.rendererManager.render(a,u,t),yield null===(n=this.videoManager)||void 0===n?void 0:n.handle(u,t),c(a),this.drEditionAds.push(u),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(u.itemId),this.observeAdView(e,u,t),null===(i=e.querySelector("a"))||void 0===i||i.addEventListener("pointerup",()=>null)):c(a))):(r("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(a),this.showBackfill(e),void c(a))})}observeAdView(e,t,n){this.observeCarousel(e,t,n)||((e,t,n={threshold:.5})=>{new IntersectionObserver(([e],n)=>{e.isIntersecting&&(t(),n.disconnect())},n).observe(e)})(e,()=>this.pulseManager.trackContentView(e,t,n),{threshold:.5})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";const i=null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"";l(i)}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){const i=e.querySelector(".dr-edition-slider");if(!i)return!1;let r=null;const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.intersectionRatio>=.9&&(r&&clearTimeout(r),r=setTimeout(()=>{e.target.onclick=()=>this.pulseManager.trackContentClick(e.target,t,n),this.pulseManager.trackContentView(e.target,t,n)},500)),[...i.children].forEach(e=>{o.observe(e)})})},{threshold:[.9]});return[...i.children].forEach(e=>{o.observe(e)}),!0}}const v=e=>new Promise(t=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void t(!1);const n=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const t=Number(e);return r("Advertising permission value obtained synchronously: ",e),Boolean(t)})();if(null!==n)return void t(n);let i=!1;const o=e=>{i||(r("Resolving advertising permission value obtained"),i=!0,t(e))},s=setTimeout(()=>{r("Advertising permission timed out, resolving with false"),o(!1)},3e3);window._tcf_.onTcfReady(()=>{r("On Tcf Ready called, waiting for permission"),clearTimeout(s)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(s);const t=Number(e);r("Advertising permission value obtained asynchronously: ",e),o(Boolean(t))})}),p="no",g="se",h="cmp:loaded";let m,y=!1;const f=(e,t,i)=>{const o=!!(null==e?void 0:e.enabled),s=(null==e?void 0:e.timeout)||3e3,a=(d="bypass_tcf",new URLSearchParams(window.location.search).get(d));var d;const l=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(r("TCF bypass param detected, returning consent: true"),!0):(r("TCF is not enabled, returning consent: true"),!0))(o,a))return!0;if(y)return null;if(!m)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=m.getConsentedToAllSync();return r(`TCF consented to all is: ${t}`),m.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(r("Getting TCF consent manager..."),window._tcf_)return r("TCF consent manager is already available"),m=window._tcf_,void e(m);r("TCF consent manager is not available");const n=()=>{r("CMP loaded, resolving consent manager..."),i&&clearTimeout(i),window._tcf_?(m=window._tcf_,e(m)):t(new Error("CMP loaded but window._tcf_ is not defined"))},i=setTimeout(()=>{document.removeEventListener(h,n),y=!0,t(new Error("Timeout waiting for CMP to load"))},s);r("Listening for CMP loaded event..."),document.addEventListener(h,n,{once:!0})}):Promise.resolve(null),getConsentSync:l,getConsentAsync:()=>n(void 0,void 0,void 0,function*(){if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return r(`Schibsted Ad Choices override value is set, returning override value: ${e.schibstedAdChoicesOverrideValue}`),Boolean(Number(e.schibstedAdChoicesOverrideValue));const n=(null==e?void 0:e.schibstedAdChoicesEnabled)&&i===g,o=(null==e?void 0:e.schibstedAdChoicesEnabled)&&!t&&i===p;if(n||o)return r("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield v(e);if(!(null==e?void 0:e.enabled))return!0;const a=l();return null!==a?a:yield new Promise((e,t)=>{try{if(!m)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let t=!1;const n=n=>{t||(t=!0,e(n))},i=setTimeout(()=>{r("TCF isConsentedToAll timed out, resolving with false"),n(!1)},s);m.onTcfReady(()=>{r("On Tcf Ready called, waiting for consent"),clearTimeout(i)}),m.isConsentedToAll(t=>{clearTimeout(i),e(t)})}catch(e){t(e)}})})}},w="mobile";class b{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,t,i){return n(this,void 0,void 0,function*(){if(!(null==t?void 0:t.itemId))return;const{getConsentAsync:n}=f(i.tcf,i.isMobileApp,i.country),r=yield n(),o=i.device===w?t.mobileHTML:t.desktopHTML;const s=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=s,e.querySelectorAll("a").forEach(e=>{var n,r,o;e.search=null!==(o=null===(r=(n=this.newsroomStrategy).getUrlSearchParams)||void 0===r?void 0:r.call(n,e,t,i))&&void 0!==o?o:"",e.onclick=()=>this.pulseManager.trackContentClick(e,t,i)})})}}class E{constructor(e){this.strategy=e}handle(e,t){return n(this,void 0,void 0,function*(){const{videoConfiguration:{id:n,preview:i}={}}=e;(n||i)&&(yield this.importScript(t),yield this.createVideoElement(e,t))})}importScript(e){return n(this,void 0,void 0,function*(){const t=e.drEditionConfig.videoScriptUrl,i=document.querySelector(`script[src="${t}"]`);if(t&&!window.autoplayQueue&&!i)try{yield((e,...t)=>n(void 0,[e,...t],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,i)=>{const r=document.createElement("script");r.async=!0,r.src=e;const o=()=>{a(),n()},s=()=>{a(),i(new Error(`Failed to load ${e}`))},a=()=>{r.removeEventListener("load",o),r.removeEventListener("error",s),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",s);const d=setTimeout(()=>{a(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(t)}catch(e){r("Error! Failed to prepare SVP player script for Dr. Edition!",e)}})}createVideoElement(e,t){return n(this,void 0,void 0,function*(){const n=document.createElement("div"),{node:i}=e.videoConfiguration,r=[...document.querySelectorAll(`#${i}`)||[]].find(e=>0===e.children.length);if(this.handlePreviewVideo(e,t))return;this.strategy.handleVideo(n,e),null==r||r.appendChild(n),window.autoplayQueue=window.autoplayQueue||[],window.autoplayQueue.push(e=>{e.parse()});const o=null==r?void 0:r.parentNode;if(!o)return;const s=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");s!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:s}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const a=document.querySelector(".dr-edition-preview .preview-video");return!!a&&(a.setAttribute("src",o),a.setAttribute("playsinline",""),!(!a||!s)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,a),!0))}}class P{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t,n,i){return{}}mapPageType(e){return{front:"Frontpage",article:"Article",section:"Article",collection:"Article",other:"Article"}[e||"front"]||"Frontpage"}getArticleId(){return location.pathname.split("/").slice(-2,-1).pop()||""}getTeaserElementText(e,t){if(!e)return"";const n=e.querySelector({title:".dr-edition-title",subtitle:".dr-edition-subtitle",image:"img.teaser-main-image"}[t]);if(!n)return"";if("image"===t)return n.src||"";const i=null==n?void 0:n.textContent;return i?i.trim():""}getEventTarget(e,t){const{itemId:n,pulseData:{url:i}={}}=t,r=this.getTeaserElementText(e,"title");return{id:n,name:this.normalizePlacementTitle(null!=r?r:""),type:"Page",url:i}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e,t,i){return n(this,void 0,void 0,function*(){var n,r,o,s,a,d,l,c;if(!this.pulse)return;const u=this.getEventInput(e,t,i,"view");(null===(n=this.pulse)||void 0===n?void 0:n.trackLegacyViewUIElement)?null===(o=null===(r=this.pulse)||void 0===r?void 0:r.trackLegacyViewUIElement)||void 0===o||o.call(r,u):(null===(s=this.pulse)||void 0===s?void 0:s.trackViewUIElement)?null===(d=null===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)||void 0===d||d.call(a,u):null===(c=null===(l=this.pulse)||void 0===l?void 0:l.trackElementView)||void 0===c||c.call(l,u)})}trackContentClick(e,t,i){return n(this,void 0,void 0,function*(){var n,r,o,s,a,d;if(!this.pulse)return;const l=this.getEventInput(e,t,i,"click");this.pulse.trackLegacyClickUIElement?null===(r=(n=this.pulse).trackLegacyClickUIElement)||void 0===r||r.call(n,l):this.pulse.trackClickUIElement?null===(s=(o=this.pulse).trackClickUIElement)||void 0===s||s.call(o,l):null===(d=(a=this.pulse).trackElementClick)||void 0===d||d.call(a,l)})}}class T extends P{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){const{pulseData:{title:i,clientName:r="",creativeId:o}={}}=t,{columnName:s,primaryPosition:a}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:s,primaryPosition:a},"spt:custom":{is_sponsored:!0,sponsor:r,"spt:creativeId":o},url:location.origin}}getEventInput(e,t,n){return{object:this.getEventBaseData(e,t,n),target:this.getEventTarget(e,t)}}}class C extends P{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,s,a,d;const{itemId:l,pulseData:{clientName:c,creativeId:u}={}}=t,v=n.editionName,p=this.mapPageType(this.pageType),g=null===(i=this.newsroomStrategy)||void 0===i?void 0:i.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(s=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==s?s:v,"@type":"UIElement",position:v,elementType:"Article",custom:{customer:c,creativeId:null!=u?u:l},page:{"@id":null!=g?g:v,"@type":p,url:location.origin},tags:null===(d=null===(a=this.newsroomStrategy)||void 0===a?void 0:a.getTags)||void 0===d?void 0:d.call(a,e)}}getEventInput(e,t,n,i){return{object:this.getEventBaseData(e,t,n),partnerstudio:this.getEventPartnerstudioData(e,t,n,i),target:this.getEventTarget(e,t),provider:this.getProviderData()}}getEventPartnerstudioData(e,t,n,i){var r,o,s,a;const{pulseData:{algorithm:d="sov",clientName:l,creativeId:c,editionId:u,itemId:v,url:p,probability:g}={}}=t,h=Math.floor(Date.now()/1e3),m=this.getTeaserElementText(e,"title"),y=this.getTeaserElementText(e,"subtitle"),f=this.getTeaserElementText(e,"image"),w=null!==(a=null!==(s=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getUrlWithParams)||void 0===o?void 0:o.call(r,t,n))&&void 0!==s?s:p)&&void 0!==a?a:"";return{algorithm:d,clientName:l,probability:g,creativeId:c,device:n.device,editionId:u,itemId:v,link:w,placement:n.editionName,subtitle:y,time:h,title:m,type:i,imageUrl:f,frontId:86,tracking_type:"ad",xandrAdLoaded:!1}}getProviderData(){return{productTag:"partnerstudio"}}}const I="svd",S="vg",k="aftonbladet",A="e24",L="front",j=e=>n(void 0,void 0,void 0,function*(){var t,n;return(null===(t=null===window||void 0===window?void 0:window.SVP)||void 0===t?void 0:t.Player)?new window.SVP.Player(e):((()=>{const e="svp-player-sdk",t=document.querySelector(e),n=Array.from(document.querySelectorAll('script[src^="https://cdn.stream.schibsted.media/player"]'));if(t||n.length>0)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.stream.schibsted.media/player/3.78.1/player.min.js",i.async=!0;try{i.src=i.src.replace("player.min","player.next.min")}catch(e){console.error("Failed to set player.next.min source:",e)}document.head.insertBefore(i,document.head.firstChild)})(),(null===(n=window.SVP)||void 0===n?void 0:n.isLoaded)?new window.SVP.Player(e):yield new Promise(t=>{window.addEventListener("onSvpPlayerReady",()=>t(new window.SVP.Player(e)))}))}),M={ContentMutePlugin:e=>{window.SVP.Player.Plugins.register({getName:()=>"ContentMutePlugin",initialize(){},setup(){const t=this.player.config.get("mute");this.container=e||this.player.getContainer(),this.muted=t,t&&this.listenToOnce(this.player,"ready",this.renderButtonElement,this)},getButtonElement(){const e=document.createElement("button");e.className="player-plugin-content-mute";const t=document.createElement("span");return t.className="volume-button-icon",e.appendChild(t),e},renderButtonElement(){this.buttonElement=this.getButtonElement(),this.buttonElement.addEventListener("click",this.onButtonClick.bind(this)),this.container.appendChild(this.buttonElement),this.isVideo()||(this.buttonElement.style.display="none"),this.getJWPlayer()&&this.getJWPlayer().on("mute",this.onMuteChange,this)},onButtonClick(){this.getJWPlayer()&&(this.container.classList.add("has-interacted"),this.muted=!this.muted,this.getJWPlayer().setMute(this.muted))},onMuteChange(e){this.muted=e.mute,this.muted?this.buttonElement.classList.remove("content-video-volume-on"):this.buttonElement.classList.add("content-video-volume-on")},isVideo(){return"video"===this.player.getRawAsset().assetType},getJWPlayer(){return this.player.model.player}})},IntegrationMenu:()=>{window.SVP.Player.Plugins.register({getName:()=>"IntegrationMenu",setup(){return n(this,void 0,void 0,function*(){yield Promise.resolve().then(function(){return G})})}})}};class O{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:i,autoplay:r,mute:o,vendor:s}}){yield n(void 0,void 0,void 0,function*(){return yield new Promise(e=>{var t;Boolean(null===(t=window.SVP)||void 0===t?void 0:t.Player)?e(!0):window.addEventListener("onSvpPlayerReady",()=>e(!0))})});const a=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=a)||l.forEach(e=>{M[e](c)});const u={id:t,node:i,autoplay:r,mute:o,vendor:s,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield j(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,a)}),v.once("ready",()=>{const t=e;new MutationObserver(e=>{e.forEach(({type:e,attributeName:n})=>{"attributes"===e&&"class"===n&&(t.classList.contains("jw-state-playing")?d.classList.add("is-playing"):d.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?d.classList.add("is-inactive"):d.classList.remove("is-inactive"))})}).observe(t,{attributes:!0,attributeFilter:["class"]})}),v.once("PulseStats:ready",()=>n(this,void 0,void 0,function*(){const e=yield v.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"e24",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:e24:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===L?"sdrn:e24:frontpage:front":`sdrn:e24:article:${t}`}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];if(!n.includes("https://e24.no/annonsorinnhold/"))return[n];const{pathname:i}=new URL(n),r=i.split("/").filter(Boolean);return r.length?[...r.slice(1),n]:[n]}createPlayerOverlay(e){const t=document.createElement("div");t.classList.add("cm-custom-video-overlay"),e.parentElement&&(t.innerHTML=e.parentElement.innerHTML,e.parentElement.replaceChild(t,e));return t.addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),t.classList.add("has-interacted")}),t}}const V="https://www.aftonbladet.se/video-player-extras/latest/";class _{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const s={id:t,node:n,autoplay:i,mute:r,vendor:o,autopause:"viewable",maxBitrate:600,pulse:{provider:"aftonbladet"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"",url:""},plugins:{[`${V}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${V}external-link.js`]:{name:"ExternalLink"}}};yield j(s),this.addEditionVideoClass(e)})}addEditionVideoClass(e){var t;(null===(t=null==e?void 0:e.parentElement)||void 0===t?void 0:t.parentElement)&&e.parentElement.parentElement.classList.add("dr-edition-video-player")}getPulseObjectId(){return""}getPulsePageId(){return""}}const N=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);class U{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:i,autoplay:r,mute:o,vendor:s}}){const a={id:t,node:i,autoplay:r,mute:o,vendor:s,locale:"se",autopause:"viewable",maxBitrate:600,sharing:!1,recommended:!1,pulse:{provider:"svdse",decorator:(e,t)=>Object.assign(Object.assign({},N(e)?e:{}),{provider:Object.assign(Object.assign({},N(null==e?void 0:e.provider)?e.provider:{}),{productTag:"partnerstudio"})})},skin:{name:"svd-player",url:""},settings:{pulse:{host:"se-aftonbladet.videoplaza.tv",contentMetadata:{category:"SvD",tags:["standard-linears","pause",`video-${t}`]},requestSettings:{}}}},d=yield j(a);d.once("PulseStats:ready",()=>n(this,void 0,void 0,function*(){const e=yield d.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"svdse",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:svdse:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===L?"sdrn:svdse:frontpage:front":`sdrn:svdse:article:${t}`}}class D{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const x=(e,t,n)=>{var i;const{publisher:r,pageType:o,country:d}=e,l={[S]:new a,[A]:new O,[k]:new _,[I]:new U}[r]||new D,c=new(d===g?T:C)(n,l,o),v=new s(t,null!==(i=null==n?void 0:n.pulseTracker)&&void 0!==i?i:n),p=new b(l,c),h=new E(l);return new u(v,p,h,c)},B=({editionName:n,fallbackTargetId:i,children:r,pulseData:o})=>{const s=(e=>{const t={};if(!e)return t;for(const[n,i]of Object.entries(e))t[`data-pulse-${n}`]=String(i);return t})(o);return e("div",Object.assign({className:"dr-edition-wrapper dr-edition-lock-height","data-edition-name":n},s,{children:[t("div",{className:"inscreen-target"}),t("div",{className:"container"}),t("div",{className:"fallback","data-fallback-target-id":i,style:{display:"none"},children:r})]}))},R=()=>n(void 0,void 0,void 0,function*(){return yield new Promise(e=>{if("undefined"!=typeof window)if(window.Identity)e(window.Identity);else{const t=()=>{e(window.Identity)};window.addEventListener("identity-initialized",t,{once:!0})}else e(void 0)})});class ${constructor(e){this.identity=e,this.getIdentityUser=this.getIdentityUser.bind(this),this.isUserLoggedIn=this.isUserLoggedIn.bind(this),this.onIdentityLogout=this.onIdentityLogout.bind(this)}getIdentityUser(){return n(this,void 0,void 0,function*(){var e;try{const t=yield null===(e=this.identity)||void 0===e?void 0:e.getUser();return null!=t?t:null}catch(e){return r("[Privacy Broker] User is not logged in."),null}})}isUserLoggedIn(){return n(this,void 0,void 0,function*(){var e,t;return null!==(t=yield null===(e=this.identity)||void 0===e?void 0:e.isLoggedIn())&&void 0!==t&&t})}onIdentityLogout(e){var t;null===(t=this.identity)||void 0===t||t.on("logout",e)}}const F=(e,t,n)=>{const{wrapperSelector:i}=null==e?void 0:e.drEditionConfig,r=document.querySelectorAll(i),o=new IntersectionObserver((i,r)=>((e,t,n,i,r)=>{const o=x(n,i,r);e.forEach(e=>{var i,r,s;if(!e.isIntersecting)return;const a=e.target,d=null!==(i=a.dataset.editionName)&&void 0!==i?i:"",l=null!==(r=a.dataset.pulseColumnname)&&void 0!==r?r:"",c=null!==(s=a.dataset.pulsePrimaryposition)&&void 0!==s?s:"";o.fetchAndRenderAd(a,Object.assign(Object.assign({},n),{editionName:d,columnName:l,primaryPosition:c})),t.unobserve(a)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},q=(e,t,i,...o)=>n(void 0,[e,t,i,...o],void 0,function*(e,t,n,i="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return r(`Schibsted Consent to Pay is not enabled, returning true for ${i}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return r(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${i}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:o}=f(e,t,n);return(yield o())?(r(`Schibsted Ad Choices consent given according to TCF consent manager for ${i}`),!0):(r(`Schibsted Ad Choices consent not given according to TCF consent manager for ${i}`),!1)}),H=[],z=(e,t)=>n(void 0,void 0,void 0,function*(){var n;const{pulse:i,tcf:s,deviceType:a,drEdition:d,publisher:l,pageType:c,country:u,isMobileApp:v}=e;if(!(yield q(s,v,u,"handleDrEditionBackfill")))return;const p=((e,t)=>{var n;const{deviceType:i,placements:r,drEdition:{fallbackGlobalEditionName:s}={}}=e,a=r[i]||r.desktop,d=(e=>{const t=e.split("-"),n=t[t.length-1];return 6===n.length&&n.match(/^[a-zA-Z0-9]+$/)?t.slice(0,-1).join("-"):e})(t.targetId),l=a.find(e=>e.id===d),c=o.some(e=>d.startsWith(e)),u=H.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||s;return l&&c&&!u&&v?(H.push(d),Object.assign(Object.assign({},l),{drEdition:Object.assign(Object.assign({},l.drEdition),{editionName:v})})):null})(e,t);if(!p)return;if(!(null==i?void 0:i.instance))return void r("Pulse has not been passed as a prop, aborting");const g=yield R(),h=new $(g),m=x({publisher:l,pageType:c,country:u},h,null==i?void 0:i.instance),y=document.getElementById(t.targetId);if(!y||!d)return;y.classList.value="";const f=document.createElement("div");f.className=d.containerSelector.replace(/^[.#:[\]]+/,""),y.innerHTML=f.outerHTML;const w={editionName:(null===(n=null==p?void 0:p.drEdition)||void 0===n?void 0:n.editionName)||"",drEditionConfig:d,device:a,tcf:s,isMobileApp:v,country:u,renderAsBackfill:!0};yield m.fetchAndRenderAd(y,w)}),W=e=>n(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;if(!(yield q(e.tcf,e.isMobileApp,e.country,"handleDrEdition")))return;const n=yield R(),i=new $(n);F({publisher:e.publisher,drEditionConfig:e.drEdition,device:e.deviceType,pageType:e.pageType,country:e.country},i,null===(t=e.pulse)||void 0===t?void 0:t.instance)});const J=function(e){if("undefined"==typeof window)return;const t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}("[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-slider-time{display:none}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container{padding:0 6px;height:36px}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon{margin-right:3px;height:unset;width:unset;bottom:0}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-volume,[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-playback{display:flex}");var G=Object.freeze({__proto__:null,default:J});export{B as DrEdition,x as getDrEditionManager,W as handleDrEdition,z as handleDrEditionBackfill};
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";function n(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}d((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i={get:(e,t)=>n(void 0,void 0,void 0,function*(){const n=yield fetch(e,t);if(!n.ok)throw new Error(n.statusText);return yield n.json()}),post:(e,t,i)=>n(void 0,void 0,void 0,function*(){const n=JSON.stringify(i),r=yield fetch(e,{method:"POST",headers:t,body:n});if(!r.ok)throw new Error(r.statusText);return yield r.json()})},r=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},o=["netboard","board"];class s{constructor(e,t){this.identityFacade=e,this.tracker=t}buildUrl(e,t){var n,i;const{editionName:r}=e,o=(()=>{const e=window.location.href;return new URL(e).searchParams.get("dre_override_inv_code")||""})(),s=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),a=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return a.searchParams.append("editionName",r),o&&a.searchParams.append("urlData",o),s&&a.searchParams.append("excludedItems",s),l&&a.searchParams.append("spid",l),d&&a.searchParams.append("envid",d),a.toString()}fetchData(e){return n(this,void 0,void 0,function*(){var t,n;const o=yield this.identityFacade.getIdentityUser(),s=null!==(n=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==n?n:"",a=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:s,spid:a});try{r("Starting fetching DrEdition ad from URL:",d);const e={method:"GET"},t=yield i.get(d,e);return r("Fetch operation completed successfully."),t}catch(e){r("Error during fetch operation:",e)}return null})}}class a{getDrEditionUTMParams(e,t){var n;const{title:i="",clientName:r,creativeId:o}=null!==(n=null==e?void 0:e.pulseData)&&void 0!==n?n:{},{editionName:s}=t,a=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:s,utm_campaign:r,utm_medium:a},o&&{utm_id:`df-${o}`})}getUrlSearchParams(e,t,n){if(!e)return"";const i=this.getDrEditionUTMParams(t,n),r=new URLSearchParams(decodeURIComponent(e.search)),o=new URLSearchParams(e.search);return Object.entries(i).forEach(([e,t])=>{r.has(e)||o.set(e,null!=t?t:"")}),o.toString().replace(/\+/g,"%20")}getUrlWithParams(e,t){var n;const i=null===(n=null==e?void 0:e.pulseData)||void 0===n?void 0:n.url;if(!i)return"";const r=this.getDrEditionUTMParams(e,t),o=new URL(i);return Object.entries(r).forEach(([e,t])=>{o.searchParams.has(e)||o.searchParams.set(e,null!=t?t:"")}),o.toString()}handleVideo(e,t){return n(this,void 0,void 0,function*(){const{id:n,autoplay:i,mute:r,videoLoop:o,vendor:s}=t.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:n,vgtvVendor:s,vgtvAutoplay:i,vgtvMuted:r,vgtvLoop:!!o,vgtvNa:!0,vgtvRecommended:!1,vgtvPulseProvider:"vg",vgtvPulseProductTag:"partnerstudio"})})}getPulseObjectId(){return"sdrn:vg:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(){return"sdrn:vg:frontpage:front"}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];const{host:i,pathname:r}=new URL(n);if(!i.includes("www.vg.no")&&!r.includes("annonsorinnhold"))return[n];const o=r.split("/");return o.length?[...o.filter(Boolean).slice(1).map(e=>e),n]:[n]}}const d=e=>{if(window.location.href.includes("collapse_ad=0"))return;const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.setProperty("width","0","important"),t.style.setProperty("height","0","important"),t.style.setProperty("display","none","important"),n.style.setProperty("display","none","important"),e.includes("wallpaper")&&(()=>{const e=document.querySelector(".advertory-wallpaper-background");e&&e.remove()})())},l=e=>{const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("display"),n.style.removeProperty("display"))},c=e=>{const t=e.parentElement;t?t.classList.remove("dr-edition-lock-height"):r("Dr. Edition container does not have a parent element, cannot remove height lock.")};class u{constructor(e,t,n,i){this.drEditionService=e,this.rendererManager=t,this.videoManager=n,this.pulseManager=i,this.drEditionAds=[]}fetchAndRenderAd(e,t){return n(this,void 0,void 0,function*(){var n,i;const{drEditionConfig:{containerSelector:o},renderAsBackfill:s=!1}=t,a=e.querySelector(o);if(!a)return void r(`Container with selector "${o}" not found.`);const u=yield this.drEditionService.fetchData(t);return(null==u?void 0:u.itemId)||s?!(null==u?void 0:u.itemId)&&s?(r("No Dr. Edition ads available to render. Collapsing whole placement."),d(e.id),void c(a)):((null==u?void 0:u.itemId)&&s&&(r("Dr. Edition ad available to render as a Xandr backfill."),l(e.id)),void(u?(u.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(u.css,"style"),yield this.rendererManager.render(a,u,t),yield null===(n=this.videoManager)||void 0===n?void 0:n.handle(u,t),c(a),this.drEditionAds.push(u),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(u.itemId),this.observeAdView(e,u,t),null===(i=e.querySelector("a"))||void 0===i||i.addEventListener("pointerup",()=>null)):c(a))):(r("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(a),this.showBackfill(e),void c(a))})}observeAdView(e,t,n){this.observeCarousel(e,t,n)||((e,t,n={threshold:.5})=>{new IntersectionObserver(([e],n)=>{e.isIntersecting&&(t(),n.disconnect())},n).observe(e)})(e,()=>this.pulseManager.trackContentView(e,t,n),{threshold:.5})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";const i=null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"";l(i)}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){const i=e.querySelector(".dr-edition-slider");if(!i)return!1;let r=null;const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.intersectionRatio>=.9&&(r&&clearTimeout(r),r=setTimeout(()=>{e.target.onclick=()=>this.pulseManager.trackContentClick(e.target,t,n),this.pulseManager.trackContentView(e.target,t,n)},500)),[...i.children].forEach(e=>{o.observe(e)})})},{threshold:[.9]});return[...i.children].forEach(e=>{o.observe(e)}),!0}}const v=e=>new Promise(t=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void t(!1);const n=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const t=Number(e);return r("Advertising permission value obtained synchronously: ",e),Boolean(t)})();if(null!==n)return void t(n);let i=!1;const o=e=>{i||(r("Resolving advertising permission value obtained"),i=!0,t(e))},s=setTimeout(()=>{r("Advertising permission timed out, resolving with false"),o(!1)},3e3);window._tcf_.onTcfReady(()=>{r("On Tcf Ready called, waiting for permission"),clearTimeout(s)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(s);const t=Number(e);r("Advertising permission value obtained asynchronously: ",e),o(Boolean(t))})}),p="no",h="se",g="cmp:loaded";let m,y=!1;const f=(e,t,i)=>{const o=!!(null==e?void 0:e.enabled),s=(null==e?void 0:e.timeout)||3e3,a=(d="bypass_tcf",new URLSearchParams(window.location.search).get(d));var d;const l=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(r("TCF bypass param detected, returning consent: true"),!0):(r("TCF is not enabled, returning consent: true"),!0))(o,a))return!0;if(y)return null;if(!m)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=m.getConsentedToAllSync();return r(`TCF consented to all is: ${t}`),m.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(r("Getting TCF consent manager..."),window._tcf_)return r("TCF consent manager is already available"),m=window._tcf_,void e(m);r("TCF consent manager is not available");const n=()=>{r("CMP loaded, resolving consent manager..."),i&&clearTimeout(i),window._tcf_?(m=window._tcf_,e(m)):t(new Error("CMP loaded but window._tcf_ is not defined"))},i=setTimeout(()=>{document.removeEventListener(g,n),y=!0,t(new Error("Timeout waiting for CMP to load"))},s);r("Listening for CMP loaded event..."),document.addEventListener(g,n,{once:!0})}):Promise.resolve(null),getConsentSync:l,getConsentAsync:()=>n(void 0,void 0,void 0,function*(){if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return r(`Schibsted Ad Choices override value is set, returning override value: ${e.schibstedAdChoicesOverrideValue}`),Boolean(Number(e.schibstedAdChoicesOverrideValue));const n=(null==e?void 0:e.schibstedAdChoicesEnabled)&&i===h,o=(null==e?void 0:e.schibstedAdChoicesEnabled)&&!t&&i===p;if(n||o)return r("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield v(e);if(!(null==e?void 0:e.enabled))return!0;const a=l();return null!==a?a:yield new Promise((e,t)=>{try{if(!m)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let t=!1;const n=n=>{t||(t=!0,e(n))},i=setTimeout(()=>{r("TCF isConsentedToAll timed out, resolving with false"),n(!1)},s);m.onTcfReady(()=>{r("On Tcf Ready called, waiting for consent"),clearTimeout(i)}),m.isConsentedToAll(t=>{clearTimeout(i),e(t)})}catch(e){t(e)}})})}},w="mobile";class b{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,t,i){return n(this,void 0,void 0,function*(){if(!(null==t?void 0:t.itemId))return;const{getConsentAsync:n}=f(i.tcf,i.isMobileApp,i.country),r=yield n(),o=i.device===w?t.mobileHTML:t.desktopHTML;const s=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=s,e.querySelectorAll("a").forEach(e=>{var n,r,o;e.search=null!==(o=null===(r=(n=this.newsroomStrategy).getUrlSearchParams)||void 0===r?void 0:r.call(n,e,t,i))&&void 0!==o?o:"",e.onclick=()=>this.pulseManager.trackContentClick(e,t,i)})})}}class E{constructor(e){this.strategy=e}handle(e,t){return n(this,void 0,void 0,function*(){const{videoConfiguration:{id:n,preview:i}={}}=e;(n||i)&&(yield this.importScript(t),yield this.createVideoElement(e,t))})}importScript(e){return n(this,void 0,void 0,function*(){const t=e.drEditionConfig.videoScriptUrl,i=document.querySelector(`script[src="${t}"]`);if(t&&!window.autoplayQueue&&!i)try{yield((e,...t)=>n(void 0,[e,...t],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,i)=>{const r=document.createElement("script");r.async=!0,r.src=e;const o=()=>{a(),n()},s=()=>{a(),i(new Error(`Failed to load ${e}`))},a=()=>{r.removeEventListener("load",o),r.removeEventListener("error",s),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",s);const d=setTimeout(()=>{a(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(t)}catch(e){r("Error! Failed to prepare SVP player script for Dr. Edition!",e)}})}createVideoElement(e,t){return n(this,void 0,void 0,function*(){const n=document.createElement("div"),{node:i}=e.videoConfiguration,r=[...document.querySelectorAll(`#${i}`)||[]].find(e=>0===e.children.length);if(this.handlePreviewVideo(e,t))return;this.strategy.handleVideo(n,e),null==r||r.appendChild(n),window.autoplayQueue=window.autoplayQueue||[],window.autoplayQueue.push(e=>{e.parse()});const o=null==r?void 0:r.parentNode;if(!o)return;const s=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");s!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:s}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const a=document.querySelector(".dr-edition-preview .preview-video");return!!a&&(a.setAttribute("src",o),a.setAttribute("playsinline",""),!(!a||!s)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,a),!0))}}class P{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t,n,i){return{}}mapPageType(e){return{front:"Frontpage",article:"Article",section:"Article",collection:"Article",other:"Article"}[e||"front"]||"Frontpage"}getArticleId(){return location.pathname.split("/").slice(-2,-1).pop()||""}getTeaserElementText(e,t){if(!e)return"";const n=e.querySelector({title:".dr-edition-title",subtitle:".dr-edition-subtitle",image:"img.teaser-main-image"}[t]);if(!n)return"";if("image"===t)return n.src||"";const i=null==n?void 0:n.textContent;return i?i.trim():""}getEventTarget(e,t){const{itemId:n,pulseData:{url:i}={}}=t,r=this.getTeaserElementText(e,"title");return{id:n,name:this.normalizePlacementTitle(null!=r?r:""),type:"Page",url:i}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e,t,i){return n(this,void 0,void 0,function*(){var n,r,o,s,a,d,l,c;if(!this.pulse)return;const u=this.getEventInput(e,t,i,"view");(null===(n=this.pulse)||void 0===n?void 0:n.trackLegacyViewUIElement)?null===(o=null===(r=this.pulse)||void 0===r?void 0:r.trackLegacyViewUIElement)||void 0===o||o.call(r,u):(null===(s=this.pulse)||void 0===s?void 0:s.trackViewUIElement)?null===(d=null===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)||void 0===d||d.call(a,u):null===(c=null===(l=this.pulse)||void 0===l?void 0:l.trackElementView)||void 0===c||c.call(l,u)})}trackContentClick(e,t,i){return n(this,void 0,void 0,function*(){var n,r,o,s,a,d;if(!this.pulse)return;const l=this.getEventInput(e,t,i,"click");this.pulse.trackLegacyClickUIElement?null===(r=(n=this.pulse).trackLegacyClickUIElement)||void 0===r||r.call(n,l):this.pulse.trackClickUIElement?null===(s=(o=this.pulse).trackClickUIElement)||void 0===s||s.call(o,l):null===(d=(a=this.pulse).trackElementClick)||void 0===d||d.call(a,l)})}}class T extends P{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){const{pulseData:{title:i,clientName:r="",creativeId:o}={}}=t,{columnName:s,primaryPosition:a}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:s,primaryPosition:a},"spt:custom":{is_sponsored:!0,sponsor:r,"spt:creativeId":o},url:location.origin}}getEventInput(e,t,n){return{object:this.getEventBaseData(e,t,n),target:this.getEventTarget(e,t)}}}class C extends P{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,s,a,d;const{itemId:l,pulseData:{clientName:c,creativeId:u}={}}=t,v=n.editionName,p=this.mapPageType(this.pageType),h=null===(i=this.newsroomStrategy)||void 0===i?void 0:i.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(s=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==s?s:v,"@type":"UIElement",position:v,elementType:"Article",custom:{customer:c,creativeId:null!=u?u:l},page:{"@id":null!=h?h:v,"@type":p,url:location.origin},tags:null===(d=null===(a=this.newsroomStrategy)||void 0===a?void 0:a.getTags)||void 0===d?void 0:d.call(a,e)}}getEventInput(e,t,n,i){return{object:this.getEventBaseData(e,t,n),partnerstudio:this.getEventPartnerstudioData(e,t,n,i),target:this.getEventTarget(e,t),provider:this.getProviderData()}}getEventPartnerstudioData(e,t,n,i){var r,o,s,a;const{pulseData:{algorithm:d="sov",clientName:l,creativeId:c,editionId:u,itemId:v,url:p,probability:h}={}}=t,g=Math.floor(Date.now()/1e3),m=this.getTeaserElementText(e,"title"),y=this.getTeaserElementText(e,"subtitle"),f=this.getTeaserElementText(e,"image"),w=null!==(a=null!==(s=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getUrlWithParams)||void 0===o?void 0:o.call(r,t,n))&&void 0!==s?s:p)&&void 0!==a?a:"";return{algorithm:d,clientName:l,probability:h,creativeId:c,device:n.device,editionId:u,itemId:v,link:w,placement:n.editionName,subtitle:y,time:g,title:m,type:i,imageUrl:f,frontId:86,tracking_type:"ad",xandrAdLoaded:!1}}getProviderData(){return{productTag:"partnerstudio"}}}const I="svd",S="vg",A="aftonbladet",k="e24",L="front",j=e=>n(void 0,void 0,void 0,function*(){var t,n;return(null===(t=null===window||void 0===window?void 0:window.SVP)||void 0===t?void 0:t.Player)?new window.SVP.Player(e):((()=>{const e="svp-player-sdk",t=document.querySelector(e),n=Array.from(document.querySelectorAll('script[src^="https://cdn.stream.schibsted.media/player"]'));if(t||n.length>0)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.stream.schibsted.media/player/3.78.1/player.min.js",i.async=!0;try{i.src=i.src.replace("player.min","player.next.min")}catch(e){console.error("Failed to set player.next.min source:",e)}document.head.insertBefore(i,document.head.firstChild)})(),(null===(n=window.SVP)||void 0===n?void 0:n.isLoaded)?new window.SVP.Player(e):yield new Promise(t=>{window.addEventListener("onSvpPlayerReady",()=>t(new window.SVP.Player(e)))}))}),M={ContentMutePlugin:e=>{window.SVP.Player.Plugins.register({getName:()=>"ContentMutePlugin",initialize(){},setup(){const t=this.player.config.get("mute");this.container=e||this.player.getContainer(),this.muted=t,t&&this.listenToOnce(this.player,"ready",this.renderButtonElement,this)},getButtonElement(){const e=document.createElement("button");e.className="player-plugin-content-mute";const t=document.createElement("span");return t.className="volume-button-icon",e.appendChild(t),e},renderButtonElement(){this.buttonElement=this.getButtonElement(),this.buttonElement.addEventListener("click",this.onButtonClick.bind(this)),this.container.appendChild(this.buttonElement),this.isVideo()||(this.buttonElement.style.display="none"),this.getJWPlayer()&&this.getJWPlayer().on("mute",this.onMuteChange,this)},onButtonClick(){this.getJWPlayer()&&(this.container.classList.add("has-interacted"),this.muted=!this.muted,this.getJWPlayer().setMute(this.muted))},onMuteChange(e){this.muted=e.mute,this.muted?this.buttonElement.classList.remove("content-video-volume-on"):this.buttonElement.classList.add("content-video-volume-on")},isVideo(){return"video"===this.player.getRawAsset().assetType},getJWPlayer(){return this.player.model.player}})},IntegrationMenu:()=>{window.SVP.Player.Plugins.register({getName:()=>"IntegrationMenu",setup(){return n(this,void 0,void 0,function*(){yield Promise.resolve().then(function(){return G})})}})}};class O{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:i,autoplay:r,mute:o,vendor:s}}){yield n(void 0,void 0,void 0,function*(){return yield new Promise(e=>{var t;Boolean(null===(t=window.SVP)||void 0===t?void 0:t.Player)?e(!0):window.addEventListener("onSvpPlayerReady",()=>e(!0))})});const a=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=a)||l.forEach(e=>{M[e](c)});const u={id:t,node:i,autoplay:r,mute:o,vendor:s,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield j(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,a)}),v.once("ready",()=>{const t=e;new MutationObserver(e=>{e.forEach(({type:e,attributeName:n})=>{"attributes"===e&&"class"===n&&(t.classList.contains("jw-state-playing")?d.classList.add("is-playing"):d.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?d.classList.add("is-inactive"):d.classList.remove("is-inactive"))})}).observe(t,{attributes:!0,attributeFilter:["class"]})}),v.once("PulseStats:ready",()=>n(this,void 0,void 0,function*(){const e=yield v.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"e24",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:e24:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===L?"sdrn:e24:frontpage:front":`sdrn:e24:article:${t}`}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];if(!n.includes("https://e24.no/annonsorinnhold/"))return[n];const{pathname:i}=new URL(n),r=i.split("/").filter(Boolean);return r.length?[...r.slice(1),n]:[n]}createPlayerOverlay(e){const t=document.createElement("div");t.classList.add("cm-custom-video-overlay"),e.parentElement&&(t.innerHTML=e.parentElement.innerHTML,e.parentElement.replaceChild(t,e));return t.addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),t.classList.add("has-interacted")}),t}}const V="https://www.aftonbladet.se/video-player-extras/latest/";class _{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const s={id:t,node:n,autoplay:i,mute:r,vendor:o,autopause:"viewable",maxBitrate:600,pulse:{provider:"aftonbladet"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"",url:""},plugins:{[`${V}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${V}external-link.js`]:{name:"ExternalLink"}}};yield j(s),this.addEditionVideoClass(e)})}addEditionVideoClass(e){var t;(null===(t=null==e?void 0:e.parentElement)||void 0===t?void 0:t.parentElement)&&e.parentElement.parentElement.classList.add("dr-edition-video-player")}getPulseObjectId(){return""}getPulsePageId(){return""}}const N=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);class U{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:i,autoplay:r,mute:o,vendor:s}}){const a={id:t,node:i,autoplay:r,mute:o,vendor:s,locale:"se",autopause:"viewable",maxBitrate:600,sharing:!1,recommended:!1,pulse:{provider:"svdse",decorator:(e,t)=>Object.assign(Object.assign({},N(e)?e:{}),{provider:Object.assign(Object.assign({},N(null==e?void 0:e.provider)?e.provider:{}),{productTag:"partnerstudio"})})},skin:{name:"svd-player",url:""},settings:{pulse:{host:"se-aftonbladet.videoplaza.tv",contentMetadata:{category:"SvD",tags:["standard-linears","pause",`video-${t}`]},requestSettings:{}}}},d=yield j(a);d.once("PulseStats:ready",()=>n(this,void 0,void 0,function*(){const e=yield d.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"svdse",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:svdse:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===L?"sdrn:svdse:frontpage:front":`sdrn:svdse:article:${t}`}}class D{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const x=(e,t,n)=>{var i;const{publisher:r,pageType:o,country:d}=e,l={[S]:new a,[k]:new O,[A]:new _,[I]:new U}[r]||new D,c=new(d===h?T:C)(n,l,o),v=new s(t,null!==(i=null==n?void 0:n.pulseTracker)&&void 0!==i?i:n),p=new b(l,c),g=new E(l);return new u(v,p,g,c)},B=({editionName:n,fallbackTargetId:i,children:r,pulseData:o,htmlAttributes:s})=>{const a=(e,t)=>{const n={};if(!e)return n;for(const[i,r]of Object.entries(e)){n[t?`${t}-${i}`:i]=String(r)}return n},d=a(o,"data-pulse"),l=a(s,"data");return e("div",Object.assign({className:"dr-edition-wrapper dr-edition-lock-height","data-edition-name":n},d,l,{children:[t("div",{className:"inscreen-target"}),t("div",{className:"container"}),t("div",{className:"fallback","data-fallback-target-id":i,style:{display:"none"},children:r})]}))},R=()=>n(void 0,void 0,void 0,function*(){return yield new Promise(e=>{if("undefined"!=typeof window)if(window.Identity)e(window.Identity);else{const t=()=>{e(window.Identity)};window.addEventListener("identity-initialized",t,{once:!0})}else e(void 0)})});class ${constructor(e){this.identity=e,this.getIdentityUser=this.getIdentityUser.bind(this),this.isUserLoggedIn=this.isUserLoggedIn.bind(this),this.onIdentityLogout=this.onIdentityLogout.bind(this)}getIdentityUser(){return n(this,void 0,void 0,function*(){var e;try{const t=yield null===(e=this.identity)||void 0===e?void 0:e.getUser();return null!=t?t:null}catch(e){return r("[Privacy Broker] User is not logged in."),null}})}isUserLoggedIn(){return n(this,void 0,void 0,function*(){var e,t;return null!==(t=yield null===(e=this.identity)||void 0===e?void 0:e.isLoggedIn())&&void 0!==t&&t})}onIdentityLogout(e){var t;null===(t=this.identity)||void 0===t||t.on("logout",e)}}const F=(e,t,n)=>{const{wrapperSelector:i}=null==e?void 0:e.drEditionConfig,r=document.querySelectorAll(i),o=new IntersectionObserver((i,r)=>((e,t,n,i,r)=>{const o=x(n,i,r);e.forEach(e=>{var i,r,s;if(!e.isIntersecting)return;const a=e.target,d=null!==(i=a.dataset.editionName)&&void 0!==i?i:"",l=null!==(r=a.dataset.pulseColumnname)&&void 0!==r?r:"",c=null!==(s=a.dataset.pulsePrimaryposition)&&void 0!==s?s:"";o.fetchAndRenderAd(a,Object.assign(Object.assign({},n),{editionName:d,columnName:l,primaryPosition:c})),t.unobserve(a)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},q=(e,t,i,...o)=>n(void 0,[e,t,i,...o],void 0,function*(e,t,n,i="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return r(`Schibsted Consent to Pay is not enabled, returning true for ${i}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return r(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${i}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:o}=f(e,t,n);return(yield o())?(r(`Schibsted Ad Choices consent given according to TCF consent manager for ${i}`),!0):(r(`Schibsted Ad Choices consent not given according to TCF consent manager for ${i}`),!1)}),H=[],z=(e,t)=>n(void 0,void 0,void 0,function*(){var n;const{pulse:i,tcf:s,deviceType:a,drEdition:d,publisher:l,pageType:c,country:u,isMobileApp:v}=e;if(!(yield q(s,v,u,"handleDrEditionBackfill")))return;const p=((e,t)=>{var n;const{deviceType:i,placements:r,drEdition:{fallbackGlobalEditionName:s}={}}=e,a=r[i]||r.desktop,d=(e=>{const t=e.split("-"),n=t[t.length-1];return 6===n.length&&n.match(/^[a-zA-Z0-9]+$/)?t.slice(0,-1).join("-"):e})(t.targetId),l=a.find(e=>e.id===d),c=o.some(e=>d.startsWith(e)),u=H.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||s;return l&&c&&!u&&v?(H.push(d),Object.assign(Object.assign({},l),{drEdition:Object.assign(Object.assign({},l.drEdition),{editionName:v})})):null})(e,t);if(!p)return;if(!(null==i?void 0:i.instance))return void r("Pulse has not been passed as a prop, aborting");const h=yield R(),g=new $(h),m=x({publisher:l,pageType:c,country:u},g,null==i?void 0:i.instance),y=document.getElementById(t.targetId);if(!y||!d)return;y.classList.value="";const f=document.createElement("div");f.className=d.containerSelector.replace(/^[.#:[\]]+/,""),y.innerHTML=f.outerHTML;const w={editionName:(null===(n=null==p?void 0:p.drEdition)||void 0===n?void 0:n.editionName)||"",drEditionConfig:d,device:a,tcf:s,isMobileApp:v,country:u,renderAsBackfill:!0};yield m.fetchAndRenderAd(y,w)}),W=e=>n(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;if(!(yield q(e.tcf,e.isMobileApp,e.country,"handleDrEdition")))return;const n=yield R(),i=new $(n);F({publisher:e.publisher,drEditionConfig:e.drEdition,device:e.deviceType,pageType:e.pageType,country:e.country},i,null===(t=e.pulse)||void 0===t?void 0:t.instance)});const J=function(e){if("undefined"==typeof window)return;const t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}("[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-slider-time{display:none}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container{padding:0 6px;height:36px}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon{margin-right:3px;height:unset;width:unset;bottom:0}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-volume,[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-playback{display:flex}");var G=Object.freeze({__proto__:null,default:J});export{B as DrEdition,x as getDrEditionManager,W as handleDrEdition,z as handleDrEditionBackfill};
|
|
@@ -265,6 +265,7 @@ interface SiteConfig {
|
|
|
265
265
|
};
|
|
266
266
|
useAppTabletInvCode?: boolean;
|
|
267
267
|
adScaleConfig?: AdScaleConfig;
|
|
268
|
+
widescreenSwitching?: WidescreenSwitchingConfig;
|
|
268
269
|
}
|
|
269
270
|
interface NativeTrackingConfig {
|
|
270
271
|
nativeTrackingEnabled?: boolean;
|
|
@@ -274,6 +275,7 @@ interface SiteSpecificConfig {
|
|
|
274
275
|
publisherClassName?: Newsroom;
|
|
275
276
|
fullWidthFormatClassName?: 'netboard' | 'panorama';
|
|
276
277
|
classesToRemoveOnRefresh?: Array<string>;
|
|
278
|
+
mainColumnWidth?: number;
|
|
277
279
|
}
|
|
278
280
|
interface Placement {
|
|
279
281
|
id: string;
|
|
@@ -494,6 +496,11 @@ interface DevicePlacementBatches {
|
|
|
494
496
|
type PlacementBatchesConfig = {
|
|
495
497
|
[device in DeviceType]: DevicePlacementBatches;
|
|
496
498
|
};
|
|
499
|
+
interface WidescreenSwitchingConfig {
|
|
500
|
+
enabled: boolean;
|
|
501
|
+
rotationInterval?: number;
|
|
502
|
+
widescreenIdPrefix?: string;
|
|
503
|
+
}
|
|
497
504
|
|
|
498
505
|
interface DrEditionParams {
|
|
499
506
|
editionName: string;
|
|
@@ -562,9 +569,11 @@ interface DrEditionComponentProps {
|
|
|
562
569
|
editionName: string;
|
|
563
570
|
children: ReactNode;
|
|
564
571
|
fallbackTargetId?: string;
|
|
565
|
-
pulseData?:
|
|
566
|
-
|
|
567
|
-
|
|
572
|
+
pulseData?: DrEditionHtmlAttributes;
|
|
573
|
+
htmlAttributes?: DrEditionHtmlAttributes;
|
|
574
|
+
}
|
|
575
|
+
interface DrEditionHtmlAttributes {
|
|
576
|
+
[key: string]: string | boolean | number;
|
|
568
577
|
}
|
|
569
578
|
type DrEditionObserverProperties = Pick<DrEditionObserverConfig, 'publisher' | 'pageType' | 'country'>;
|
|
570
579
|
|
|
@@ -600,7 +609,7 @@ declare class DrEditionManager {
|
|
|
600
609
|
|
|
601
610
|
declare const getDrEditionManager: (drEditionPageProperties: DrEditionObserverProperties, identityFacade: IdentityFacade, pulse?: PulseInstance) => DrEditionManager;
|
|
602
611
|
|
|
603
|
-
declare const DrEdition: ({ editionName, fallbackTargetId, children, pulseData }: DrEditionComponentProps) => ReactNode;
|
|
612
|
+
declare const DrEdition: ({ editionName, fallbackTargetId, children, pulseData, htmlAttributes }: DrEditionComponentProps) => ReactNode;
|
|
604
613
|
|
|
605
614
|
declare const handleDrEditionBackfill: (config: SiteConfig, adObj: AstAdObj) => Promise<void>;
|
|
606
615
|
declare const handleDrEdition: (siteConfig: SiteConfig) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime");function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}d((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const n={get:(e,n)=>t(void 0,void 0,void 0,function*(){const t=yield fetch(e,n);if(!t.ok)throw new Error(t.statusText);return yield t.json()}),post:(e,n,i)=>t(void 0,void 0,void 0,function*(){const t=JSON.stringify(i),r=yield fetch(e,{method:"POST",headers:n,body:t});if(!r.ok)throw new Error(r.statusText);return yield r.json()})},i=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},r=["netboard","board"];class o{constructor(e,t){this.identityFacade=e,this.tracker=t}buildUrl(e,t){var n,i;const{editionName:r}=e,o=(()=>{const e=window.location.href;return new URL(e).searchParams.get("dre_override_inv_code")||""})(),s=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),a=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return a.searchParams.append("editionName",r),o&&a.searchParams.append("urlData",o),s&&a.searchParams.append("excludedItems",s),l&&a.searchParams.append("spid",l),d&&a.searchParams.append("envid",d),a.toString()}fetchData(e){return t(this,void 0,void 0,function*(){var t,r;const o=yield this.identityFacade.getIdentityUser(),s=null!==(r=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==r?r:"",a=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:s,spid:a});try{i("Starting fetching DrEdition ad from URL:",d);const e={method:"GET"},t=yield n.get(d,e);return i("Fetch operation completed successfully."),t}catch(e){i("Error during fetch operation:",e)}return null})}}class s{getDrEditionUTMParams(e,t){var n;const{title:i="",clientName:r,creativeId:o}=null!==(n=null==e?void 0:e.pulseData)&&void 0!==n?n:{},{editionName:s}=t,a=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:s,utm_campaign:r,utm_medium:a},o&&{utm_id:`df-${o}`})}getUrlSearchParams(e,t,n){if(!e)return"";const i=this.getDrEditionUTMParams(t,n),r=new URLSearchParams(decodeURIComponent(e.search)),o=new URLSearchParams(e.search);return Object.entries(i).forEach(([e,t])=>{r.has(e)||o.set(e,null!=t?t:"")}),o.toString().replace(/\+/g,"%20")}getUrlWithParams(e,t){var n;const i=null===(n=null==e?void 0:e.pulseData)||void 0===n?void 0:n.url;if(!i)return"";const r=this.getDrEditionUTMParams(e,t),o=new URL(i);return Object.entries(r).forEach(([e,t])=>{o.searchParams.has(e)||o.searchParams.set(e,null!=t?t:"")}),o.toString()}handleVideo(e,n){return t(this,void 0,void 0,function*(){const{id:t,autoplay:i,mute:r,videoLoop:o,vendor:s}=n.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:t,vgtvVendor:s,vgtvAutoplay:i,vgtvMuted:r,vgtvLoop:!!o,vgtvNa:!0,vgtvRecommended:!1,vgtvPulseProvider:"vg",vgtvPulseProductTag:"partnerstudio"})})}getPulseObjectId(){return"sdrn:vg:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(){return"sdrn:vg:frontpage:front"}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];const{host:i,pathname:r}=new URL(n);if(!i.includes("www.vg.no")&&!r.includes("annonsorinnhold"))return[n];const o=r.split("/");return o.length?[...o.filter(Boolean).slice(1).map(e=>e),n]:[n]}}const a=e=>{if(window.location.href.includes("collapse_ad=0"))return;const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.setProperty("width","0","important"),t.style.setProperty("height","0","important"),t.style.setProperty("display","none","important"),n.style.setProperty("display","none","important"),e.includes("wallpaper")&&(()=>{const e=document.querySelector(".advertory-wallpaper-background");e&&e.remove()})())},d=e=>{const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("display"),n.style.removeProperty("display"))},l=e=>{const t=e.parentElement;t?t.classList.remove("dr-edition-lock-height"):i("Dr. Edition container does not have a parent element, cannot remove height lock.")};class c{constructor(e,t,n,i){this.drEditionService=e,this.rendererManager=t,this.videoManager=n,this.pulseManager=i,this.drEditionAds=[]}fetchAndRenderAd(e,n){return t(this,void 0,void 0,function*(){var t,r;const{drEditionConfig:{containerSelector:o},renderAsBackfill:s=!1}=n,c=e.querySelector(o);if(!c)return void i(`Container with selector "${o}" not found.`);const u=yield this.drEditionService.fetchData(n);return(null==u?void 0:u.itemId)||s?!(null==u?void 0:u.itemId)&&s?(i("No Dr. Edition ads available to render. Collapsing whole placement."),a(e.id),void l(c)):((null==u?void 0:u.itemId)&&s&&(i("Dr. Edition ad available to render as a Xandr backfill."),d(e.id)),void(u?(u.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(u.css,"style"),yield this.rendererManager.render(c,u,n),yield null===(t=this.videoManager)||void 0===t?void 0:t.handle(u,n),l(c),this.drEditionAds.push(u),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(u.itemId),this.observeAdView(e,u,n),null===(r=e.querySelector("a"))||void 0===r||r.addEventListener("pointerup",()=>null)):l(c))):(i("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(c),this.showBackfill(e),void l(c))})}observeAdView(e,t,n){this.observeCarousel(e,t,n)||((e,t,n={threshold:.5})=>{new IntersectionObserver(([e],n)=>{e.isIntersecting&&(t(),n.disconnect())},n).observe(e)})(e,()=>this.pulseManager.trackContentView(e,t,n),{threshold:.5})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";const i=null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"";d(i)}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){const i=e.querySelector(".dr-edition-slider");if(!i)return!1;let r=null;const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.intersectionRatio>=.9&&(r&&clearTimeout(r),r=setTimeout(()=>{e.target.onclick=()=>this.pulseManager.trackContentClick(e.target,t,n),this.pulseManager.trackContentView(e.target,t,n)},500)),[...i.children].forEach(e=>{o.observe(e)})})},{threshold:[.9]});return[...i.children].forEach(e=>{o.observe(e)}),!0}}const u=e=>new Promise(t=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void t(!1);const n=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const t=Number(e);return i("Advertising permission value obtained synchronously: ",e),Boolean(t)})();if(null!==n)return void t(n);let r=!1;const o=e=>{r||(i("Resolving advertising permission value obtained"),r=!0,t(e))},s=setTimeout(()=>{i("Advertising permission timed out, resolving with false"),o(!1)},3e3);window._tcf_.onTcfReady(()=>{i("On Tcf Ready called, waiting for permission"),clearTimeout(s)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(s);const t=Number(e);i("Advertising permission value obtained asynchronously: ",e),o(Boolean(t))})}),v="no",p="se",g="cmp:loaded";let h,m=!1;const y=(e,n,r)=>{const o=!!(null==e?void 0:e.enabled),s=(null==e?void 0:e.timeout)||3e3,a=(d="bypass_tcf",new URLSearchParams(window.location.search).get(d));var d;const l=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(i("TCF bypass param detected, returning consent: true"),!0):(i("TCF is not enabled, returning consent: true"),!0))(o,a))return!0;if(m)return null;if(!h)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=h.getConsentedToAllSync();return i(`TCF consented to all is: ${t}`),h.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(i("Getting TCF consent manager..."),window._tcf_)return i("TCF consent manager is already available"),h=window._tcf_,void e(h);i("TCF consent manager is not available");const n=()=>{i("CMP loaded, resolving consent manager..."),r&&clearTimeout(r),window._tcf_?(h=window._tcf_,e(h)):t(new Error("CMP loaded but window._tcf_ is not defined"))},r=setTimeout(()=>{document.removeEventListener(g,n),m=!0,t(new Error("Timeout waiting for CMP to load"))},s);i("Listening for CMP loaded event..."),document.addEventListener(g,n,{once:!0})}):Promise.resolve(null),getConsentSync:l,getConsentAsync:()=>t(void 0,void 0,void 0,function*(){if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return i(`Schibsted Ad Choices override value is set, returning override value: ${e.schibstedAdChoicesOverrideValue}`),Boolean(Number(e.schibstedAdChoicesOverrideValue));const t=(null==e?void 0:e.schibstedAdChoicesEnabled)&&r===p,o=(null==e?void 0:e.schibstedAdChoicesEnabled)&&!n&&r===v;if(t||o)return i("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield u(e);if(!(null==e?void 0:e.enabled))return!0;const a=l();return null!==a?a:yield new Promise((e,t)=>{try{if(!h)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let t=!1;const n=n=>{t||(t=!0,e(n))},r=setTimeout(()=>{i("TCF isConsentedToAll timed out, resolving with false"),n(!1)},s);h.onTcfReady(()=>{i("On Tcf Ready called, waiting for consent"),clearTimeout(r)}),h.isConsentedToAll(t=>{clearTimeout(r),e(t)})}catch(e){t(e)}})})}},f="mobile";class w{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,n,i){return t(this,void 0,void 0,function*(){if(!(null==n?void 0:n.itemId))return;const{getConsentAsync:t}=y(i.tcf,i.isMobileApp,i.country),r=yield t(),o=i.device===f?n.mobileHTML:n.desktopHTML;const s=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=s,e.querySelectorAll("a").forEach(e=>{var t,r,o;e.search=null!==(o=null===(r=(t=this.newsroomStrategy).getUrlSearchParams)||void 0===r?void 0:r.call(t,e,n,i))&&void 0!==o?o:"",e.onclick=()=>this.pulseManager.trackContentClick(e,n,i)})})}}class b{constructor(e){this.strategy=e}handle(e,n){return t(this,void 0,void 0,function*(){const{videoConfiguration:{id:t,preview:i}={}}=e;(t||i)&&(yield this.importScript(n),yield this.createVideoElement(e,n))})}importScript(e){return t(this,void 0,void 0,function*(){const n=e.drEditionConfig.videoScriptUrl,r=document.querySelector(`script[src="${n}"]`);if(n&&!window.autoplayQueue&&!r)try{yield((e,...n)=>t(void 0,[e,...n],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,i)=>{const r=document.createElement("script");r.async=!0,r.src=e;const o=()=>{a(),n()},s=()=>{a(),i(new Error(`Failed to load ${e}`))},a=()=>{r.removeEventListener("load",o),r.removeEventListener("error",s),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",s);const d=setTimeout(()=>{a(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(n)}catch(e){i("Error! Failed to prepare SVP player script for Dr. Edition!",e)}})}createVideoElement(e,n){return t(this,void 0,void 0,function*(){const t=document.createElement("div"),{node:i}=e.videoConfiguration,r=[...document.querySelectorAll(`#${i}`)||[]].find(e=>0===e.children.length);if(this.handlePreviewVideo(e,n))return;this.strategy.handleVideo(t,e),null==r||r.appendChild(t),window.autoplayQueue=window.autoplayQueue||[],window.autoplayQueue.push(e=>{e.parse()});const o=null==r?void 0:r.parentNode;if(!o)return;const s=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");s!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:s}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const a=document.querySelector(".dr-edition-preview .preview-video");return!!a&&(a.setAttribute("src",o),a.setAttribute("playsinline",""),!(!a||!s)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,a),!0))}}class E{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t,n,i){return{}}mapPageType(e){return{front:"Frontpage",article:"Article",section:"Article",collection:"Article",other:"Article"}[e||"front"]||"Frontpage"}getArticleId(){return location.pathname.split("/").slice(-2,-1).pop()||""}getTeaserElementText(e,t){if(!e)return"";const n=e.querySelector({title:".dr-edition-title",subtitle:".dr-edition-subtitle",image:"img.teaser-main-image"}[t]);if(!n)return"";if("image"===t)return n.src||"";const i=null==n?void 0:n.textContent;return i?i.trim():""}getEventTarget(e,t){const{itemId:n,pulseData:{url:i}={}}=t,r=this.getTeaserElementText(e,"title");return{id:n,name:this.normalizePlacementTitle(null!=r?r:""),type:"Page",url:i}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o,s,a,d,l,c;if(!this.pulse)return;const u=this.getEventInput(e,n,i,"view");(null===(t=this.pulse)||void 0===t?void 0:t.trackLegacyViewUIElement)?null===(o=null===(r=this.pulse)||void 0===r?void 0:r.trackLegacyViewUIElement)||void 0===o||o.call(r,u):(null===(s=this.pulse)||void 0===s?void 0:s.trackViewUIElement)?null===(d=null===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)||void 0===d||d.call(a,u):null===(c=null===(l=this.pulse)||void 0===l?void 0:l.trackElementView)||void 0===c||c.call(l,u)})}trackContentClick(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o,s,a,d;if(!this.pulse)return;const l=this.getEventInput(e,n,i,"click");this.pulse.trackLegacyClickUIElement?null===(r=(t=this.pulse).trackLegacyClickUIElement)||void 0===r||r.call(t,l):this.pulse.trackClickUIElement?null===(s=(o=this.pulse).trackClickUIElement)||void 0===s||s.call(o,l):null===(d=(a=this.pulse).trackElementClick)||void 0===d||d.call(a,l)})}}class P extends E{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){const{pulseData:{title:i,clientName:r="",creativeId:o}={}}=t,{columnName:s,primaryPosition:a}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:s,primaryPosition:a},"spt:custom":{is_sponsored:!0,sponsor:r,"spt:creativeId":o},url:location.origin}}getEventInput(e,t,n){return{object:this.getEventBaseData(e,t,n),target:this.getEventTarget(e,t)}}}class T extends E{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,s,a,d;const{itemId:l,pulseData:{clientName:c,creativeId:u}={}}=t,v=n.editionName,p=this.mapPageType(this.pageType),g=null===(i=this.newsroomStrategy)||void 0===i?void 0:i.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(s=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==s?s:v,"@type":"UIElement",position:v,elementType:"Article",custom:{customer:c,creativeId:null!=u?u:l},page:{"@id":null!=g?g:v,"@type":p,url:location.origin},tags:null===(d=null===(a=this.newsroomStrategy)||void 0===a?void 0:a.getTags)||void 0===d?void 0:d.call(a,e)}}getEventInput(e,t,n,i){return{object:this.getEventBaseData(e,t,n),partnerstudio:this.getEventPartnerstudioData(e,t,n,i),target:this.getEventTarget(e,t),provider:this.getProviderData()}}getEventPartnerstudioData(e,t,n,i){var r,o,s,a;const{pulseData:{algorithm:d="sov",clientName:l,creativeId:c,editionId:u,itemId:v,url:p,probability:g}={}}=t,h=Math.floor(Date.now()/1e3),m=this.getTeaserElementText(e,"title"),y=this.getTeaserElementText(e,"subtitle"),f=this.getTeaserElementText(e,"image"),w=null!==(a=null!==(s=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getUrlWithParams)||void 0===o?void 0:o.call(r,t,n))&&void 0!==s?s:p)&&void 0!==a?a:"";return{algorithm:d,clientName:l,probability:g,creativeId:c,device:n.device,editionId:u,itemId:v,link:w,placement:n.editionName,subtitle:y,time:h,title:m,type:i,imageUrl:f,frontId:86,tracking_type:"ad",xandrAdLoaded:!1}}getProviderData(){return{productTag:"partnerstudio"}}}const C="svd",I="vg",S="aftonbladet",k="e24",A="front",L=e=>t(void 0,void 0,void 0,function*(){var t,n;return(null===(t=null===window||void 0===window?void 0:window.SVP)||void 0===t?void 0:t.Player)?new window.SVP.Player(e):((()=>{const e="svp-player-sdk",t=document.querySelector(e),n=Array.from(document.querySelectorAll('script[src^="https://cdn.stream.schibsted.media/player"]'));if(t||n.length>0)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.stream.schibsted.media/player/3.78.1/player.min.js",i.async=!0;try{i.src=i.src.replace("player.min","player.next.min")}catch(e){console.error("Failed to set player.next.min source:",e)}document.head.insertBefore(i,document.head.firstChild)})(),(null===(n=window.SVP)||void 0===n?void 0:n.isLoaded)?new window.SVP.Player(e):yield new Promise(t=>{window.addEventListener("onSvpPlayerReady",()=>t(new window.SVP.Player(e)))}))}),j={ContentMutePlugin:e=>{window.SVP.Player.Plugins.register({getName:()=>"ContentMutePlugin",initialize(){},setup(){const t=this.player.config.get("mute");this.container=e||this.player.getContainer(),this.muted=t,t&&this.listenToOnce(this.player,"ready",this.renderButtonElement,this)},getButtonElement(){const e=document.createElement("button");e.className="player-plugin-content-mute";const t=document.createElement("span");return t.className="volume-button-icon",e.appendChild(t),e},renderButtonElement(){this.buttonElement=this.getButtonElement(),this.buttonElement.addEventListener("click",this.onButtonClick.bind(this)),this.container.appendChild(this.buttonElement),this.isVideo()||(this.buttonElement.style.display="none"),this.getJWPlayer()&&this.getJWPlayer().on("mute",this.onMuteChange,this)},onButtonClick(){this.getJWPlayer()&&(this.container.classList.add("has-interacted"),this.muted=!this.muted,this.getJWPlayer().setMute(this.muted))},onMuteChange(e){this.muted=e.mute,this.muted?this.buttonElement.classList.remove("content-video-volume-on"):this.buttonElement.classList.add("content-video-volume-on")},isVideo(){return"video"===this.player.getRawAsset().assetType},getJWPlayer(){return this.player.model.player}})},IntegrationMenu:()=>{window.SVP.Player.Plugins.register({getName:()=>"IntegrationMenu",setup(){return t(this,void 0,void 0,function*(){yield Promise.resolve().then(function(){return H})})}})}};class M{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:n,node:i,autoplay:r,mute:o,vendor:s}}){yield t(void 0,void 0,void 0,function*(){return yield new Promise(e=>{var t;Boolean(null===(t=window.SVP)||void 0===t?void 0:t.Player)?e(!0):window.addEventListener("onSvpPlayerReady",()=>e(!0))})});const a=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=a)||l.forEach(e=>{j[e](c)});const u={id:n,node:i,autoplay:r,mute:o,vendor:s,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield L(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,a)}),v.once("ready",()=>{const t=e;new MutationObserver(e=>{e.forEach(({type:e,attributeName:n})=>{"attributes"===e&&"class"===n&&(t.classList.contains("jw-state-playing")?d.classList.add("is-playing"):d.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?d.classList.add("is-inactive"):d.classList.remove("is-inactive"))})}).observe(t,{attributes:!0,attributeFilter:["class"]})}),v.once("PulseStats:ready",()=>t(this,void 0,void 0,function*(){const e=yield v.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"e24",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:e24:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===A?"sdrn:e24:frontpage:front":`sdrn:e24:article:${t}`}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];if(!n.includes("https://e24.no/annonsorinnhold/"))return[n];const{pathname:i}=new URL(n),r=i.split("/").filter(Boolean);return r.length?[...r.slice(1),n]:[n]}createPlayerOverlay(e){const t=document.createElement("div");t.classList.add("cm-custom-video-overlay"),e.parentElement&&(t.innerHTML=e.parentElement.innerHTML,e.parentElement.replaceChild(t,e));return t.addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),t.classList.add("has-interacted")}),t}}const D="https://www.aftonbladet.se/video-player-extras/latest/";class O{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const s={id:t,node:n,autoplay:i,mute:r,vendor:o,autopause:"viewable",maxBitrate:600,pulse:{provider:"aftonbladet"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"",url:""},plugins:{[`${D}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${D}external-link.js`]:{name:"ExternalLink"}}};yield L(s),this.addEditionVideoClass(e)})}addEditionVideoClass(e){var t;(null===(t=null==e?void 0:e.parentElement)||void 0===t?void 0:t.parentElement)&&e.parentElement.parentElement.classList.add("dr-edition-video-player")}getPulseObjectId(){return""}getPulsePageId(){return""}}const V=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);class _{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:n,node:i,autoplay:r,mute:o,vendor:s}}){const a={id:n,node:i,autoplay:r,mute:o,vendor:s,locale:"se",autopause:"viewable",maxBitrate:600,sharing:!1,recommended:!1,pulse:{provider:"svdse",decorator:(e,t)=>Object.assign(Object.assign({},V(e)?e:{}),{provider:Object.assign(Object.assign({},V(null==e?void 0:e.provider)?e.provider:{}),{productTag:"partnerstudio"})})},skin:{name:"svd-player",url:""},settings:{pulse:{host:"se-aftonbladet.videoplaza.tv",contentMetadata:{category:"SvD",tags:["standard-linears","pause",`video-${n}`]},requestSettings:{}}}},d=yield L(a);d.once("PulseStats:ready",()=>t(this,void 0,void 0,function*(){const e=yield d.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"svdse",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:svdse:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===A?"sdrn:svdse:frontpage:front":`sdrn:svdse:article:${t}`}}class N{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const U=(e,t,n)=>{var i;const{publisher:r,pageType:a,country:d}=e,l={[I]:new s,[k]:new M,[S]:new O,[C]:new _}[r]||new N,u=new(d===p?P:T)(n,l,a),v=new o(t,null!==(i=null==n?void 0:n.pulseTracker)&&void 0!==i?i:n),g=new w(l,u),h=new b(l);return new c(v,g,h,u)},x=()=>t(void 0,void 0,void 0,function*(){return yield new Promise(e=>{if("undefined"!=typeof window)if(window.Identity)e(window.Identity);else{const t=()=>{e(window.Identity)};window.addEventListener("identity-initialized",t,{once:!0})}else e(void 0)})});class B{constructor(e){this.identity=e,this.getIdentityUser=this.getIdentityUser.bind(this),this.isUserLoggedIn=this.isUserLoggedIn.bind(this),this.onIdentityLogout=this.onIdentityLogout.bind(this)}getIdentityUser(){return t(this,void 0,void 0,function*(){var e;try{const t=yield null===(e=this.identity)||void 0===e?void 0:e.getUser();return null!=t?t:null}catch(e){return i("[Privacy Broker] User is not logged in."),null}})}isUserLoggedIn(){return t(this,void 0,void 0,function*(){var e,t;return null!==(t=yield null===(e=this.identity)||void 0===e?void 0:e.isLoggedIn())&&void 0!==t&&t})}onIdentityLogout(e){var t;null===(t=this.identity)||void 0===t||t.on("logout",e)}}const R=(e,t,n)=>{const{wrapperSelector:i}=null==e?void 0:e.drEditionConfig,r=document.querySelectorAll(i),o=new IntersectionObserver((i,r)=>((e,t,n,i,r)=>{const o=U(n,i,r);e.forEach(e=>{var i,r,s;if(!e.isIntersecting)return;const a=e.target,d=null!==(i=a.dataset.editionName)&&void 0!==i?i:"",l=null!==(r=a.dataset.pulseColumnname)&&void 0!==r?r:"",c=null!==(s=a.dataset.pulsePrimaryposition)&&void 0!==s?s:"";o.fetchAndRenderAd(a,Object.assign(Object.assign({},n),{editionName:d,columnName:l,primaryPosition:c})),t.unobserve(a)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},$=(e,n,r,...o)=>t(void 0,[e,n,r,...o],void 0,function*(e,t,n,r="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return i(`Schibsted Consent to Pay is not enabled, returning true for ${r}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return i(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${r}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:o}=y(e,t,n);return(yield o())?(i(`Schibsted Ad Choices consent given according to TCF consent manager for ${r}`),!0):(i(`Schibsted Ad Choices consent not given according to TCF consent manager for ${r}`),!1)}),q=[];const F=function(e){if("undefined"==typeof window)return;const t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}("[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-slider-time{display:none}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container{padding:0 6px;height:36px}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon{margin-right:3px;height:unset;width:unset;bottom:0}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-volume,[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-playback{display:flex}");var H=Object.freeze({__proto__:null,default:F});exports.DrEdition=({editionName:t,fallbackTargetId:n,children:i,pulseData:r})=>{const o=(e=>{const t={};if(!e)return t;for(const[n,i]of Object.entries(e))t[`data-pulse-${n}`]=String(i);return t})(r);return e.jsxs("div",Object.assign({className:"dr-edition-wrapper dr-edition-lock-height","data-edition-name":t},o,{children:[e.jsx("div",{className:"inscreen-target"}),e.jsx("div",{className:"container"}),e.jsx("div",{className:"fallback","data-fallback-target-id":n,style:{display:"none"},children:i})]}))},exports.getDrEditionManager=U,exports.handleDrEdition=e=>t(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;if(!(yield $(e.tcf,e.isMobileApp,e.country,"handleDrEdition")))return;const n=yield x(),i=new B(n);R({publisher:e.publisher,drEditionConfig:e.drEdition,device:e.deviceType,pageType:e.pageType,country:e.country},i,null===(t=e.pulse)||void 0===t?void 0:t.instance)}),exports.handleDrEditionBackfill=(e,n)=>t(void 0,void 0,void 0,function*(){var t;const{pulse:o,tcf:s,deviceType:a,drEdition:d,publisher:l,pageType:c,country:u,isMobileApp:v}=e;if(!(yield $(s,v,u,"handleDrEditionBackfill")))return;const p=((e,t)=>{var n;const{deviceType:i,placements:o,drEdition:{fallbackGlobalEditionName:s}={}}=e,a=o[i]||o.desktop,d=(e=>{const t=e.split("-"),n=t[t.length-1];return 6===n.length&&n.match(/^[a-zA-Z0-9]+$/)?t.slice(0,-1).join("-"):e})(t.targetId),l=a.find(e=>e.id===d),c=r.some(e=>d.startsWith(e)),u=q.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||s;return l&&c&&!u&&v?(q.push(d),Object.assign(Object.assign({},l),{drEdition:Object.assign(Object.assign({},l.drEdition),{editionName:v})})):null})(e,n);if(!p)return;if(!(null==o?void 0:o.instance))return void i("Pulse has not been passed as a prop, aborting");const g=yield x(),h=new B(g),m=U({publisher:l,pageType:c,country:u},h,null==o?void 0:o.instance),y=document.getElementById(n.targetId);if(!y||!d)return;y.classList.value="";const f=document.createElement("div");f.className=d.containerSelector.replace(/^[.#:[\]]+/,""),y.innerHTML=f.outerHTML;const w={editionName:(null===(t=null==p?void 0:p.drEdition)||void 0===t?void 0:t.editionName)||"",drEditionConfig:d,device:a,tcf:s,isMobileApp:v,country:u,renderAsBackfill:!0};yield m.fetchAndRenderAd(y,w)});
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime");function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}d((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const n={get:(e,n)=>t(void 0,void 0,void 0,function*(){const t=yield fetch(e,n);if(!t.ok)throw new Error(t.statusText);return yield t.json()}),post:(e,n,i)=>t(void 0,void 0,void 0,function*(){const t=JSON.stringify(i),r=yield fetch(e,{method:"POST",headers:n,body:t});if(!r.ok)throw new Error(r.statusText);return yield r.json()})},i=(e,t)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(t?console.log(n,e,t):console.log(n,e))},r=["netboard","board"];class o{constructor(e,t){this.identityFacade=e,this.tracker=t}buildUrl(e,t){var n,i;const{editionName:r}=e,o=(()=>{const e=window.location.href;return new URL(e).searchParams.get("dre_override_inv_code")||""})(),s=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),a=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return a.searchParams.append("editionName",r),o&&a.searchParams.append("urlData",o),s&&a.searchParams.append("excludedItems",s),l&&a.searchParams.append("spid",l),d&&a.searchParams.append("envid",d),a.toString()}fetchData(e){return t(this,void 0,void 0,function*(){var t,r;const o=yield this.identityFacade.getIdentityUser(),s=null!==(r=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==r?r:"",a=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:s,spid:a});try{i("Starting fetching DrEdition ad from URL:",d);const e={method:"GET"},t=yield n.get(d,e);return i("Fetch operation completed successfully."),t}catch(e){i("Error during fetch operation:",e)}return null})}}class s{getDrEditionUTMParams(e,t){var n;const{title:i="",clientName:r,creativeId:o}=null!==(n=null==e?void 0:e.pulseData)&&void 0!==n?n:{},{editionName:s}=t,a=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:s,utm_campaign:r,utm_medium:a},o&&{utm_id:`df-${o}`})}getUrlSearchParams(e,t,n){if(!e)return"";const i=this.getDrEditionUTMParams(t,n),r=new URLSearchParams(decodeURIComponent(e.search)),o=new URLSearchParams(e.search);return Object.entries(i).forEach(([e,t])=>{r.has(e)||o.set(e,null!=t?t:"")}),o.toString().replace(/\+/g,"%20")}getUrlWithParams(e,t){var n;const i=null===(n=null==e?void 0:e.pulseData)||void 0===n?void 0:n.url;if(!i)return"";const r=this.getDrEditionUTMParams(e,t),o=new URL(i);return Object.entries(r).forEach(([e,t])=>{o.searchParams.has(e)||o.searchParams.set(e,null!=t?t:"")}),o.toString()}handleVideo(e,n){return t(this,void 0,void 0,function*(){const{id:t,autoplay:i,mute:r,videoLoop:o,vendor:s}=n.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:t,vgtvVendor:s,vgtvAutoplay:i,vgtvMuted:r,vgtvLoop:!!o,vgtvNa:!0,vgtvRecommended:!1,vgtvPulseProvider:"vg",vgtvPulseProductTag:"partnerstudio"})})}getPulseObjectId(){return"sdrn:vg:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(){return"sdrn:vg:frontpage:front"}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];const{host:i,pathname:r}=new URL(n);if(!i.includes("www.vg.no")&&!r.includes("annonsorinnhold"))return[n];const o=r.split("/");return o.length?[...o.filter(Boolean).slice(1).map(e=>e),n]:[n]}}const a=e=>{if(window.location.href.includes("collapse_ad=0"))return;const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.setProperty("width","0","important"),t.style.setProperty("height","0","important"),t.style.setProperty("display","none","important"),n.style.setProperty("display","none","important"),e.includes("wallpaper")&&(()=>{const e=document.querySelector(".advertory-wallpaper-background");e&&e.remove()})())},d=e=>{const t=document.querySelector(`div[id^="${e}"]`);if(!t)return;const n=t.parentElement;n&&(t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("display"),n.style.removeProperty("display"))},l=e=>{const t=e.parentElement;t?t.classList.remove("dr-edition-lock-height"):i("Dr. Edition container does not have a parent element, cannot remove height lock.")};class c{constructor(e,t,n,i){this.drEditionService=e,this.rendererManager=t,this.videoManager=n,this.pulseManager=i,this.drEditionAds=[]}fetchAndRenderAd(e,n){return t(this,void 0,void 0,function*(){var t,r;const{drEditionConfig:{containerSelector:o},renderAsBackfill:s=!1}=n,c=e.querySelector(o);if(!c)return void i(`Container with selector "${o}" not found.`);const u=yield this.drEditionService.fetchData(n);return(null==u?void 0:u.itemId)||s?!(null==u?void 0:u.itemId)&&s?(i("No Dr. Edition ads available to render. Collapsing whole placement."),a(e.id),void l(c)):((null==u?void 0:u.itemId)&&s&&(i("Dr. Edition ad available to render as a Xandr backfill."),d(e.id)),void(u?(u.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(u.css,"style"),yield this.rendererManager.render(c,u,n),yield null===(t=this.videoManager)||void 0===t?void 0:t.handle(u,n),l(c),this.drEditionAds.push(u),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(u.itemId),this.observeAdView(e,u,n),null===(r=e.querySelector("a"))||void 0===r||r.addEventListener("pointerup",()=>null)):l(c))):(i("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(c),this.showBackfill(e),void l(c))})}observeAdView(e,t,n){this.observeCarousel(e,t,n)||((e,t,n={threshold:.5})=>{new IntersectionObserver(([e],n)=>{e.isIntersecting&&(t(),n.disconnect())},n).observe(e)})(e,()=>this.pulseManager.trackContentView(e,t,n),{threshold:.5})}showBackfill(e){var t;const n=e.querySelector(".fallback");if(!n)return;n.style.display="block";const i=null!==(t=n.dataset.fallbackTargetId)&&void 0!==t?t:"";d(i)}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){const i=e.querySelector(".dr-edition-slider");if(!i)return!1;let r=null;const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.intersectionRatio>=.9&&(r&&clearTimeout(r),r=setTimeout(()=>{e.target.onclick=()=>this.pulseManager.trackContentClick(e.target,t,n),this.pulseManager.trackContentView(e.target,t,n)},500)),[...i.children].forEach(e=>{o.observe(e)})})},{threshold:[.9]});return[...i.children].forEach(e=>{o.observe(e)}),!0}}const u=e=>new Promise(t=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void t(!1);const n=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const t=Number(e);return i("Advertising permission value obtained synchronously: ",e),Boolean(t)})();if(null!==n)return void t(n);let r=!1;const o=e=>{r||(i("Resolving advertising permission value obtained"),r=!0,t(e))},s=setTimeout(()=>{i("Advertising permission timed out, resolving with false"),o(!1)},3e3);window._tcf_.onTcfReady(()=>{i("On Tcf Ready called, waiting for permission"),clearTimeout(s)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(s);const t=Number(e);i("Advertising permission value obtained asynchronously: ",e),o(Boolean(t))})}),v="no",p="se",h="cmp:loaded";let g,m=!1;const y=(e,n,r)=>{const o=!!(null==e?void 0:e.enabled),s=(null==e?void 0:e.timeout)||3e3,a=(d="bypass_tcf",new URLSearchParams(window.location.search).get(d));var d;const l=()=>{if(!(null==e?void 0:e.enabled))return!0;if(((e,t)=>e?!!t&&(i("TCF bypass param detected, returning consent: true"),!0):(i("TCF is not enabled, returning consent: true"),!0))(o,a))return!0;if(m)return null;if(!g)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=g.getConsentedToAllSync();return i(`TCF consented to all is: ${t}`),g.getConsentedToAllSync()};return{initConsentManager:()=>(null==e?void 0:e.enabled)?new Promise((e,t)=>{if(i("Getting TCF consent manager..."),window._tcf_)return i("TCF consent manager is already available"),g=window._tcf_,void e(g);i("TCF consent manager is not available");const n=()=>{i("CMP loaded, resolving consent manager..."),r&&clearTimeout(r),window._tcf_?(g=window._tcf_,e(g)):t(new Error("CMP loaded but window._tcf_ is not defined"))},r=setTimeout(()=>{document.removeEventListener(h,n),m=!0,t(new Error("Timeout waiting for CMP to load"))},s);i("Listening for CMP loaded event..."),document.addEventListener(h,n,{once:!0})}):Promise.resolve(null),getConsentSync:l,getConsentAsync:()=>t(void 0,void 0,void 0,function*(){if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return i(`Schibsted Ad Choices override value is set, returning override value: ${e.schibstedAdChoicesOverrideValue}`),Boolean(Number(e.schibstedAdChoicesOverrideValue));const t=(null==e?void 0:e.schibstedAdChoicesEnabled)&&r===p,o=(null==e?void 0:e.schibstedAdChoicesEnabled)&&!n&&r===v;if(t||o)return i("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield u(e);if(!(null==e?void 0:e.enabled))return!0;const a=l();return null!==a?a:yield new Promise((e,t)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let t=!1;const n=n=>{t||(t=!0,e(n))},r=setTimeout(()=>{i("TCF isConsentedToAll timed out, resolving with false"),n(!1)},s);g.onTcfReady(()=>{i("On Tcf Ready called, waiting for consent"),clearTimeout(r)}),g.isConsentedToAll(t=>{clearTimeout(r),e(t)})}catch(e){t(e)}})})}},f="mobile";class w{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,n,i){return t(this,void 0,void 0,function*(){if(!(null==n?void 0:n.itemId))return;const{getConsentAsync:t}=y(i.tcf,i.isMobileApp,i.country),r=yield t(),o=i.device===f?n.mobileHTML:n.desktopHTML;const s=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=s,e.querySelectorAll("a").forEach(e=>{var t,r,o;e.search=null!==(o=null===(r=(t=this.newsroomStrategy).getUrlSearchParams)||void 0===r?void 0:r.call(t,e,n,i))&&void 0!==o?o:"",e.onclick=()=>this.pulseManager.trackContentClick(e,n,i)})})}}class b{constructor(e){this.strategy=e}handle(e,n){return t(this,void 0,void 0,function*(){const{videoConfiguration:{id:t,preview:i}={}}=e;(t||i)&&(yield this.importScript(n),yield this.createVideoElement(e,n))})}importScript(e){return t(this,void 0,void 0,function*(){const n=e.drEditionConfig.videoScriptUrl,r=document.querySelector(`script[src="${n}"]`);if(n&&!window.autoplayQueue&&!r)try{yield((e,...n)=>t(void 0,[e,...n],void 0,function*(e,{timeout:t}={timeout:1e3}){document.querySelector(`script[src="${e}"]:not([type="module"])`)||(yield new Promise((n,i)=>{const r=document.createElement("script");r.async=!0,r.src=e;const o=()=>{a(),n()},s=()=>{a(),i(new Error(`Failed to load ${e}`))},a=()=>{r.removeEventListener("load",o),r.removeEventListener("error",s),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",s);const d=setTimeout(()=>{a(),i(new Error(`Loading script timed out: ${e}`))},t);document.head.appendChild(r)}).catch(e=>{console.error(e)}))}))(n)}catch(e){i("Error! Failed to prepare SVP player script for Dr. Edition!",e)}})}createVideoElement(e,n){return t(this,void 0,void 0,function*(){const t=document.createElement("div"),{node:i}=e.videoConfiguration,r=[...document.querySelectorAll(`#${i}`)||[]].find(e=>0===e.children.length);if(this.handlePreviewVideo(e,n))return;this.strategy.handleVideo(t,e),null==r||r.appendChild(t),window.autoplayQueue=window.autoplayQueue||[],window.autoplayQueue.push(e=>{e.parse()});const o=null==r?void 0:r.parentNode;if(!o)return;const s=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");s!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:s}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const a=document.querySelector(".dr-edition-preview .preview-video");return!!a&&(a.setAttribute("src",o),a.setAttribute("playsinline",""),!(!a||!s)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,a),!0))}}class E{constructor(e,t){this.pulse=e,this.newsroomStrategy=t}getEventInput(e,t,n,i){return{}}mapPageType(e){return{front:"Frontpage",article:"Article",section:"Article",collection:"Article",other:"Article"}[e||"front"]||"Frontpage"}getArticleId(){return location.pathname.split("/").slice(-2,-1).pop()||""}getTeaserElementText(e,t){if(!e)return"";const n=e.querySelector({title:".dr-edition-title",subtitle:".dr-edition-subtitle",image:"img.teaser-main-image"}[t]);if(!n)return"";if("image"===t)return n.src||"";const i=null==n?void 0:n.textContent;return i?i.trim():""}getEventTarget(e,t){const{itemId:n,pulseData:{url:i}={}}=t,r=this.getTeaserElementText(e,"title");return{id:n,name:this.normalizePlacementTitle(null!=r?r:""),type:"Page",url:i}}normalizePlacementTitle(e){return e.replace(/<[^>]+>/gi,"").replace(/[^a-z0-9æøå\s_-]/gi,"")}trackContentView(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o,s,a,d,l,c;if(!this.pulse)return;const u=this.getEventInput(e,n,i,"view");(null===(t=this.pulse)||void 0===t?void 0:t.trackLegacyViewUIElement)?null===(o=null===(r=this.pulse)||void 0===r?void 0:r.trackLegacyViewUIElement)||void 0===o||o.call(r,u):(null===(s=this.pulse)||void 0===s?void 0:s.trackViewUIElement)?null===(d=null===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)||void 0===d||d.call(a,u):null===(c=null===(l=this.pulse)||void 0===l?void 0:l.trackElementView)||void 0===c||c.call(l,u)})}trackContentClick(e,n,i){return t(this,void 0,void 0,function*(){var t,r,o,s,a,d;if(!this.pulse)return;const l=this.getEventInput(e,n,i,"click");this.pulse.trackLegacyClickUIElement?null===(r=(t=this.pulse).trackLegacyClickUIElement)||void 0===r||r.call(t,l):this.pulse.trackClickUIElement?null===(s=(o=this.pulse).trackClickUIElement)||void 0===s||s.call(o,l):null===(d=(a=this.pulse).trackElementClick)||void 0===d||d.call(a,l)})}}class P extends E{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){const{pulseData:{title:i,clientName:r="",creativeId:o}={}}=t,{columnName:s,primaryPosition:a}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:s,primaryPosition:a},"spt:custom":{is_sponsored:!0,sponsor:r,"spt:creativeId":o},url:location.origin}}getEventInput(e,t,n){return{object:this.getEventBaseData(e,t,n),target:this.getEventTarget(e,t)}}}class T extends E{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,s,a,d;const{itemId:l,pulseData:{clientName:c,creativeId:u}={}}=t,v=n.editionName,p=this.mapPageType(this.pageType),h=null===(i=this.newsroomStrategy)||void 0===i?void 0:i.getPulsePageId(this.pageType||"front",this.getArticleId());return{"@id":null!==(s=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==s?s:v,"@type":"UIElement",position:v,elementType:"Article",custom:{customer:c,creativeId:null!=u?u:l},page:{"@id":null!=h?h:v,"@type":p,url:location.origin},tags:null===(d=null===(a=this.newsroomStrategy)||void 0===a?void 0:a.getTags)||void 0===d?void 0:d.call(a,e)}}getEventInput(e,t,n,i){return{object:this.getEventBaseData(e,t,n),partnerstudio:this.getEventPartnerstudioData(e,t,n,i),target:this.getEventTarget(e,t),provider:this.getProviderData()}}getEventPartnerstudioData(e,t,n,i){var r,o,s,a;const{pulseData:{algorithm:d="sov",clientName:l,creativeId:c,editionId:u,itemId:v,url:p,probability:h}={}}=t,g=Math.floor(Date.now()/1e3),m=this.getTeaserElementText(e,"title"),y=this.getTeaserElementText(e,"subtitle"),f=this.getTeaserElementText(e,"image"),w=null!==(a=null!==(s=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getUrlWithParams)||void 0===o?void 0:o.call(r,t,n))&&void 0!==s?s:p)&&void 0!==a?a:"";return{algorithm:d,clientName:l,probability:h,creativeId:c,device:n.device,editionId:u,itemId:v,link:w,placement:n.editionName,subtitle:y,time:g,title:m,type:i,imageUrl:f,frontId:86,tracking_type:"ad",xandrAdLoaded:!1}}getProviderData(){return{productTag:"partnerstudio"}}}const C="svd",I="vg",S="aftonbladet",k="e24",A="front",L=e=>t(void 0,void 0,void 0,function*(){var t,n;return(null===(t=null===window||void 0===window?void 0:window.SVP)||void 0===t?void 0:t.Player)?new window.SVP.Player(e):((()=>{const e="svp-player-sdk",t=document.querySelector(e),n=Array.from(document.querySelectorAll('script[src^="https://cdn.stream.schibsted.media/player"]'));if(t||n.length>0)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.stream.schibsted.media/player/3.78.1/player.min.js",i.async=!0;try{i.src=i.src.replace("player.min","player.next.min")}catch(e){console.error("Failed to set player.next.min source:",e)}document.head.insertBefore(i,document.head.firstChild)})(),(null===(n=window.SVP)||void 0===n?void 0:n.isLoaded)?new window.SVP.Player(e):yield new Promise(t=>{window.addEventListener("onSvpPlayerReady",()=>t(new window.SVP.Player(e)))}))}),j={ContentMutePlugin:e=>{window.SVP.Player.Plugins.register({getName:()=>"ContentMutePlugin",initialize(){},setup(){const t=this.player.config.get("mute");this.container=e||this.player.getContainer(),this.muted=t,t&&this.listenToOnce(this.player,"ready",this.renderButtonElement,this)},getButtonElement(){const e=document.createElement("button");e.className="player-plugin-content-mute";const t=document.createElement("span");return t.className="volume-button-icon",e.appendChild(t),e},renderButtonElement(){this.buttonElement=this.getButtonElement(),this.buttonElement.addEventListener("click",this.onButtonClick.bind(this)),this.container.appendChild(this.buttonElement),this.isVideo()||(this.buttonElement.style.display="none"),this.getJWPlayer()&&this.getJWPlayer().on("mute",this.onMuteChange,this)},onButtonClick(){this.getJWPlayer()&&(this.container.classList.add("has-interacted"),this.muted=!this.muted,this.getJWPlayer().setMute(this.muted))},onMuteChange(e){this.muted=e.mute,this.muted?this.buttonElement.classList.remove("content-video-volume-on"):this.buttonElement.classList.add("content-video-volume-on")},isVideo(){return"video"===this.player.getRawAsset().assetType},getJWPlayer(){return this.player.model.player}})},IntegrationMenu:()=>{window.SVP.Player.Plugins.register({getName:()=>"IntegrationMenu",setup(){return t(this,void 0,void 0,function*(){yield Promise.resolve().then(function(){return H})})}})}};class M{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:n,node:i,autoplay:r,mute:o,vendor:s}}){yield t(void 0,void 0,void 0,function*(){return yield new Promise(e=>{var t;Boolean(null===(t=window.SVP)||void 0===t?void 0:t.Player)?e(!0):window.addEventListener("onSvpPlayerReady",()=>e(!0))})});const a=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=a)||l.forEach(e=>{j[e](c)});const u={id:n,node:i,autoplay:r,mute:o,vendor:s,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield L(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,a)}),v.once("ready",()=>{const t=e;new MutationObserver(e=>{e.forEach(({type:e,attributeName:n})=>{"attributes"===e&&"class"===n&&(t.classList.contains("jw-state-playing")?d.classList.add("is-playing"):d.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?d.classList.add("is-inactive"):d.classList.remove("is-inactive"))})}).observe(t,{attributes:!0,attributeFilter:["class"]})}),v.once("PulseStats:ready",()=>t(this,void 0,void 0,function*(){const e=yield v.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"e24",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:e24:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===A?"sdrn:e24:frontpage:front":`sdrn:e24:article:${t}`}getTags(e){var t;let n;if(n=e instanceof HTMLAnchorElement?e.href:null===(t=null==e?void 0:e.querySelector("a"))||void 0===t?void 0:t.href,!n)return[];if(!n.includes("https://e24.no/annonsorinnhold/"))return[n];const{pathname:i}=new URL(n),r=i.split("/").filter(Boolean);return r.length?[...r.slice(1),n]:[n]}createPlayerOverlay(e){const t=document.createElement("div");t.classList.add("cm-custom-video-overlay"),e.parentElement&&(t.innerHTML=e.parentElement.innerHTML,e.parentElement.replaceChild(t,e));return t.addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),t.classList.add("has-interacted")}),t}}const D="https://www.aftonbladet.se/video-player-extras/latest/";class O{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const s={id:t,node:n,autoplay:i,mute:r,vendor:o,autopause:"viewable",maxBitrate:600,pulse:{provider:"aftonbladet"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"",url:""},plugins:{[`${D}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${D}external-link.js`]:{name:"ExternalLink"}}};yield L(s),this.addEditionVideoClass(e)})}addEditionVideoClass(e){var t;(null===(t=null==e?void 0:e.parentElement)||void 0===t?void 0:t.parentElement)&&e.parentElement.parentElement.classList.add("dr-edition-video-player")}getPulseObjectId(){return""}getPulsePageId(){return""}}const V=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);class _{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:n,node:i,autoplay:r,mute:o,vendor:s}}){const a={id:n,node:i,autoplay:r,mute:o,vendor:s,locale:"se",autopause:"viewable",maxBitrate:600,sharing:!1,recommended:!1,pulse:{provider:"svdse",decorator:(e,t)=>Object.assign(Object.assign({},V(e)?e:{}),{provider:Object.assign(Object.assign({},V(null==e?void 0:e.provider)?e.provider:{}),{productTag:"partnerstudio"})})},skin:{name:"svd-player",url:""},settings:{pulse:{host:"se-aftonbladet.videoplaza.tv",contentMetadata:{category:"SvD",tags:["standard-linears","pause",`video-${n}`]},requestSettings:{}}}},d=yield L(a);d.once("PulseStats:ready",()=>t(this,void 0,void 0,function*(){const e=yield d.getPlugin("PulseStats").getTracker();null==e||e.update({provider:{id:"svdse",productTag:"partnerstudio"}})}))})}getPulseObjectId(){return"sdrn:svdse:content:partnerstudio:element:partnerstudio:stats"}getPulsePageId(e,t){return e===A?"sdrn:svdse:frontpage:front":`sdrn:svdse:article:${t}`}}class N{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const U=(e,t,n)=>{var i;const{publisher:r,pageType:a,country:d}=e,l={[I]:new s,[k]:new M,[S]:new O,[C]:new _}[r]||new N,u=new(d===p?P:T)(n,l,a),v=new o(t,null!==(i=null==n?void 0:n.pulseTracker)&&void 0!==i?i:n),h=new w(l,u),g=new b(l);return new c(v,h,g,u)},x=()=>t(void 0,void 0,void 0,function*(){return yield new Promise(e=>{if("undefined"!=typeof window)if(window.Identity)e(window.Identity);else{const t=()=>{e(window.Identity)};window.addEventListener("identity-initialized",t,{once:!0})}else e(void 0)})});class B{constructor(e){this.identity=e,this.getIdentityUser=this.getIdentityUser.bind(this),this.isUserLoggedIn=this.isUserLoggedIn.bind(this),this.onIdentityLogout=this.onIdentityLogout.bind(this)}getIdentityUser(){return t(this,void 0,void 0,function*(){var e;try{const t=yield null===(e=this.identity)||void 0===e?void 0:e.getUser();return null!=t?t:null}catch(e){return i("[Privacy Broker] User is not logged in."),null}})}isUserLoggedIn(){return t(this,void 0,void 0,function*(){var e,t;return null!==(t=yield null===(e=this.identity)||void 0===e?void 0:e.isLoggedIn())&&void 0!==t&&t})}onIdentityLogout(e){var t;null===(t=this.identity)||void 0===t||t.on("logout",e)}}const R=(e,t,n)=>{const{wrapperSelector:i}=null==e?void 0:e.drEditionConfig,r=document.querySelectorAll(i),o=new IntersectionObserver((i,r)=>((e,t,n,i,r)=>{const o=U(n,i,r);e.forEach(e=>{var i,r,s;if(!e.isIntersecting)return;const a=e.target,d=null!==(i=a.dataset.editionName)&&void 0!==i?i:"",l=null!==(r=a.dataset.pulseColumnname)&&void 0!==r?r:"",c=null!==(s=a.dataset.pulsePrimaryposition)&&void 0!==s?s:"";o.fetchAndRenderAd(a,Object.assign(Object.assign({},n),{editionName:d,columnName:l,primaryPosition:c})),t.unobserve(a)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},$=(e,n,r,...o)=>t(void 0,[e,n,r,...o],void 0,function*(e,t,n,r="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return i(`Schibsted Consent to Pay is not enabled, returning true for ${r}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return i(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${r}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:o}=y(e,t,n);return(yield o())?(i(`Schibsted Ad Choices consent given according to TCF consent manager for ${r}`),!0):(i(`Schibsted Ad Choices consent not given according to TCF consent manager for ${r}`),!1)}),q=[];const F=function(e){if("undefined"==typeof window)return;const t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}("[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-slider-time{display:none}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container{padding:0 6px;height:36px}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon{margin-right:3px;height:unset;width:unset;bottom:0}[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-volume,[id^=integration_godt-menu]>article .jw-controls>.jw-controlbar .jw-button-container .jw-icon-playback{display:flex}");var H=Object.freeze({__proto__:null,default:F});exports.DrEdition=({editionName:t,fallbackTargetId:n,children:i,pulseData:r,htmlAttributes:o})=>{const s=(e,t)=>{const n={};if(!e)return n;for(const[i,r]of Object.entries(e)){n[t?`${t}-${i}`:i]=String(r)}return n},a=s(r,"data-pulse"),d=s(o,"data");return e.jsxs("div",Object.assign({className:"dr-edition-wrapper dr-edition-lock-height","data-edition-name":t},a,d,{children:[e.jsx("div",{className:"inscreen-target"}),e.jsx("div",{className:"container"}),e.jsx("div",{className:"fallback","data-fallback-target-id":n,style:{display:"none"},children:i})]}))},exports.getDrEditionManager=U,exports.handleDrEdition=e=>t(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;if(!(yield $(e.tcf,e.isMobileApp,e.country,"handleDrEdition")))return;const n=yield x(),i=new B(n);R({publisher:e.publisher,drEditionConfig:e.drEdition,device:e.deviceType,pageType:e.pageType,country:e.country},i,null===(t=e.pulse)||void 0===t?void 0:t.instance)}),exports.handleDrEditionBackfill=(e,n)=>t(void 0,void 0,void 0,function*(){var t;const{pulse:o,tcf:s,deviceType:a,drEdition:d,publisher:l,pageType:c,country:u,isMobileApp:v}=e;if(!(yield $(s,v,u,"handleDrEditionBackfill")))return;const p=((e,t)=>{var n;const{deviceType:i,placements:o,drEdition:{fallbackGlobalEditionName:s}={}}=e,a=o[i]||o.desktop,d=(e=>{const t=e.split("-"),n=t[t.length-1];return 6===n.length&&n.match(/^[a-zA-Z0-9]+$/)?t.slice(0,-1).join("-"):e})(t.targetId),l=a.find(e=>e.id===d),c=r.some(e=>d.startsWith(e)),u=q.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||s;return l&&c&&!u&&v?(q.push(d),Object.assign(Object.assign({},l),{drEdition:Object.assign(Object.assign({},l.drEdition),{editionName:v})})):null})(e,n);if(!p)return;if(!(null==o?void 0:o.instance))return void i("Pulse has not been passed as a prop, aborting");const h=yield x(),g=new B(h),m=U({publisher:l,pageType:c,country:u},g,null==o?void 0:o.instance),y=document.getElementById(n.targetId);if(!y||!d)return;y.classList.value="";const f=document.createElement("div");f.className=d.containerSelector.replace(/^[.#:[\]]+/,""),y.innerHTML=f.outerHTML;const w={editionName:(null===(t=null==p?void 0:p.drEdition)||void 0===t?void 0:t.editionName)||"",drEditionConfig:d,device:a,tcf:s,isMobileApp:v,country:u,renderAsBackfill:!0};yield m.fetchAndRenderAd(y,w)});
|
|
@@ -210,6 +210,7 @@ interface SiteConfig {
|
|
|
210
210
|
};
|
|
211
211
|
useAppTabletInvCode?: boolean;
|
|
212
212
|
adScaleConfig?: AdScaleConfig;
|
|
213
|
+
widescreenSwitching?: WidescreenSwitchingConfig;
|
|
213
214
|
}
|
|
214
215
|
interface NativeTrackingConfig {
|
|
215
216
|
nativeTrackingEnabled?: boolean;
|
|
@@ -219,6 +220,7 @@ interface SiteSpecificConfig {
|
|
|
219
220
|
publisherClassName?: Newsroom;
|
|
220
221
|
fullWidthFormatClassName?: 'netboard' | 'panorama';
|
|
221
222
|
classesToRemoveOnRefresh?: Array<string>;
|
|
223
|
+
mainColumnWidth?: number;
|
|
222
224
|
}
|
|
223
225
|
interface Placement {
|
|
224
226
|
id: string;
|
|
@@ -439,6 +441,11 @@ interface DevicePlacementBatches {
|
|
|
439
441
|
type PlacementBatchesConfig = {
|
|
440
442
|
[device in DeviceType]: DevicePlacementBatches;
|
|
441
443
|
};
|
|
444
|
+
interface WidescreenSwitchingConfig {
|
|
445
|
+
enabled: boolean;
|
|
446
|
+
rotationInterval?: number;
|
|
447
|
+
widescreenIdPrefix?: string;
|
|
448
|
+
}
|
|
442
449
|
|
|
443
450
|
declare const setXandrPPIDs: (siteConfig: SiteConfig) => Promise<void>;
|
|
444
451
|
declare const getUserIdsObject: (country: Country) => UserIdsObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schibsted/advertory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.61.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "node node_modules/rollup/dist/bin/rollup -c rollup-config/default.mjs && npm run post:build",
|
|
6
6
|
"build:dev": "MODE=dev NODE_OPTIONS=--max-old-space-size=131072 npm run build",
|