(()=>{"use strict";const e=(e,t,n={})=>!(!newspackPopupsData||!newspackPopupsData[t])&&{...newspackPopupsData[t],...n,action:e},t=(e,t="np_prompt_interaction")=>{"function"==typeof gtag&&e&>ag("event",t,e)},n=e=>{const t=e.split("_");return parseInt(t[t.length-1])},s=e=>{const t=e.currentTarget.closest(".newspack-lightbox");t&&t.contains(e.currentTarget)&&(t.style.display="none"),t.overlayId&&window.newspackReaderActivation?.overlays&&window.newspackReaderActivation.overlays.remove(t.overlayId),e.preventDefault()},r=(e,t)=>{newspack_popups_view.debug&&(window.newspack_popups_debug=window.newspack_popups_debug||{},window.newspack_popups_debug[e]=t)};function o(e){return e?window.newspackPopupsCriteria.criteria[e]:window.newspackPopupsCriteria.criteria}window.newspackPopupsCriteria=window.newspackPopupsCriteria||{criteria:{}},window.newspackPopupsCriteria.criteria=window.newspackPopupsCriteria.criteria||{};const a=864e5,i={day:a,week:7*a,month:30*a},c=e=>{for(const t of e){const e=o(t.criteria_id);if(e&&!e.matches(t))return!1}return!0},p=(e,t=null)=>{const n=((e=null)=>{e||(e=window.location.search);const t=new URLSearchParams(e);return t.get("view_as")?t.get("view_as").split(";").reduce(((e,t)=>{const n=t.split(":");return 1===n.length?e[n[0]]=!0:e[n[0]]=n[1],e}),{}):null})(t);if(n?.segment)return n.segment;const s=[];for(const t in e)c(e[t].criteria)&&s.push({id:t,priority:e[t].priority});return s.length?(s.sort(((e,t)=>e.priority-t.priority)),s[0].id):null},u=(e,t,s,o=null)=>{const a=e.getAttribute("id"),c=[],p={element:e},u=(()=>{if(!0===o||!1===o)return p.override=!0,o||c.push("Prompt suppressed by override."),o;if(!s)return c.push("Prompt not displayed because RAS is not available."),!1;const[r,u,d,l]=e.getAttribute("data-frequency").split(","),w=s.store.get("pageviews");if(w[l]){const e=w[l].count||0;if(e<=parseInt(r))return c.push(`Prompt displayed starting at pageview ${parseInt(r)+1}. Reader has only ${e} pageviews.`),!1;if(0e.data?.prompt_id===t&&i[l]>Date.now()-e.timestamp));if(0=parseInt(d))return c.push(`Prompt already displayed the max of ${d} times.`),!1}const g=e.getAttribute("data-suppression");if(g){const e=s.store.get("utm_source")||[],t=new URLSearchParams(window.location.search).get("utm_source");let n=!1;if(-1m.indexOf(t)&&(c.push("Reader does not match prompt’s assigned segments."),1))})();return p.displayed=u,0{let t;const n=new IntersectionObserver((s=>{s.forEach((s=>{s.isIntersecting?t||(t=setTimeout((()=>{e(),n.unobserve(s.target)}),250)):t&&(clearTimeout(t),t=!1)}))}),{threshold:.5});return n};function l(e){"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}const w=e=>{const t=Date.now(),n={day:{count:0,start:t},week:{count:0,start:t},month:{count:0,start:t},...e.store.get("pageviews")||{}};let s;document.body.classList.forEach((e=>{0===e.indexOf("page-id-")&&(s=parseInt(e.replace("page-id-","")))})),s&&parseInt(newspack_popups_view?.donor_landing_page)===s&&e.store.set("is_donor",!0);for(const e in n)i[e]{const t=(t=null)=>{const o=newspack_popups_view?.segments||{},a=p(o);let i;r("matchingSegment",a),e.forEach((e=>{const r=e.getAttribute("id"),c=e.classList.contains("newspack-lightbox"),l=((e,t=!1,n=!1,s=null)=>e===((e=null)=>{e||(e=window.location.search);const t=new URLSearchParams(e);return t.get("pid")?parseInt(t.get("pid")):null})(s)||(!t||!n)&&null)(n(r),c,i);[...e.querySelectorAll(".newspack-lightbox__close, button.newspack-lightbox-overlay")].forEach((e=>{e.addEventListener("click",s)}));const w=u(e,a,t,l);if(!i&&c&&w&&(i=!0),w){const s=()=>{const t=e.getAttribute("data-delay")||0;setTimeout(a,t)},a=()=>{const r=p(o);u(e,r,t,l)&&(t?.overlays&&t.overlays.get().length?s():(e.classList.remove("hidden"),t&&((e,t)=>{d((()=>t.dispatchActivity("prompt_seen",{prompt_id:n(e.getAttribute("id"))}))).observe(e,{attributes:!0})})(e,t),c&&t?.overlays&&(e.overlayId=t.overlays.add())))};if(c)if(e.getAttribute("data-scroll")){const e=document.getElementById(`page-position-marker_${r}`);e&&d(a).observe(e)}else s();else a()}}))};newspack_popups_view.segments?(window.newspackRAS=window.newspackRAS||[],window.newspackRAS.push(t)):t()},m=s=>{s.forEach((s=>{new MutationObserver((r=>{r.forEach((r=>{"amp-access-hide"!==r.attributeName||"attributes"!==r.type||r.target.hasAttribute("amp-access-hide")||(()=>{const r=e("loaded",n(s.getAttribute("id")));t(r)})()}))})).observe(s,{attributes:!0})}))};window.newspackRAS=window.newspackRAS||[],window.newspackRAS.push((e=>{function t(t){const n=o(t.dataset.criteria);n&&(t.innerHTML=n.getValue(e),e.on("data",(()=>{t.innerHTML=n.getValue(e)})))}l((()=>{const e=document.querySelectorAll(".merge-tag");if(e.length)for(const n of e)n.dataset.criteria&&t(n)}))})),l((()=>{if(window.newspackRAS=window.newspackRAS||[],window.newspackRAS.push(w),!newspack_popups_view?.has_disabled_prompts){const s=[...document.querySelectorAll(".newspack-popup-container")];g(s),(s=>{"function"==typeof gtag&&(m(s),window.newspackRAS=window.newspackRAS||[],window.newspackRAS.push((n=>{n.on("activity",(({detail:{action:n,data:s}})=>{if("prompt_seen"===n){const{prompt_id:n}=s,r=e("seen",n);t(r)}}))})),(s=>{s.forEach((s=>{const r=s.querySelector(".newspack-lightbox__close"),o=[...s.querySelectorAll(".newspack-popup-container form")];if(r){const a=()=>{const r=e("dismissed",n(s.getAttribute("id")));t(r)};r.addEventListener("click",a),o.forEach((e=>{e.addEventListener("submit",(()=>r.removeEventListener("click",a)))}))}}))})(s),(s=>{s.forEach((s=>{const r=[...s.querySelectorAll(".newspack-popup-container a")],o=r=>{const o={};r.currentTarget?.href&&"#"!==r.currentTarget?.href&&(o.action_value=r.currentTarget.getAttribute("href"));const a=e("clicked",n(s.getAttribute("id")),o);t(a)};r.forEach((e=>e.addEventListener("click",o)))}))})(s),(s=>{s.forEach((s=>{const r=[...s.querySelectorAll(".newspack-popup-container form")],o=()=>{const r=e("form_submission",n(s.getAttribute("id")));t(r)};r.forEach((e=>e.addEventListener("submit",o)))}))})(s))})(s)}}))})();