hypnagaga/docs/assets/AdSlot.stories-06cc65ab.js
2024-02-28 12:08:07 +00:00

35 lines
9.8 KiB
JavaScript

import{S as T,i as E,s as I,o as m,b as i,e as p,n as $,f,D as C,g as _,m as h,t as w,h as k,j as b,y as v,d as S,C as D}from"./index-43e9a565.js";import{g as x,a as P}from"./spread-8a54911c.js";import{p as O,M as z,T as M,S as Q}from"./collect-stories-23d08061.js";import{B as U}from"./Block-db774151.js";import{w as j}from"./withParams-47e2ab71.js";const B=`Display a FreeStar Ad Slot
Note: You must use this domain to access the story book:
\`http://localhost.arcpublishing.com:3000\`
This domain has been whitelisted on the Ad server. To setup the domain locally, add the following line to \`/etc/hosts\`:
\`\`\`
127.0.0.1 localhost localhost.arcpublishing.com
\`\`\`
\`\`\`svelte
<script>
import { AdSlot, AdScripts } from '@reuters-graphics/graphics-components';
<\/script>
<!-- Include only ONCE per page -->
<AdScripts />
<AdSlot
placementName="reuters_desktop_native"
slotId="reuters_desktop_native"
/>
<AdSlot
placementName="reuters_desktop_native"
slotId="reuters_desktop_native"
/>
\`\`\`
`,N=(o,e=window.location.href)=>{o=o.replace(/[\[\]]/g,"\\$&");const t=new RegExp("[?&]"+o+"(=([^&#]*)|&|#|$)").exec(e);return t?t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"":null},L=600,V=()=>new Promise(o=>{const e=setTimeout(()=>{o("Resolved with timeout")},L),a=()=>{clearTimeout(e),window.__iasPET=window.__iasPET||{},window.__iasPET.queue=window.__iasPET.queue||[],window.__iasPET.pubId="931336",o("loaded")},t=document.createElement("script");t.src="//static.adsafeprotected.com/iasPET.1.js",t.setAttribute("async","async"),document.head.appendChild(t),t.onload=a,t.onerror=()=>{o("error")}}),R=(o,e)=>{const a=document.createElement("script");a.addEventListener("load",e),a.src=o,document.head.append(a)},G="ot_logs",K="ot_geolocation_mock",Y="38cb75bd-fbe1-4ac8-b4af-e531ab368caf-test",H=()=>{window.freestar=window.freestar||{};const o=window.freestar;o.debug=!0,o.queue=o.queue||[],o.config=o.config||{},o.config.enabled_slots=[],o.initCallback=function(){o.config.enabled_slots.length===0?o.initCallbackCalled=!1:o.newAdSlots(o.config.enabled_slots)},o.config.channel="/4735792/reuters.com/home",window.initBootstrap({onetrust_logs:N(G)||"false",geolocation_mock:N(K)||"default",onetrust_script_id:Y},e=>{const a=V();return Promise.all([a]).then(t=>{const[r]=t;return{...e,ias:r}})}),window.bootstrap.getResults(e=>{R("https://a.pub.network/reuters-com/pubfig.min.js"),window.googletag=window.googletag||{cmd:[]},window.googletag.cmd.push(()=>{var r;window.googletag.pubads().enableSingleRequest(),window.googletag.pubads().enableAsyncRendering(),window.googletag.pubads().collapseEmptyDivs(!0);const a=new URL(document.location.href).searchParams.get("adstest");a&&window.googletag.pubads().setTargeting("adstest",a);const t=(r=document.querySelector('meta[name="ad:template"]'))==null?void 0:r.content;t&&window.googletag.pubads().setTargeting("template",t)}),Array.isArray(window.graphicsAdQueue)||console.error("Ad queue not initialized!"),o.queue.push(function(){o.newAdSlots(window.graphicsAdQueue||[],"foobar")}),o.queue.push(function(){window.googletag.pubads().set("page_url","https://www.reuters.com/")})})};function J(o){let e,a,t,r,l,d,c,u,n,s;return{c(){e=m("link"),a=m("link"),t=m("link"),r=m("link"),l=m("link"),d=m("link"),c=m("link"),u=m("link"),n=m("link"),s=m("link"),i(e,"rel","preconnect"),i(e,"href","https://a.pub.network/"),i(e,"crossorigin",""),i(a,"rel","preconnect"),i(a,"href","https://b.pub.network/"),i(a,"crossorigin",""),i(t,"rel","preconnect"),i(t,"href","https://c.pub.network/"),i(t,"crossorigin",""),i(r,"rel","preconnect"),i(r,"href","https://d.pub.network/"),i(r,"crossorigin",""),i(l,"rel","preconnect"),i(l,"href","https://c.amazon-adsystem.com"),i(l,"crossorigin",""),i(d,"rel","preconnect"),i(d,"href","https://s.amazon-adsystem.com"),i(d,"crossorigin",""),i(c,"rel","preconnect"),i(c,"href","https://btloader.com/"),i(c,"crossorigin",""),i(u,"rel","preconnect"),i(u,"href","https://api.btloader.com/"),i(u,"crossorigin",""),i(n,"rel","preconnect"),i(n,"href","https://confiant-integrations.global.ssl.fastly.net"),i(n,"crossorigin",""),i(s,"rel","stylesheet"),i(s,"href","https://a.pub.network/reuters-com/cls.css")},m(g,A){p(document.head,e),p(document.head,a),p(document.head,t),p(document.head,r),p(document.head,l),p(document.head,d),p(document.head,c),p(document.head,u),p(document.head,n),p(document.head,s)},p:$,i:$,o:$,d(g){f(e),f(a),f(t),f(r),f(l),f(d),f(c),f(u),f(n),f(s)}}}function W(o){return C(()=>{window.graphicsAdQueue=window.graphicsAdQueue||[],R("https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js",H)}),[]}class q extends T{constructor(e){super(),E(this,e,W,J,I,{})}}q.__docgen={version:3,name:"AdScripts.svelte",data:[],computed:[],methods:[],components:[],description:null,keywords:[],events:[],slots:[],refs:[]};function X(o){let e,a,t,r,l,d,c,u;return{c(){e=m("div"),a=m("div"),a.textContent="Advertisement · Scroll to continue",t=v(),r=m("div"),l=m("div"),d=m("div"),c=m("div"),i(a,"class","ad-label svelte-1gzmm8s"),i(c,"data-freestar-ad",u=o[0]||null),i(c,"id",o[3]),i(c,"class","svelte-1gzmm8s"),i(d,"class","svelte-1gzmm8s"),i(l,"class","ad-slot__inner svelte-1gzmm8s"),i(r,"class","ad-container svelte-1gzmm8s"),i(e,"class","ad-block svelte-1gzmm8s")},m(n,s){S(n,e,s),p(e,a),p(e,t),p(e,r),p(r,l),p(l,d),p(d,c)},p(n,s){s&1&&u!==(u=n[0]||null)&&i(c,"data-freestar-ad",u)},d(n){n&&f(e)}}}function Z(o){let e,a;return e=new U({props:{id:o[1],class:"freestar-adslot "+o[2],$$slots:{default:[X]},$$scope:{ctx:o}}}),{c(){_(e.$$.fragment)},m(t,r){h(e,t,r),a=!0},p(t,[r]){const l={};r&2&&(l.id=t[1]),r&4&&(l.class="freestar-adslot "+t[2]),r&129&&(l.$$scope={dirty:r,ctx:t}),e.$set(l)},i(t){a||(w(e.$$.fragment,t),a=!0)},o(t){k(e.$$.fragment,t),a=!1},d(t){b(e,t)}}}function ee(o,e,a){let{placementName:t="reuters_desktop_native_1"}=e,{dataFreestarAd:r="__970x250"}=e,{id:l=""}=e,{class:d="my-12"}=e;const c=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1),u="ad-"+c()+c(),n=s=>{switch(s){case"reuters_sponsorlogo":return"Sponsorlogo";case"reuters_mobile_mpu_1":return"mpu";default:return"native"}};return C(()=>{const g=new URLSearchParams(window.location.search).get("adstest");window.graphicsAdQueue=window.graphicsAdQueue||[],window.graphicsAdQueue.push({placementName:t,slotId:u,type:n(t),graphicId:window.location.pathname,adstest:g})}),o.$$set=s=>{"placementName"in s&&a(4,t=s.placementName),"dataFreestarAd"in s&&a(0,r=s.dataFreestarAd),"id"in s&&a(1,l=s.id),"class"in s&&a(2,d=s.class)},[r,l,d,u,t]}class y extends T{constructor(e){super(),E(this,e,ee,Z,I,{placementName:4,dataFreestarAd:0,id:1,class:2})}}y.__docgen={version:3,name:"AdSlot.svelte",data:[{keywords:[{name:"required",description:""}],visibility:"public",description:"The unique placement name from FreeStar dashboard.",name:"placementName",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:"reuters_desktop_native_1"},{keywords:[],visibility:"public",description:"The unique slot Id from FreeStar dashboard.",name:"dataFreestarAd",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:"__970x250"},{keywords:[],visibility:"public",description:"Add an ID to target with SCSS.",name:"id",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:""},{visibility:"public",description:"Add a class to target with SCSS.",keywords:[],name:"class",kind:"const",static:!1,readonly:!0,type:{kind:"type",text:"string",type:"string"},localName:"cls",defaultValue:"my-12"}],computed:[],methods:[],components:[],description:"",keywords:[{name:"component",description:"`AdSlot` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-AdSlot--default)"}],events:[],slots:[],refs:[]};function te(o){let e,a,t,r,l,d,c;a=new q({});const u=[o[1]];let n={};for(let s=0;s<u.length;s+=1)n=D(n,u[s]);return r=new y({props:n}),d=new y({props:{placementName:"reuters_desktop_canvas",dataFreestarAd:"__970x250"}}),{c(){e=m("div"),_(a.$$.fragment),t=v(),_(r.$$.fragment),l=v(),_(d.$$.fragment)},m(s,g){S(s,e,g),h(a,e,null),p(e,t),h(r,e,null),p(e,l),h(d,e,null),c=!0},p(s,g){const A=g&2?x(u,[P(s[1])]):{};r.$set(A)},i(s){c||(w(a.$$.fragment,s),w(r.$$.fragment,s),w(d.$$.fragment,s),c=!0)},o(s){k(a.$$.fragment,s),k(r.$$.fragment,s),k(d.$$.fragment,s),c=!1},d(s){s&&f(e),b(a),b(r),b(d)}}}function se(o){let e,a,t,r,l,d;const c=[o[0]];let u={};for(let n=0;n<c.length;n+=1)u=D(u,c[n]);return e=new z({props:u}),t=new M({props:{$$slots:{default:[te,({args:n})=>({1:n}),({args:n})=>n?2:0]},$$scope:{ctx:o}}}),l=new Q({props:{name:"Default",args:{placementName:"reuters_desktop_native_1",dataFreestarAd:"__970x250"}}}),{c(){_(e.$$.fragment),a=v(),_(t.$$.fragment),r=v(),_(l.$$.fragment)},m(n,s){h(e,n,s),S(n,a,s),h(t,n,s),S(n,r,s),h(l,n,s),d=!0},p(n,[s]){const g=s&1?x(c,[P(n[0])]):{};e.$set(g);const A={};s&6&&(A.$$scope={dirty:s,ctx:n}),t.$set(A)},i(n){d||(w(e.$$.fragment,n),w(t.$$.fragment,n),w(l.$$.fragment,n),d=!0)},o(n){k(e.$$.fragment,n),k(t.$$.fragment,n),k(l.$$.fragment,n),d=!1},d(n){n&&(f(a),f(r)),b(e,n),b(t,n),b(l,n)}}}function ne(o){return[{title:"Components/AdSlot",component:y,...j(B),argTypes:{placementName:{control:"select",options:["reuters_desktop_leaderboard_atf","reuters_desktop_native","reuters_desktop_canvas"]},dataFreestarAd:{control:"select",options:["__970x250"]}}}]}class oe extends T{constructor(e){super(),E(this,e,ne,se,I,{})}}const F=O(oe,{meta:{},stories:{"tpl:default":{name:"default",template:!0,source:`<div>
<AdScripts />
<AdSlot {...args} />
<AdSlot placementName="reuters_desktop_canvas" dataFreestarAd="__970x250" />
</div>`,hasArgs:!0},Default:{name:"Default",template:!1,source:"",hasArgs:!1}},allocatedIds:["default","Meta","Template","Story","componentDocs","AdScripts","AdSlot","withComponentDocs"]}),ce=F.meta,ue=["Default"],pe=F.stories.Default;export{pe as Default,ue as __namedExportsOrder,ce as default};
//# sourceMappingURL=AdSlot.stories-06cc65ab.js.map