1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8650],{68650:function(e,t,n){"use strict";n.d(t,{Z:function(){return g}});var a=n(57437),r=n(2265),s=n(87138),o=n(66648),i=n(38472),l=n(30998),c=n(16463),d=n(49251),u=n(38797),f=n(25771);n(61915);let h={MOBILE:1,PASSWORD:2,OTP:3};function g(){let{passwordVisible:e,togglePasswordVisibility:t}=(0,r.useContext)(d.a),n=(0,c.useRouter)(),g=u.JK,{refreshSubscription:p}=(0,f.z)(),[m,x]=(0,r.useState)(h.MOBILE),[y,b]=(0,r.useState)(!1),[v,j]=(0,r.useState)(""),[w,S]=(0,r.useState)("+91"),[k,D]=(0,r.useState)(""),[N,C]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),[T,O]=(0,r.useState)(!0),[F,B]=(0,r.useState)("phone"),[A,I]=(0,r.useState)(""),[L,z]=(0,r.useState)(""),[R,U]=(0,r.useState)(""),[Z,W]=(0,r.useState)(""),[K,M]=(0,r.useState)(""),[_,H]=(0,r.useState)(["","","",""]),[J,V]=(0,r.useState)(""),[G,Y]=(0,r.useState)(30),[$,q]=(0,r.useState)(!1),Q=(0,r.useRef)([]),X="".concat(w).concat(k);(0,r.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.allSettled([fetch("https://restcountries.com/v3.1/all?fields=name,idd,flag,cca2"),fetch("https://ipapi.co/json/")]),n=[];if("fulfilled"===e.status&&e.value.ok){let t=await e.value.json(),a={"+1":"US"},r=new Set;n=t.map(e=>{var t,n,a,r;let s=(null===(t=e.idd)||void 0===t?void 0:t.root)||"",o=(null===(a=e.idd)||void 0===a?void 0:null===(n=a.suffixes)||void 0===n?void 0:n.length)===1?e.idd.suffixes[0]:"";return{name:(null===(r=e.name)||void 0===r?void 0:r.common)||"",code:s+o,flag:e.flag||"",cca2:e.cca2||""}}).filter(e=>e.code&&e.name&&e.code.length<=5).sort((e,t)=>{let n=a[e.code];if(n){if(e.cca2===n)return -1;if(t.cca2===n)return 1}return e.name.localeCompare(t.name)}).filter(e=>!r.has(e.code)&&(r.add(e.code),!0)),E(n)}else n=[{name:"India",code:"+91",flag:"\uD83C\uDDEE\uD83C\uDDF3",cca2:"IN"},{name:"United States",code:"+1",flag:"\uD83C\uDDFA\uD83C\uDDF8",cca2:"US"},{name:"United Kingdom",code:"+44",flag:"\uD83C\uDDEC\uD83C\uDDE7",cca2:"GB"},{name:"UAE",code:"+971",flag:"\uD83C\uDDE6\uD83C\uDDEA",cca2:"AE"},{name:"Singapore",code:"+65",flag:"\uD83C\uDDF8\uD83C\uDDEC",cca2:"SG"},{name:"Australia",code:"+61",flag:"\uD83C\uDDE6\uD83C\uDDFA",cca2:"AU"}],E(n);if("fulfilled"===t.status&&t.value.ok){let e=(await t.value.json()).country_calling_code;e&&n.some(t=>t.code===e)&&S(e)}}catch(e){console.error("Failed to load countries:",e)}finally{O(!1)}})()},[]),(0,r.useEffect)(()=>{if(m!==h.OTP)return;Y(30),q(!1);let e=setInterval(()=>{Y(t=>t<=1?(clearInterval(e),q(!0),0):t-1)},1e3);return()=>clearInterval(e)},[m]);let ee=async()=>{if(j(""),!A.trim()){z("Enter your username");return}z("");try{b(!0);let e=await i.Z.post("".concat(g,"/check-username-login"),{username:A});if(!e.data.exists){j("No account found. Please sign up first.");return}e.data.hasPassword?(M(e.data.phoneNumber),x(h.PASSWORD)):await en(e.data.phoneNumber)}catch(n){var e,t;j((null===(t=n.response)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.error)||"Something went wrong. Please try again.")}finally{b(!1)}},et=async()=>{if(j(""),!k.trim()){C("Enter your mobile number");return}if(k.length<5){C("Enter a valid mobile number");return}C("");try{b(!0);let e=await i.Z.post("".concat(g,"/check-phone"),{phoneNumber:X});if(!e.data.exists){j("No account found. Please sign up first.");return}e.data.hasPassword?x(h.PASSWORD):await en()}catch(n){var e,t;j((null===(t=n.response)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.error)||"Something went wrong. Please try again.")}finally{b(!1)}},en=async e=>{let t=e||X;try{b(!0),M(t),await i.Z.post("".concat(g,"/generateOTP"),{phoneNumber:t}),x(h.OTP)}catch(e){var n,a;j((null===(a=e.response)||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:n.error)||"Could not send OTP. Please try again.")}finally{b(!1)}},ea=async()=>{if(W(""),j(""),!R.trim()){W("Enter your password");return}try{b(!0);let e=await (0,l.signIn)("phone-password",{identifier:"phone"===F?X:A,password:R,role:"student",redirect:!1});if(null==e?void 0:e.error){if(e.error.includes("no_password")){W(""),await en();return}W("Invalid password. Please try again.");return}await el()}catch(e){j("Something went wrong. Please try again.")}finally{b(!1)}},er=async()=>{W(""),j(""),await en("phone"===F?X:K)},es=(e,t)=>{var n;if(!/^\d*$/.test(t))return;let a=[..._];a[e]=t.slice(-1),H(a),t&&e<3&&(null===(n=Q.current[e+1])||void 0===n||n.focus()),a.every(e=>""!==e)&&setTimeout(()=>ei(a.join("")),100)},eo=(e,t)=>{if("Backspace"===t.key&&!_[e]&&e>0){var n;null===(n=Q.current[e-1])||void 0===n||n.focus()}},ei=async e=>{var t,n,a,r;let s=e||_.join("");if(s.length<4){V("Enter the complete 4-digit OTP");return}V("");try{b(!0);let e=K||X;if(!(await i.Z.post("".concat(g,"/verifyOTP"),{phoneNumber:e,otp:s})).data.success){V("Invalid OTP. Please try again."),H(["","","",""]),null===(t=Q.current[0])||void 0===t||t.focus();return}let{token:n,userId:a,isNewUser:r,onboardingComplete:o,subscription:c}=(await i.Z.post("".concat(g,"/register-or-login"),{phoneNumber:e})).data,d=await (0,l.signIn)("phone-otp",{token:n,userId:a,phoneNumber:e,isNewUser:String(r),onboardingComplete:String(o),subscription:c?JSON.stringify(c):"",redirect:!1});if(null==d?void 0:d.error){V("Session creation failed. Please try again.");return}await el()}catch(e){V((null===(a=e.response)||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:n.message)||"Verification failed. Please try again."),H(["","","",""]),null===(r=Q.current[0])||void 0===r||r.focus()}finally{b(!1)}},el=async()=>{b(!0);try{await p(),n.push("/dashboard")}catch(e){console.error("Login redirect error:",e),n.push("/dashboard")}},ec=async()=>{$&&(H(["","","",""]),V(""),await en())};return(0,a.jsx)("div",{className:"login-container",children:(0,a.jsxs)("div",{className:"login-box",children:[(0,a.jsx)("div",{className:"logo-container",children:(0,a.jsx)(s.default,{href:"/",children:(0,a.jsx)(o.default,{src:"/assets/img/brands/SlateBook-logo.png",alt:"SlateBook Logo",width:160,height:48,className:"login-logo cursor-pointer"})})}),(0,a.jsx)("div",{style:{display:"flex",gap:6,marginBottom:28},children:[1,2,3].map(e=>(0,a.jsx)("div",{style:{height:4,flex:1,borderRadius:2,background:e<=m?"#ff8c00":"#e0e0e0",transition:"background 0.3s"}},e))}),v&&(0,a.jsx)("div",{className:"error-alert",children:v}),m===h.MOBILE&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{className:"form-title",children:"Welcome back"}),(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:20},children:[(0,a.jsx)("button",{onClick:()=>{B("phone"),I(""),z(""),j("")},style:{flex:1,padding:"8px 0",borderRadius:8,border:"none",cursor:"pointer",background:"phone"===F?"#ff8c00":"#f5f5f5",color:"phone"===F?"#fff":"#666",fontWeight:"phone"===F?600:400,fontSize:13,transition:"all 0.2s"},children:"Mobile Number"}),(0,a.jsx)("span",{style:{color:"#ccc",fontSize:12,flexShrink:0},children:"or"}),(0,a.jsx)("button",{onClick:()=>{B("username"),D(""),C(""),j("")},style:{flex:1,padding:"8px 0",borderRadius:8,border:"none",cursor:"pointer",background:"username"===F?"#ff8c00":"#f5f5f5",color:"username"===F?"#fff":"#666",fontWeight:"username"===F?600:400,fontSize:13,transition:"all 0.2s"},children:"Username"})]}),"phone"===F?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:4},children:[T?(0,a.jsx)("div",{style:{width:110,height:42,borderRadius:8,background:"#f5f5f5",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,color:"#999",flexShrink:0},children:"Loading..."}):(0,a.jsx)("select",{value:w,onChange:e=>S(e.target.value),className:"country-code-select",style:{width:110,flexShrink:0},children:P.map((e,t)=>(0,a.jsxs)("option",{value:e.code,children:[e.flag," ",e.code]},"".concat(e.cca2,"-").concat(t)))}),(0,a.jsx)("input",{type:"tel",value:k,onChange:e=>D(e.target.value.replace(/\D/g,"")),onKeyDown:e=>"Enter"===e.key&&et(),placeholder:"Mobile number",className:"form-input",style:{flex:1},maxLength:12,autoFocus:!0})]}),N&&(0,a.jsx)("p",{className:"error-text",children:N}),(0,a.jsx)("button",{className:"btn btn-primary w-100 login-btn",onClick:et,disabled:y||T,children:y?"Checking...":"Continue â"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"text",value:A,onChange:e=>{I(e.target.value),z("")},onKeyDown:e=>"Enter"===e.key&&ee(),placeholder:"Username",className:"form-input",style:{marginBottom:4},autoFocus:!0}),L&&(0,a.jsx)("p",{className:"error-text",children:L}),(0,a.jsx)("button",{className:"btn btn-primary w-100 login-btn",onClick:ee,disabled:y,children:y?"Checking...":"Continue â"})]}),(0,a.jsxs)("p",{className:"signup-link",children:["Don't have an account? ",(0,a.jsx)(s.default,{href:"/signup",children:"Sign up"})]})]}),m===h.PASSWORD&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{className:"form-title",children:"Enter your password"}),(0,a.jsxs)("p",{className:"mandatory-note",children:["phone"===F?"".concat(w," ").concat(k):A," ",(0,a.jsx)("button",{onClick:()=>{x(h.MOBILE),U(""),W(""),j("")},style:{background:"none",border:"none",color:"#ff8c00",cursor:"pointer",fontSize:13,textDecoration:"underline",padding:0,marginLeft:4},children:"Change"})]}),(0,a.jsxs)("div",{className:"password-wrapper",style:{position:"relative"},children:[(0,a.jsx)("input",{type:e?"text":"password",value:R,onChange:e=>{U(e.target.value),W("")},onKeyDown:e=>"Enter"===e.key&&ea(),placeholder:"Password",className:"form-input",autoFocus:!0}),(0,a.jsx)("button",{type:"button",className:"toggle-password",onClick:t,children:(0,a.jsx)("i",{className:"fa-duotone ".concat(e?"fa-eye":"fa-eye-slash")})})]}),Z&&(0,a.jsx)("p",{className:"error-text",children:Z}),(0,a.jsx)("button",{className:"btn btn-primary w-100 login-btn",onClick:ea,disabled:y,children:y?"Signing in...":"Login â"}),(0,a.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:16},children:(0,a.jsx)("button",{type:"button",onClick:er,disabled:y,style:{background:"none",border:"none",color:"#ff8c00",cursor:"pointer",fontSize:13,fontWeight:600},children:"Login with OTP instead"})}),(0,a.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:12},children:(0,a.jsx)(s.default,{href:"/resetPassword",style:{fontSize:13,color:"#888"},children:"Forgot password?"})})]}),m===h.OTP&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{className:"form-title",children:"Verify your number"}),(0,a.jsxs)("p",{className:"mandatory-note",children:["OTP sent to ",w," ",k," ",(0,a.jsx)("button",{onClick:()=>{x(h.MOBILE),H(["","","",""]),V(""),j("")},style:{background:"none",border:"none",color:"#ff8c00",cursor:"pointer",fontSize:13,textDecoration:"underline",padding:0,marginLeft:4},children:"Change"})]}),(0,a.jsx)("div",{style:{display:"flex",gap:10,justifyContent:"center",margin:"28px 0"},onPaste:e=>{let t=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,4);if(4===t.length){var n;H(t.split("")),null===(n=Q.current[3])||void 0===n||n.focus(),setTimeout(()=>ei(t),100)}},children:_.map((e,t)=>(0,a.jsx)("input",{ref:e=>Q.current[t]=e,type:"text",inputMode:"numeric",maxLength:1,value:e,onCh
1ange:e=>es(t,e.target.value),onKeyDown:e=>eo(t,e),autoFocus:0===t,style:{width:54,height:60,textAlign:"center",fontSize:24,fontWeight:600,border:e?"2px solid #ff8c00":"1.5px solid #e0e0e0",borderRadius:10,outline:"none",background:e?"#FFF3E0":"#fff",transition:"all 0.15s",caretColor:"transparent"}},t))}),J&&(0,a.jsx)("p",{className:"error-text",style:{textAlign:"center"},children:J}),y&&(0,a.jsx)("p",{style:{textAlign:"center",color:"#ff8c00",fontSize:13},children:"Verifying..."}),!y&&_.some(e=>""===e)&&(0,a.jsx)("button",{className:"btn btn-primary w-100 login-btn",onClick:()=>ei(),disabled:_.join("").length<4,children:"Verify OTP â"}),(0,a.jsx)("p",{style:{textAlign:"center",marginTop:20,fontSize:13,color:"#888"},children:$?(0,a.jsx)("button",{onClick:ec,style:{background:"none",border:"none",color:"#ff8c00",cursor:"pointer",fontSize:13,textDecoration:"underline"},children:"Resend OTP"}):(0,a.jsxs)(a.Fragment,{children:["Resend OTP in ",(0,a.jsxs)("strong",{children:[G,"s"]})]})})]})]})})}},38797:function(e,t,n){"use strict";n.d(t,{JK:function(){return a},sG:function(){return r}});let a="https://api.slatebook.ai",r="https://backend.slatebook.ai"},25771:function(e,t,n){"use strict";n.d(t,{z:function(){return f}});var a=n(57437),r=n(30998),s=n(2265),o=n(67185),i=n(12808),l=n(87138),c=n(49251);function d(e){let{variant:t="warning",iconClass:n="fas fa-frown",title:r,message:d,ctaText:u,ctaHref:f,supportEmail:h="[email protected]"}=e,{isLightTheme:g}=(0,s.useContext)(c.a),p=g?"text-dark":"text-light";return(0,a.jsx)("div",{className:"d-flex vh-100 justify-content-center align-items-center px-3",children:(0,a.jsx)(o.Z,{bg:g?"light":"dark",text:g?"dark":"white",border:t,style:{maxWidth:"24rem",width:"100%"},className:"text-center shadow-sm",children:(0,a.jsxs)(o.Z.Body,{children:[(0,a.jsx)("i",{className:"".concat(n," display-1 mb-3 ").concat(p)}),(0,a.jsx)(o.Z.Title,{className:"h4 mb-2 ".concat(p),children:r}),(0,a.jsx)(o.Z.Text,{className:"".concat(p," mb-4"),children:d}),(0,a.jsx)(l.default,{href:f,passHref:!0,children:(0,a.jsx)(i.Z,{variant:"danger"===t?"danger":"primary",className:"mb-3",children:u})}),(0,a.jsx)("hr",{className:g?"":"border-light"}),(0,a.jsxs)("div",{className:"text-start small ".concat(p),children:[(0,a.jsx)("p",{className:"mb-1",children:(0,a.jsx)("strong",{children:"Need help?"})}),(0,a.jsxs)("p",{className:"mb-0",children:["Email us at ",(0,a.jsx)("a",{className:p,href:"mailto:".concat(h),children:h})]})]})]})})})}var u=n(38797);function f(){var e,t;let{data:n,status:o}=(0,r.useSession)(),[i,l]=(0,s.useState)(null),[c,f]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!0),p=(0,s.useCallback)(async()=>{var e;if(!(null==n?void 0:null===(e=n.user)||void 0===e?void 0:e.accessToken)){l(null),f(!1),g(!1);return}try{g(!0);let e=await fetch("".concat(u.JK,"/get_subscription"),{headers:{Authorization:"Bearer ".concat(n.user.accessToken)}});if(e.ok){let t=await e.json();l(t),f(new Date(t.endDate)<new Date)}else l(null),f(!1)}catch(e){console.error("Failed to refresh subscription:",e),l(null),f(!1)}finally{g(!1)}},[null==n?void 0:null===(e=n.user)||void 0===e?void 0:e.accessToken]);(0,s.useEffect)(()=>{p()},[p]);let m="loading"===o||h,x=null;return m?x=(0,a.jsx)("div",{className:"d-flex vh-100 justify-content-center align-items-center",children:(0,a.jsx)("img",{src:"/assets/gif/Blocks.gif",alt:"Loading...",style:{width:"150px",height:"150px"}})}):i?c&&"Free"!==i.plan?x=(0,a.jsx)(d,{variant:"danger",iconClass:"bi bi-lock-fill text-danger",title:"Plan Expired",message:"Your ".concat(i.plan," plan expired on ").concat(new Date(i.endDate).toLocaleDateString(),". Renew now to restore full access and pick up right where you left off."),ctaText:"Upgrade Now",ctaHref:"/user-account"}):"Free"===i.plan&&(null!==(t=i.remainingCredits)&&void 0!==t?t:0)<=0&&(x=(0,a.jsx)(d,{variant:"warning",iconClass:"bi bi-battery-low text-warning",title:"Credits Exhausted",message:"You have used all your free credits. Upgrade to a Basic, Premium or Platinum plan to get unlimited access and continue your learning journey.",ctaText:"Upgrade Now",ctaHref:"/user-account"})):x=(0,a.jsx)(d,{variant:"danger",iconClass:"fas fa-sad-tear",title:"Oops, you donât have any plans",message:"Please subscribe to a Basic, Premium or Platinum plan to continue your journey.",ctaText:"Upgrade Plan",ctaHref:"/user-account"}),{loading:m,subscription:i,expired:c,subscriptionAlert:x,refreshSubscription:p}}},61915:function(){}}]);
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.