@schibsted/advertory 2.57.0 → 2.57.2-test-INV-1208

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/core/aftenposten/es/index.css +1 -1
  2. package/core/aftenposten/es/index.js +1 -1
  3. package/core/aftenposten/index.js +1 -1
  4. package/core/aftonbladet/es/index.css +1 -1
  5. package/core/aftonbladet/es/index.js +1 -1
  6. package/core/aftonbladet/index.js +1 -1
  7. package/core/aftonbladetv2/es/index.css +1 -1
  8. package/core/aftonbladetv2/es/index.js +1 -1
  9. package/core/bt/es/index.css +1 -1
  10. package/core/bt/es/index.js +1 -1
  11. package/core/bt/index.js +1 -1
  12. package/core/e24/es/index.css +1 -1
  13. package/core/e24/es/index.js +1 -1
  14. package/core/e24/index.js +1 -1
  15. package/core/e24v2/es/index.css +1 -1
  16. package/core/e24v2/es/index.js +1 -1
  17. package/core/fotbollskanalen/es/index.css +1 -1
  18. package/core/fotbollskanalen/es/index.js +1 -1
  19. package/core/fotbollskanalen/index.js +1 -1
  20. package/core/godare/index.js +1 -1
  21. package/core/godt/index.js +1 -1
  22. package/core/klart/index.js +1 -1
  23. package/core/koket/es/index.js +1 -1
  24. package/core/koket/index.js +1 -1
  25. package/core/kompakt/index.js +1 -1
  26. package/core/minmote/index.js +1 -1
  27. package/core/pent/index.js +1 -1
  28. package/core/sa/es/index.css +1 -1
  29. package/core/sa/es/index.js +1 -1
  30. package/core/sa/index.js +1 -1
  31. package/core/svd/es/index.css +1 -1
  32. package/core/svd/es/index.js +1 -1
  33. package/core/svd/index.js +1 -1
  34. package/core/svdv2/es/index.css +1 -1
  35. package/core/svdv2/es/index.js +1 -1
  36. package/core/tek/index.js +1 -1
  37. package/core/tv4/es/index.js +1 -1
  38. package/core/tv4/index.js +1 -1
  39. package/core/tvnu/index.js +1 -1
  40. package/core/vg/es/index.css +1 -1
  41. package/core/vg/es/index.js +1 -1
  42. package/core/vg/index.js +1 -1
  43. package/core/vgv2/es/index.css +1 -1
  44. package/core/vgv2/es/index.js +1 -1
  45. package/features/dr-edition/es/index.d.ts +55 -1
  46. package/features/dr-edition/es/index.js +1 -1
  47. package/features/dr-edition/index.d.ts +55 -1
  48. package/features/dr-edition/index.js +1 -1
  49. package/package.json +1 -1
  50. package/sites/aftenposten/es/index.css +1 -1
  51. package/sites/aftonbladet/es/index.css +1 -1
  52. package/sites/aftonbladetv2/es/index.css +1 -1
  53. package/sites/bt/es/index.css +1 -1
  54. package/sites/e24/es/index.css +1 -1
  55. package/sites/e24v2/es/index.css +1 -1
  56. package/sites/fotbollskanalen/es/index.css +1 -1
  57. package/sites/sa/es/index.css +1 -1
  58. package/sites/svd/es/index.css +1 -1
  59. package/sites/svdv2/es/index.css +1 -1
  60. package/sites/vg/es/index.css +1 -1
  61. package/sites/vgv2/es/index.css +1 -1
  62. package/types/core/interface/keywords.d.ts +5 -0
  63. package/types/core/prepare-page-options/prepare-page-options-no.d.ts +2 -1
  64. package/types/core/prepare-page-options/prepare-page-options-no.test.d.ts +1 -0
  65. package/types/core/prepare-page-options/prepare-page-options-se.d.ts +2 -1
  66. package/types/features/dr-edition/composition.d.ts +5 -1
  67. package/types/features/dr-edition/constants.d.ts +2 -1
  68. package/types/features/dr-edition/types.d.ts +34 -0
  69. package/types/features/dr-edition/xandr-manager.d.ts +17 -0
  70. package/types/features/dr-edition/xandr-renderer.d.ts +8 -0
  71. package/types/features/dr-edition/xandr-service.d.ts +9 -0
