1import{r as _,j as e}from"../chunks/vendor-react-DdEP1kCQ.js";import{U as Oe}from"../chunks/DefaultLayout-B4mESSua.js";import{a as se,b as D,F as me,c as ce,u as Ue}from"../chunks/use-feed-item-DCZ-30t0.js";import{u as ne,U as ze,d as y,h as Ge,F as Ce,k as Ve,p as Ne,j as We,V as Ze,l as Ke,I as he,x as qe,b as Xe}from"../chunks/core-Bpuic6mr.js";import{i as S,c as Ye}from"../chunks/jsxUtils-DqtdO-_O.js";import{t as de,g as Je,a as Qe}from"../chunks/images-rIYVm8bk.js";import{u as et,D as tt,C as st}from"../chunks/DynamicLabelInput-E-f88jJS.js";import{I as nt}from"../chunks/Input-xTKQaCJR.js";import{I as at}from"../chunks/chunk-Cgl-0otj.js";import{a as ye}from"../chunks/vendor-shared-ShLQKC4n.js";import{u as it}from"../chunks/Prose-DGUfNRzF.js";import{T as P}from"../chunks/Timestamp-TnBnwR0Z.js";import{g as rt}from"../chunks/getBestArticleId-9I1mHE39.js";import{B as ot}from"../chunks/Body-D2I8VDDX.js";import{N as lt}from"../chunks/chunk-C6dy8-dY.js";import"../chunks/Header-DuP3RNUx.js";import"../chunks/sciam-B_IQ-Vo8.js";import"../chunks/sciam-CvuG93yt.js";import"../chunks/data-BmhhWP9E.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="08eddad2-5178-4d11-996d-f6404fab2b8f",t._sentryDebugIdIdentifier="sentry-dbid-08eddad2-5178-4d11-996d-f6404fab2b8f")}catch{}})();function Se(t,s=null){const{previews:n}=ne();return n?.[t]||s||null}function ct(t){const{previewMeta:s}=ne();return s?.[t]||null}function z(t){const{ctas:s}=ne();return s?.[t]||null}function Ie(){const{feedMeta:t}=ne();return t||{}}function dt(t,s,n){const a=[];let i=0,c=0,r=0,m=0;const o=new Set,f=[...s];for(let l=0;l<t.length;l++){const j=t[l];if(a.push({type:"feed_item",position:i,...j}),i++,c++,!(c<3)&&!(l>=t.length-2))for(;f.length>0;){const x=f.shift();if(!x)break;if(ut(x,n,o)){u(x);break}}}return a;function u(l){l==="ad"?a.push({type:"break",break_type:"ad",position:i,break_index:++m,ad_index:++r,variant:"standard"}):(a.push({type:"break",break_type:l,position:i,break_index:++m}),o.add(l)),c=0}}function ut(t,s,n){return t==="ad"?!s.hasAdFree:n.has(t)?!1:t==="newsletter"?!s.getsNewsletter:t==="subscribe"?!s.isSubscriber:!0}const _e={strategy:"interleave",slots:["popular","curated","primary"],fallbacks:["latest","grab_bag"],debug:!1};function mt(t,s=_e){const n={..._e,...s},a=new Set,i=[],c={...t,primary:t.personalized?.length?t.personalized:t.trending,fallback:n.fallbacks?.flatMap(o=>t[o])||[]},r=Object.fromEntries(Object.keys(c).map(o=>[o,0]));let m=0;for(;n.slots.some(o=>r[o]<c[o].length);){m++;for(const o of n.slots){const f=c[o];let u=!1;for(r[o]||=0;r[o]<f.length;){const l=f[r[o]];if(!a.has(l.contentful_id)){a.add(l.contentful_id),i.push({...l,segment:o,segment_index:r[o]}),u=!0;break}r[o]++,r[o]>=f.length&&n.debug&&console.log(`[mixFeed] Exhausted ${o} feed at slot index ${r[o]}.`)}if(!u){for(;r.fallback<c.fallback.length;){const l=c.fallback[r.fallback];if(!a.has(l.contentful_id)){a.add(l.contentful_id),i.push({...l,segment:"fallback",segment_index:r.fallback}),u=!0,n.debug&&console.log(`[mixFeed] Pulling ${l.source} feed item into ${o} slot.`);break}r.fallback++}!u&&n.debug&&console.log(`[mixFeed] No more items in ${o} feed or fallback, skipping`)}}if(m>200){n.debug&&console.warn("[mixFeed] Hit iteration limit.");break}}return i}const Le=_.createContext({level:0});function Ae(){return _.useContext(Le)}function ht({level:t,delta:s=0,children:n,...a},i){const{level:c}=Ae(),r=Math.round(Math.max((t||c)+s,1)),m=`h${Math.min(r,6)}`,o=a.id||`heading-${_.useId()}`;return r<c&&console.warn(`#${o} is being rendered as an h${r} but the current heading level is h${c}.`),_.createElement(m,{...a,ref:i,id:o},n)}function ae({override:t,children:s}){const{level:n}=Ae();return e.jsx(Le.Provider,{value:{level:t||n+1},children:s})}const ue=Object.assign(_.forwardRef(ht),{displayName:"Heading",Scope:ae}),gt={edit_top:{slug:"edit_top",label:"Editorial Curation",color:"var(--color-blue)"},edit_rec:{slug:"edit_rec",label:"Editorial Recommendation",color:"var(--color-light-blue-4)"},latest:{slug:"latest",label:"Latest",color:"var(--color-green)"},popular:{slug:"popular",label:"Popular",color:"var(--color-red-2)"},trending:{slug:"trending",label:"Recommendation",color:"var(--color-gold)"},user_feed:{slug:"user_feed",label:"Personalized Feed",color:"var(--color-gold)"}},ee=t=>gt[t]||{label:t||"Unknown",color:"#ccc",slug:"unknown"},Te={ad:{slug:"ad",label:"Ad",color:"var(--color-red-2)"},newsletter:{slug:"newsletter",label:"Newsletter CTA",color:"var(--color-black-highlighted)"},column:{slug:"column",label:"Column Alert CTA",color:"var(--color-black-highlighted)"},issue:{slug:"issue",label:"Latest Issue Spotlight",color:"var(--color-medium-blue)"},feature:{slug:"feature",label:"Feature Spotlight",color:"var(--color-medium-blue)"},discussion:{slug:"discussion",label:"Discussion Spotlight",color:"var(--color-medium-blue)"},game:{slug:"game",label:"Game Spotlight",color:"var(--color-medium-blue)"},topic:{slug:"topic",label:"Topic Spotlight",color:"var(--color-medium-blue)"},travel:{slug:"travel",label:"Travel Promo",color:"var(--color-medium-blue)"},events:{slug:"events",label:"Events Promo",color:"var(--color-medium-blue)"}};function Fe({children:t,id:s}){return e.jsx(ze,{fallback:void 0,children:t})}const pt="cta-pNSqT",ft="hero-c8l0I",xt="content-RLvgA",ge={cta:pt,hero:ft,content:xt};function F({as:t="div",className:s,...n}){return e.jsx(t,{className:y(ge.cta,s),...S(n)})}function M({as:t="div",className:s,...n}){return e.jsx(t,{className:y(ge.hero,s),...S(n)})}function $({as:t="div",className:s,...n}){return e.jsx(t,{className:y(ge.content,s),...S(n)})}Object.assign(F,{CtaHero:M,CtaContent:$});const jt="collection-s5REU",bt="heading-aqGeK",yt="dek-uYbXw",_t="button-KXV0y",vt="hero-zrS6D",Z={collection:jt,heading:bt,dek:yt,button:_t,hero:vt},kt="The 2026 Solar Eclipse",wt="A total solar eclipse will take place on August 12, and millions of sky-gazers will, for a few brief minutes, see the world plunged into darkness as the moon passes directly in front of our star. The best views of this solar eclipse are from the Arctic Circle, Iceland, Spain and parts of Portugal.",Ct="https://static.scientificamerican.com/dam/asset/08121757-3a1c-4299-a544-28831468b201/solar-eclipse-guide.jpeg?m=1785961451.881&w=1000",re="/report/the-2026-solar-eclipse/";function Nt(){return e.jsxs(F,{className:Z.collection,"data-cta":"collection","data-click-position":"feed-card-collection-spotlight",children:[e.jsx(M,{className:Z.hero,children:e.jsx("a",{href:re,"data-click-position":"feed-card-collection-spotlight-landing",children:e.jsx("img",{src:Ct,alt:"The 2026 total solar eclipse",loading:"lazy"})})}),e.jsxs($,{children:[e.jsx("h3",{className:Z.heading,children:e.jsx("a",{href:re,"data-click-position":"feed-card-collection-spotlight-landing",children:kt})}),e.jsx("div",{className:Z.dek,children:wt}),e.jsx("div",{children:e.jsx("a",{href:re,className:Z.button,"data-click-position":"feed-card-collection-spotlight-landing",children:"Read the Report"})})]})]})}
1const St="discussionCTA-lgi88",It="quote-H-AEm",Lt="links-8zTe5",oe={discussionCTA:St,quote:It,links:Lt};function At(){const t=z("discussion")?.featuredDiscussion;return t?e.jsxs("div",{"data-cta":"discussions",className:oe.discussionCTA,"data-click-position":"feed-card-discussion-spotlight",children:[e.jsx("h2",{children:e.jsx("a",{href:"/discussions/","data-click-position":"feed-card-discussion-spotlight-view-all",children:"Discussions"})}),e.jsxs("p",{className:oe.quote,children:["â",t.featured_posts[0].message_preview.trim(),"â",e.jsx("br",{}),"â ",t.featured_posts[0].commenter_display_name]}),e.jsxs("ul",{className:oe.links,children:[e.jsx("li",{children:e.jsx("a",{href:t.url,"data-click-position":"feed-card-discussion-spotlight-single-discussion",children:t.title})}),e.jsx("li",{children:e.jsx("a",{href:"/discussions/","data-click-position":"feed-card-discussion-spotlight-view-all",children:"View all Discussions"})})]})]}):null}function Tt(){return z("events")?e.jsxs(F,{"data-cta":"events",style:{"--cta-background":"var(--color-gold)","--cta-color":"white"},children:[e.jsx(M,{}),e.jsx($,{children:e.jsx("strong",{children:"Events"})})]}):null}const Ft="ctaLogoHeader-CNo4L",Mt={ctaLogoHeader:Ft};function Me({imageSrc:t,width:s,height:n,text:a,url:i,alt:c=""}){return e.jsx("h2",{className:Mt.ctaLogoHeader,style:{"--w":s,"--h":n},children:e.jsxs("a",{href:i,children:[e.jsx("span",{className:"sr-only",children:a}),e.jsx("img",{src:t,alt:c})]})})}const $t="/static/assets/sciam-games-CcSJ307s.png",Rt="game-etxTd",Et="gameCta_header-T-HQp",Bt="gameCta_hero-FgtVt",Dt="gameCta_heroimage-EY9J7",K={game:Rt,gameCta_header:Et,gameCta_hero:Bt,gameCta_heroimage:Dt};function Pt(){const t=z("game"),s=t?.scheduledGame;return t?e.jsxs(F,{"data-cta":"games",className:K.game,"data-click-position":"feed-card-games-spotlight",children:[e.jsx("a",{href:s.url,"data-click-position":"feed-card-games-spotlight-landing",className:K.hero,children:e.jsx(M,{className:K.gameCta_hero,style:{"--cta-hero-background":s.color},children:e.jsx("img",{src:`${s.image_url}`,alt:"SciAm Games",className:K.gameCta_heroimage})})}),e.jsxs($,{children:[e.jsx(Me,{imageSrc:$t,text:"SciAm Games",url:"/games/",alt:"Sciam Games Logo","data-click-position":"feed-card-games-spotlight-landing"}),e.jsx("h3",{className:K.gameCta_header,dangerouslySetInnerHTML:{__html:s.display_title}}),e.jsx("div",{dangerouslySetInnerHTML:{__html:s.dek?s.dek:s.description}}),e.jsx("div",{children:e.jsx("a",{href:s.url,"data-click-position":"feed-card-games-spotlight-landing",children:"Play now"})})]})]}):null}const Ht="issue-pj4sO",Ot="cover-HalVh",Ut="blur-LknMI",zt="hed-vDTXr",Gt="dek-1DArZ",Vt="issueLink-Wmgp4",Wt="actions-sOi3U",A={issue:Ht,cover:Ot,blur:Ut,hed:zt,dek:Gt,issueLink:Vt,actions:Wt};function Zt(){const t=z("issue");if(!t?.currentIssue)return null;const s=t.currentIssue.image_width/t.currentIssue.image_height,n=de(t.currentIssue.image_url,{width:512,height:s?Math.round(512/s):void 0}),a=t.currentIssue.bg_image_url?de(t.currentIssue.bg_image_url,{width:512,height:s?Math.round(512/s):void 0}):"",i=Ge(t.currentIssue.issue_date);return e.jsx(F,{"data-cta":"issue",className:A.issue,"data-click-position":"feed-card-issue-spotlight",children:e.jsxs(ae,{children:[e.jsx("a",{href:t.currentIssue.path,"data-click-position":"feed-card-issue-spotlight",children:e.jsx(M,{className:y(A.cover,a&&A.blur),style:a?{"--cta-hero-background":`url("${a}") center/cover no-repeat`,"object-fit":"cover"}:{"--cta-hero-background":`url("${n}")`,"--cta-hero-bg-inset":"-50px","--cta-hero-bg-filter":"blur(30px) contrast(0.8) saturate(1.5) brightness(0.8)"},children:e.jsx("figure",{style:{"--w":t.currentIssue.image_width,"--h":t.currentIssue.image_height},children:e.jsx("img",{src:n,alt:t.currentIssue.image_alt_text||t.currentIssue.issue_title,width:t.currentIssue.image_width,height:t.currentIssue.image_height})})})}),e.jsxs($,{children:[e.jsx(ue,{className:A.hed,children:e.jsxs("a",{href:t.currentIssue.path,"data-click-position":"feed-card-issue-spotlight",children:[i," Issue"]})}),e.jsx("div",{className:A.dek,dangerouslySetInnerHTML:{__html:t.currentIssue.description}}),e.jsx("a",{href:t.currentIssue.path,className:A.issueLink,"data-click-position":"feed-card-issue-spotlight",children:"View Full Contents"}),e.jsxs("div",{className:A.actions,children:[e.jsx("a",{href:"/archive/issues/",className:y(A.action,A.link),"data-click-position":"feed-card-issue-spotlight-archive",children:"View Archive"}),e.jsxs("a",{href:"/newsletters/",className:y(A.action,A.button),"data-click-position":"feed-card-issue-spotlight-newsletters",children:[e.jsx(Kt,{}),"Sign up for the New Issue Alert"]})]})]})]})})}const Kt=()=>e.jsx("svg",{width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{marginRight:"0.5ch",display:"inline-block",verticalAlign:"middle"},children:e.jsx("path",{d:"M19.6316 7.67761L11.3816 2.17761C11.2686 2.10224
111.1358 2.06201 11 2.06201C10.8642 2.06201 10.7314 2.10224 10.6184 2.17761L2.36844 7.67761C2.27426 7.74045 2.19706 7.82557 2.14368 7.92542C2.09031 8.02526 2.06243 8.13674 2.0625 8.24996V17.1875C2.0625 17.5521 2.20737 17.9019 2.46523 18.1597C2.72309 18.4176 3.07283 18.5625 3.4375 18.5625H18.5625C18.9272 18.5625 19.2769 18.4176 19.5348 18.1597C19.7926 17.9019 19.9375 17.5521 19.9375 17.1875V8.24996C19.9376 8.13674 19.9097 8.02526 19.8563 7.92542C19.8029 7.82557 19.7257 7.74045 19.6316 7.67761ZM8.31188 13.0625L3.4375 16.5V9.58457L8.31188 13.0625ZM9.71867 13.75H12.2813L17.148 17.1875H4.85203L9.71867 13.75ZM13.6881 13.0625L18.5625 9.58457V16.5L13.6881 13.0625ZM11 3.57582L18.0391 8.26887L12.2813 12.375H9.72039L3.96258 8.26887L11 3.57582Z",fill:"#4BBBE0"})}),qt="/static/assets/today_in_science_mockup-Bp-Vt1F7.png",Xt="gridContainer--2lZD",Yt="newsletter-VYVPj",Jt="newsletterMainText-wlflp",Qt="newsletterDek-Y66yN",es="newsletterForm-yucvs",ts="message-BAUWT",ss="control-pDso6",ns="input-I-Mu8",as="privacyCheckboxContainer-W9OHG",is="icon-nKdsV",rs="newsletterEmailInput-E6u6X",os="privacyCheckbox-Owm79",ls="newsletterPrivacyLabel-h-M6p",cs="newsletterBtn-P-9hW baseBtn-ZNLef largeBtn-jOmOm darkGrayBtn-p1Ce6",ds="newsletterImgWrap-XQSPM",us="newsletterImg-cBE8s",ms="status-success-ir7W-",w={gridContainer:Xt,newsletter:Yt,newsletterMainText:Jt,newsletterDek:Qt,newsletterForm:es,message:ts,control:ss,input:ns,privacyCheckboxContainer:as,icon:is,newsletterEmailInput:rs,privacyCheckbox:os,newsletterPrivacyLabel:ls,newsletterBtn:cs,newsletterImgWrap:ds,newsletterImg:us,"status-success":"status-success-ir7W-",statusSuccess:ms},hs=()=>e.jsx("svg",{width:"18",height:"14",viewBox:"0 0 18 14",fill:"none",className:w.icon,children:e.jsx("path",{d:"M6.75 12.25L1.75 7.25L0.25 8.75L6.75 15.25L18.25 3.75L16.75 2.25L6.75 12.25Z",fill:"currentColor"})});function gs(){const{countEvent:t}=Ce(),s=z("newsletter"),n=_.useRef(null),a=_.useRef(null),{login:i}=Ve(),[c,r]=_.useState(null),[m,o]=_.useState(!1),{api:f,collectorError:u,collectorResponse:l,subscribe:j}=et();let x="idle";f.loading?x="loading":l?.action==="success"?x="success":u&&(x="error");const v=p=>{p.preventDefault(),C()},C=async(p=!1)=>{const h=new FormData(n.current).get("email").toString();r(h),o(!1);const g=await j({email:h,lists:["today_in_science"],ignore_suggestion:p});"action"in g&&g.action==="success"&&(Ne({event:"email-obtained-newsletter-signup",user:{newsletters:"today_in_science"}}),t("newsletter_signup","homepage-feed",!1,{context_newsletters_added:["today_in_science"]}))};return s?e.jsxs(F,{"data-cta":"newsletter",id:"newsletter",className:w.newsletter,"data-click-position":"feed-card-newsletter-spotlight",children:[e.jsx(M,{className:w.newsletterImgWrap,children:e.jsx("img",{src:qt,role:"presentation",alt:"Today in Science newsletter preview",loading:"lazy",className:w.newsletterImg})}),e.jsxs($,{className:w.gridContainer,children:[e.jsxs("form",{className:y(w.newsletterForm,w["status-"+x]),onSubmit:v,ref:n,children:[e.jsxs("h2",{className:w.newsletterMainText,children:["Sign up for the ",e.jsx("i",{children:"Today in Science"})," Newsletter"]}),e.jsx("p",{className:w.newsletterDek,children:"Delivered free, every weekday"}),e.jsx("div",{className:w.control,children:e.jsx(tt,{ref:a,onInput:()=>o(!0)})}),!m&&!f.loading&&(x==="error"||l?.action&&l?.action!=="success")&&e.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"1rem",color:"var(--color-red)"},children:[u&&e.jsx("p",{children:u?.message||u?.error||"There was a problem submitting your email. Please try again."}),l?.action==="suggest"&&e.jsxs("p",{children:["Did you mean:"," ",e.jsx("a",{href:"#email",className:w.emailCollectorModalSignInLnk,onClick:p=>{p.preventDefault(),a.current.focus(),requestAnimationFrame(()=>{a.current.value=l.suggestion}),o(!0)},"data-click-position":"feed-card-newsletter-spotlight-suggest-fix",children:l.suggestion}),"?"]}),l?.action==="reject"&&e.jsx("p",{children:l.message}),l?.action==="soft-reject"&&e.jsxs("p",{children:[l.message," Try another email or"," ",e.jsx("a",{href:"/login/",id:"emailCollectorModalErrSignInLnk",className:w.emailCollectorModalSignInLnk,onClick:p=>{p.preventDefault(),i()},"data-click-position":"feed-card-newsletter-spotlight-sign-in",children:"sign in"}),"."]})]}),e.jsxs("div",{className:w.privacyCheckboxContainer,children:[e.jsx(nt,{className:y(w.checkbox,w.privacyCheckbox),type:"checkbox",id:"privacy-policy",required:!0}),e.jsx("label",{className:w.newsletterPrivacyLabel,htmlFor:"privacy-policy",children:e.jsx(st,{})})]}),e.jsx("button",{disabled:x==="loading"||x==="success",className:w.newsletterBtn,"data-click-position":"feed-card-newsletter-spotlight-sign-up",type:"submit",children:"Sign Up"})]}),e.jsxs("div",{className:y(w.message,w["status-"+x]),children:[e.jsx("p",{children:"Thank y
1ou for signing up!"}),e.jsx("div",{className:w.inputContainer,children:e.jsxs("div",{className:y("form-input",w.input),children:[e.jsx("span",{children:c||" "}),e.jsx(hs,{})]})}),e.jsx("p",{children:e.jsx("b",{children:e.jsx("a",{href:"/newsletters/","data-click-position":"feed-card-newsletter-spotlight-other-newsletters",children:"Check out our other newsletters"})})})]})]})]}):null}const ps="/static/assets/subCTA-Bj95gvdx.jpg",fs="subscribe-stYL1",xs="hero-LKBjo",js="subscribeCta__hdr-hKG6f",q={subscribe:fs,hero:xs,subscribeCta__hdr:js};function bs(){return e.jsxs(F,{className:q.subscribe,"data-click-position":"feed-card-subscribe",children:[e.jsx("a",{href:"/getsciam/","data-click-position":"feed-card-subscribe-landing",children:e.jsx(M,{className:q.hero,children:e.jsx("img",{src:ps,alt:"SciAm Subscribe",className:q.subscribeCta_heroimage})})}),e.jsxs($,{children:[e.jsx("h3",{className:q.subscribeCta__hdr,children:e.jsx("a",{href:"/getsciam/",className:q.subscribeCta__link,"data-click-position":"feed-card-subscribe-landing",children:"Itâs Time to Stand Up for Science"})}),e.jsx("div",{children:"Our subscribers support more than 180 years of science journalism. You get the facts, and you help us ensure that science is shared with rigor and independence."}),e.jsx("div",{children:e.jsx("a",{href:"/getsciam/","data-click-position":"feed-card-subscribe-landing",children:"Support Science Journalism"})})]})]})}const ys="/static/assets/sciam-travel-ZJz4ECv4.png",_s="travel-E3Cyf",vs="tripImage-XCXEZ",ve={travel:_s,tripImage:vs};function ks(){const s=z("travel")?.upcomingTrip;return s?e.jsxs(F,{"data-cta":"travel","data-click-position":"feed-card-travel-spotlight",className:ve.travel,children:[e.jsx(M,{className:ve.tripImage,children:e.jsx("a",{href:s.relative_url,children:e.jsx("img",{src:de(s.lead_image.image_url,{width:800}),alt:s.lead_image.image_alt_text,loading:"lazy"})})}),e.jsxs($,{children:[e.jsx(Me,{imageSrc:ys,text:"Scientific American Travel",url:"/travel/",alt:"SciAm Travel Logo"}),e.jsx("h3",{children:s.title}),e.jsx("div",{dangerouslySetInnerHTML:{__html:s.dek}}),e.jsx("div",{children:e.jsx("a",{href:s.relative_url,className:"button",children:"Learn More"})})]})]}):null}const ws={issue:Zt,collection:Nt,discussion:At,game:Pt,newsletter:gs,subscribe:bs,travel:ks,events:Tt};function $e({as:t="div",...s}){const n=Ie(),{areaName:a,items:i,userRecsMeta:c}=se(),{item:r,preview:m,previewMeta:o}=D(),{countEvent:f}=Ce(),{consent:u}=We(),l=!!u.analytics,j=_.useRef(null),x=it(j,{once:!0,amount:.5}),v={item:r,items:i,preview:m,areaName:a,feedMeta:n,userRecsMeta:c},C=_.useRef(v);C.current=v;function p(){const h="hp_session_id";let g=ye.get(h);return g||(g=Ze()),ye.set(h,g,{expires:1/24,secure:!0}),g}function d(h,g){if(!l){console.debug("[homepage] nothing recorded, awaiting consent");return}const{item:b,items:E,preview:I,areaName:G,feedMeta:Y,userRecsMeta:H}=C.current,O={};let V;if(Y.model_name&&(V=Y),H?.model_name&&(V=H),V?.model_name){let ie="general";G!=="main_feed"?ie="static":H?.model_name&&(ie="personalized"),O.context_algorithm=`${V.model_name}, ${V.model_version}, ${ie}`}let W="article";b.break_type?W=b.break_type:I.media_type?W=I.media_type:I.subtype==="game"&&(W="game"),f("homepage_activity",h,!1,{context_section:G,context_contentful_id:b.contentful_id,context_source:b.source,context_card_position:b.position,context_card_type:W,context_card_url:g??b.url??I?.url,context_homepage_session_id:p(),...O}),Ne({event:"homepage_activity",homepage_activity:{activity_type:h,section:G,contentful_id:b.contentful_id,source:b.source,card_position:b.position,card_type:W,card_url:g??b.url??I?.url,homepage_session_id:p(),algorithm:O.context_algorithm??""}})}return _.useEffect(()=>{if(!l)return;let h;return x?h=setTimeout(()=>{x&&d("card_impression")},1e3):clearTimeout(h),()=>{clearTimeout(h)}},[x,l]),_.useEffect(()=>{const h=j.current;if(!h)return;const g=b=>{const E=b.target.tagName==="A"?b.target:b.target.closest("a");E&&d("card_click",E.href)};return h.addEventListener("click",g),()=>{h.removeEventListener("click",g)}},[j.current,l]),e.jsx(t,{ref:j,"data-card-wrapper":!0,...S({...s})})}const Cs="mainFeed-PLuBJ",Ns="feedItem-MLWDy",Ss="layout-large-y7wbm",Is="layout-spotlight-WJLO6",Ls="feedBreak-oSHGK",te={mainFeed:Cs,feedItem:Ns,"layout-large":"layout-large-y7wbm",layoutLarge:Ss,"layout-spotlight":"layout-spotlight-WJLO6",layoutSpotlight:Is,feedBreak:Ls};function As({item:t,debug:s=!1}){if(!t?.break_type)return null;if(t.break_type==="ad")return e.jsx(Re,{item:t});const n=ws[t.break_type];if(!n){const a=Te[t.break_type]||{label:t.break_type||"Unknown"};throw new Error(`No CTA component found for break type "${t.break_type}".`,a)}return e.jsx(me,{item:t,children:e.jsxs($e,{className:te.feedBreak,children:[e.jsx(n,{...t}),s&&e.jsx(Ts,{...t})]})})}function Re({item:t}){return e.jsx(at,{position:`hp-${t.ad_index+1}`,margin:!1})}function Ts({type:t,position:s,break_type:n}){const a=Te[n]||{label:n||"Unknown",color:"#ccc"};return e.jsxs("div",{style:{position:"absolute",top:0,right:"1rem",background:a.color,color:"#fff",padding:"0.25rem 0.5rem",fontSize:"0.625rem",fontWeight:"bold",borderBottomLeftRadius:"0.25rem",borderBottomRightRadius:"0.25rem"},children:[a.label," ⢠pos. ",s]})}const Fs="feedInfo-jF46B",Ms="sourceGrid-PknWS",$s="sourceCard-8aR9q",Rs="noRecs-mohGZ",Es="dataList-y6sLS",Bs="compositionGraph-A5E8E",Ds="compositionEmpty-dQ99o",Ps="graphSegment-yB-IR",Hs="segmentItems-mJkDY",Os="segmentRecommended-9rH7V",Us="segmentAds-Z-tB9",zs="segmentCtas-sAk22",Gs="compositionLegend-RvZE6",Vs="swatch-8zjzW",k={feedInfo:Fs,sourceGrid:Ms,sourceCard:$s,noRecs:Rs,dataList:Es,compositionGraph:Bs,compositionEmpty:Ds,graphSegment:Ps,segmentItems:Hs,segmentRecommended:Os,segmentAds:Us,segmentCtas:zs,compositionLegend:Gs,swatch:Vs};function Ws({feed:t,userRecs:s}){const{curated_at:n,recommended_at:a,model_created_at:i,model_name:c,model_updated_at:r,model_version:m}=Ie(),o=t.length,{feedItemCount:f,recommendedFeedItemCount:u,adCount:l,ctaCount:j}=t.reduce((d,h)=>(h.type==="feed_item"?(d.feedItemCount+=1,(h.source==="trending"||h.source==="user_feed")&&(d.recommendedFeedItemCount+=1)):h.type==="break"&&(h.break_type==="ad"?d.adCount+=1:d.ctaCount+=1),d),{feedItemCount:0,recommendedFeedItemCount:0,adCount:0,ctaCount:0}),v=[{key:"items",label:"Feed items",count:f-u,className:k.segmentItems},{key:"recommended",label:"Recommended",count:u,className:k.segmentRecommended},{key:"ads",label:"Ads",count:l,className:k.segmentAds},{key:"ctas",label:"CTAs",count:j,className:k.segmentCtas}],C=[{key:"items",label:"Feed items",count:f,className:k.segmentItems,suffix:`${u} recommended`},{key:"ads",label:"Ads",count:l,className:k.segmentAds},{key:"ctas",label:"CTAs",count:j,className:k.segmentCtas}],p=s?.items.reduce((d,{created_at:h,updated_at:g,user_id:b})=>{if(!d)return{user_id:b,created_at:new Date(h),updated_at:new Date(g)};const E=(d.updated_at||d.created_at).getTime();return new Date(g||h).getTime()>E?{user_id:b,created_at:new Date(h),updated_at:new Date(g)}:d},null);return e.jsxs("div",{className:k.feedInfo,children:[e.jsxs("section",{children:[e.jsx("h3",{children:"Main Feed Breakdown"}),e.jsxs("div",{className:k.compositionGraph,role:"img","aria-label":`Feed composition with ${f} feed items (${u}
1 recommended), ${l} ads, and ${j} CTAs`,children:[o===0&&e.jsx("div",{className:k.compositionEmpty,children:"No feed items"}),o>0&&v.map(d=>{if(d.count===0)return null;const h=d.count/o,g=Math.round(h*100);return e.jsx("div",{className:`${k.graphSegment} ${d.className}`,style:{flex:Math.max(h*100,2)},title:`${d.label}: ${d.count} (${g}%)`,children:h>=.05?`${d.count}`:""},d.key)})]}),e.jsxs("ul",{className:k.compositionLegend,children:[C.map(d=>{const h=o>0?Math.round(d.count/o*100):0;return e.jsxs("li",{children:[e.jsx("span",{className:`${k.swatch} ${d.className}`,"aria-hidden":"true"}),e.jsx("span",{children:d.label}),e.jsx("strong",{children:d.count}),"(",h,"%",d.suffix?", "+d.suffix:"",")"]},d.key)}),e.jsxs("li",{children:[e.jsx("strong",{children:"Total:"})," ",o]})]}),e.jsxs("details",{children:[e.jsx("summary",{children:"Final Mixed Feed (table view)"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Slot 1"}),e.jsx("th",{children:"Slot 2"}),e.jsx("th",{children:"Slot 3"}),e.jsx("th",{children:"Break"})]})}),e.jsx("tbody",{children:t.reduce((d,h)=>{if(h.type==="feed_item"){const g=d[d.length-1];!g||g.length>=3?d.push([h]):g.push(h)}else if(h.type==="break"){const g=d[d.length-1];if(!g)d.push([h]);else if(g.length===4)d.push([h]);else if(g.length<3){for(;g.length<3;)g.push({type:"empty"});g.push(h)}else g.push(h)}return d},[]).map((d,h)=>e.jsxs("tr",{children:[d.map((g,b)=>e.jsx("td",{style:{border:"1px solid #ccc",padding:"4px"},children:g.type==="feed_item"?`${g.source} #${g.source_index+1}`:g.break_type},b)),d.length<4&&Array.from({length:4-d.length}).map((g,b)=>e.jsx("td",{style:{border:"1px solid #ccc",padding:"4px"}},"empty-"+b))]},h))})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Feed Sources"}),e.jsxs("div",{className:k.sourceGrid,children:[(p||s.meta?.model_name)&&e.jsxs("div",{className:k.sourceCard,children:[e.jsx("h4",{children:"Personalized Recommendations"}),!p&&s.meta?.model_name&&e.jsx("p",{className:k.noRecs,children:"No personalized recommendations for this user"}),p&&e.jsxs("dl",{className:k.dataList,children:[e.jsxs("div",{children:[e.jsx("dt",{children:"User"}),e.jsx("dd",{children:p.user_id})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Latest rec"}),e.jsx("dd",{children:e.jsx(P,{dateTime:p.created_at})})]}),s.meta?.model_name&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsxs("dd",{children:[s.meta.model_name,s.meta.model_name.includes(s.meta.model_version)?"":` ${s.meta.model_version}`]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Created"}),e.jsxs("dd",{children:[e.jsx(P,{dateTime:s.meta.model_created_at})," EST"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsxs("dd",{children:[e.jsx(P,{dateTime:s.meta.model_updated_at})," EST"]})]})]})]})]}),e.jsxs("div",{className:k.sourceCard,children:[e.jsx("h4",{children:"Trending Recommendations"}),e.jsxs("dl",{className:k.dataList,children:[a&&e.jsxs("div",{children:[e.jsx("dt",{children:"Latest rec"}),e.jsxs("dd",{children:[e.jsx(P,{dateTime:a})," EST"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsxs("dd",{children:[c,c?.includes(m)?"":` ${m}`]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Created"}),e.jsxs("dd",{children:[e.jsx(P,{dateTime:i})," EST"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsxs("dd",{children:[e.jsx(P,{dateTime:r})," EST"]})]})]})]}),e.jsxs("div",{className:k.sourceCard,children:[e.jsx("h4",{children:"Editorial Curation"}),e.jsx("dl",{className:k.dataList,children:e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsxs("dd",{children:[n?e.jsx(P,{dateTime:n}):"N/A"," EST"]})]})})]})]})]})]})}function pe(t,s){const n=!!s?.isSponsored,a=!!s?.isPodcastList,i=rt(t),c=t.display_date||t.date_published||t.release_date,r=t.display_title||t.title||t.print_title||"Untitled";let m=t.subtype?.toLowerCase(),o=t.category,f=t.custom_category,u=t.authors;t.advertiser&&!n&&(o="Sponsored",u=t.advertiser),t.media_type==="podcast"&&!a&&(m="podcast",u=[]),m||(t.digital_column||t.column?m="col":o==="Games"||t.url?.startsWith("/game/")?m="game":m=t.media_type||void 0),typeof u=="string"?(u=u.trim(),u=u?[{name:u}]:[]):Array.isArray(u)||(u=[]);const l=Ke(u);return{id:i,display_date:c,display_title:r,subtype:m,category:o,custom_category:f,authors:u,byline:l}}const Zs={cssModule:{},href:null,linkProps:{}},[Ks,R]=Ye("Card",Zs),qs="cardLink-Kf2Ro",Xs={cardLink:qs};function Ee({children:t,className:s="",...n}){const{cssModule:a}=R();return e.jsx("a",{...n,className:y(Xs.cardLink,a?.cardLink,s),children:t})}const Ys="card-DKAVT",Js="hed-7UW9B",Qs="dek-wjiYE",en="withLink-9GnS6",tn="figure-EvD4V",sn="kicker--ugFD",nn="b
1yline-jZvTT",an="meta-55nGQ",rn="media-rkumf",on="actions-gcVvQ",ln="content-sFURk",T={card:Ys,hed:Js,dek:Qs,withLink:en,figure:tn,kicker:sn,byline:nn,meta:an,media:rn,actions:on,content:ln},cn="cardLink-fquhq",dn="native-8V2Kl",un="figure-gONav",mn="kicker-YV3Ro",hn="hed-ui-QB",gn="dek-h0VQL",pn="byline-P74-1",fn="media-FRktk",xn="content-0LlWC",jn={cardLink:cn,native:dn,figure:un,kicker:mn,hed:hn,dek:gn,byline:pn,media:fn,content:xn};function bn({as:t="article",cssModule:s=jn,className:n,variant:a="default",href:i=null,linkProps:c={},children:r,...m},o){return e.jsx(Ks,{cssModule:s,href:i,linkProps:c,children:e.jsx(t,{className:y([T.card,s.card],!!a&&[T[`is_${a}`],s?.[`is_${a}`]],!!i&&[T.withLink,s?.withLink],n),ref:o,...m,children:r})})}const yn=({className:t,children:s,html:n,...a})=>{const i=R();return e.jsx("div",{className:y(T.hed,i.cssModule?.hed,t),...a,children:i.href?e.jsx(Ee,{href:i.href,...i.linkProps,children:e.jsx(ue,{...S({children:s,html:n})})}):e.jsx(ue,{...S({children:s,html:n})})})},_n=({as:t="div",className:s,...n})=>{const{cssModule:a}=R();return e.jsx(t,{className:y(T.dek,a.dek,s),...S(n)})},vn=({as:t="div",className:s,...n})=>{const{cssModule:a}=R();return e.jsx(t,{className:y(T.kicker,a.kicker,s),...S(n)})},kn=({as:t="div",className:s,...n})=>{const{cssModule:a}=R();return e.jsx(t,{className:y(T.byline,a.byline,s),...S(n)})},wn=({as:t="div",className:s,...n})=>{const{cssModule:a}=R();return e.jsx(t,{className:y(T.meta,a.meta,s),...S(n)})},Be=({as:t="figure",className:s,...n})=>{const{cssModule:a}=R();return e.jsx(t,{className:y(T.figure,a.figure,s),...S(n)})},Cn=({as:t="div",className:s,...n})=>{const{cssModule:a}=R();return e.jsx(t,{className:y(T.media,a.media,s),...S(n)})},Nn=({as:t="section",className:s,...n})=>{const{cssModule:a}=R();return e.jsx(t,{className:y(T.actions,a.actions,s),...S(n)})},N=Object.assign(_.forwardRef(bn),{displayName:"Card",Link:Ee,Hed:yn,Dek:_n,Kicker:vn,Media:Cn,Figure:Be,Byline:kn,Meta:wn,Actions:Nn}),fe=({article:t,...s})=>{const n=t;return e.jsx(Be,{"data-disable-apple-news":!!n?.image_block_syndication||void 0,...s})};function xe({article:t,layout:s,expectedWidth:n=400,expectedMaxWidth:a=660,fallback:i=!0,lazy:c=!0,...r}){const m=t,{image_url:o,image_alt_text:f,subtype:u}=m||{};if(!i&&!o)return null;const l=_.useMemo(()=>{const j=o?{src:o,alt:f}:Sn(u);return{...s?Je(j.src,s):Qe(j.src,n,a),alt:j.alt}},[o,f,s]);return e.jsx("img",{loading:c?"lazy":"eager",...l,...r})}function Sn(t){return t?.toLocaleLowerCase?.()==="podcast"?{src:"/static/science-quickly-logo.jpg",alt:"Podcast from Scientific American"}:{src:"/static/sciam-mark.jpg",alt:"Scientific American"}}const In="badge-gsTeb",Ln={badge:In};function je({as:t="div",className:s,...n}){return e.jsx(t,{className:y(Ln.badge,s),...S(n)})}const De=({mediaType:t,...s})=>{const n=Fn[t];return n?e.jsx(n,{...s}):null},An=({color:t="#fff",backgroundColor:s="#000",style:n={},...a})=>{const i=_.useId();return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",fill:"none",viewBox:"0 0 64 64",...a,style:{color:t,...n},children:[e.jsx("circle",{cx:"32",cy:"32",r:"30",fill:s,opacity:"0.5"}),e.jsx("g",{filter:`url(#filter0_d_425_879-${i})`,children:e.jsx("path",{fill:"currentColor",d:"M32 2C15.432 2 2 15.432 2 32c0 16.569 13.432 30 30 30 16.569 0 30-13.431 30-30-.018-16.561-13.439-29.982-30-30m0 57.6C16.757 59.6 4.4 47.243 4.4 32S16.757 4.4 32 4.4 59.6 16.757 59.6 32C59.583 47.236 47.236 59.584 32 59.6m13.836-28.617-19.2-12A1.2 1.2 0 0 0 24.8 20v24a1.2 1.2 0 0 0 1.836 1.017l19.2-12a1.2 1.2 0 0 0 0-2.034M27.2 41.834V22.166L42.935 32z"})}),e.jsx("defs",{children:e.jsxs("filter",{id:`filter0_d_425_879-${i}`,width:"64",height:"64",x:"0",y:"0",colorInterpolationFilters:"sRGB",filterUnits:"userSpaceOnUse",children:[e.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),e.jsx("feColorMatrix",{in:"SourceAlpha",result:"hardAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),e.jsx("feOffset",{}),e.jsx("feGaussianBlur",{stdDeviation:"1"}),e.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),e.jsx("feColorMatrix",{values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0"}
1),e.jsx("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_425_879"}),e.jsx("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_425_879",result:"shape"})]})})]})},Tn=({color:t="#fff",backgroundColor:s="#000",style:n={},...a})=>{const i=_.useId();return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"60",height:"60",fill:"none",viewBox:"0 0 60 60",...a,style:{color:t,...n},children:[e.jsxs("g",{fill:"currentColor",clipPath:`url(#clip0_942_99-${i})`,filter:`url(#filter0_d_942_99-${i})`,children:[e.jsx("path",{fill:s,stroke:s,d:"M30 2C14.879 2 2 14.879 2 30s12.879 28 28 28 28-12.879 28-28S45.121 2 30 2z",opacity:.5}),e.jsx("path",{d:"M30.099 17.577h-.1c-7.14 0-12.928 5.787-12.928 12.928v6.962a2.985 2.985 0 0 0 2.984 2.983h1.99a2.985 2.985 0 0 0 2.984-2.983v-4.974a2.985 2.985 0 0 0-2.984-2.984h-2.94A10.94 10.94 0 0 1 30 19.564h.084a10.906 10.906 0 0 1 10.815 9.945h-2.942a2.985 2.985 0 0 0-2.983 2.984v4.974a2.985 2.985 0 0 0 2.983 2.983h1.99a2.985 2.985 0 0 0 2.984-2.983v-6.962a12.86 12.86 0 0 0-3.743-9.116 12.86 12.86 0 0 0-9.087-3.812zm-8.054 13.922c.55 0 .994.446.994.994v4.974c0 .55-.447.993-.994.993h-1.99a.994.994 0 0 1-.994-.993v-5.968zm18.896 5.968c0 .55-.446.993-.994.993h-1.99a.994.994 0 0 1-.993-.993v-4.974c0-.55.446-.994.993-.994h2.984z"}),e.jsx("path",{d:"M30 0C13.459 0 0 13.459 0 30s13.459 30 30 30 30-13.459 30-30S46.544 0 30 0m0 57.78C14.682 57.78 2.22 45.319 2.22 30S14.681 2.22 30 2.22 57.78 14.681 57.78 30 45.319 57.78 30 57.78"})]}),e.jsxs("defs",{children:[e.jsx("clipPath",{id:`clip0_942_99-${i}`,children:e.jsx("path",{fill:"currentColor",d:"M0 0h60v60H0z"})}),e.jsxs("filter",{id:`filter0_d_942_99-${i}`,width:"64",height:"64",x:"-2",y:"-2",colorInterpolationFilters:"sRGB",filterUnits:"userSpaceOnUse",children:[e.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),e.jsx("feColorMatrix",{in:"SourceAlpha",result:"hardAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),e.jsx("feOffset",{}),e.jsx("feGaussianBlur",{stdDeviation:"1"}),e.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),e.jsx("feColorMatrix",{values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0"}),e.jsx("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_942_99"}),e.jsx("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_942_99",result:"shape"})]})]})]})},Fn={podcast:Tn,video:An};function be({preview:t,source:s,greedyKicker:n=!1}){let a="",i="";const c=t.category||"";return t.custom_category?a=t.custom_category:s?.slug==="popular"?a=s.label:t.display_category?a=t.display_category:n&&c&&(a=c),a!==c&&(i||=c),{kickerLabel:a,bylineCategory:i}}const Mn="card-3VAB0",$n="layout-compact-wMA8N",Rn="figure-YTawo",En="layout-small-5NDug",Bn="layout-large-sj0jH",Dn="figure-right-gxVl4",Pn="hed-Zp1V-",Hn="kicker-RGlz3",On="cardLink-eGVr4",Un="meta-lMeRT",zn="byline-7hw2P",Gn="authors-P6Sld",Vn="dek-xhBqF",Wn="icon-nZ3xJ",J={card:Mn,"layout-compact":"layout-compact-wMA8N",layoutCompact:$n,figure:Rn,"layout-small":"layout-small-5NDug",layoutSmall:En,"layout-large":"layout-large-sj0jH",layoutLarge:Bn,"figure-right":"figure-right-gxVl4",figureRight:Dn,hed:Pn,kicker:Hn,cardLink:On,meta:Un,byline:zn,authors:Gn,dek:Vn,icon:Wn},Zn="byline-HIzg9",Kn="meta-ii1lF",U={byline:Zn,meta:Kn};function ke({layout:t,className:s="",lazy:n=!1,forceDek:a=!1,noKicker:i=!1}){const{item:c,preview:r,source:m,default_layout:o}=D(),f=se();if(f.areaName==="top_rail"&&(i=!0),!c)return console.warn("ArticleFeedCard rendered without item context. Rendering null."),null;if(!r)return console.warn("ArticleFeedCard rendered without preview context. Rendering null."),null;const u=pe(r,f),l={...r,...u},{id:j,url:x,display_date:v,media_type:C,category:p,byline:d,display_title:h,summary:g}=l,{kickerLabel:b,bylineCategory:E}=be({preview:l,source:m}),I=t||o,G=["compact"].includes(I)?!1:I==="big"||!!l.image_url,Y=g&&(a||["normal","large","spotlight"].includes(I)),H=b&&!i&&I!=="compact",O=H?E:b||E;return e.jsxs(N,{href:x,cssModule:J,className:y(`layout-${I}`,s),"data-click-position":"feed-card-article",children:[G&&e.jsxs(fe,{article:l,children:[e.jsx(xe,{article:l,lazy:n,expectedWidth:300,expectedMaxWidth:600}),e.jsx(De,{mediaType:C,className:J.icon})]}),H&&e.jsx(N.Kicker,{children:e.jsx(je,{children:b})}),e.jsx(N.Hed,{html:h}),Y&&e.jsx(N.Dek,{html:g}),e.jsx(N.Byline,{className:U.byline,children:d?.length>=30&&e.jsx("span",{className:J.authors,dangerouslySetInnerHTML:{__html:d}})}),e.jsxs(N.Meta,{className:U.meta,children:[d&&d?.length<30&&e.jsx("span",{className:J.authors,dangerouslySetInnerHTML:{__html:d}}),v&&e.jsx("time",{dateTime:v,children:he(v)}),O&&e.jsx("span",{children:O})]})]})}function qn(){const{item:t,preview:s,default_layout:n}=D();return s?e.jsxs("div",{style:{border:"1px solid #ccc",padding:"1rem",marginBottom:"1rem"},children:[e.jsx("div",{children:"Podcast Card"}),e.jsx("h3",{dangerouslySetInnerHTML:{__html:s.display_title||s.title||"Episode Data Missing"}})]}):null}const Xn="spotlightCard-Je8Nt",Yn="hero-yLawe",Jn="hed-iHDfi",Qn="dek-jMf6U",ea="icon-MRSp8",X={spotlightCard:Xn,hero:Yn,hed:Jn,dek:Qn,icon:ea};function ta(){const{item:t,preview:s,source:n,default_layout:a}=D(),i=se();if(!s||!t)return null;const c=pe(s,i),r={...s,...c},{id:m,display_date:o,subtype:f,category:u,byline:l,display_title:j,title:x,summary:v}=r,{kickerLabel:C,bylineCategory:p}=be({preview:r,source:n}),d=!!r.image_url||!!r.media_url;return r.media_type,e.jsx(N,{href:r.url,"data-click-position":"feed-card-spotlight-article",children:e.jsx(F,{className:X.spotlightCard,children:e.jsxs(ae,{children:[d&&e.jsx(M,{className:X.hero,children:e.jsxs(fe,{article:r,children:[e.jsx(xe,{article:r,expectedWidth:550,expectedMaxWidth:600}),e.jsx(De,{mediaType:r.media_type,className:X.icon})]})}),e.jsxs($,{children:[C&&e.jsx(je,{children:C}
1),e.jsx(N.Hed,{html:j||x,className:X.hed}),e.jsx("div",{dangerouslySetInnerHTML:{__html:v},className:X.dek}),e.jsx(N.Byline,{className:U.byline,children:l?.length>=50&&e.jsx("span",{dangerouslySetInnerHTML:{__html:l}})}),e.jsxs(N.Meta,{className:U.meta,children:[l&&l?.length<50&&e.jsx("span",{dangerouslySetInnerHTML:{__html:l}}),r.media_type==="podcast"&&e.jsx("span",{children:"Science Quickly"}),o&&e.jsx("time",{dateTime:o,children:he(o)}),p&&e.jsx("span",{children:p})]})]})]})})})}function sa(){const{item:t,preview:s,default_layout:n}=D();return s?e.jsxs("div",{style:{border:"1px solid #ccc",padding:"1rem",marginBottom:"1rem"},children:[e.jsx("div",{children:"Video Card"}),e.jsx("h3",{dangerouslySetInnerHTML:{__html:s.display_title||s.title||"Article Data Missing"}})]}):null}const na="card-1WzAu",aa="cardLink-6ovwL",ia="figure-uE2ZH",ra="dek-bW3SQ",oa="byline-lcLeM",la="meta-Kgory",ca={card:na,cardLink:aa,figure:ia,dek:ra,byline:oa,meta:la};function da({}){const{item:t,preview:s,source:n,default_layout:a}=D(),i=se();if(!s||!t)return null;const c=pe(s,i),r={...s,...c},{id:m,display_date:o,category:f,byline:u,display_title:l,title:j,summary:x}=r,{kickerLabel:v,bylineCategory:C}=be({preview:r,source:n}),p=!!r.image_url||!!r.media_url;return e.jsxs(N,{href:r.url||"#",cssModule:ca,"data-click-position":"feed-card-top-story",style:{"--font-heading":"var(--font-condensed)","--font-heading-weight":"500","--font-subheading":"var(--font-condensed)","--font-subheading-weight":"400"},children:[p&&e.jsx(fe,{article:r,children:e.jsx(xe,{article:r,expectedWidth:550,expectedMaxWidth:800,lazy:!1,fetchpriority:"high"})}),v&&e.jsx(N.Kicker,{children:e.jsx(je,{children:v})}),e.jsx(N.Hed,{html:l||j}),e.jsx(N.Dek,{html:x}),e.jsx(N.Byline,{className:U.byline,children:u?.length>=50&&e.jsx("span",{dangerouslySetInnerHTML:{__html:u}})}),e.jsxs(N.Meta,{className:U.meta,children:[u&&u?.length<50&&e.jsx("span",{dangerouslySetInnerHTML:{__html:u}}),o&&e.jsx("time",{dateTime:o,children:he(o)}),C&&e.jsx("span",{children:C})]})]})}const le={default:ke,video:sa,podcast:qn,game:ke,spotlight:ta,big:da},ua="badge-zFvAm",ma="summary-jUitt",ha="summaryExpanded-NXess",ga="detailsPanel-Dp6on",pa="detailsPre-uwn0F",fa="metaRow-y5u5G",xa="debugHelpText-N8I3e",ja="scoreRow-0ZiqK",ba="helpTextBubble--Pe37",ya="divider-pZRrm",L={badge:ua,summary:ma,summaryExpanded:ha,detailsPanel:ga,detailsPre:pa,metaRow:fa,debugHelpText:xa,scoreRow:ja,helpTextBubble:ba,divider:ya};function _a(){const{item:t,source:s,previewMeta:n}=D(),a=[];for(const[u,l]of Object.entries(n||{}))l?.index!==void 0&&u!==s.slug&&a.push(`${u} #${l.index+1}`);const i={"Contentful ID":t.contentful_id,"Feed Item ID":t?.id,"Feed Item Position":typeof t.position=="number"?"#"+(t.position+1):"N/A","Feed Segment":t.segment&&t.segment+" #"+(t.segment_index+1),Source:s.label&&s.label+" #"+(t.source_index+1),"Other Sources":a.join(", ")||void 0},c={[s.label+" Score"]:t?.score,[s.label+" Popularity"]:t?.popularity_score,[s.label+" Recency"]:t?.recency_score,[s.label+" Similarity"]:t?.similarity_score,"Anonymous Rec. Combined Score":s.slug==="trending"?void 0:n?.trending?.score,"Anonymous Rec. Recency":n?.trending?.recency_score,"Anonymous Rec. Similarity":n?.trending?.similarity_score,"Anonymous Rec. Popularity":n?.trending?.popularity_score},r='When present, "Anonymous Rec" scores come from the anonymous user/general recommendation feed, but are not necessarily factored into the final ranking.',m={"Contentful ID":`<a href="https://app.contentful.com/spaces/3mxwuprd8d5z/entries/${t.contentful_id}" target="_blank" rel="noopener">Open in Contentful</a>`,"Feed Item ID":`Unique identifier for this ${s.label} item.`,"Feed Item Position":"The position of this item in the feed (1-based index)","Feed Segment":'The internal "segment" this item belongs to after feed mixing.<br>For example, "curated #5" would means this item is the 5th item added to the "curated" slot of the main feed.<br>When we run out of items for a slot, it will be filled with items from other segments/sources.',Source:'The feed source (aka Django endpoint) that this story/item originates from.<br>For example, "Recommendation #1" represents first item in the anonymous user recommendation endpoint.<br>Expect the number to occasionally "jump" a few due to deduplication and prioritization rules.',"Other Sources":"Other feed sources that included this story/item, but have not rendered due to deduplication and prioritization rules.",[s.label+" Score"]:"The raw relevance score assigned to this item by the feed source's ranking algorithm.","Anonymous Rec. Combined Score":r,"Anonymous Rec. Recency":r,"Anonymous Rec. Similarity":r,"Anonymous Rec. Popularity":r},[o,f]=_.useState(!1);return e.jsxs("details",{className:L.badge,open:o,onToggle:u=>f(u.currentTarget.open),children:[e.jsx("summary",{className:y(L.summary,o&&L.summaryExpanded),style:{backgroundColor:s.color},children:e.jsxs("span",{children:[s?.label&&s?.label+" #"+(t.source_index+1),typeof t.score=="number"&&t.score>=0?e.jsx("code",{children:` (${t.score.toFixed(3)})`}):""]})}),o&&e.jsx(va,{helpText:m,meta:i,scores:c}
1)]})}function va({helpText:t,meta:s,scores:n}){return e.jsx("div",{className:L.detailsPanel,children:e.jsxs("pre",{className:L.detailsPre,children:[s&&e.jsx(e.Fragment,{children:Object.entries(s).filter(([a,i])=>i!==void 0).map(([a,i])=>e.jsxs("div",{className:L.metaRow,children:[a,"".padEnd(30-a.length)," ",typeof i=="number"?i.toFixed(0):i??"N/A",t[a]&&e.jsx("div",{className:L.debugHelpText,children:e.jsx("div",{className:L.helpTextBubble,dangerouslySetInnerHTML:{__html:t[a]}})})]},a))}),Object.values(n).some(a=>a>0)&&e.jsx("hr",{className:L.divider}),Object.entries(n).map(([a,i])=>i>=0&&e.jsxs("div",{className:L.scoreRow,children:[e.jsxs("span",{children:[a,"".padEnd(30-a.length)," ",typeof i=="number"?i.toFixed(3):"N/A"]}),t[a]&&e.jsx("div",{className:L.debugHelpText,children:e.jsx("div",{className:L.helpTextBubble,dangerouslySetInnerHTML:{__html:t[a]}})})]},a))]})})}function Pe({layout:t=null,lazy:s=!1,debug:n}){const{item:a,preview:i,default_layout:c,debug:r}=D(),m=t||a?.preferred_layout||c,o=le[a?.item_type]||le[m]||le.default;if(!o)throw new Error(`No card component found for item type "${a?.item_type}" and layout "${m}".`);return e.jsxs($e,{className:y(te.feedItem,te["layout-"+m]),children:[e.jsx(o,{...a,layout:m,lazy:s}),(n||r)&&e.jsx(_a,{})]})}function ka({segments:t,breaks:s=[],userRecs:n={},userState:a={},disableUserFeed:i=!1,exclude:c=[],compact:r=!1,mock:m=!1,debug:o=!1,showDebugLabels:f=!1,lazy:u=!0,children:l}){const j=!i&&n.items?.filter(p=>!c.includes(p.object?.contentful_id)).map((p,d)=>({source:"user_feed",source_index:d,id:p?.object?.id,contentful_id:p.object?.contentful_id,...p})),x=mt({...t,personalized:j||[]},{debug:f}),v=dt(x,s,a),C=r?"mini":"normal";return e.jsxs(ce,{areaName:"main_feed",segments:["main_feed"],items:x,userRecsMeta:j?.length?n.meta:void 0,debug:f,children:[e.jsxs(ot,{as:"section",className:te.mainFeed,children:[o&&e.jsx(Ws,{feed:v,userRecs:n}),v.map((p,d)=>p?.type==="feed_item"?e.jsx(wa,{item:p,size:C,lazy:u,debug:f},p.contentful_id||`${p.item_type}-${d}`):e.jsx(As,{item:p,debug:f},`${p.break_type}-${p.position}`))]}),l]})}function wa({item:t,size:s,lazy:n,debug:a}){const i=t.contentful_id||t.object?.contentful_id||"",c=Se(i,t.object||null),r=ct(i);let m=r;if(t.source&&t.object){const{object:u,...l}=t;m={...r,[t.source]:{...r?.[t.source]||{},...l}}}const o=t?.url?{...c||{},...t}:c,f=ee(t.source);return e.jsx(Fe,{id:t.contentful_id,children:e.jsx(me,{item:t,preview:o,previewMeta:m,default_layout:s,source:f,debug:a,children:e.jsx(Pe,{layout:s==="mini"?"compact":null,lazy:n,debug:a})})})}const Ca="viewAllBtn-Kj3ut baseBtn-ZNLef darkGrayBtn-p1Ce6",Na="viewAllLnk--FX29",He={viewAllBtn:Ca,viewAllLnk:Na},Sa="topFold--iOr1",Ia="mainStory-O5LUA",La="rail-Ae1-M",Aa="hp_native_ux2-7hMfx",Q={topFold:Sa,mainStory:Ia,rail:La,hp_native_ux2:Aa};function Ta({topStories:t,topRail:s,showDebug:n=!1}){const[a,...i]=t.items||[],c=[...i,...s.items||[]];return e.jsxs("section",{className:Q.topFold,children:[e.jsx("h1",{className:"sr-only",children:"Scientific American"}),e.jsx(ce,{areaName:"top_stories",segments:["top_stories"],items:t.items||[],debug:!0,children:e.jsx("div",{className:Q.mainStory,children:a&&e.jsx(we,{source:ee(a.source),item:{position:0,...a},layout:"big",debug:n})})}),e.jsx(ce,{areaName:"top_rail",segments:["top_rail"],items:c,debug:!0,children:e.jsxs("aside",{className:Q.rail,"aria-label":"Top Articles",children:[c.map((r,m)=>e.jsx(we,{source:ee(r.source),item:{position:m,...r},layout:"small",debug:n},r.contentful_id||r.object?.contentful_id||r.id)),e.jsx(lt,{className:Q.hp_native_ux2,position:"native-hp-latest"}),e.jsx("a",{href:"/latest/",className:He.viewAllLnk,"data-click-position":"homepage-top-fold-view-all-stories",children:"View All Stories"})]})})]})}function we({item:t,layout:s,renderItem:n,debug:a}){const i=Se(t.contentful_id||t.object?.contentful_id||"",t.object||null),c=ee(t.source);return e.jsx(Fe,{children:e.jsx(me,{source:c,item:t,preview:i,default_layout:s,debug:a,children:e.jsx(Pe,{layout:s})})})}function Fa({state:t,onChange:s,compact:n=!1,onCompactChange:a,hasUserFeedItems:i=!1,showDebug:c=!1,onDebugChange:r}){const m=o=>s({...t,[o]:!t[o]});return e.jsxs("div",{className:"toggle",style:{display:"flex",gap:"1rem",flexWrap:"wrap",margin:"2rem auto -1rem",borderRadius:"1rem 1rem 0 0",width:"1100px",maxWidth:"calc(100% - 2rem)"},children:[e.jsx(B,{checked:c,onChange:()=>r?.(!c),label:"Labels"}),e.jsx(B,{checked:n,onChange:()=>a?.(!n),label:"Compact Cards"}),e.jsx(B,{checked:!!t.isSubscriber,onChange:()=>m("isSubscriber"),label:"Has Paid Sub",hidden:!0}),e.jsx(B,{checked:!!t.hasAdFree,onChange:()=>m("hasAdFree"),label:"Ad-Free"}),e.jsx(B,{checked:!!t.getsIssueAlert,onChange:()=>m("getsIssueAlert"),label:"Gets Issue Alerts",hidden:!0}),e.jsx(B,{checked:!!t.getsColumnAlert,onChange:()=>m("getsColumnAlert"),label:"Gets Column Alerts"}
1),e.jsx(B,{checked:!!t.getsNewsletter,onChange:()=>m("getsNewsletter"),label:"Gets TIS Newsletter"}),i&&e.jsx(B,{checked:!!t.disableUserFeed,onChange:()=>m("disableUserFeed"),label:"Hide Personalized Recs"})]})}function B({checked:t,onChange:s,label:n,hidden:a=!1,style:i={}}){return e.jsx("div",{className:"control",children:e.jsxs("label",{style:{display:a?"none":void 0,marginLeft:"0.5rem",fontSize:"0.875rem",userSelect:"none",...i},children:[e.jsx("input",{type:"checkbox",checked:t,onChange:s,style:{borderRadius:"4px"}})," ",e.jsx("span",{children:n})]})})}const Ma="temp_fix-Kuqp-",$a={temp_fix:Ma};function ei({sections:t,mock:s=!1,debug:n=!1}){const{top_stories:a,top_rail:i,main_feed:c}=t,[r,m]=_.useState(n),[o,f]=_.useState(!1),[u,l]=_.useState(!1),[j,x]=_.useState({disableUserFeed:!1,hasAdFree:!1,isSubscriber:!1,getsNewsletter:!1}),{isActiveSubscriber:v}=qe(),{hasAdFree:C}=Xe();_.useEffect(()=>{x(h=>({...h,hasAdFree:!!C,isSubscriber:!!v}))},[C,v]);const{userFeed:p}=Ue({feedName:s?"mock":"user-feed",userId:typeof window<"u"&&new URLSearchParams(window.location.search).get("user_id")||void 0}),d=h=>{x(h),f(!!h.disableUserFeed)};return e.jsx(Oe,{fullLogo:!0,children:e.jsx("div",{style:{"--font-heading":"var(--font-condensed)","--font-heading-weight":"500","--font-subheading":"var(--font-sans)","--font-subheading-weight":"400"},className:$a.temp_fix,children:e.jsxs(ae,{override:2,children:[" ",s&&e.jsx("div",{style:{color:"var(--color-red)",fontWeight:"bold",textAlign:"center",marginBottom:"1rem"},children:"Mock Data Mode"}),e.jsx(Ta,{topStories:a,topRail:i,showDebug:r}),!j.hasAdFree&&e.jsx(Re,{item:{break_type:"ad",variant:"default",position:0,ad_index:0}}),n&&e.jsx(Fa,{state:j,onChange:d,compact:u,onCompactChange:l,hasUserFeedItems:!!p.items?.length,showDebug:r,onDebugChange:m}),e.jsx(ka,{segments:c?.segments,userRecs:p,breaks:c?.breaks||[],exclude:c?.exclude||[],userState:j,disableUserFeed:o,compact:u,debug:n,showDebugLabels:r,mock:s,children:e.jsx("a",{className:He.viewAllBtn,href:"/latest/","data-click-position":"homepage-mainfeed-view-all-stories",children:"View All Stories"})})]})})})}export{ei as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.