1import me from"./BR2SjIP9.js";import ge from"./Dl1B8w5w.js";import{_ as ve}from"./DEWBa1i1.js";import{l as pe,A as ye,x as be,r as d,b as M,f as xe,B as U,v as Z,C as he,c as i,a as D,w as ke,o as a,j as o,m as T,u as s,k as x,D as Q,E as we,i as F,G as Ce,t as E,F as X,q as Se,H as _e,s as Pe,I as Ie,J as Oe,K as J,L as $e}from"#entry";import{u as q}from"./Cp20q_vb.js";import"./IljeZfEr.js";import"./em0n8Frv.js";import"./DpJz9ovz.js";import"./BiPjllOI.js";import"./DlAUqK2U.js";const Ne={class:"max-w-md mx-auto leading-loose px-4"},Te={class:"pt-6 sm:pt-12"},Ve={class:"bg-default-bg-light rounded-2xl shadow-lg border border-default-bg-lighter overflow-hidden"},Me={key:0,class:"p-8"},Ue={key:0},Ee={key:0,class:"mt-4 flex justify-between text-sm"},Re={key:1,class:"p-8 space-y-5"},je={class:"text-center"},Le={class:"text-sm text-default-text-lighter"},Be={class:"font-semibold text-indigo-500"},Ae={class:"flex gap-1.5 justify-center my-5"},De=["value","onInput","onKeydown"],Fe={key:0,class:"flex items-center text-default-bg-lightest text-xl select-none px-0.5"},Je={class:"space-y-1.5"},qe={key:0},ze={class:"flex justify-between text-xs text-default-text-lighter mb-1"},Ge={class:"font-mono font-medium text-default-text-light"},He={class:"w-full bg-default-bg-lighter rounded-full h-1"},Ke={key:1,class:"text-xs text-amber-600 dark:text-amber-400 text-center"},We={class:"flex items-center justify-between text-sm"},Ye=["disabled"],Ze={key:2,class:"p-8 text-center space-y-3"},Qe={class:"text-sm text-default-text-lighter"},Xe={class:"font-medium text-default-text-light"},v=8,ee="Sign In to Python Fiddle",ct={__name:"login",setup(et){const{$analytics:S}=pe(),h=ye().public,I=be(),l=d(""),O=d(!1),z=d(!1),R=d(null),j=d(null),c=d(!1),f=d(!1),k=M(()=>I.query.resetPassword??!1),w=d(""),_=d(""),b=d(0);let m=null;const p=d(Array(v).fill("")),P=d([]),G=M(()=>p.value.join("")),L=()=>{p.value=Array(v).fill("")},te=()=>{u.value=[],$.value=[]},H=t=>String(t??"").toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/[01IO]/g,"").slice(0,v),oe=(t,e)=>{const n=H(e.target.value),C=n?n[n.length-1]:"",y=[...p.value];y[t]=C,p.value=y,C&&t<v-1&&P.value[t+1]?.focus()},se=(t,e)=>{if(e.key==="Backspace"&&!p.value[t]&&t>0){const n=[...p.value];n[t-1]="",p.value=n,P.value[t-1]?.focus()}else e.key==="ArrowLeft"&&t>0?P.value[t-1]?.focus():e.key==="ArrowRight"&&t<v-1&&P.value[t+1]?.focus()},le=t=>{const e=H(t.clipboardData.getData("text")),n=Array(v).fill("");for(let y=0;y<Math.min(e.length,v);y++)n[y]=e[y];p.value=n;const C=Math.min(e.length,v-1);$e(()=>P.value[C]?.focus())};xe(()=>{m&&clearInterval(m)});const ne=t=>{const e=Math.floor(t/60),n=Math.max(t%60,0);return`${e}:${n.toString().padStart(2,"0")}`},K=()=>{m&&clearInterval(m),b.value=300,m=Oe(()=>{b.value--,b.value<=0&&(b.value=0,clearInterval(m))},1e3)},V=M(()=>c.value&&f.value?"Send Password Reset Email":c.value?"Sign In":k.value?"Reset Password":"Send Login Code");function B(t){if(t.status==="error")return alert(t.message),J("/login");Z().login(t),S.track("SIGN_IN",{email:t.user.email});const n=I.query.redirect??"/";return J(n)}const ae=M(()=>u.value.length>0),A=(t,e)=>t?.data?.message||t?.response?._data?.message||t?.response?.data?.message||e,{loading:re,errors:u,asyncHandler:ie}=q(async()=>{if(R.value.checkValidity()===!1){R.value.reportValidity();return}if(l.value=l.value.trim(),!c.value&&!f.value&&!k.value)try{await $fetch(`${h.backendUrl}/email-login-link`,{method:"POST",body:JSON.stringify({email:l.value})}),S.track("SIGN_IN_OTP_SENT",{email:l.value}),O.value=!0,L(),K()}catch(t){console.error("Send OTP error:",t),u.value=[A(t,"Unable to send verification code. Please try again.")]}else if(c.value&&!f.value){const t=await $fetch(`${h.backendUrl}/login-with-password`,{method:"POST",body:JSON.stringify({email:l.value,password:w.value})});B(t)}else if(f.value){const t=I.query.redirect??"/";await $fetch(`${h.backendUrl}/password-reset-link`,{method:"POST",body:JSON.stringify({email:l.value,url:`${h.siteUrl}/login?resetPassword=true&redirect=${t}`})}),z.value=!0,S.track("FORGOT_PASSWORD",{email:l.value})}else if(k.value){if(w.value!==_.value){alert("Passwords do not match");return}const t=await $fetch(`${h.backendUrl}/reset-password`,{method:"POST",body:JSON.stringify({email:l.value,password:w.value,passwordConfirm:_.value,token:I.query.token})});B(t)}}),{loading:ue,errors:$,asyncHandler:de}=q(async()=>
1{if(j.value.checkValidity()===!1){j.value.reportValidity();return}const t=G.value;if(t.length!==v){u.value=[`Please enter the ${v}-character code`];return}try{const e=await $fetch(`${h.backendUrl}/verify-otp`,{method:"POST",body:JSON.stringify({email:l.value,otp_code:t})});m&&clearInterval(m),B(e),S.track("SIGN_IN",{email:e.user.email}),S.conversion("AW-17636665751/K9vCCIfM6KobEJfT6NlB",void 0,"")}catch(e){console.error("Verify OTP error:",e),u.value=[A(e,"Invalid verification code. Please try again.")]}}),{loading:W,asyncHandler:Y}=q(async()=>{try{await $fetch(`${h.backendUrl}/email-login-link`,{method:"POST",body:JSON.stringify({email:l.value})}),S.track("SIGN_IN_OTP_RESENT",{email:l.value}),L(),K(),u.value=[]}catch(t){console.error("Resend OTP error:",t),u.value=[A(t,"Unable to resend verification code. Please try again.")]}}),ce=()=>{O.value=!1,L(),u.value=[],$.value=[],m&&clearInterval(m)};U([$],()=>{$.value.length>0&&(u.value=$.value)}),U(G,()=>{O.value&&te()});const fe=Z();return U(()=>fe.loggedIn,()=>J(I.query.redirect??"/")),U([V,l,w,_],()=>{u.value=[]}),he({title:ee,ogTitle:ee,description:V.value,ogDescription:V.value}),(t,e)=>{const n=me,C=ge,y=ve;return a(),i("div",null,[D(y,null,{default:ke(()=>[o("div",Ne,[o("div",Te,[e[23]||(e[23]=o("div",{class:"text-center mb-8"},[o("h1",{class:"text-4xl sm:text-5xl font-bold leading-tight tracking-tight"},[T(" Create, run, and share "),o("span",{class:"text-indigo-500"},"Python notebooks")])],-1)),o("div",Ve,[!s(O)&&!s(z)?(a(),i("div",Me,[e[11]||(e[11]=o("div",{class:"text-center mb-6"},[o("div",{class:"inline-flex items-center justify-center w-12 h-12 bg-indigo-500/15 rounded-full mb-3"},[o("svg",{class:"w-6 h-6 text-indigo-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})])]),o("h2",{class:"text-lg font-semibold"},"Sign in to your account")],-1)),o("form",{ref_key:"formEl",ref:R,class:"space-y-4"},[s(k)?x("",!0):(a(),i("div",Ue,[e[10]||(e[10]=o("label",{class:"block text-sm font-medium text-default-text-light mb-1.5"},"Email address",-1)),we(o("input",{id:"email","onUpdate:modelValue":e[0]||(e[0]=r=>F(l)?l.value=r:null),name:"email",type:"email",autocomplete:"email",required:"",class:"block w-full px-4 py-3 rounded-xl border border-default-bg-lighter bg-default-bg-lighter text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all placeholder-gray-400",placeholder:"[email protected]",onFocus:e[1]||(e[1]=r=>u.value=[]),autofocus:""},null,544),[[Ce,s(l)]])])),s(c)&&!s(f)||s(k)?(a(),Q(n,{key:1,modelValue:s(w),"onUpdate:modelValue":e[2]||(e[2]=r=>F(w)?w.value=r:null),label:"Password"},null,8,["modelValue"])):x("",!0),s(k)?(a(),Q(n,{key:2,modelValue:s(_),"onUpdate:modelValue":e[3]||(e[3]=r=>F(_)?_.value=r:null),label:"Confirm Password"},null,8,["modelValue"])):x("",!0),D(C,{type:"submit",class:"block w-full","is-loading":s(re),errors:s(u),label:s(V),onClick:s(ie),disabled:s(ae)},null,8,["is-loading","errors","label","onClick","disabled"])],512),s(k)?x("",!0):(a(),i("div",Ee,[!s(c)||s(f)?(a(),i("button",{key:0,class:"text-indigo-500 hover:text-indigo-700 font-medium transition-colors",onClick:e[4]||(e[4]=r=>{c.value=!0,f.value=!1})},"Use Password")):x("",!0),s(c)?(a(),i("button",{key:1,class:"text-indigo-500 hover:text-indigo-700 font-medium transition-colors",onClick:e[5]||(e[5]=r=>{c.value=!1,f.value=!1})},"Use Login Code")):x("",!0),s(c)&&!s(f)?(a(),i("button",{key:2,class:"text-default-text-lighter hover:text-gray-600 font-medium transition-colors",onClick:e[6]||(e[6]=r=>f.value=!0)},"Forgot password?")):x("",!0)]))])):s(O)?(a(),i("div",Re,[o("div",je,[e[14]||(e[14]=o("div",{class:"inline-flex items-center justify-center w-14 h-14 bg-indigo-500/15 rounded-full mb-3"},[o("svg",{class:"w-7 h-7 text-indigo-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 8l7.89 4.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})])],-1)),e[15]||(e[15]=o("h2",{class:"text-xl font-bold mb-1"},"Check your email",-1)),o("p",Le,[e[12]||(e[12]=T(" We sent an 8-character code to",-1)),e[13]||(e[13]=o("br",null,null,-1)),o("span",Be,E(s(l)),1)])]),o("form",{ref_key:"otpFormEl",ref:j},[o("div",Ae,[(a(!0),i(X,null,Se(s(p),(r,N)=>(a(),i(X,{key:N},[o("input",{ref_for:!0,ref:g=>{g&&(s(P)[N]=g)},type:"text",inputmode:"text",maxlength:"2",autocomplete:"off",spellcheck:"false",value:r,class:Pe(["w-10 h-12 text-center text-lg font-bold uppercase rounded-lg border-2 transition-all focus:outline-none font-mono",r?"border-indigo-500 bg-indigo-500/10 text-indigo-600":"border-default-bg-lightest bg-default-bg-lighter","focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500/20"]),onInput:g=>oe(N,g),onKeydown:g=>se(N,g),onPaste:e[7]||(e[7]=_e(g=>le(g),["prevent"])),onFocus:e[8]||(e[8]=g=>g.target.select())},null,42,De),N===3?(a(),i("span",Fe,"â")):x("",!0)],64))),128))]),D(C,{type:"submit",class:"block w-full","is-loading":s(ue),errors:s(u),label:"Verify & Sign in",onClick:s(de)},null,8,["is-loading","errors","onClick"])],512),o("div",Je,[s(b)>0?(a(),i("div",qe,[o("div",ze,[e[16]||(e[16]=o("span",null,"Code expires in",-1)),o("span",Ge,E(ne(s(b))),1)]),o("div",He,[o("div",{class:"bg-indigo-500 h-1 rounded-full transition-all duration-1000",style:Ie({width:`${s(b)/300*100}%`})},null,4)])])):(a(),i("p",Ke,"Your code has expired."))]),o("div",We,[o("button",{onClick:ce,class:"text-default-text-lighter hover:text-default-text-light font-medium flex items-center gap-1 transition-colors"},[...e[17]||(e[17]=[o("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})],-1),T(" Different email ",-1)])]),o("button",{onClick:e[9]||(e[9]=(...r)=>s(Y)&&s(Y)(...r)),disabled:s(W)||s(b)>240,class:"text-indigo-500 hover:text-indigo-700 font-medium disabled:text-default-text-lightest disabled:cursor-not-allowed transition-colors"},E(s(W)?"Sending...":"Resend code"),9,Ye)])])):(a(),i("div",Ze,[e[20]||(e[20]=o("div",{class:"inline-flex items-center justify-center w-14 h-14 bg-emerald-500/15 rounded-full mb-2"},[o("svg",{class:"w-7 h-7 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})])],-1)),e[21]||(e[21]=o("h3",{class:"font-semibold text-lg"},"Check your inbox",-1)),o("p",Qe,[e[18]||(e[18]=T(" If an account exists for ",-1)),o("span",Xe,E(s(l)),1),e[19]||(e[19]=T(", you'll receive a password reset link shortly. ",-1))]),e[22]||(e[22]=o("p",{class:"text-sm text-default-text-lighter"},"Don't see it? Check your spam folder.",-1))]))])])])]),_:1})])}}};export{ct 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.