@@ -549,6 +549,17 @@ interface DrEdition$1 {
549
549
  interface Renderer {
550
550
  render: (container: HTMLElement, drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => Promise<void>;
551
551
  }
552
+ interface Strategy {
553
+ getDrEditionUTMParams?: (drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => object;
554
+ getUrlWithParams?: (drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => string;
555
+ getUrlSearchParams?: (anchor: HTMLAnchorElement, drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => string;
556
+ appendTrackingDataScript?: (pulseData: PulseData, editionName: string, container: HTMLElement | null) => void;
557
+ appendDataAttributesForContainer?: (element: HTMLElement, pulseData: PulseData, placementId: string) => void;
558
+ handleVideo: (videoElement: HTMLElement, drEditionAd: DrEdition$1) => void;
559
+ getPulseObjectId: () => string;
560
+ getPulsePageId: (pageType: PageType, articleId?: string) => string;
561
+ getTags?: (anchor: HTMLElement | HTMLAnchorElement) => Array<string>;
562
+ }
552
563
  interface VideoManager {
553
564
  handle: (drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => Promise<void>;
554
565
  }
@@ -564,7 +575,19 @@ interface DrEditionComponentProps {
564
575
  [key: string]: string;
565
576
  };
566
577
  }
578
+ interface XandrParams {
579
+ invCode: string;
580
+ keywords: string;
581
+ drEditionConfig: DrEditionConfig;
582
+ device: DeviceType;
583
+ tcf?: TCFConfig;
584
+ renderAsBackfill?: boolean;
585
+ }
567
586
  type DrEditionObserverProperties = Pick<DrEditionObserverConfig, 'publisher' | 'pageType' | 'country'>;
587
+ interface XandrResponse {
588
+ desktopHTML: string;
589
+ mobileHTML: string;
590
+ }
568
591
 
569
592
  declare class IdentityFacade {
570
593
  private readonly identity;
@@ -596,7 +619,38 @@ declare class DrEditionManager {
596
619
  private observeCarousel;
597
620
  }
598
621
 
599
- declare const getDrEditionManager: (drEditionPageProperties: DrEditionObserverProperties, identityFacade: IdentityFacade, pulse?: PulseInstance) => DrEditionManager;
622
+ declare class XandrService {
623
+ private readonly identityFacade;
624
+ private readonly tracker?;
625
+ constructor(identityFacade: IdentityFacade, tracker?: TrackerInstance | undefined);
626
+ fetchData(xandrParams: XandrParams): Promise<XandrResponse | null>;
627
+ }
628
+
629
+ declare class XandrRenderer {
630
+ private readonly newsroomStrategy;
631
+ private readonly pulseManager;
632
+ constructor(newsroomStrategy: Strategy, pulseManager: PulseManager);
633
+ render(container: HTMLElement, drEditionResponse: XandrResponse, xandrParams: XandrParams): void;
634
+ }
635
+
636
+ declare class XandrManager {
637
+ private readonly xandrService;
638
+ private readonly rendererManager;
639
+ private readonly videoManager;
640
+ private readonly pulseManager;
641
+ private readonly drEditionAds;
642
+ constructor(xandrService: XandrService, rendererManager: XandrRenderer, videoManager: VideoManager, pulseManager: PulseManager);
643
+ fetchAndRenderAd(wrapper: HTMLElement, xandrParams: XandrParams): Promise<void>;
644
+ private observeAdView;
645
+ private showBackfill;
646
+ private hideDrEdition;
647
+ private observeCarousel;
648
+ }
649
+
650
+ declare const getDrEditionManager: (drEditionPageProperties: DrEditionObserverProperties, identityFacade: IdentityFacade, pulse?: PulseInstance) => {
651
+ drEditionManager: DrEditionManager;
652
+ xandrManager: XandrManager;
653
+ };
600
654
 
601
655
  declare const DrEdition: ({ editionName, fallbackTargetId, children, pulseData }: DrEditionComponentProps) => ReactNode;
602
656
 
@@ -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="cmp:loaded";let g,h=!1;const m=(e,t)=>{const i=!!(null==e?void 0:e.enabled),o=(null==e?void 0:e.timeout)||3e3,s=(a="bypass_tcf",new URLSearchParams(window.location.search).get(a));var a;const d=()=>{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))(i,s))return!0;if(h)return null;if(!g)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=g.getConsentedToAllSync();return r(`TCF consented to all is: ${t}`),g.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"),g=window._tcf_,void e(g);r("TCF consent manager is not available");const n=()=>{r("CMP loaded, resolving consent manager..."),i&&clearTimeout(i),window._tcf_?(g=window._tcf_,e(g)):t(new Error("CMP loaded but window._tcf_ is not defined"))},i=setTimeout(()=>{document.removeEventListener(p,n),h=!0,t(new Error("Timeout waiting for CMP to load"))},o);r("Listening for CMP loaded event..."),document.addEventListener(p,n,{once:!0})}):Promise.resolve(null),getConsentSync:d,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));if(null==e?void 0:e.schibstedAdChoicesEnabled)return r("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield v(e);if(!(null==e?void 0:e.enabled))return!0;const t=d();return null!==t?t:yield new Promise((e,t)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");g.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}})})}},y="mobile";class f{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}=m(i.tcf,i.isMobileApp),r=yield n(),o=i.device===y?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 w{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("playsinline",""),!(!a||!s)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,a),!0))}}class b{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 E extends b{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 P extends b{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",T="vg",I="aftonbladet",S="e24",k="front",A=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)))}))}),L={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 J})})}})}};class j{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=>{L[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 A(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===k?"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 M="https://www.aftonbladet.se/video-player-extras/latest/";class V{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:{[`${M}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${M}external-link.js`]:{name:"ExternalLink"}}};yield A(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 _=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);class N{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({},_(e)?e:{}),{provider:Object.assign(Object.assign({},_(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 A(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===k?"sdrn:svdse:frontpage:front":`sdrn:svdse:article:${t}`}}class O{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const U="se",D=(e,t,n)=>{var i;const{publisher:r,pageType:o,country:d}=e,l={[T]:new a,[S]:new j,[I]:new V,[C]:new N}[r]||new O,c=new(d===U?E:P)(n,l,o),v=new s(t,null!==(i=null==n?void 0:n.pulseTracker)&&void 0!==i?i:n),p=new f(l,c),g=new w(l);return new u(v,p,g,c)},x=({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})]}))},B=()=>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 R{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 $=(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=D(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)=>n(void 0,[e,t,...i],void 0,function*(e,t,n="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return r(`Schibsted Consent to Pay is not enabled, returning true for ${n}`),!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 ${n}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:i}=m(e);return(yield i())?(r(`Schibsted Ad Choices consent given according to TCF consent manager for ${n}`),!0):(r(`Schibsted Ad Choices consent not given according to TCF consent manager for ${n}`),!1)}),F=[],H=(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,"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=F.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||s;return l&&c&&!u&&v?(F.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 B(),h=new R(g),m=D({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,renderAsBackfill:!0};yield m.fetchAndRenderAd(y,w)}),z=e=>n(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;if(!(yield q(e.tcf,e.isMobileApp,"handleDrEdition")))return;const n=yield B(),i=new R(n);$({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 W=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 J=Object.freeze({__proto__:null,default:W});export{x as DrEdition,D as getDrEditionManager,z as handleDrEdition,H 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 a(e){try{s(i.next(e))}catch(e){o(e)}}function d(e){try{s(i.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,d)}s((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"],a="https://dr-edition-teaser-server.staging.inventory.schibsted.io/xandr";class d{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")||""})(),a=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),d=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:s,spid:l}=t;return d.searchParams.append("editionName",r),o&&d.searchParams.append("urlData",o),a&&d.searchParams.append("excludedItems",a),l&&d.searchParams.append("spid",l),s&&d.searchParams.append("envid",s),d.toString()}fetchData(e){return n(this,void 0,void 0,function*(){var t,n;const o=yield this.identityFacade.getIdentityUser(),a=null!==(n=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==n?n:"",d=(null==o?void 0:o.userId)?String(o.userId):"",s=this.buildUrl(e,{envId:a,spid:d});try{r("Starting fetching DrEdition ad from URL:",s);const e={method:"GET"},t=yield i.get(s,e);return r("Fetch operation completed successfully."),t}catch(e){r("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:a}=t,d=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:a,utm_campaign:r,utm_medium:d},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:a}=t.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:n,vgtvVendor:a,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 l=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()})())},c=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"))},u=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 v{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:a=!1}=t,d=e.querySelector(o);if(!d)return void r(`Container with selector "${o}" not found.`);const s=yield this.drEditionService.fetchData(t);return(null==s?void 0:s.itemId)||a?!(null==s?void 0:s.itemId)&&a?(r("No Dr. Edition ads available to render. Collapsing whole placement."),l(e.id),void u(d)):((null==s?void 0:s.itemId)&&a&&(r("Dr. Edition ad available to render as a Xandr backfill."),c(e.id)),void(s?(s.css&&((e,t)=>{const n=document.createElement("link");n.rel="preload",n.href=e,n.as=t,document.head.appendChild(n)})(s.css,"style"),yield this.rendererManager.render(d,s,t),yield null===(n=this.videoManager)||void 0===n?void 0:n.handle(s,t),u(d),this.drEditionAds.push(s),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],window.advertory.renderedDrEditionAds.push(s.itemId),this.observeAdView(e,s,t),null===(i=e.querySelector("a"))||void 0===i||i.addEventListener("pointerup",()=>null)):u(d))):(r("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(d),this.showBackfill(e),void u(d))})}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:"";c(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 p=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))},a=setTimeout(()=>{r("Advertising permission timed out, resolving with false"),o(!1)},3e3);window._tcf_.onTcfReady(()=>{r("On Tcf Ready called, waiting for permission"),clearTimeout(a)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(a);const t=Number(e);r("Advertising permission value obtained asynchronously: ",e),o(Boolean(t))})}),g="cmp:loaded";let h,m=!1;const y=(e,t)=>{const i=!!(null==e?void 0:e.enabled),o=(null==e?void 0:e.timeout)||3e3,a=(d="bypass_tcf",new URLSearchParams(window.location.search).get(d));var d;const s=()=>{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))(i,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 r(`TCF consented to all is: ${t}`),h.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"),h=window._tcf_,void e(h);r("TCF consent manager is not available");const n=()=>{r("CMP loaded, resolving consent manager..."),i&&clearTimeout(i),window._tcf_?(h=window._tcf_,e(h)):t(new Error("CMP loaded but window._tcf_ is not defined"))},i=setTimeout(()=>{document.removeEventListener(g,n),m=!0,t(new Error("Timeout waiting for CMP to load"))},o);r("Listening for CMP loaded event..."),document.addEventListener(g,n,{once:!0})}):Promise.resolve(null),getConsentSync:s,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));if(null==e?void 0:e.schibstedAdChoicesEnabled)return r("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield p(e);if(!(null==e?void 0:e.enabled))return!0;const t=s();return null!==t?t:yield new Promise((e,t)=>{try{if(!h)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");h.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}})})}},f="mobile";class w{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}=y(i.tcf,i.isMobileApp),r=yield n(),o=i.device===f?t.mobileHTML:t.desktopHTML;const a=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=a,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 b{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=()=>{d(),n()},a=()=>{d(),i(new Error(`Failed to load ${e}`))},d=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(s)};r.addEventListener("load",o),r.addEventListener("error",a);const s=setTimeout(()=>{d(),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 a=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");a!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:a}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const d=document.querySelector(".dr-edition-preview .preview-video");return!!d&&(d.setAttribute("playsinline",""),!(!d||!a)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,d),!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,t,i){return n(this,void 0,void 0,function*(){var n,r,o,a,d,s,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===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)?null===(s=null===(d=this.pulse)||void 0===d?void 0:d.trackViewUIElement)||void 0===s||s.call(d,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,a,d,s;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===(a=(o=this.pulse).trackClickUIElement)||void 0===a||a.call(o,l):null===(s=(d=this.pulse).trackElementClick)||void 0===s||s.call(d,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:a,primaryPosition:d}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:a,primaryPosition:d},"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 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,a,d,s;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!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==a?a: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===(s=null===(d=this.newsroomStrategy)||void 0===d?void 0:d.getTags)||void 0===s?void 0:s.call(d,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,a,d;const{pulseData:{algorithm:s="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!==(d=null!==(a=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!==a?a:p)&&void 0!==d?d:"";return{algorithm:s,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 S="svd",T="vg",A="aftonbladet",I="e24",k="front",L=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 le})})}})}};class O{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:i,autoplay:r,mute:o,vendor:a}}){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 d=["ContentMutePlugin"],s=this.createPlayerOverlay(e);var l,c;c=s,null==(l=d)||l.forEach(e=>{M[e](c)});const u={id:t,node:i,autoplay:r,mute:o,vendor:a,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,d)}),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")?s.classList.add("is-playing"):s.classList.remove("is-playing"),t.classList.contains("jw-flag-user-inactive")?s.classList.add("is-inactive"):s.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===k?"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 j="https://www.aftonbladet.se/video-player-extras/latest/";class D{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:n,autoplay:i,mute:r,vendor:o}}){const a={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:{[`${j}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${j}external-link.js`]:{name:"ExternalLink"}}};yield L(a),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 _=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);class N{handleVideo(e,t){return n(this,arguments,void 0,function*(e,{videoConfiguration:{id:t,node:i,autoplay:r,mute:o,vendor:a}}){const d={id:t,node:i,autoplay:r,mute:o,vendor:a,locale:"se",autopause:"viewable",maxBitrate:600,sharing:!1,recommended:!1,pulse:{provider:"svdse",decorator:(e,t)=>Object.assign(Object.assign({},_(e)?e:{}),{provider:Object.assign(Object.assign({},_(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:{}}}},s=yield L(d);s.once("PulseStats:ready",()=>n(this,void 0,void 0,function*(){const e=yield s.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===k?"sdrn:svdse:frontpage:front":`sdrn:svdse:article:${t}`}}class x{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const U="se",R="0123456789abcdefghijklmnopqrstuvwxyz",V=(e=6)=>{if(e<=0)return"";let t="";for(let n=0;n<e;n++){t+=R[Math.floor(36*Math.random())]}return t},B=e=>{window.apntag.anq.push(e)};new Promise(e=>{"undefined"!=typeof document&&document.prerendering?document.addEventListener("prerenderingchange",()=>e()):e()}),new Promise(e=>{if("undefined"==typeof document||!document.hidden)return void e();const t=()=>{document.hidden||(document.removeEventListener("visibilitychange",t),e())};document.addEventListener("visibilitychange",t,{once:!0})});function q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $,H;var F=q(function(){if(H)return $;H=1;var e=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var n=Object.prototype.toString.call(e);return"[object RegExp]"===n||"[object Date]"===n||function(e){return e.$$typeof===t}(e)}(e)},t="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?d((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function i(e,t,i){return e.concat(t).map(function(e){return n(e,i)})}function r(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,t,i){var a={};return i.isMergeableObject(e)&&r(e).forEach(function(t){a[t]=n(e[t],i)}),r(t).forEach(function(r){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(o(e,r)&&i.isMergeableObject(t[r])?a[r]=function(e,t){if(!t.customMerge)return d;var n=t.customMerge(e);return"function"==typeof n?n:d}(r,i)(e[r],t[r],i):a[r]=n(t[r],i))}),a}function d(t,r,o){(o=o||{}).arrayMerge=o.arrayMerge||i,o.isMergeableObject=o.isMergeableObject||e,o.cloneUnlessOtherwiseSpecified=n;var d=Array.isArray(r);return d===Array.isArray(t)?d?o.arrayMerge(t,r,o):a(t,r,o):n(r,o)}return d.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return d(e,n,t)},{})},$=d}());const z=["deviceType","pageType","placements","takeover","refreshConfig","editableConfiguration"],X={adRequested:()=>{},adAvailable:e=>{},adLoaded:e=>{},adNoBid:e=>{},adError:(e,t)=>{},adCollapse:()=>{},adRequestFailure:e=>{},adBadRequest:e=>{},adLoadedMediated:e=>{},adNoBidMediated:e=>{}};class W{set(e){this.config=e}modifyConfigProperties(e){if(!this.config)throw new Error("Config was accessed before it had been initialized.");const t={};for(const n of z){const i=e[n];void 0!==i&&(t[n]=i)}Object.assign(this.config,t),Object.prototype.hasOwnProperty.call(e,"pageOptions")&&void 0!==e.pageOptions&&(this.config.pageOptions=Object.assign(Object.assign({},this.config.pageOptions),e.pageOptions))}get(){if(!this.config)throw new Error("Config was accessed before it had been initialized.");return this.config}getHandlers(){if(!this.siteHandlers)throw new Error("Handlers were accessed before it had been initialized.");return this.siteHandlers}setHandlers(e){this.siteHandlers=F(W.DEFAULT_SITE_HANDLERS,e)}}W.DEFAULT_SITE_HANDLERS={siteEvents:X,initNativeAd:function(){}};const J=new W;J.modifyConfigProperties.bind(J);const G=()=>n(void 0,void 0,void 0,function*(){const{tcf:e,isMobileApp:t}=J.get(),{getConsentAsync:n}=y(e);if(!(yield n()))return;const i=(e=>{const t=encodeURIComponent(e).replace(/[-.+*]/g,"\\$&"),n=new RegExp(`(?:(?:^|.*;)\\s*${t}\\s*\\=\\s*([^;]*).*$)|^.*$`);return decodeURIComponent(document.cookie.replace(n,"$1"))||null})("_pulse2data");return i?i.split(",")[9]:void 0});class Q{constructor(e,t){this.identityFacade=e,this.tracker=t}fetchData(e){return n(this,void 0,void 0,function*(){var t,o;const d=yield this.identityFacade.getIdentityUser(),s=null!==(o=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==o?o:"",l=(null==d?void 0:d.userId)?String(d.userId):"",c=yield n(void 0,void 0,void 0,function*(){return window.__tcfapi?{gdpr:1,gdpr_consent:yield(e=window.__tcfapi,new Promise((t,n)=>{e("addEventListener",2,(n,i)=>{var r;i||t(""),"tcloaded"!==n.eventStatus&&"useractioncomplete"!==n.eventStatus||(t(null!==(r=n.tcString)&&void 0!==r?r:""),e("removeEventListener",2,()=>{},n.listenerId))})}))}:{};var e}),{invCode:u,keywords:v}=e,p=`aa-sch-publisher=no-vg,aa-sch-supply_type=web_desktop${v?`,${v}`:""}`;console.log("INV CODE FOR PLACEMENTS IS",u),console.log("KEYWORDS FOR PLACEMENTS IS",v);try{r("Starting fetching Studio ad from Xandr:",a);const e=new Headers({"Content-Type":"application/json"}),t=new URL(window.location.href),n={plcmtcnt:1,context:1,contextsubtype:10,plcmttype:1,assets:[{id:1,title:{len:100},required:0},{id:2,img:{type:1,hmin:10,wmin:10},required:0},{id:3,img:{type:3,hmin:10,wmin:10},required:0},{id:4,data:{type:2},required:0},{id:5,data:{type:12},required:0}],ver:"1.2",eventtrackers:[{event:1,methods:[1,2]}]},o={id:V(36),imp:[{id:"no-vg-wde-front_partnerstudio_1",native:{request:JSON.stringify(n),ver:"1.1"},secure:1,tagid:u,ext:{appnexus:{placement_id:36792536,code:u,keywords:p,use_pmt_rule:!1}}}],site:{domain:t.hostname,page:t.href,publisher:{id:"1",domain:t.hostname},ext:{amp:0}},device:{dnt:Number((null===navigator||void 0===navigator?void 0:navigator.globalPrivacyControl)||"1"===(null===navigator||void 0===navigator?void 0:navigator.doNotTrack)),ua:window.navigator.userAgent,h:screen.height,w:screen.width,language:(navigator.language||"sv-SE").split("-")[0]},regs:{ext:{gdpr:c.gdpr||0}},user:{id:G(),ext:{consent:c.gdpr_consent||"",eids:[...s&&[{source:"SCHSE-EnvHash",uids:[{id:s,atype:1,ext:{stype:"ppuid"}}]}],...l&&[{source:"schse-envhash-v3",uids:[{id:l,atype:1,ext:{stype:"ppuid"}}]}]]}},at:1,cur:["SEK"],source:{tid:V(36)},ext:{prebid:{bidder:{appnexus:{member:9826}}}}};console.log("BEFORE XANDR CALL",{payload:o});const d=yield i.post(a,e,o);return console.log("AFTER XANDR CALL",d),r("Fetch operation completed successfully.",d),d}catch(e){r("Error during fetch operation:",e)}return null})}}class K{constructor(e,t,n,i){this.xandrService=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;const{drEditionConfig:{containerSelector:i},renderAsBackfill:o=!1}=t,a=e.querySelector(i);if(!a)return void r(`Container with selector "${i}" not found.`);const d=yield this.xandrService.fetchData(t);return(null==d?void 0:d.desktopHTML)||o?!(null==d?void 0:d.desktopHTML)&&o?(r("No Dr. Edition ads available to render from Xandr. Collapsing whole placement."),void l(e.id)):((null==d?void 0:d.desktopHTML)&&o&&(r("Dr. Edition ad available to render as a Xandr backfill."),c(e.id)),void(d&&(this.rendererManager.render(a,d,t),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],null===(n=e.querySelector("a"))||void 0===n||n.addEventListener("pointerup",()=>null)))):(r("No Dr. Edition ads available to render from Xandr. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(a),void this.showBackfill(e))})}observeAdView(e,t,n){}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:"",r=window.apntag;c(i),B(()=>r.loadTags([i])),B(()=>r.showTag(i))}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){return!0}}class Y{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,t,n){console.log("RENDERING XANDR AD",{container:e,drEditionResponse:t,xandrParams:n}),t.desktopHTML&&("mobile"===n.device?e.innerHTML=t.mobileHTML:e.innerHTML=t.desktopHTML)}}const Z=(e,t,n)=>{var i;const{publisher:r,pageType:o,country:a}=e,l={[T]:new s,[I]:new O,[A]:new D,[S]:new N}[r]||new x,c=new(a===U?P:C)(n,l,o),u=new d(t,null!==(i=null==n?void 0:n.pulseTracker)&&void 0!==i?i:n),p=new Q(t,null==n?void 0:n.pulseTracker),g=new Y(l,c),h=new w(l,c),m=new b(l);return{drEditionManager:new v(u,h,m,c),xandrManager:new K(p,g,m,c)}},ee=({editionName:n,fallbackTargetId:i,children:r,pulseData:o})=>{const a=(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},a,{children:[t("div",{className:"inscreen-target"}),t("div",{className:"container"}),t("div",{className:"fallback","data-fallback-target-id":i,style:{display:"none"},children:r})]}))},te=()=>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 ne{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 ie=(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{drEditionManager:o,xandrManager:a}=Z(n,i,r);e.forEach(e=>{var i,r,d,s,l;if(!e.isIntersecting)return;const c=e.target,u=null!==(i=c.dataset.editionName)&&void 0!==i?i:"",v=null!==(r=c.dataset.invCode)&&void 0!==r?r:null,p=null!==(d=c.dataset.keywords)&&void 0!==d?d:"",g=null!==(s=c.dataset.pulseColumnname)&&void 0!==s?s:"",h=null!==(l=c.dataset.pulsePrimaryposition)&&void 0!==l?l:"";v?a.fetchAndRenderAd(c,Object.assign(Object.assign({},n),{invCode:v,keywords:p})):o.fetchAndRenderAd(c,Object.assign(Object.assign({},n),{editionName:u,columnName:g,primaryPosition:h})),t.unobserve(c)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},re=(e,t,...i)=>n(void 0,[e,t,...i],void 0,function*(e,t,n="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return r(`Schibsted Consent to Pay is not enabled, returning true for ${n}`),!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 ${n}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:i}=y(e);return(yield i())?(r(`Schibsted Ad Choices consent given according to TCF consent manager for ${n}`),!0):(r(`Schibsted Ad Choices consent not given according to TCF consent manager for ${n}`),!1)}),oe=[],ae=(e,t)=>n(void 0,void 0,void 0,function*(){var n;const{pulse:i,tcf:a,deviceType:d,drEdition:s,publisher:l,pageType:c,country:u,isMobileApp:v}=e;if(!(yield re(a,v,"handleDrEditionBackfill")))return;const p=((e,t)=>{var n;const{deviceType:i,placements:r,drEdition:{fallbackGlobalEditionName:a}={}}=e,d=r[i]||r.desktop,s=(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=d.find(e=>e.id===s),c=o.some(e=>s.startsWith(e)),u=oe.includes(s),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||a;return l&&c&&!u&&v?(oe.push(s),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 te(),h=new ne(g),{drEditionManager:m}=Z({publisher:l,pageType:c,country:u},h,null==i?void 0:i.instance),y=document.getElementById(t.targetId);if(!y||!s)return;y.classList.value="";const f=document.createElement("div");f.className=s.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:s,device:d,tcf:a,isMobileApp:v,renderAsBackfill:!0};yield m.fetchAndRenderAd(y,w)}),de=e=>n(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;if(!(yield re(e.tcf,e.isMobileApp,"handleDrEdition")))return;const n=yield te(),i=new ne(n);ie({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 se=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 le=Object.freeze({__proto__:null,default:se});export{ee as DrEdition,Z as getDrEditionManager,de as handleDrEdition,ae as handleDrEditionBackfill};
@@ -549,6 +549,17 @@ interface DrEdition$1 {
549
549
  interface Renderer {
550
550
  render: (container: HTMLElement, drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => Promise<void>;
551
551
  }
552
+ interface Strategy {
553
+ getDrEditionUTMParams?: (drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => object;
554
+ getUrlWithParams?: (drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => string;
555
+ getUrlSearchParams?: (anchor: HTMLAnchorElement, drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => string;
556
+ appendTrackingDataScript?: (pulseData: PulseData, editionName: string, container: HTMLElement | null) => void;
557
+ appendDataAttributesForContainer?: (element: HTMLElement, pulseData: PulseData, placementId: string) => void;
558
+ handleVideo: (videoElement: HTMLElement, drEditionAd: DrEdition$1) => void;
559
+ getPulseObjectId: () => string;
560
+ getPulsePageId: (pageType: PageType, articleId?: string) => string;
561
+ getTags?: (anchor: HTMLElement | HTMLAnchorElement) => Array<string>;
562
+ }
552
563
  interface VideoManager {
553
564
  handle: (drEditionAd: DrEdition$1, drEditionParams: DrEditionParams) => Promise<void>;
554
565
  }
@@ -564,7 +575,19 @@ interface DrEditionComponentProps {
564
575
  [key: string]: string;
565
576
  };
566
577
  }
578
+ interface XandrParams {
579
+ invCode: string;
580
+ keywords: string;
581
+ drEditionConfig: DrEditionConfig;
582
+ device: DeviceType;
583
+ tcf?: TCFConfig;
584
+ renderAsBackfill?: boolean;
585
+ }
567
586
  type DrEditionObserverProperties = Pick<DrEditionObserverConfig, 'publisher' | 'pageType' | 'country'>;
587
+ interface XandrResponse {
588
+ desktopHTML: string;
589
+ mobileHTML: string;
590
+ }
568
591
 
569
592
  declare class IdentityFacade {
570
593
  private readonly identity;
@@ -596,7 +619,38 @@ declare class DrEditionManager {
596
619
  private observeCarousel;
597
620
  }
598
621
 
599
- declare const getDrEditionManager: (drEditionPageProperties: DrEditionObserverProperties, identityFacade: IdentityFacade, pulse?: PulseInstance) => DrEditionManager;
622
+ declare class XandrService {
623
+ private readonly identityFacade;
624
+ private readonly tracker?;
625
+ constructor(identityFacade: IdentityFacade, tracker?: TrackerInstance | undefined);
626
+ fetchData(xandrParams: XandrParams): Promise<XandrResponse | null>;
627
+ }
628
+
629
+ declare class XandrRenderer {
630
+ private readonly newsroomStrategy;
631
+ private readonly pulseManager;
632
+ constructor(newsroomStrategy: Strategy, pulseManager: PulseManager);
633
+ render(container: HTMLElement, drEditionResponse: XandrResponse, xandrParams: XandrParams): void;
634
+ }
635
+
636
+ declare class XandrManager {
637
+ private readonly xandrService;
638
+ private readonly rendererManager;
639
+ private readonly videoManager;
640
+ private readonly pulseManager;
641
+ private readonly drEditionAds;
642
+ constructor(xandrService: XandrService, rendererManager: XandrRenderer, videoManager: VideoManager, pulseManager: PulseManager);
643
+ fetchAndRenderAd(wrapper: HTMLElement, xandrParams: XandrParams): Promise<void>;
644
+ private observeAdView;
645
+ private showBackfill;
646
+ private hideDrEdition;
647
+ private observeCarousel;
648
+ }
649
+
650
+ declare const getDrEditionManager: (drEditionPageProperties: DrEditionObserverProperties, identityFacade: IdentityFacade, pulse?: PulseInstance) => {
651
+ drEditionManager: DrEditionManager;
652
+ xandrManager: XandrManager;
653
+ };
600
654
 
601
655
  declare const DrEdition: ({ editionName, fallbackTargetId, children, pulseData }: DrEditionComponentProps) => ReactNode;
602
656
 
@@ -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="cmp:loaded";let p,g=!1;const h=(e,n)=>{const r=!!(null==e?void 0:e.enabled),o=(null==e?void 0:e.timeout)||3e3,s=(a="bypass_tcf",new URLSearchParams(window.location.search).get(a));var a;const d=()=>{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))(r,s))return!0;if(g)return null;if(!p)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const t=p.getConsentedToAllSync();return i(`TCF consented to all is: ${t}`),p.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"),p=window._tcf_,void e(p);i("TCF consent manager is not available");const n=()=>{i("CMP loaded, resolving consent manager..."),r&&clearTimeout(r),window._tcf_?(p=window._tcf_,e(p)):t(new Error("CMP loaded but window._tcf_ is not defined"))},r=setTimeout(()=>{document.removeEventListener(v,n),g=!0,t(new Error("Timeout waiting for CMP to load"))},o);i("Listening for CMP loaded event..."),document.addEventListener(v,n,{once:!0})}):Promise.resolve(null),getConsentSync:d,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));if(null==e?void 0:e.schibstedAdChoicesEnabled)return i("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield u(e);if(!(null==e?void 0:e.enabled))return!0;const t=d();return null!==t?t:yield new Promise((e,t)=>{try{if(!p)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");p.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}})})}},m="mobile";class y{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}=h(i.tcf,i.isMobileApp),r=yield t(),o=i.device===m?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 f{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("playsinline",""),!(!a||!s)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,a),!0))}}class w{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 b extends w{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 E extends w{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 P="svd",C="vg",T="aftonbladet",I="e24",S="front",k=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)))}))}),A={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 F})})}})}};class L{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=>{A[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 k(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===S?"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 j="https://www.aftonbladet.se/video-player-extras/latest/";class M{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:{[`${j}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${j}external-link.js`]:{name:"ExternalLink"}}};yield k(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 D=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);class V{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({},D(e)?e:{}),{provider:Object.assign(Object.assign({},D(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 k(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===S?"sdrn:svdse:frontpage:front":`sdrn:svdse:article:${t}`}}class _{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const N="se",O=(e,t,n)=>{var i;const{publisher:r,pageType:a,country:d}=e,l={[C]:new s,[I]:new L,[T]:new M,[P]:new V}[r]||new _,u=new(d===N?b:E)(n,l,a),v=new o(t,null!==(i=null==n?void 0:n.pulseTracker)&&void 0!==i?i:n),p=new y(l,u),g=new f(l);return new c(v,p,g,u)},U=()=>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 x{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 B=(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=O(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))},R=(e,n,...r)=>t(void 0,[e,n,...r],void 0,function*(e,t,n="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return i(`Schibsted Consent to Pay is not enabled, returning true for ${n}`),!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 ${n}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:r}=h(e);return(yield r())?(i(`Schibsted Ad Choices consent given according to TCF consent manager for ${n}`),!0):(i(`Schibsted Ad Choices consent not given according to TCF consent manager for ${n}`),!1)}),$=[];const q=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 F=Object.freeze({__proto__:null,default:q});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=O,exports.handleDrEdition=e=>t(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;if(!(yield R(e.tcf,e.isMobileApp,"handleDrEdition")))return;const n=yield U(),i=new x(n);B({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 R(s,v,"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=$.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||s;return l&&c&&!u&&v?($.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 U(),h=new x(g),m=O({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,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 a(e){try{d(i.next(e))}catch(e){o(e)}}function s(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(a,s)}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"],o="https://dr-edition-teaser-server.staging.inventory.schibsted.io/xandr";class a{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")||""})(),a=JSON.stringify(null!==(i=null===(n=window.advertory)||void 0===n?void 0:n.renderedDrEditionAds)&&void 0!==i?i:[]),s=new URL("https://dr-edition-teaser-server.inventory.schibsted.io/editions"),{envId:d,spid:l}=t;return s.searchParams.append("editionName",r),o&&s.searchParams.append("urlData",o),a&&s.searchParams.append("excludedItems",a),l&&s.searchParams.append("spid",l),d&&s.searchParams.append("envid",d),s.toString()}fetchData(e){return t(this,void 0,void 0,function*(){var t,r;const o=yield this.identityFacade.getIdentityUser(),a=null!==(r=yield null===(t=this.tracker)||void 0===t?void 0:t.getEnvironmentId())&&void 0!==r?r:"",s=(null==o?void 0:o.userId)?String(o.userId):"",d=this.buildUrl(e,{envId:a,spid:s});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:a}=t,s=i.replace(/<[^>]*>/g,"");return Object.assign({utm_source:"vgfront",utm_content:a,utm_campaign:r,utm_medium:s},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:a}=n.videoConfiguration;e.classList.add("vgtv-video-container"),Object.assign(e.dataset,{vgtvVideoId:t,vgtvVendor:a,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"):i("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,n){return t(this,void 0,void 0,function*(){var t,r;const{drEditionConfig:{containerSelector:o},renderAsBackfill:a=!1}=n,s=e.querySelector(o);if(!s)return void i(`Container with selector "${o}" not found.`);const u=yield this.drEditionService.fetchData(n);return(null==u?void 0:u.itemId)||a?!(null==u?void 0:u.itemId)&&a?(i("No Dr. Edition ads available to render. Collapsing whole placement."),d(e.id),void c(s)):((null==u?void 0:u.itemId)&&a&&(i("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(s,u,n),yield null===(t=this.videoManager)||void 0===t?void 0:t.handle(u,n),c(s),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)):c(s))):(i("No Dr. Edition ads available to render. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(s),this.showBackfill(e),void c(s))})}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 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))},a=setTimeout(()=>{i("Advertising permission timed out, resolving with false"),o(!1)},3e3);window._tcf_.onTcfReady(()=>{i("On Tcf Ready called, waiting for permission"),clearTimeout(a)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(a);const t=Number(e);i("Advertising permission value obtained asynchronously: ",e),o(Boolean(t))})}),p="cmp:loaded";let g,h=!1;const m=(e,n)=>{const r=!!(null==e?void 0:e.enabled),o=(null==e?void 0:e.timeout)||3e3,a=(s="bypass_tcf",new URLSearchParams(window.location.search).get(s));var s;const d=()=>{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))(r,a))return!0;if(h)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(p,n),h=!0,t(new Error("Timeout waiting for CMP to load"))},o);i("Listening for CMP loaded event..."),document.addEventListener(p,n,{once:!0})}):Promise.resolve(null),getConsentSync:d,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));if(null==e?void 0:e.schibstedAdChoicesEnabled)return i("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield v(e);if(!(null==e?void 0:e.enabled))return!0;const t=d();return null!==t?t:yield new Promise((e,t)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");g.isConsentedToAll(t=>{e(t)})}catch(e){t(e)}})})}},y="mobile";class f{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}=m(i.tcf,i.isMobileApp),r=yield t(),o=i.device===y?n.mobileHTML:n.desktopHTML;const a=r?o:o.replace(/<img [^>]*class="tracking-pixel"[^>]*>/g,"");e.innerHTML=a,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 w{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=()=>{s(),n()},a=()=>{s(),i(new Error(`Failed to load ${e}`))},s=()=>{r.removeEventListener("load",o),r.removeEventListener("error",a),clearTimeout(d)};r.addEventListener("load",o),r.addEventListener("error",a);const d=setTimeout(()=>{s(),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 a=o.closest("a");o.addEventListener("click",e=>{const t=e.target.closest("a");a!==t&&t||(e.stopPropagation(),e.preventDefault())})})}handlePreviewVideo(e,t){var n,i,r;const{preview:{url:o,thumbnail:a}}=null!==(n=e.videoConfiguration)&&void 0!==n?n:{};if(!o)return!1;const s=document.querySelector(".dr-edition-preview .preview-video");return!!s&&(s.setAttribute("playsinline",""),!(!s||!a)&&(null===(r=(i=t.drEditionConfig).addPreviewVideo)||void 0===r||r.call(i,s),!0))}}class b{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,a,s,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===(a=this.pulse)||void 0===a?void 0:a.trackViewUIElement)?null===(d=null===(s=this.pulse)||void 0===s?void 0:s.trackViewUIElement)||void 0===d||d.call(s,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,a,s,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===(a=(o=this.pulse).trackClickUIElement)||void 0===a||a.call(o,l):null===(d=(s=this.pulse).trackElementClick)||void 0===d||d.call(s,l)})}}class E extends b{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:a,primaryPosition:s}=n;return{"@type":"UIElement",elementType:"Teaser",layout:{elementSize:"large",imageUrl:"",name:"large"},name:i,placement:{columnName:a,primaryPosition:s},"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 P extends b{constructor(e,t,n){super(e,t),this.pulse=e,this.newsroomStrategy=t,this.pageType=n}getEventBaseData(e,t,n){var i,r,o,a,s,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!==(a=null===(o=null===(r=this.newsroomStrategy)||void 0===r?void 0:r.getPulseObjectId)||void 0===o?void 0:o.call(r))&&void 0!==a?a: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===(s=this.newsroomStrategy)||void 0===s?void 0:s.getTags)||void 0===d?void 0:d.call(s,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,a,s;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!==(s=null!==(a=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!==a?a:p)&&void 0!==s?s:"";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",S="vg",T="aftonbladet",A="e24",I="front",k=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)))}))}),L={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 oe})})}})}};class M{handleVideo(e,n){return t(this,arguments,void 0,function*(e,{videoConfiguration:{id:n,node:i,autoplay:r,mute:o,vendor:a}}){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 s=["ContentMutePlugin"],d=this.createPlayerOverlay(e);var l,c;c=d,null==(l=s)||l.forEach(e=>{L[e](c)});const u={id:n,node:i,autoplay:r,mute:o,vendor:a,autopause:"viewable",maxBitrate:600,pulse:{provider:"e24"},recommended:{autoplay:!1,next:{countdown:10}},skin:{name:"e24-default",url:""}},v=yield k(u);v.once("assetReady",()=>{((e,t)=>{null==t||t.forEach(t=>{const n=window.SVP.Player.Plugins.get(t);e.addPlugin(new n)})})(v,s)}),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===I?"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 j="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 a={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:{[`${j}cta-button.js`]:{name:"CtaButton",options:{type:"unmute"}},[`${j}external-link.js`]:{name:"ExternalLink"}}};yield k(a),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 D=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:a}}){const s={id:n,node:i,autoplay:r,mute:o,vendor:a,locale:"se",autopause:"viewable",maxBitrate:600,sharing:!1,recommended:!1,pulse:{provider:"svdse",decorator:(e,t)=>Object.assign(Object.assign({},D(e)?e:{}),{provider:Object.assign(Object.assign({},D(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 k(s);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===I?"sdrn:svdse:frontpage:front":`sdrn:svdse:article:${t}`}}class x{handleVideo(e,t){}getPulseObjectId(){return""}getPulsePageId(e,t){return""}}const N="se",U="0123456789abcdefghijklmnopqrstuvwxyz",R=(e=6)=>{if(e<=0)return"";let t="";for(let n=0;n<e;n++){t+=U[Math.floor(36*Math.random())]}return t},V=e=>{window.apntag.anq.push(e)};new Promise(e=>{"undefined"!=typeof document&&document.prerendering?document.addEventListener("prerenderingchange",()=>e()):e()}),new Promise(e=>{if("undefined"==typeof document||!document.hidden)return void e();const t=()=>{document.hidden||(document.removeEventListener("visibilitychange",t),e())};document.addEventListener("visibilitychange",t,{once:!0})});function B(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var q,$;var H=B(function(){if($)return q;$=1;var e=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var n=Object.prototype.toString.call(e);return"[object RegExp]"===n||"[object Date]"===n||function(e){return e.$$typeof===t}(e)}(e)},t="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function i(e,t,i){return e.concat(t).map(function(e){return n(e,i)})}function r(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,t,i){var a={};return i.isMergeableObject(e)&&r(e).forEach(function(t){a[t]=n(e[t],i)}),r(t).forEach(function(r){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(o(e,r)&&i.isMergeableObject(t[r])?a[r]=function(e,t){if(!t.customMerge)return s;var n=t.customMerge(e);return"function"==typeof n?n:s}(r,i)(e[r],t[r],i):a[r]=n(t[r],i))}),a}function s(t,r,o){(o=o||{}).arrayMerge=o.arrayMerge||i,o.isMergeableObject=o.isMergeableObject||e,o.cloneUnlessOtherwiseSpecified=n;var s=Array.isArray(r);return s===Array.isArray(t)?s?o.arrayMerge(t,r,o):a(t,r,o):n(r,o)}return s.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})},q=s}());const F=["deviceType","pageType","placements","takeover","refreshConfig","editableConfiguration"],z={adRequested:()=>{},adAvailable:e=>{},adLoaded:e=>{},adNoBid:e=>{},adError:(e,t)=>{},adCollapse:()=>{},adRequestFailure:e=>{},adBadRequest:e=>{},adLoadedMediated:e=>{},adNoBidMediated:e=>{}};class X{set(e){this.config=e}modifyConfigProperties(e){if(!this.config)throw new Error("Config was accessed before it had been initialized.");const t={};for(const n of F){const i=e[n];void 0!==i&&(t[n]=i)}Object.assign(this.config,t),Object.prototype.hasOwnProperty.call(e,"pageOptions")&&void 0!==e.pageOptions&&(this.config.pageOptions=Object.assign(Object.assign({},this.config.pageOptions),e.pageOptions))}get(){if(!this.config)throw new Error("Config was accessed before it had been initialized.");return this.config}getHandlers(){if(!this.siteHandlers)throw new Error("Handlers were accessed before it had been initialized.");return this.siteHandlers}setHandlers(e){this.siteHandlers=H(X.DEFAULT_SITE_HANDLERS,e)}}X.DEFAULT_SITE_HANDLERS={siteEvents:z,initNativeAd:function(){}};const W=new X;W.modifyConfigProperties.bind(W);const J=()=>t(void 0,void 0,void 0,function*(){const{tcf:e,isMobileApp:t}=W.get(),{getConsentAsync:n}=m(e);if(!(yield n()))return;const i=(e=>{const t=encodeURIComponent(e).replace(/[-.+*]/g,"\\$&"),n=new RegExp(`(?:(?:^|.*;)\\s*${t}\\s*\\=\\s*([^;]*).*$)|^.*$`);return decodeURIComponent(document.cookie.replace(n,"$1"))||null})("_pulse2data");return i?i.split(",")[9]:void 0});class G{constructor(e,t){this.identityFacade=e,this.tracker=t}fetchData(e){return t(this,void 0,void 0,function*(){var r,a;const s=yield this.identityFacade.getIdentityUser(),d=null!==(a=yield null===(r=this.tracker)||void 0===r?void 0:r.getEnvironmentId())&&void 0!==a?a:"",l=(null==s?void 0:s.userId)?String(s.userId):"",c=yield t(void 0,void 0,void 0,function*(){return window.__tcfapi?{gdpr:1,gdpr_consent:yield(e=window.__tcfapi,new Promise((t,n)=>{e("addEventListener",2,(n,i)=>{var r;i||t(""),"tcloaded"!==n.eventStatus&&"useractioncomplete"!==n.eventStatus||(t(null!==(r=n.tcString)&&void 0!==r?r:""),e("removeEventListener",2,()=>{},n.listenerId))})}))}:{};var e}),{invCode:u,keywords:v}=e,p=`aa-sch-publisher=no-vg,aa-sch-supply_type=web_desktop${v?`,${v}`:""}`;console.log("INV CODE FOR PLACEMENTS IS",u),console.log("KEYWORDS FOR PLACEMENTS IS",v);try{i("Starting fetching Studio ad from Xandr:",o);const e=new Headers({"Content-Type":"application/json"}),t=new URL(window.location.href),r={plcmtcnt:1,context:1,contextsubtype:10,plcmttype:1,assets:[{id:1,title:{len:100},required:0},{id:2,img:{type:1,hmin:10,wmin:10},required:0},{id:3,img:{type:3,hmin:10,wmin:10},required:0},{id:4,data:{type:2},required:0},{id:5,data:{type:12},required:0}],ver:"1.2",eventtrackers:[{event:1,methods:[1,2]}]},a={id:R(36),imp:[{id:"no-vg-wde-front_partnerstudio_1",native:{request:JSON.stringify(r),ver:"1.1"},secure:1,tagid:u,ext:{appnexus:{placement_id:36792536,code:u,keywords:p,use_pmt_rule:!1}}}],site:{domain:t.hostname,page:t.href,publisher:{id:"1",domain:t.hostname},ext:{amp:0}},device:{dnt:Number((null===navigator||void 0===navigator?void 0:navigator.globalPrivacyControl)||"1"===(null===navigator||void 0===navigator?void 0:navigator.doNotTrack)),ua:window.navigator.userAgent,h:screen.height,w:screen.width,language:(navigator.language||"sv-SE").split("-")[0]},regs:{ext:{gdpr:c.gdpr||0}},user:{id:J(),ext:{consent:c.gdpr_consent||"",eids:[...d&&[{source:"SCHSE-EnvHash",uids:[{id:d,atype:1,ext:{stype:"ppuid"}}]}],...l&&[{source:"schse-envhash-v3",uids:[{id:l,atype:1,ext:{stype:"ppuid"}}]}]]}},at:1,cur:["SEK"],source:{tid:R(36)},ext:{prebid:{bidder:{appnexus:{member:9826}}}}};console.log("BEFORE XANDR CALL",{payload:a});const s=yield n.post(o,e,a);return console.log("AFTER XANDR CALL",s),i("Fetch operation completed successfully.",s),s}catch(e){i("Error during fetch operation:",e)}return null})}}class Q{constructor(e,t,n,i){this.xandrService=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;const{drEditionConfig:{containerSelector:r},renderAsBackfill:o=!1}=n,a=e.querySelector(r);if(!a)return void i(`Container with selector "${r}" not found.`);const s=yield this.xandrService.fetchData(n);return(null==s?void 0:s.desktopHTML)||o?!(null==s?void 0:s.desktopHTML)&&o?(i("No Dr. Edition ads available to render from Xandr. Collapsing whole placement."),void d(e.id)):((null==s?void 0:s.desktopHTML)&&o&&(i("Dr. Edition ad available to render as a Xandr backfill."),l(e.id)),void(s&&(this.rendererManager.render(a,s,n),window.advertory=window.advertory||{},window.advertory.renderedDrEditionAds=window.advertory.renderedDrEditionAds||[],null===(t=e.querySelector("a"))||void 0===t||t.addEventListener("pointerup",()=>null)))):(i("No Dr. Edition ads available to render from Xandr. Hiding Dr. Edition and rendering Xandr backfill."),this.hideDrEdition(a),void this.showBackfill(e))})}observeAdView(e,t,n){}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:"",r=window.apntag;l(i),V(()=>r.loadTags([i])),V(()=>r.showTag(i))}hideDrEdition(e){e.style.display="none"}observeCarousel(e,t,n){return!0}}class K{constructor(e,t){this.newsroomStrategy=e,this.pulseManager=t}render(e,t,n){console.log("RENDERING XANDR AD",{container:e,drEditionResponse:t,xandrParams:n}),t.desktopHTML&&("mobile"===n.device?e.innerHTML=t.mobileHTML:e.innerHTML=t.desktopHTML)}}const Y=(e,t,n)=>{var i;const{publisher:r,pageType:o,country:d}=e,l={[S]:new s,[A]:new M,[T]:new O,[C]:new _}[r]||new x,c=new(d===N?E:P)(n,l,o),v=new a(t,null!==(i=null==n?void 0:n.pulseTracker)&&void 0!==i?i:n),p=new G(t,null==n?void 0:n.pulseTracker),g=new K(l,c),h=new f(l,c),m=new w(l);return{drEditionManager:new u(v,h,m,c),xandrManager:new Q(p,g,m,c)}},Z=()=>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 ee{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 te=(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{drEditionManager:o,xandrManager:a}=Y(n,i,r);e.forEach(e=>{var i,r,s,d,l;if(!e.isIntersecting)return;const c=e.target,u=null!==(i=c.dataset.editionName)&&void 0!==i?i:"",v=null!==(r=c.dataset.invCode)&&void 0!==r?r:null,p=null!==(s=c.dataset.keywords)&&void 0!==s?s:"",g=null!==(d=c.dataset.pulseColumnname)&&void 0!==d?d:"",h=null!==(l=c.dataset.pulsePrimaryposition)&&void 0!==l?l:"";v?a.fetchAndRenderAd(c,Object.assign(Object.assign({},n),{invCode:v,keywords:p})):o.fetchAndRenderAd(c,Object.assign(Object.assign({},n),{editionName:u,columnName:g,primaryPosition:h})),t.unobserve(c)})})(i,r,e,t,n),{rootMargin:"400% 0px"});r.forEach(e=>o.observe(e))},ne=(e,n,...r)=>t(void 0,[e,n,...r],void 0,function*(e,t,n="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return i(`Schibsted Consent to Pay is not enabled, returning true for ${n}`),!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 ${n}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:r}=m(e);return(yield r())?(i(`Schibsted Ad Choices consent given according to TCF consent manager for ${n}`),!0):(i(`Schibsted Ad Choices consent not given according to TCF consent manager for ${n}`),!1)}),ie=[];const re=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 oe=Object.freeze({__proto__:null,default:re});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=Y,exports.handleDrEdition=e=>t(void 0,void 0,void 0,function*(){var t;if(!e.drEdition)return;if(!(yield ne(e.tcf,e.isMobileApp,"handleDrEdition")))return;const n=yield Z(),i=new ee(n);te({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:a,deviceType:s,drEdition:d,publisher:l,pageType:c,country:u,isMobileApp:v}=e;if(!(yield ne(a,v,"handleDrEditionBackfill")))return;const p=((e,t)=>{var n;const{deviceType:i,placements:o,drEdition:{fallbackGlobalEditionName:a}={}}=e,s=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=s.find(e=>e.id===d),c=r.some(e=>d.startsWith(e)),u=ie.includes(d),v=(null===(n=null==l?void 0:l.drEdition)||void 0===n?void 0:n.editionName)||a;return l&&c&&!u&&v?(ie.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 Z(),h=new ee(g),{drEditionManager:m}=Y({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:s,tcf:a,isMobileApp:v,renderAsBackfill:!0};yield m.fetchAndRenderAd(y,w)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/advertory",
3
- "version": "2.57.0",
3
+ "version": "2.57.2-test-INV-1208",
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",