PageSourceSearch

https://www.ok.co.uk/nav-web-static/main-845a7bd6bcfe540cfbbbfa18b…/static/chunks/3266.6e5bb11ab4539360.js

js ok.co.uk collected 2026-10-02 03:28:42 UTC 16,917 bytes, 2 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3266],{3266:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>Z});var s=l(95155),n=l(12115),a=l(18692),r=l(40457),o=l(5897),i=l(82866),c=l.n(i),d=l(76203);let u=async(e,t,l)=>{let s=new Headers;s.append("accept","application/json"),s.append("Content-Type","application/json");let n=await fetch(e,{mode:"cors",method:"POST",headers:s,body:JSON.stringify({option:t,publication:l})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Vote failed with status ${n.status}`)}return n},p=async e=>{let{email:t,publicationId:l,consentDate:s,consentAccepted:n,newsletterPublicIntegrations:a,mailingLists:r,pollTitle:o,consentText:i}=e,c=new Date,u=`${c.toLocaleString("en-GB",{month:"short"})}${String(c.getFullYear()).slice(2)}`,p=o.replace(/[^a-zA-Z0-9]/g,""),_=`${u}_CUEPoll_${p}`;try{let e=await fetch(`${a}/integrations/public`,{mode:"cors",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,signupSource:"CUEPolls",subSignupSource:_,mailingListIds:r.map(e=>e.id),consentAccepted:n,consentStatementId:"2",consentStatementText:i,brandId:l,consentDate:s})}),o=await e.json().catch(()=>null);if(!o||!Array.isArray(o.data))return(0,d.A)().error({message:"PollNewsletter: unrecognised integrations response",statusCode:e.status}),{ok:!1};let c=o.data.some(e=>e?.success===!0);return c||(0,d.A)().error({message:"PollNewsletter: integrations request reported all subscriptions failed",statusCode:e.status}),{ok:c}}catch(e){return(0,d.A)().error({message:"PollNewsletter: integrations request failed",error:e}),{ok:!1}}};var _=l(7927),m=l(26180),h=l(96074),x=l(47255),g=l(16440),w=l.n(g),b=l(57261);let f=function({id:e,publication:t,question:l,results:n,imageData:a,closed:r,className:o}){let i=n?.reduce((e,t)=>e+t,0)??0,c=[w()["poll-heading"],(0,h.Q1)(t),(0,x.gR)(t)?w()["cu-fontweight"]:w()["le-fontweight"]].join(" ");return(0,s.jsxs)("div",{className:(0,_.t)(w()["poll-lead-image"],o),children:[(0,s.jsx)("h2",{className:c,id:`${e}-heading`,children:l}),(0,s.jsxs)("p",{className:w()["vote-count"],children:[r?(0,s.jsxs)(s.Fragment,{children:["POLL CLOSED",(0,s.jsx)("br",{})]}):null,i,i>=100?"+":""," Votes",r?"":" so far"]}),a?.src?(0,s.jsx)("div",{className:w()["poll-image-container"],children:(0,s.jsx)(m.A,{alt:a.altText||"",className:w()["poll-image"],src:a.src})}):null,a?.src&&a?.caption?(0,s.jsx)(b.A,{captionCredit:a.credits,captionTitle:a.caption}):null]})},j=(0,n.forwardRef)(function({id:e,publication:t,question:l,results:a,imageData:r,options:o,pollApiUrl:i,onSelectionChange:p},_){let[m,h]=(0,n.useState)(null),x=(0,n.useRef)(null),g=(0,n.useRef)([]),w=(0,n.useRef)(o.length);w.current=o.length;let b=(0,n.useCallback)(async()=>{if(null!==x.current)try{await u(i,x.current,t)}catch(e){throw(0,d.A)().error({message:"Failed to cast vote",error:e}),e}},[i,t]);(0,n.useImperativeHandle)(_,()=>({submit:b}),[b]);let j=(0,n.useCallback)(e=>{h(e),x.current=e,p?.(!0,e)},[p]),k=(0,n.useCallback)(e=>{let t,l=g.current.indexOf(e.currentTarget),s=w.current;if("ArrowDown"===e.key||"ArrowRight"===e.key)e.preventDefault(),t=(l+1)%s;else{if("ArrowUp"!==e.key&&"ArrowLeft"!==e.key)return;e.preventDefault(),t=(l-1+s)%s}j(t),g.current[t]?.focus()},[j]);return(0,s.jsxs)("section",{className:c()["step1-container"],children:[(0,s.jsx)(f,{id:e,imageData:r,publication:t,question:l,results:a}),(0,s.jsx)("div",{"aria-labelledby":`${e}-options`,className:c()["poll-options"],"data-testid":"poll-options",role:"group",children:o.map((t,l)=>(0,s.jsx)("button",{"aria-pressed":m===l,className:`${c()["poll-button"]} ${m===l?c().selected:""}`,"data-testid":`poll-option-${l}`,id:`${e}-${l}`,onClick:()=>j(l),onKeyDown:k,ref:e=>{g.current[l]=e},type:"button",children:t.text},t.option))})]})});var k=l(50910),N=l(58487),P=l.n(N);let v=function({children:e,id:t,...l}){let a=(0,n.useId)(),r=t||a;return(0,s.jsxs)("div",{className:P()["checkbox-wrapper"],children:[(0,s.jsx)("input",{className:P()["checkbox-input"],id:r,type:"checkbox",...l}),(0,s.jsx)("label",{className:P()["checkbox-label"],htmlFor:r,children:e})]})};var y=l(71660),S=l(3977),C=l(90505),E=l(84868),L=l.n(E);let A=(0,n.forwardRef)(function({consentDate:e,newsletters:t,publicationId:l,publicationName:a,newsletterPublicIntegrations:r,pollTitle:o,onSelectionChange:i},c){let d=(0,k.c3)("components.molecules.PollNewsletter"),u=d("consentText"),[_,m]=(0,n.use
1State)(""),[h,x]=(0,n.useState)(!1),[g,w]=(0,n.useState)(!1),[b,f]=(0,n.useState)(!1),[j,N]=(0,n.useState)(new Map),P=(0,n.useCallback)((e,t,l)=>{let s=e.trim().length>0,n=t.size>0;if(l)return void i?.((0,C.A)(e));let a=!s&&!n||(0,C.A)(e)&&n;i?.(a)},[i]),E=(0,n.useCallback)(e=>{let t=e.target.value;m(t),x(t.trim().length>0&&!(0,C.A)(t)),P(t,j,b)},[j,b,P]),A=(0,n.useCallback)(e=>{let{checked:t}=e.target;f(t),P(_,j,t)},[_,j,P]),I=(0,n.useCallback)(async()=>{let t=_.trim().length>0,s=j.size>0;if(!t&&!s)return{skipped:!0};if(t&&!s&&!b)throw w(!0),Error("validation");let{ok:n}=await p({email:_,publicationId:l,consentDate:e,consentAccepted:b,newsletterPublicIntegrations:r,mailingLists:Array.from(j,([e,t])=>({id:e,label:t})),pollTitle:o,consentText:u});return{skipped:!1,submitted:n,consentAccepted:b}},[_,j,l,r,e,b,o,u]);return(0,n.useImperativeHandle)(c,()=>({submit:I}),[I]),(0,s.jsxs)("section",{className:L()["newsletter-section"],"data-testid":"poll-newsletter",children:[(0,s.jsx)("h3",{className:L()["newsletter-heading"],children:d("title")}),(0,s.jsxs)("div",{className:L()["newsletter-list-container"],children:[(0,s.jsx)("p",{className:L()["newsletter-description"],children:d("description")}),(0,s.jsx)("div",{className:L()["newsletter-list"],"data-testid":"poll-newsletter-list",children:t?.length>0?t.map(e=>(0,s.jsx)(v,{"data-testid":`poll-newsletter-checkbox-${e.mailing_list_id}`,name:e.mailing_list_pref_label,onChange:t=>{var l,s,n;let a;return l=e.mailing_list_id,s=e.mailing_list_pref_label,n=t.target.checked,a=new Map(j),void(n?a.set(l,s):a.delete(l),N(a),P(_,a,b),g&&w(!1))},value:e.mailing_list_id,children:(0,s.jsxs)("span",{className:L()["newsletter-item"],children:[(0,s.jsxs)("strong",{className:L()["newsletter-item-title"],children:[e.mailing_list_pref_label,":"]})," ",e.description]})},e.mailing_list_id)):null}),g||_&&!h&&!b&&0===j.size?(0,s.jsxs)("span",{className:L()["validation-error"],"data-testid":"poll-newsletter-checkbox-error",children:[(0,s.jsx)(S.A,{}),d("newsletterSelectionRequired")]}):null]}),(0,s.jsxs)("div",{className:L()["email-container"],children:[(0,s.jsx)("p",{className:L()["email-label"],children:d("emailLabel")}),(0,s.jsx)(y.A,{className:L()["newsletter-email-input"],"data-testid":"poll-newsletter-email-input",isValid:!h,onChange:E,placeholder:d("enterEmail"),type:"email",value:_}),h||!_&&(j.size>0||b)?(0,s.jsxs)("span",{className:L()["validation-error"],"data-testid":"poll-newsletter-email-error",children:[(0,s.jsx)(S.A,{}),d("emailInvalid")]}):null,(0,s.jsx)(v,{checked:b,"data-testid":"poll-consent-checkbox",name:"poll-marketing-consent",onChange:A,children:(0,s.jsxs)("span",{className:L()["marketing-consent-container"],children:[d("marketingConsentText",{publicationName:a})," ",(0,s.jsx)("a",{className:L()["reach-family"],href:"https://www.reachplc.com/about-us/our-brands",rel:"noopener noreferrer",children:d("reachFamily")})]})}),(0,s.jsxs)("p",{className:L()["consent-container"],children:[d("consentText")," ",(0,s.jsx)("a",{className:L()["more-info-here"],href:"/privacy-notice/",rel:"noopener noreferrer",children:d("here")})]})]})]})});var I=l(79548),R=l.n(I);let T=function({optionText:e,percentage:t}){return(0,s.jsxs)("div",{className:R()["result-row"],children:[(0,s.jsxs)("span",{className:R()["percentage-label"],children:[t,"%"]}),(0,s.jsx)("div",{className:R()["bar-container"],children:(0,s.jsx)("div",{className:R()["bar-fill"],style:{width:`${t}%`}})}),(0,s.jsx)("span",{className:R()["option-text"],children:e}),(0,s.jsxs)("span",{className:R()["sr-only"],children:[e,", ",t," percent"]})]})},D=function(e){let t=e.reduce((e,t)=>e+t,0);if(0===t)return e.map(()=>0);let l=e.map(e=>e/t*100),s=l.map(e=>Math.floor(e)),n=l.map((e,t)=>e-s[t]),a=100-s.reduce((e,t)=>e+t,0),r=n.map((e,t)=>t).sort((t,l)=>n[l]-n[t]||e[l]-e[t]);for(let e=0;a>0;e++)s[r[e]]+=1,a-=1;return s},$=function({id:e,publication:t,question:l,results:n,options:a,closed:r,hideResults:o}){let i=D(n??[]);return(0,s.jsxs)("section",{"aria-labelledby":`${e}-heading`,className:R()["results-container"],role:"region",children:[(0,s.jsx)(f,{className:R()["lead-image"],closed:r??!1,id:e,publication:t,question:l,results:n}),o?null:(0,s.jsx)("div",{className:R()["results-list"],"data-testid":"poll-results-bars",children:a.map((e,t)=>(0,s.jsx)(T,{optionText:e.text,percentage:i[t]},e.option))})]})};var O=l(73477),M=l.n(O);let V=function(){return(0,s.jsxs)("div",{className:M()["skeleton-container"],children:[(0,s.jsx)("div",{className:M()["skeleton-badge"]}),(0,s.jsx)("div",{className:M()["skeleton-image"]}),(0,s.jsx)("div",{className:M()["skeleton-line"]}),(0,s.jsx)("div",{className:M()["skeleton-line-short"]}),(0,s.jsx)("div",{className:M()["skeleton-option"]}),(0,s.jsx)("div",{className:M()["skeleton-option"]}),(0,s.jsx)("div",{className:M()["skeleton-option"]}),(0,s.jsx)("div",{className:M()["skeleton-option"]}),(0,s.jsx)("div",{className:M()["skeleton-button"]})]})};var J=l(79712),Q=l(88104),q=l(76945);let F=(e,t)=>`poll-step-${e}-${t}`;var G=l(81572),U=l.n(G);let Z=function({publication:e="curiously",publicationId:t,publicationName:l,question:i,options:c,closed:u,hideResults:p,id:_,articleId:m,dataTestId:h="poll",dataTmDataTrack:x="inline-widget",dataTmdatatrackType:g,results:w,imageData:b,pollApiUrl:f,newsletters:k,newsletterPublicIntegrations:N,consentDate:P}){let{actions:{clickEvent:v},state:{client:{analytics:y}}}=(0,J.w)(e=>e),S=(0,Q.A)(e=>(0,q.SM)(e)),C=k?.length>
10,[E,L]=(0,n.useState)(null),[I,R]=(0,n.useTransition)(),[T,D]=(0,n.useState)(!1),[O,M]=(0,n.useState)(null),G=(0,n.useRef)(null),Z=(0,n.useRef)(null),B=(0,n.useRef)(null),z=(0,n.useRef)(null),H=(0,n.useRef)(!1),Y=(0,n.useRef)(S);(0,n.useEffect)(()=>{Y.current=S},[S]),(0,n.useEffect)(()=>{let e=((e,t,l,s)=>{let n;if(l)return window.localStorage.removeItem(F(e,t)),3;let a=(n=window.localStorage.getItem(F(e,t)))?Number(n):null;if(a){let e=Math.min(a,3);return 2!==e||s?e:3}return 1})(_,m,u,C);L(e),D(2===e)},[_,m,u,C]),(0,n.useEffect)(()=>{if(H.current&&(H.current=!1,B.current)){let e=document.querySelector("header"),t=Math.max(e?.getBoundingClientRect().bottom??0,0);Y.current&&document.getElementById("primis-mobile-fp-anchor")&&(t=Math.max(t,120));let l=B.current.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:l-t-24,behavior:"smooth"}),B.current.focus({preventScroll:!0})}},[E,S]);let K=(0,n.useCallback)((e,t)=>{D(e),void 0!==t&&(z.current=t)},[]),W=(0,n.useCallback)(()=>{R(async()=>{try{if(1===E&&G.current&&(await G.current.submit(),v("POLL:VOTE_COMPLETED",{componentID:_,...y}),null!==z.current)){let e=[...w??[]];e[z.current]=(e[z.current]??0)+1,M(e)}if(2===E&&Z.current){let{skipped:e=!1,submitted:t=!1,consentAccepted:l=!1}=await Z.current.submit()??{};e?v("POLL:NEWSLETTER_SKIPPED",{componentID:_,...y}):t&&(v("POLL:NEWSLETTER_SUBMITTED",{componentID:_,...y}),v(l?"POLL:CONSENT_ACCEPTED":"POLL:CONSENT_DECLINED",{componentID:_,...y}))}H.current=!0;let e=(E??1)+1,t=2!==e||C?Math.min(e,3):3;L(t),window.localStorage.setItem(F(_,m),`${t}`)}catch(e){(0,d.A)().error({message:"Poll: failed to advance step",error:e})}})},[E,C,w,v,_,y,m]),X=I||3===E||1===E&&!T||2===E&&!T;return null===E?(0,s.jsx)("section",{"aria-busy":"true","aria-label":"Loading poll",className:U()["poll-container"],children:(0,s.jsx)("div",{className:U()["poll-wrapper"],children:(0,s.jsx)(V,{})})}):(0,s.jsx)(o.default,{children:(0,s.jsx)("section",{"aria-labelledby":`poll-heading-${_}`,className:U()["poll-container"],ref:B,tabIndex:-1,children:(0,s.jsxs)("div",{className:U()["poll-wrapper"],children:[(0,s.jsx)("header",{className:U()["top-heading"],children:(0,s.jsx)(r.A,{linkText:"POLL"})}),(0,s.jsxs)("div",{"aria-describedby":`${_}-body`,"aria-label":i,className:U()["step-container"],"data-testid":h,"data-tmdatatrack":x,"data-tmdatatrack-articleid":_,"data-tmdatatrack-type":g,children:[1===E?(0,s.jsx)(j,{id:_,imageData:b,onSelectionChange:K,options:c,pollApiUrl:f,publication:e,question:i,ref:G,results:w}):null,2===E?(0,s.jsx)(A,{consentDate:P,newsletterPublicIntegrations:N,newsletters:k,onSelectionChange:D,pollTitle:i,publicationId:t,publicationName:l,ref:Z}):null,3===E?(0,s.jsx)($,{closed:u,hideResults:p,id:_,options:c,publication:e,question:i,results:O??w}):null,u?null:(0,s.jsxs)("footer",{className:U()["cta-container"],children:[(0,s.jsx)("ol",{className:U()["step-dots"],children:Array.from({length:3},(e,t)=>(0,s.jsx)("li",{"aria-current":t+1===E?"step":void 0,"aria-label":`Step ${t+1}`,className:t+1===E?U()["dot-active"]:U().dot},t))}),E<3?(0,s.jsx)(a.A,{dataTestId:"poll-next-button",design:"primary",disabled:X,label:"Next",onClick:W}):null]})]})]})})})}},3977:(e,t,l)=>{"use strict";l.d(t,{A:()=>n});var s=l(95155);let n=({size:e=18})=>(0,s.jsxs)("svg",{width:e,height:e,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsxs)("g",{clipPath:"url(#clip0_5118_2332)",children:[(0,s.jsx)("circle",{opacity:"0.16",cx:"9",cy:"9",r:"6.75",fill:"#EA3D3E"}),(0,s.jsx)("circle",{cx:"9",cy:"9",r:"6.75",stroke:"#EA3D3E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("rect",{x:"9",y:"12",width:"0.0075",height:"0.0075",stroke:"#EA3D3E",strokeWidth:"2.25",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M9 9L9 6",stroke:"#EA3D3E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,s.jsx)("defs",{children:(0,s.jsx)("clipPath",{id:"clip0_5118_2332",children:(0,s.jsx)("rect",{width:"18",height:"18",fill:"white"})})})]})},16440:e=>{e.exports={"poll-lead-image":"PollLeadImage_poll-lead-image__jZuQl","poll-heading":"PollLeadImage_poll-heading__Gx0n1","cu-fontweight":"PollLeadImage_cu-fontweight__7JNyK","le-fontweight":"PollLeadImage_le-fontweight__ufGam","vote-count":"PollLeadImage_vote-count__G_gNL","poll-image-container":"PollLeadImage_poll-image-container__9QpMe","poll-image":"PollLeadImage_poll-image__HXgdc"}},58487:e=>{e.exports={"checkbox-wrapper":"Checkbox_checkbox-wrapper__vQ_Un","checkbox-input":"Checkbox_checkbox-input__J_KTQ","checkbox-label":"Checkbox_checkbox-label__A95QS"}},73477:e=>{e.exports={"skeleton-container":"PollSkeleton_skeleton-container__TowZM","skeleton-badge":"PollSkeleton_skeleton-badge__VUZ9m","skeleton-pulse":"PollSkeleton_skeleton-pulse__gAsoc","skeleton-image":"PollSkeleton_skeleton-image__9Swm1","skeleton-line":"PollSkeleton_skeleton-line__Kp_DE","skeleton-line-short":"PollSkeleton_skeleton-line-short__bScVp","skeleton-option":"PollSkeleton_skeleton-option__qQNeS"}},79548:e=>{e.exports={"results-container":"PollResults_results-container__cOfkZ","lead-image":"PollResults_lead-image__snvjy","results-list":"PollResults_results-list__kFAX_","result-row":"PollResults_result-row__CYQC_","percentage-label":"PollResults_percentage-label__Py2PZ","bar-container":"PollResults_bar-container__cXFIC","bar-fill":"PollResults_bar-fill__4XJS5","bar-grow":"PollResults_bar-grow___aJxu","option-text":"PollResults_option-text__6HB5p","sr-only":"PollResults_sr-only__pedl3"}},81572:e=>{e.exports={"poll-container":"Poll_poll-container__66GSR","poll-wrapper":"Poll_poll-wrapper__GEzx8","top-heading":"Poll_top-heading__J0mbM","step-container":"Poll_step-container__FDbmi","cta-container":"Poll_cta-container__dVZ0U","step-dots":"Poll_step-dots__PYdlH",dot:"Poll_dot__upZkG","dot-active":"Poll_dot-active__KojW7"}},82866:e=>{e.exports={"step1-container":"PollVote_step1-container__ZCzIn","poll-options":"PollVote_poll-options__YxFdJ","poll-button":"PollVote_poll-button__Bm0DE",selected:"PollVote_selected__jl4fJ"}},84868:e=>{e.exports={"newsletter-section":"PollNewsletter_newsletter-section__2RUjh","newsletter-heading":"PollNewsletter_newsletter-heading__unmYD","newsletter-description":"PollNewsletter_newsletter-description__dTaI_","newsletter-list-container":"PollNewsletter_newsletter-list-container__vD1ge","newsletter-list":"PollNewsletter_newsletter-list__9GLRe","newsletter-item":"PollNewsletter_newsletter-item__MIQNu","newsletter-item-title":"PollNewsletter_newsletter-item-title__8diYV","email-label":"PollNewsletter_email-label__QbyON","email-container":"PollNewsletter_email-container__X0h0T","newsletter-email-input":"PollNewsletter_newsletter-email-input__7jI7J","consent-container":"PollNewsletter_consent-container__v2juR","validation-error":"PollNewsletter_validation-error___jAOG","more-info-here":"PollNewsletter_more-info-here__h2H2s","marketing-consent-container":"PollNewsletter_marketing-consent-container__Oi3yt"}}}]);
2//# sourceMappingURL=3266.6e5bb11ab4539360.js.map

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.