(()=>{"use strict";function e(e,t){let r,o;return r=this,o=function*(){let r=document.querySelectorAll(e);r||console.log(`[Logora] No container matches selector ${e}`);for(let e=0;e{var n=e=>{try{l(o.next(e))}catch(e){t(e)}},i=e=>{try{l(o.throw(e))}catch(e){t(e)}},l=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,i);l((o=o.apply(r,null)).next())})}function t(e,t){return new URL(t,e).href}let r={description:{rules:[['meta[property="og:description"]',e=>e.getAttribute("content")],["description",e=>e,!0],['meta[name="description" i]',e=>e.getAttribute("content")]]},icon:{rules:[['link[rel="apple-touch-icon"]',e=>e.getAttribute("href")],['link[rel="apple-touch-icon-precomposed"]',e=>e.getAttribute("href")],['link[rel="icon" i]',e=>e.getAttribute("href")],['link[rel="fluid-icon"]',e=>e.getAttribute("href")],['link[rel="shortcut icon"]',e=>e.getAttribute("href")],['link[rel="Shortcut Icon"]',e=>e.getAttribute("href")],['link[rel="mask-icon"]',e=>e.getAttribute("href")]],scorers:[(e,t)=>{let r=e.getAttribute("sizes");if(r){let e=r.match(/\d+/g);if(e)return e[0]}}],defaultValue:e=>"favicon.ico",processors:[(e,r)=>t(r.url,e)]},image:{rules:[['meta[property="og:image:secure_url"]',e=>e.getAttribute("content")],['meta[property="og:image"]',e=>e.getAttribute("content")],['meta[property="og:image:url"]',e=>e.getAttribute("content")],['meta[name="twitter:image"]',e=>e.getAttribute("content")],['meta[property="twitter:image"]',e=>e.getAttribute("content")],['meta[name="thumbnail"]',e=>e.getAttribute("content")]],processors:[(e,r)=>t(r.url,e)]},keywords:{rules:[['meta[name="keywords" i]',e=>e.getAttribute("content")],['meta[property="article:tag"]',e=>e.getAttribute("content"),!1,!0],['meta[property="og:article:tag"]',e=>e.getAttribute("content"),!1,!0],["keywords",e=>e,!0]],processors:[(e,t)=>{let r=[];return e&&(Array.isArray(e)?r=e.flatMap(e=>"string"==typeof e||e instanceof String?e.split(",").map(e=>e.trim()):[]):("string"==typeof e||e instanceof String)&&(r=e.split(",").map(e=>e.trim()))),r.filter((e,t,r)=>r.indexOf(e)===t)}]},title:{rules:[['meta[property="og:title"]',e=>e.getAttribute("content")],["headline",e=>e,!0],['meta[name="twitter:title"]',e=>e.getAttribute("content")],['meta[property="twitter:title"]',e=>e.getAttribute("content")],['meta[name="hdl"]',e=>e.getAttribute("content")],["title",e=>e.text]]},language:{rules:[["html[lang]",e=>e.getAttribute("lang")],['meta[name="language" i]',e=>e.getAttribute("content")]],processors:[(e,t)=>e.split("-")[0]]},type:{rules:[['meta[property="og:type"]',e=>e.getAttribute("content")]]},url:{rules:[["a.amp-canurl",e=>e.getAttribute("href")],['link[rel="canonical"]',e=>e.getAttribute("href")],['meta[property="og:url"]',e=>e.getAttribute("content")]],defaultValue:e=>e.url,processors:[(e,r)=>t(r.url,e)]},provider:{rules:[['meta[property="og:site_name"]',e=>e.getAttribute("content")]],defaultValue:e=>new URL(e.url).host.replace(/www[a-zA-Z0-9]*\./,"").replace(".co.",".").split(".").slice(0,-1).join(" ")},publishedDate:{rules:[['meta[property~="article:published_time"]',e=>e.getAttribute("content")],['meta[property~="og:updated_time"]',e=>e.getAttribute("content")],["datePublished",e=>e,!0]]}},o=["Article","AdvertiserContentArticle","MedicalScholarlyArticle","NewsArticle","AnalysisNewsArticle","AskPublicNewsArticle","BackgroundNewsArticle","OpinionNewsArticle","ReportageNewsArticle","ReviewNewsArticle","Report","SatiricalArticle","ScholarlyArticle","SocialMediaPosting","BlogPosting","LiveBlogPosting","DiscussionForumPosting","TechArticle","APIReference"];function n(e,t="resource"){window.dispatchEvent(new CustomEvent("logoraContentLoaded",{detail:{[t]:e}}))}var i,l=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,r)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,d=(e,t)=>{for(var r in t||(t={}))s.call(t,r)&&u(e,r,t[r]);if(a)for(var r of a(t))c.call(t,r)&&u(e,r,t[r]);return e};i=function(e,t,i=!1,l="/embed",a="id",s="html",c="resource"){let u,p;return u=this,p=function*(){var u,p,g,m,f,h,b,y,A,w,v;let S,j,k,L,_,P,O,C=!!(h=e.getBoundingClientRect().width.toFixed(2))&&(h>=769?"desktop":h<769&&h>=565?"tablet":"mobile");!1===window.logoraDisplayAds&&(t.ads={display:!1}),t.resource=t.resource||{},(null==(p=null==(u=document.currentScript)?void 0:u.src)?void 0:p.includes("synthese.js"))?t.resource.name="synthesis":(null==(m=null==(g=document.currentScript)?void 0:g.src)?void 0:m.includes("widget.js"))&&(t.resource.name="widget");let x=i,N=l,D=a,M=s,E=c;if("iframe"!==t.insertType&&(["synthesis","widget","comments"].includes(t.resource.name)&&(x=!0,D="uid"),["synthesis","widget"].includes(t.resource.name)&&(t.resource.id=t.resource.id||(null==(f=t.debate)?void 0:f.identifier),N="",M="content",E="debate")),!t.resource.id)return console.log("[Logora] Cannot get resource identifier."),!1;let R=null;x&&(b=t,O={source_url:(S=function(e,t,o=[]){let n={},i={url:t,jsonLd:function(e,t){let r=e.querySelectorAll('script[type="application/ld+json"]');try{for(let e of r){let r=JSON.parse(e.textContent);if(Array.isArray(r))return r.find(e=>t.includes(e["@type"]))||{};if(t.includes(r["@type"]))return r}}catch(e){}return{}}(e,o)};return Object.keys(r).map(t=>{var o;let l=(o=r[t],(e,t)=>{let r,n=0,i={};for(let l=0;ln&&(n=t,r=c(e))}}}if(Object.keys(i).forEach(e=>{let t=i[e].join(", ");t.trim()&&(r=t.trim())}),!r&&o.defaultValue&&(r=o.defaultValue(t)),r){if(o.processors)for(let e of o.processors)r=e(r,t);return r.trim&&(r=r.trim()),r}});n[t]=l(e,i)}),n}(window.document,window.location,o)).url,published_date:S.publishedDate||"",title:S.title,description:S.description,origin_image_url:S.image||"",publisher:S.provider,tag_objects:S.keywords?[...new Set(S.keywords.map(e=>e.toLowerCase()))].map(e=>({name:e})).slice(0,10):[]},"source"in b&&("tag_objects"in b.source&&(b.source.tag_objects=((A=b.source.tag_objects).filter(e=>{e.uid&&(e.uid=e.uid.toLowerCase()),e.name&&(e.name=e.name.toLowerCase())}),j=[],A.filter(e=>(-1>=j.findIndex(t=>e.uid?t.uid===e.uid:t.name===e.name)&&j.push(e),null)),j.slice(0,10))),Object.assign(O,b.source)),!0===b.verbose&&console.log("[Logora] Extracted source : ",JSON.stringify(O)),R=O.published_date?(w=O.published_date,v=null==(y=b.synthesis)?void 0:y.pageExpirationDate,k=new Date,L=new Date(v||new Date().setMonth(new Date().getMonth()-18)),(P=(_=new Date(w||null))k)&&console.log(`[Logora] Source is too old or in the future, and will not be collected. Source expiration date is ${L}`),!P&&O):(console.log("[Logora] Cannot find source publication date in metadata. Make sure that the page publication date is available in meta tags or in structured data."),!1));try{let r=yield function(e,t,r,o,n,i,l="/embed",a="id",s=!1){return function(e,t={},r={}){let o="https://render.logora.fr"+e;t&&(o+=`?${new URLSearchParams(t).toString()}`);let n=new Headers({"Content-Type":"application/json"});return new Promise((e,t)=>{fetch(o,{method:"post",body:JSON.stringify(r),headers:n}).then(e=>e.json()).then(t=>{e(t)}).catch(e=>{t(e)})})}(`${l}/${e}`,d(d(d(d(d({shortname:n.shortname,[a]:t},!1===o&&{cache:!1}),i&&{device:i}),n.language&&{language:n.language}),n.redirectUrl&&{redirectUrl:n.redirectUrl}),s&&{noHtml:!0}),{source:r,config:n})}(t.resource.name,t.resource.id,R,!0,t,C,N,D);if(r.success)return"string"==typeof r[M]&&function(e,t){for(let r of(e.innerHTML=t,e.querySelectorAll("script"))){let e=document.createElement("script");for(let t of r.attributes)e.setAttribute(t.name,t.value);e.appendChild(document.createTextNode(r.innerHTML)),r.parentNode.replaceChild(e,r)}}(e,r[M]),n(r.debate||r.source||r.resource,E),!0;return n(null,E),!1}catch(e){return n(null,E),!1}},new Promise((e,t)=>{var r=e=>{try{n(p.next(e))}catch(e){t(e)}},o=e=>{try{n(p.throw(e))}catch(e){t(e)}},n=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,o);n((p=p.apply(u,null)).next())})},"u">typeof document&&("loading"!==document.readyState?e(".logora_embed, .logora_synthese",i):document.addEventListener("DOMContentLoaded",()=>{e(".logora_embed, .logora_synthese",i)}))})();