import{d as O,u as P,a as R,c as o,b as s,t as b,e as U,w as E,f as w,v as _,g as f,h as V,F as v,r,i as F,j as L,o as a}from"./index-BvsGCd9b.js";const M={class:"min-h-dvh flex flex-col bg-gradient-to-b from-brand-50 to-surface-sunken"},$={class:"flex-1 flex items-center justify-center px-6 py-12"},A={class:"w-full max-w-sm"},H={class:"text-center mb-8 animate-fade-in"},z={class:"text-title mt-4"},G={key:0,class:"block"},I={key:1,class:"block"},J={class:"text-meta font-semibold text-ink-muted"},K={key:2,class:"rounded-card border-2 border-dashed border-amber-400 bg-amber-50/70 p-3 text-amber-900 text-meta"},Q={class:"font-mono tracking-widest"},W={key:3,class:"text-red-600 text-meta"},X=["disabled"],ee=O({__name:"LoginView",setup(Y){const x=F(),C=L(),g=P(),S=R(),l=r(""),d=r(""),u=r(!1),c=r(""),i=r(""),m=r(!1);function q(){return x.query.from?x.query.from.toString():"/home"}async function N(){var p,t,n,y,h;i.value="",m.value=!0;try{if(u.value)await g.verifyOtp(l.value,d.value),C.replace(q());else{const e=await g.requestOtp(l.value);u.value=!0,e.dev_code&&(c.value=e.dev_code,d.value=e.dev_code)}}catch(e){const k=(p=e==null?void 0:e.response)==null?void 0:p.status,j=(n=(t=e==null?void 0:e.response)==null?void 0:t.data)==null?void 0:n.message,B=(h=(y=e==null?void 0:e.response)==null?void 0:y.data)!=null&&h.errors?Object.values(e.response.data.errors).flat()[0]:null,D=e!=null&&e.message&&!(e!=null&&e.response)?`Network: ${e.message}`:null;i.value=B||j||D||(k?`Sign in failed (HTTP ${k}).`:"Unable to sign in. Check your input and try again.")}finally{m.value=!1}}function T(){u.value=!1,d.value="",c.value="",i.value=""}return(p,t)=>(a(),o("div",M,[s("div",$,[s("div",A,[s("div",H,[t[2]||(t[2]=s("div",{class:"w-20 h-20 mx-auto rounded-card bg-brand-500 text-white text-4xl flex items-center justify-center shadow-card"},[s("span",null,"🔧")],-1)),s("h1",z,b(U(S).brand.name),1),t[3]||(t[3]=s("p",{class:"text-meta text-ink-muted mt-1"},"Track your vehicle repairs & estimates",-1))]),s("form",{onSubmit:E(N,["prevent"]),class:"space-y-3"},[u.value?(a(),o("label",I,[s("span",J,"Code sent to "+b(l.value),1),w(s("input",{"onUpdate:modelValue":t[1]||(t[1]=n=>d.value=n),type:"text",inputmode:"numeric",required:"",autocomplete:"one-time-code",maxlength:"6",class:"mt-1 w-full h-14 px-4 rounded-card bg-surface border border-ink/10 text-center text-2xl tracking-[0.5em] font-bold focus:border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-100",placeholder:"• • • • • •"},null,512),[[_,d.value]]),s("button",{type:"button",class:"mt-2 text-meta text-brand-600 font-semibold",onClick:T}," Change number ")])):(a(),o("label",G,[t[4]||(t[4]=s("span",{class:"text-meta font-semibold text-ink-muted"},"Phone number",-1)),w(s("input",{"onUpdate:modelValue":t[0]||(t[0]=n=>l.value=n),type:"tel",required:"",autocomplete:"tel",class:"mt-1 w-full h-12 px-4 rounded-card bg-surface border border-ink/10 text-body focus:border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-100",placeholder:"+20 100 000 0000"},null,512),[[_,l.value]])])),c.value?(a(),o("div",K,[t[5]||(t[5]=f(" 🧪 Dev code: ",-1)),s("strong",Q,b(c.value),1),t[6]||(t[6]=s("span",{class:"block text-[11px] text-amber-700 mt-0.5"},"(pre-filled — tap Verify to continue)",-1))])):V("",!0),i.value?(a(),o("p",W,b(i.value),1)):V("",!0),s("button",{type:"submit",disabled:m.value,class:"w-full h-12 rounded-card bg-brand-500 text-white font-bold text-body shadow-fab hover:bg-brand-600 active:scale-[0.99] transition disabled:opacity-50 disabled:cursor-not-allowed"},[m.value?(a(),o(v,{key:0},[f("Please wait…")],64)):u.value?(a(),o(v,{key:2},[f("Verify & sign in")],64)):(a(),o(v,{key:1},[f("Send code")],64))],8,X)],32)])])]))}});export{ee as default};
//# sourceMappingURL=LoginView-BGN1Z2En.js.map
