import{B as e,C as t,G as n,S as r,c as i,ft as a,j as o,l as s,m as c,o as ee,p as l,r as u,s as d,u as f,x as te}from"./runtime-core.esm-bundler-DTXUv7Wx.js";import{s as ne}from"./runtime-dom.esm-bundler-CXLmyuFK.js";import{a as re,o as ie,t as ae}from"./vue-router-Cyqru1db.js";import{t as oe}from"./i18n-DK-nbHGh.js";import{r as se}from"./products-BqW5PUnm.js";import{c as ce,d as p,f as m,i as h,p as g,r as _}from"./api-DlB23x7f.js";import{t as v}from"./Navbar-BBjFbxqT.js";import{t as y}from"./Button-JT3QbcL8.js";import{t as b}from"./CartDrawer-Bq07KOTX.js";import{t as x}from"./Footer-C6UzF-Nr.js";import{t as S}from"./Input-RN3gn2df.js";var C={class:`bg-cream text-ink min-h-svh`},w={class:`mx-auto w-full max-w-md px-6 py-14 sm:px-8 sm:py-20 md:py-24`},T={class:`flex flex-col gap-3 mb-8 text-center`},E={class:`eyebrow`},D={class:`font-display font-normal leading-[1.05] tracking-tight text-ink text-headline-md`},O={class:`text-[14px] text-muted`},k={key:1,class:`text-sm text-danger`,role:`alert`,"aria-live":`polite`},A={key:1,class:`rounded-md border border-line bg-paper p-6 md:p-8 flex flex-col gap-3 text-center`},j={class:`font-display text-xl text-brand`},M={class:`text-[14px] text-muted`},N={class:`mt-8 text-center text-[14px] text-muted`},P={__name:`LoginPage`,setup(P){let{t:F}=oe(),I=g(),le=re(),L=ie(),R=e(!1);function z(){R.value=!1,L.push(`/checkout`)}async function B(e){await ce(e.id,1),R.value=!0}async function V({productId:e,quantity:t}){await m(e,t)}async function H(e){await p(e)}let U=[{key:`nav.shop`,href:`/shop`},{key:`nav.bundles`,href:`/#bundles`},{key:`nav.revitalization`,href:`/#revitalize`},{key:`nav.about`,href:`/#about`},{key:`nav.kaiserhacks`,href:`/kaiserhacks`}],W=[],G=e(``),K=e(``),q=e(!1),J=e(``),Y=e(!1),X=e(!1),ue=ee(()=>G.value?Y.value?!1:K.value.length<8:!0);async function de(){J.value=``,q.value=!0;try{if(Y.value){await _({email:G.value}),X.value=!0;return}await h({email:G.value,password:K.value});let e=String(le.query.next||`/`);L.push(e)}catch(e){J.value=e?.message||F(`checkout.error.generic`)}finally{q.value=!1}}let Z=e(null),Q=null;function $(){let e=Z.value,t=e&&(e.$el||e);if(!t||typeof window>`u`)return;let n=Math.round(t.getBoundingClientRect().height);document.documentElement.style.setProperty(`--nav-h`,`${n}px`)}return r(()=>{if($(),typeof ResizeObserver<`u`&&Z.value){let e=Z.value.$el||Z.value;Q=new ResizeObserver($),Q.observe(e)}window.addEventListener(`resize`,$)}),te(()=>{Q&&Q.disconnect(),typeof window<`u`&&window.removeEventListener(`resize`,$)}),(e,r)=>(t(),f(u,null,[c(v,{ref_key:`navRef`,ref:Z,variant:`cream`,layout:`standard`,items:U,"secondary-items":W,"cart-count":n(I).count,products:n(se),onCart:r[0]||=e=>R.value=!0,onSearch:B},null,8,[`cart-count`,`products`]),d(`main`,C,[d(`div`,w,[d(`header`,T,[d(`p`,E,a(n(F)(`auth.login.eyebrow`)),1),d(`h1`,D,a(Y.value?n(F)(`auth.reset.title`):n(F)(`auth.login.title`)),1),d(`p`,O,a(Y.value?n(F)(`auth.reset.sub`):n(F)(`auth.login.sub`)),1)]),X.value?(t(),f(`div`,A,[d(`h2`,j,a(n(F)(`auth.reset.sent.title`)),1),d(`p`,M,a(n(F)(`auth.reset.sent.body`)),1),d(`button`,{type:`button`,class:`text-[13px] text-brand hover:underline self-center mt-2`,onClick:r[4]||=e=>{Y.value=!1,X.value=!1}},a(n(F)(`auth.reset.back`)),1)])):(t(),f(`form`,{key:0,class:`flex flex-col gap-5 rounded-md border border-line bg-paper p-6 md:p-8`,novalidate:``,onSubmit:ne(de,[`prevent`])},[c(S,{modelValue:G.value,"onUpdate:modelValue":r[1]||=e=>G.value=e,label:n(F)(`checkout.field.email`),type:`email`,required:``,placeholder:n(F)(`checkout.placeholder.email`)},null,8,[`modelValue`,`label`,`placeholder`]),Y.value?s(``,!0):(t(),i(S,{key:0,modelValue:K.value,"onUpdate:modelValue":r[2]||=e=>K.value=e,label:n(F)(`checkout.field.password`),type:`password`,required:``},null,8,[`modelValue`,`label`])),J.value?(t(),f(`p`,k,a(J.value),1)):s(``,!0),c(y,{type:`submit`,variant:`primary`,size:`lg`,block:``,loading:q.value,disabled:ue.value},{default:o(()=>[l(a(Y.value?n(F)(`auth.reset.cta`):n(F)(`auth.login.cta`)),1)]),_:1},8,[`loading`,`disabled`]),d(`button`,{type:`button`,class:`text-[13px] text-brand hover:underline self-start`,onClick:r[3]||=e=>Y.value=!Y.value},a(Y.value?n(F)(`auth.reset.back`):n(F)(`auth.login.forgot`)),1)],32)),d(`p`,N,[l(a(n(F)(`auth.login.newCustomer`))+` `,1),c(n(ae),{to:`/register`,class:`text-brand hover:underline`},{default:o(()=>[l(a(n(F)(`auth.login.cta.register`)),1)]),_:1})])])]),c(x),c(b,{modelValue:R.value,"onUpdate:modelValue":r[5]||=e=>R.value=e,items:n(I).items,subtotal:n(I).subtotal,count:n(I).count,onUpdateQuantity:V,onRemove:H,onCheckout:z},null,8,[`modelValue`,`items`,`subtotal`,`count`])],64))}};export{P as default};