PageSourceSearch

https://www.scientificamerican.com/static/entry/upgrade-offer.Ihku20mY.js

js scientificamerican.com collected 2026-10-01 07:50:00 UTC 8,910 bytes, 13 lines download raw bytes

1import{r as c,j as e}from"../chunks/vendor-react-DdEP1kCQ.js";import{D as w}from"../chunks/DefaultLayout-n0x-WG_8.js";import{h as y,i as v,j as _}from"../chunks/sciam-DxVNerXk.js";import{u as S,k as g,p as d,e as N,g as k}from"../chunks/core-DTFOJR-b.js";import{f as D,a as I}from"../chunks/pricing-C6VtaTQN.js";import{L as E}from"../chunks/Header-CbSg0nVW.js";import"../chunks/Header-CvZfB-VC.js";import"../chunks/sciam-BnjwuU5W.js";import"../chunks/vendor-shared-ShLQKC4n.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new r.Error().stack;t&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[t]="0af20d01-66a4-4e0b-87c2-12c631c80161",r._sentryDebugIdIdentifier="sentry-dbid-0af20d01-66a4-4e0b-87c2-12c631c80161")}catch{}})();const A="/static/assets/unProductImg-C8uQEn1D.png",P="container-8-eBl",T="upgradeOffer-3c7He",U="introSection-Yo-B-",C="introduction-65Uun",O="upgradeCard-hhpSp",L="upgradeImageSection-lMDYo",B="upgradeImage-9-aGk",M="offer-mGmiT",$="offerTitle-vUA4S",Y="price--gbuV",H="offerDescription-2dbKA",R="specialPrice-0k5FX",V="upgradeButton-LIIVb",F="benefits-VgIih",G="benefitsSection-JZbsB",J="listItem-TtRMM",W="benefitsHeader-otDo-",q="disclaimer-iPVYG",z="creditDisclaimerDesktop-GROu9",Z="creditDisclaimerMobile-4J29M",K="disclaimerLink-faRW0",Q="upgradeError-f8kIc",i={container:P,upgradeOffer:T,introSection:U,introduction:C,upgradeCard:O,upgradeImageSection:L,upgradeImage:B,offer:M,offerTitle:$,price:Y,offerDescription:H,specialPrice:R,upgradeButton:V,benefits:F,benefitsSection:G,listItem:J,benefitsHeader:W,disclaimer:q,creditDisclaimerDesktop:z,creditDisclaimerMobile:Z,disclaimerLink:K,upgradeError:Q},X=(r="")=>r?" "+r.trim():"",h=(r=0)=>I(r,{invalidFallback:"",zeroFallback:"",stripTrailingZero:!0}),x=(r=0)=>D(r,{fallback:"",outputStyle:"absolute"});function ee({offer:r}){return c.useEffect(()=>{d({event:"upgrade_offer_error",user:{offer_error:r.error}})},[]),e.jsxs("div",{className:i.upgradeError,children:[e.jsx("p",{children:e.jsx("b",{children:"Something went wrong while trying to retrieve your special offer."})}),e.jsxs("p",{children:["Please ",e.jsx("a",{href:"mailto:[email protected]",children:"contact support"}),"."]})]})}function re({offer:r}){return c.useEffect(()=>{d({event:"upgrade_offer_error",user:{offer_error:r.error}})},[]),e.jsxs("div",{className:i.upgradeError,children:[e.jsx("p",{children:e.jsx("b",{children:"Sorry, this offer has expired."})}),e.jsx("a",{className:i.upgradeButton,href:"/getsciam/",children:"See Subscription Options"})]})}function ie({offer:r}){return c.useEffect(()=>{d({event:"upgrade_offer_error",user:{offer_error:r.error}})},[]),e.jsxs("div",{className:i.upgradeError,children:[e.jsx("p",{children:"Something went wrong, this offer was intended for someone else."}),e.jsxs("p",{children:["Please ensure you're signed in using the email that received this special offer link, or"," ",e.jsx("a",{href:"mailto:[email protected]",children:"contact support"})," for assistance."]}),e.jsx("a",{className:i.upgradeButton,href:"/getsciam/",children:"See Subscription Options"})]})}function te({offer:r}){const t=x(r.offer_markdown);let s=`
2    As a loyal and valued subscriber, we want to invite you to upgrade to the Unlimited
3    subscription with a special${X(t)} discount (off our usual price of $199).
4  `;return r.offer_type==="free_upgrade"&&(s=`
5      As a loyal and valued subscriber, we want to invite you to upgrade to the Unlimited
6      subscription (valued at $199), at no additional cost.
7    `),e.jsxs("section",{className:i.introSection,children:[e.jsxs("div",{className:i.introduction,children:[e.jsx("p",{children:"Dear Reader,"}),e.jsx("p",{children:s})]}),e.jsx("div",{className:i.upgradeImageSection,children:e.jsx("img",{className:i.upgradeImage,src:A,alt:""})})]})}function p(r){return{offer_uuid:r.offer_id,offer_credit_amount:r.offer_credit_amount,offer_markdown:r.offer_markdown,offer_product_price:r.product_price,offer_term_id:r.term_id}}function se({offer:r,handlePurchaseButton:t,offerValidation:s}){if(r.error)return e.jsx("section",{className:i.upgradeCard,children:e.jsx(ee,{offer:r})});if(r.expire_timestamp!==null&&new Date>new Date(r.expire_timestamp))return e.jsx("section",{className:i.upgradeCard,children:e.jsx(re,{offer:r})});if(s==="invalid"||s==="error")return e.jsx("section",{className:i.upgradeCard,children:e.jsx(ie,{offer:r})});let o,a,n,l=`
8    *We value your commitment to supporting journalism, which is why we’re offering you a credit
9    for the remaining value of your current subscription. This credit will be used toward the
10    purchase of your Unlimited subscription. Your subscription starts today and will
11    automatically renew annually at a rate of $199 per year, plus sales tax where applicable.
12    Cancel at any time.
13  `;if(r.offer_type==="free_upgrade")o="A Free Upgrade to the Unlimited subscription",a="Enjoy the benefits of our premium subscription for the remainder of your term*",n="Your price today: $0";else{o=`${x(r.offer_markdown)} off the regular price of Unlimited`;const u=h(r.offer_credit_amount);u&&(a=`PLUS get a ${u} credit from your current subscription*`),n=`Your Price Today: ${h(r.offer_amount)}`}return e.jsxs("section",{className:i.upgradeCard,children:[e.jsxs("div",{className:i.offer,children:[e.jsx("h2",{className:i.offerTitle,children:o}),a&&e.jsx("p",{className:i.offerDescription,children:e.jsx("strong",{children:a})}),e.jsxs("div",{className:i.specialPrice,children:[e.jsx("h3",{className:i.price,children:n}),e.jsx("button",{className:i.upgradeButton,"data-click-position":"upgrade-offer-button",onClick:t,children:"Upgrade Now!"})]})]}),e.jsxs("div",{className:i.benefits,children:[e.jsxs("div",{className:i.benefitsSection,children:[e.jsx("p",{className:i.benefitsHeader,children:e.jsx("strong",{children:"Your upgrade includes these premium benefits:"})}),e.jsx("div",{children:e.jsxs("ul",{className:i.benefitsList,children:[e.jsx("li",{className:i.listItem,children:"Ad-free website experience"}),e.jsx("li",{className:i.listItem,children:"Print and online special editions"}),e.jsx("li",{className:i.listItem,children:"Subscriber-only newsletter from our Editor in Chief"}),e.jsx("li",{className:i.listItem,children:"Additional digital access to share ($39 value)"}),e.jsx("li",{className:i.listItem,children:"BONUS: SciAm tote bag"})]})})]}),e.jsx("p",{className:i.creditDisclaimerDesktop,children:l})]}),e.jsx("div",{className:i.creditDisclaimerMobile,children:e.jsx("p",{children:l})})]})}function ae(){return e.jsx("section",{children:e.jsx("div",{children:e.jsxs("p",{className:i.disclaimer,children:[e.jsx("strong",{children:"Automatic Renewal Program:"}),e.jsx("br",{}),"You can cancel your subscription at any time. After your initial term, your subscription will automatically renew until you cancel. We will email you a reminder prior to renewal with the renewal rate and date of expected charge. If you do nothing, we will charge the card entered here and your subscription will continue. You can cancel at any time for a refund of the remaining portion of your subscription, just visit your"," ",e.jsx("a",{href:"https://www.scientificamerican.com/account/",className:i.disclaimerLink,children:"subscription management page"})," ","or email us at"," ",e.jsx("a",{href:"mailto:[email protected]",className:i.disclaimerLink,children:"[email protected]"}),"."]})})})}function ne(){const t=S()?.offer,{isLoggedIn:s,login:o}=g(),a=()=>v(_(),t.term_id,t.promo_code),n=oe(t?.offer_id);c.useEffect(()=>{n==="valid"&&window.location.search.includes("checkout=true")&&a()},[n]);function l(u){if(d({event:"upgrade_offer_clicked",user:p(t)}),!s){o(window.location.pathname+window.location.search+"&checkout=true");return}a()}return c.useEffect(()=>d({event:"upgrade_offer_viewed",user:p(t)}),[]),y("checkoutComplete",()=>d({event:"upgrade_offer_purchased",user:p(t)})),e.jsxs("div",{className:i.container,children:[e.jsx(E,{title:"Exclusive Subscription Upgrade Offer"}),e.jsxs("div",{className:i.upgradeOffer,children:[e.jsx(te,{offer:t}),e.jsx(se,{offer:t,handlePurchaseButton:l,offerValidation:n}),e.jsx(ae,{})]})]})}function oe(r=null){const{user:t}=g(),{slug:s}=N(),{token:o}=k(),a=t?.email,[n,l]=c.useState("unknown"),[u,b]=c.useState(null);return c.useEffect(()=>{if(!a||!r||n==="valid")return;u?.abort?.();const m=new AbortController;b(m);const j=Object.create(globalThis.import_meta_env||null).PUBLIC_SA_API_HOST||"";fetch(`${j}/platform/api/v2/user/upsell-promocode/verify-user/?uuid=${r}`,{signal:m.signal,headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Authorization":o?`Bearer ${o}`:void 0,"x-auth-env":s}}).then(f=>f.json()).then(f=>l(f?.valid?"valid":"invalid")).catch(()=>l("error"))},[a,r]),n}function xe(){return e.jsx(w,{children:e.jsx(ne,{})})}
13export{xe 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.