1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[80503],{80503:(e,t,a)=>{a.r(t),a.d(t,{PhoneLoginModal:()=>y});var i=a(54568),n=a(7620),o=a(82175),r=a(79748),s=a(66888),l=a(22407),c=a(80250),d=a(54567),h=a(94191),u=a(54810),p=a(60616),m=a(72574),g=a(87242),x=a(18669),f=a(78611);function y({open:e,onClose:t,fullBleed:a=!1,redirectAfterLogin:b,onAuthenticated:j,headline:v="Welcome back.",subtitle:k="Enter your phone number to log back in to Flip."}){let w=(0,r.useRouter)(),B=(0,n.useMemo)(()=>(0,d.getSupabaseBrowserClient)(),[]),N=(0,f.G)(),[C,_]=(0,n.useState)("phone"),[P,F]=(0,n.useState)(u.a4.iso),[S,E]=(0,n.useState)(""),[D,I]=(0,n.useState)(["","","","","",""]),[R,$]=(0,n.useState)(!1),z=(0,n.useRef)([]),M=(0,n.useRef)(null),A=(0,n.useRef)(!1),O=(0,n.useRef)(!1),V=(0,u.E2)(P)??u.a4,W=(0,u.Rr)(V,S),J=`${V.dial} ${V.formatNational(S)}`,H=(0,u.Uu)(V,S);(0,n.useEffect)(()=>{e&&(_("phone"),F(u.a4.iso),E(""),I(["","","","","",""]))},[e]);let K=async e=>{let t=b??"/dashboard";try{let e=localStorage.getItem("auth_redirect_after_login");e&&e.startsWith("/")&&!e.startsWith("//")&&(t=e)}catch{}let a={ok:!1};try{let t=await fetch("/api/auth/establish",{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok)a=await t.json();else if(404===t.status){let e=await t.json().catch(()=>null);e?.reason}}catch{}try{localStorage.removeItem("auth_intent"),localStorage.removeItem("auth_redirect_after_login")}catch{}if(!a.ok){await B.auth.signOut({scope:"local"}),w.replace("/no-account");return}(0,g.Vj)(),j?j():w.replace(t)},L=async()=>{if(!H)return void s.o.error(V.minDigits===V.maxDigits?`Please enter a valid ${V.minDigits}-digit ${V.name} phone number`:`Please enter a valid ${V.name} phone number`);if(!A.current){if((0,m.oM)(W)){s.o.success("Demo account - enter the demo code"),_("otp");return}A.current=!0,$(!0);try{let{error:e}=await B.auth.signInWithOtp({phone:W,options:{channel:"sms"}});if(e)throw Error(e.message);s.o.success("Verification code sent!"),_("otp")}catch(e){s.o.error((0,p.t)(e,"Failed to send code. Please try again."))}finally{$(!1),A.current=!1}}},T=async()=>{if(O.current)return;let e=D.join("");if(6!==e.length)return void s.o.error("Please enter the 6-digit code");if(O.current=!0,$(!0),(0,m.oM)(W)){try{let a=await fetch("/api/demo/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phone:W,code:e})}),i=await a.json();if(!a.ok||!i.token)throw Error(i.error??"Demo login failed. Please try again.");t(),w.replace(`/login/${i.token}?next=/dashboard`)}catch(e){s.o.error((0,p.t)(e,"Demo login failed. Please try again.")),I(["","","","","",""]),_("otp")}finally{$(!1),O.current=!1}return}try{localStorage.setItem("auth_intent","login"),localStorage.removeItem("onboarding_source")}catch{}try{let{data:a,error:i}=await B.auth.verifyOtp({phone:W,token:e,type:"sms"});if(i||!a.session)throw Error(i?.message??"Verification failed. Please try again.");t(),await K(a.session)}catch(e){s.o.error((0,p.t)(e,"Verification failed. Please try again.")),I(["","","","","",""]),_("otp")}finally{$(!1),O.current=!1}};return(0,n.useEffect)(()=>{e&&"otp"===C&&D.every(e=>""!==e)&&!R&&T()},[D,C,e]),(0,i.jsx)(l.N,{children:e&&(0,i.jsx)(c.P.div,{className:a?"fixed inset-0 z-[100] flex min-h-full items-center justify-center overflow-y-auto bg-[#FAFAF8] px-5 py-6":"fixed inset-0 z-[100] flex items-end justify-center bg-black/55 backdrop-blur-[2px] md:items-center md:p-4",initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},onClick:a?void 0:t,children:(0,i.jsxs)(c.P.div,{ref:M,className:a?"relative w-full max-w-none border-0 bg-transparent shadow-none":"relative w-full overflow-hidden rounded-t-[28px] border border-white/40 bg-[#FAFAF8] shadow-[0_24px_80px_-20px_rgba(0,0,0,0.55)] md:max-w-[22rem] md:rounded-[28px]",initial:N?{opacity:0,scale:.96,y:16}:{opacity:1,scale:1,y:"100%"},animate:{opacity:1,scale:1,y:0},exit:N?{opacity:0,scale:.96,y:16}:{opacity:1,scale:1,y:"100%"},transition:{type:"spring",stiffness:420,damping:32},onClick:e=>e.stopPropagation(),children:[(0,i.jsx)("button",{type:"button",onClick:t,hidden:a,className:a?"hidden":"absolute right-4 top-4 z-10 flex h-8 w-8 items-center justify-center rounded-full text-[#1B1B1B]/45 transition-colors hover:bg-black/5 hover:text-[#1B1B1B]","aria-label":"Close",children:(0,i.jsx)("span",{className:"text-lg leading-none","aria-hidden":!0,children:"\xd7"})}),(0,i.jsx)("div",{className:"px-6 pb-6 pt-8",children:(0,i.jsxs)(l.N,{mode:"wait",children:["phone"===C&&(0,i.jsxs)(c.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2},className:"space-y-6",children:[(0,i.jsxs)("div",{className:"space-y-3 text-center",children:[(0,i.jsx)(o.default,{src:"/penguin-black-sm.gif",alt:"",width:44,height:54,unoptimized:!0,"aria-hidden":!0,className:"mx-auto h-11 w-auto -scale-x-100 object-contain"}),(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsx)("h2",{className:"font-hedvig text-[1.75rem] font-normal leading-none tracking-tight text-[#1B1B1B]",children:v}),(0,i.jsx)("p",{className:"mx-auto max-w-[16rem] font-inter text-[15px] leading-snug text-[#1B1B1B]/55",children:k})]})]}),(0,i.jsxs)("div",{className:"space-y-2.5",children:[(0,i.jsx)(h.j,{countryIso:P,onCountryChange:F,phoneDigits:S,onPhoneDigitsChange:E,disabled:R,autoFocus:!0,id:"login-phone",labelClassName:"sr-only",pickerContainerRef:M,onEnterKey:()=>void L()}),(0,i.jsx)(x.JH,{variant:"dark",onClick:()=>void L(),disabled:!H,loading:R,children:"Send code"})]})]},"login-phone"),"otp"===C&&(0,i.jsxs)(c.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2},className:"space-y-6",children:[(0,i.jsxs)("div",{className:"space-y-3 text-center",children:[(0,i.jsx)(o.default,{src:"/penguin-black-sm.gif",alt:"",width:44,height:54,unoptimized:!0,"aria-hidden":!0,className:"mx-auto h-11 w-auto -scale-x-100 object-contain"}),(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsx)("h2",{className:"font-hedvig text-[1.75rem] font-normal leading-none tracking-tight text-[#1B1B1B]",children:"Check your texts."}),(0,i.jsxs)("p",{className:"mx-auto max-w-[16rem] font-inter text-[15px] leading-snug text-[#1B1B1B]/55",children:["Enter the code sent to"," ",(0,i.jsx)("span",{className:"font-medium text-[#1B1B1B]",children:J})]})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"sr-only",htmlFor:"phone-login-otp-0",children:"Enter 6-digit code"}),(0,i.jsx)("div",{className:"flex justify-center gap-2",children:D.map((e,t)=>(0,i.jsx)("input",{id:0===t?"phone-login-otp-0":void 0,ref:e=>{z.current[t]=e},type:"text",inputMode:"numeric",autoComplete:"one-time-code",maxLength:6,value:e,onChange:e=>((e,t)=>{if(t.length>1){let a=t.replace(/\D/g,"").slice(0,6),i=[...D];for(let t=0;t<a.length;t++)e+t<6&&(i[e+t]=a[t]);I(i);let n=Math.min(e+a.length,5);z.current[n]?.focus()}else{let a=t.replace(/\D/g,""),i=[...D];i[e]=a,I(i),a&&e<5&&z.current[e+1]?.focus()}})(t,e.target.value),onKeyDown:e=>{"Backspace"===e.key&&!D[t]&&t>0&&z.current[t-1]?.focus()},className:"h-14 w-11 rounded-2xl border border-black/10 bg-[#F7F7F5] text-center text-2xl font-semibold tracking-tight text-[#1B1B1B] focus:border-black/20 focus:bg-white focus:outline-none",autoFocus:0===t},t))})]}),(0,i.jsx)(x.JH,{variant:"dark",onClick:()=>void T(),disabled:D.some(e=>!e),loading:R,children:"Verify"}),(0,i.jsx)("button",{type:"button",onClick:()=>{_("phone"),I(["","","","","",""])},className:"w-full py-1 font-inter text-[14px] tracking-tight text-[#1B1B1B]/45 transition-colors hover:text-[#1B1B1B]",children:"Use a different number"})]},"login-otp")]})})]})})})}}}]);
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.