1import{t as Re,u as We,b as Qe,r as m,c as M,d as _e,j as e,$ as ne,B as N,ac as Je,D as R,E as C,F as k,S as He,X as Ue,h as be,a8 as je,a9 as ye,ah as Ne,J as W,C as Xe,a as Ve,ap as ve,g as Ze,q as we}from"./index-BBYsJQph.js";import{L as Se}from"./label-IQVzdslc.js";import{T as et}from"./textarea-DULzZTWJ.js";import{l as Q}from"./london-time-BTshG-0l.js";import{p as tt}from"./householdIdentity-BttjfLVk.js";import{u as st,o as _,a as Ce}from"./grooming-saturday-openings-8kKksyvy.js";import{S as at}from"./search-DrqWI-TD.js";import"./index-DRp-vBl_.js";const d="#C88165",J="#BF5B2D",y=w=>`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,rt={short:"Smooth",medium:"Medium/Long",long:"Medium/Long",curly:"Medium/Long",wire:"Wire-haired",double:"Double coat"},ie=["dog","services","datetime","confirm"],nt={dog:"Dog",services:"Services",datetime:"Date & Time",confirm:"Confirm"};function ht(){Re();const{toast:w}=We(),[,ke]=Qe(),[H,U]=m.useState([]),[u,oe]=m.useState({}),[c,B]=m.useState(null),[h,L]=m.useState(null),[le,De]=m.useState(""),[ce,$e]=m.useState(!1),[p,P]=m.useState("dog"),[S,X]=m.useState(new Date),[O,V]=m.useState(""),[E,de]=m.useState("all"),{data:F=[],isLoading:Z}=M({queryKey:["/api/grooming/dogs"]}),{data:D=[]}=M({queryKey:["/api/grooming/services"]}),{data:q=[]}=M({queryKey:["/api/grooming/pricing"]}),{data:Te=[]}=M({queryKey:["/api/blocked-grooming-dates"]}),b=st(!1),Me=m.useMemo(()=>{const t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate()+185);return`/api/grooming/blocked-days?from=${Q(t)}&to=${y(s)}`},[]),{data:K}=M({queryKey:[Me]}),Le=m.useMemo(()=>new Set((K==null?void 0:K.days)??[]),[K]),l=m.useMemo(()=>H.map(t=>F.find(s=>s.id===t)).filter(t=>!!t),[F,H]),$=l[0],me=m.useRef(!1);m.useEffect(()=>{if(Z||me.current)return;me.current=!0;const t=tt(window.location.search,F);t.length&&U(t)},[F,Z]);const Fe=t=>t!=null&&t.groomingSize?D.filter(s=>!(s.applicableSizes&&s.applicableSizes.length>0&&!s.applicableSizes.includes(t.groomingSize)||s.applicableCoatTypes&&s.applicableCoatTypes.length>0&&t.groomingCoatType&&!s.applicableCoatTypes.includes(t.groomingCoatType))):D,G=(t,s)=>{if(!(t!=null&&t.groomingSize))return 0;const a=q.filter(n=>n.serviceId===s);let r=a.find(n=>n.size===t.groomingSize&&n.coatType===t.groomingCoatType);return r||(r=a.find(n=>n.size===t.groomingSize&&!n.coatType)),r?parseFloat(r.price):0},Y=(t,s)=>{const a=D.find(i=>i.id===s);if(!a||!(t!=null&&t.groomingSize))return 0;const r=q.filter(i=>i.serviceId===s);let n=r.find(i=>i.size===t.groomingSize&&i.coatType===t.groomingCoatType);return n||(n=r.find(i=>i.size===t.groomingSize&&!i.coatType)),(n==null?void 0:n.durationMinutes)||a.baseDurationMinutes},xe=m.useMemo(()=>l.reduce((t,s)=>t+(u[s.id]??[]).reduce((a,r)=>a+G(s,r),0),0),[l,u,q]),x=m.useMemo(()=>l.reduce((t,s)=>t+(u[s.id]??[]).reduce((a,r)=>a+Y(s,r),0),0),[l,u,D,q]),{data:ee,isLoading:ze,isError:Ae}=M({queryKey:["/api/grooming/appointments/recommendations",c?y(c):null,x],queryFn:async()=>{if(!c||x===0)return{slots:[]};const t=await fetch("/api/grooming/appointments/recommendations",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({date:y(c),durationMinutes:x})});if(!t.ok)throw new Error(`Availability check failed (${t.status})`);return t.json()},enabled:!!c&&x>0,retry:2,staleTime:3e4,refetchOnMount:"always"}),{data:te,isLoading:ue}=M({queryKey:["/api/grooming/appointments/next-available",x],queryFn:async()=>{const t=await fetch(`/api/grooming/appointments/next-available?durationMinutes=${x}`,{credentials:"include"});if(!t.ok)throw new Error(`Availability check failed (${t.status})`);return t.json()},enabled:p==="datetime"&&x>0,retry:2,staleTime:3e4,refetchOnMount:"always"}),se=_e({mutationFn:async t=>{const s=await fetch("/api/grooming/appointments",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(t)}),a=await s.json();if(!s.ok){if(s.status===409){const r=new Error(a.message||"Time slot is no longer available");throw r.conflict=!0,r}throw new Error(a.message||"Failed to book appointment")}return a},onSuccess:()=>{w({title:"Request Sent!",description:"We've received your grooming request â we'll email and text you once it's confirmed by our team."}),we.invalidateQueries({queryKey:["/api/grooming/appointments"]}),ke("/grooming")},onError:t=>{t.conflict?(we.invalidateQueries({queryKey:["/api/grooming/appointments/recommendations"]}),L(null),w({title:"Time Slot Taken",description:"Someone just booked that time. Please select another time.",variant:"destructive"})):w({title:"Booking Failed",description:t.message||"Could not book appointment. Please try again.",variant:"destructive"})}}),Ee=t=>s=>{const a=D.find(n=>n.id===t),r=(a==null?void 0:a.category)==="main";if(s.includes(t))return s.filter(n=>n!==t);if(r){const n=D.filter(o=>o.category==="main"&&o.id!==t).map(o=>o.id);return[...s.filter(o=>!n.includes(o)),t]}return[...s,t]}
1,Be=(t,s)=>{oe(a=>({...a,[t]:Ee(s)(a[t]??[])})),B(null),L(null)},Pe=()=>{if(!$||!c||!h||l.some(t=>{var s;return!((s=u[t.id])!=null&&s.length)})){w({title:"Missing Information",description:"Please complete all booking details.",variant:"destructive"});return}se.mutate({dogId:$.id,dateKey:y(c),startTime:h,selectedServices:u[$.id],customerNotes:le,daycareInterest:ce,...l.length>1?{additionalDogs:l.slice(1).map(t=>({dogId:t.id,selectedServices:u[t.id]}))}:{}})},T=t=>{if(t<60)return`${t} mins`;const s=Math.floor(t/60),a=t%60;return a>0?`${s}h ${a}m`:`${s}h`},ae=(t,s)=>{const[a,r]=t.split(":").map(Number),n=a*60+r+s;return`${String(Math.floor(n/60)%24).padStart(2,"0")}:${String(n%60).padStart(2,"0")}`},Oe=m.useMemo(()=>{const t=S.getFullYear(),s=S.getMonth(),a=new Date(t,s,1),r=new Date(t,s+1,0),n=a.getDay(),i=[];for(let o=0;o<n;o++)i.push(null);for(let o=1;o<=r.getDate();o++)i.push(new Date(t,s,o));return i},[S]),he=t=>{if(!t)return!1;const s=y(t);return Le.has(s)?!0:Te.some(a=>Q(a.date)===s)},pe=t=>{if(!t)return!1;const s=y(t);if(s<Q(new Date)||t.getDay()===0)return!1;if(t.getDay()===6){const a=_(b.data,s);if(b.isLoading||b.isError||!a)return!1}return!he(t)},qe=c?y(c):"",I=(c==null?void 0:c.getDay())===6?b.isError?void 0:_(b.data,qe):void 0,fe=((ee==null?void 0:ee.slots)??[]).filter(t=>(c==null?void 0:c.getDay())!==6||Ce(I,t.time,x)),ge=((te==null?void 0:te.slots)??[]).filter(t=>{const[s,a,r]=t.dateKey.split("-").map(Number),n=new Date(s,a-1,r,12);return pe(n)?n.getDay()!==6||Ce(_(b.data,t.dateKey),t.time,x):!1}),Ke=t=>{const[s,a,r]=t.dateKey.split("-").map(Number),n=new Date(s,a-1,r);B(n),X(new Date(s,a-1,1)),L(t.time)},Ge=t=>{const[s,a,r]=t.split("-").map(Number);return new Date(s,a-1,r).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})},z=ie.indexOf(p),Ye=()=>{z>0&&P(ie[z-1])},Ie=(t,s,a)=>r=>{const n=G(t,r.id),i=Y(t,r.id),o=s.includes(r.id);return e.jsx("div",{className:`p-4 rounded-xl border-2 cursor-pointer transition-all active:scale-[0.98] ${o?"border-[#C88165] bg-[#C88165]/5":"border-[#ece2d2] bg-white hover:border-[#d8c5ac]"}`,onClick:()=>a(r.id),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 w-6 h-6 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${o?"border-[#C88165] bg-[#C88165]":"border-[#d8c5ac]"}`,children:o&&e.jsx(ve,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"font-semibold text-base",children:r.name}),e.jsxs("span",{className:"font-bold text-lg whitespace-nowrap",style:{color:d},children:["from £",n.toFixed(0)]})]}),r.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:r.description}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 text-xs text-muted-foreground",children:[e.jsx(W,{className:"h-3 w-3"}),e.jsxs("span",{children:["approx. ",T(i)]})]})]})]})},r.id)};return e.jsxs("div",{className:"min-h-screen bg-[#f6f1e7] flex flex-col",children:[e.jsxs("header",{className:"bg-[#faf7f2] border-b border-[#ece2d2] sticky top-0 z-10",children:[e.jsx("div",{className:"w-full px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ne,{href:"/grooming",children:e.jsx(N,{variant:"ghost",size:"icon",className:"h-10 w-10",children:e.jsx(Je,{className:"h-5 w-5"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-base font-bold truncate",children:"Book Grooming"}),$&&p!=="dog"&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["for ",l.map(t=>t.name).join(", ")]})]})]})}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx("div",{className:"flex items-center justify-between gap-1",children:ie.map((t,s)=>e.jsxs("div",{className:"flex-1 flex flex-col items-center",children:[e.jsx("div",{className:`w-full h-1.5 rounded-full mb-1 ${s<z||s===z?"bg-[#C88165]":"bg-[#ece2d2]"}`}),e.jsx("span",{className:`text-[10px] font-medium ${s<=z?"text-[#C88165]":"text-[#b9a99b]"}`,children:nt[t]})]},t))})})]}),e.jsx("main",{className:"flex-1 px-4 py-4 pb-32",children:e.jsxs("div",{className:"max-w-lg mx-auto",children:[p==="dog"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full mx-auto mb-3 flex items-center justify-center",style:{backgroundColor:`${d}15`},children:e.jsx(R,{className:"h-8 w-8",style:{color:d}})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Select Your Dogs"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Choose every dog joining this grooming visit. Their order is their grooming order."})]}),Z?e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})}):F.length===0?e.jsx(C,{children:e.jsxs(k,{className:"p-6 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No dogs found. Add a dog first to book grooming."}),e.jsx(ne,{href:"/grooming/dogs",children:e.jsx(N,{style:{backgroundColor:d},children:"Add a Dog"})})]})}):e.jsx("div",{className:"space-y-3",children:F.map(t=>{const s=!t.isGroomingRegistered||!t.groomingSize,a=H.indexOf(t.id),r=a!==-1;return e.jsx("div",{className:`p-4 rounded-xl border-2 transition-all ${s?"border-[#e1a95f]/50 bg-[#e1a95f]/10":r?"border-[#C88165] bg-[#C88165]/5 curs
1or-pointer active:scale-[0.98]":"border-[#ece2d2] bg-white hover:border-[#d8c5ac] cursor-pointer active:scale-[0.98]"}`,role:"checkbox","aria-checked":r,tabIndex:s?-1:0,"data-testid":`button-select-grooming-dog-${t.id}`,onKeyDown:n=>{!s&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),U(i=>i.includes(t.id)?i.filter(o=>o!==t.id):[...i,t.id]))},onClick:()=>{s||(U(n=>n.includes(t.id)?n.filter(i=>i!==t.id):[...n,t.id]),oe(n=>{if(!n[t.id])return n;const i={...n};return delete i[t.id],i}),B(null),L(null))},children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`w-14 h-14 rounded-full flex items-center justify-center flex-shrink-0 ${r?"bg-[#C88165]":"bg-[#f3e6da]"}`,children:e.jsx(R,{className:`h-7 w-7 ${r?"text-white":"text-[#c4a68a]"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-lg",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:t.breed}),!s&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.groomingSize," ⢠",t.groomingCoatType?rt[t.groomingCoatType]||t.groomingCoatType:"Coat not set"]}),s&&e.jsx("p",{className:"text-xs text-[#8a5a1f] mt-1",children:"Needs grooming setup"})]}),s?e.jsx(ne,{href:`/grooming/dogs?setup=${t.id}`,children:e.jsx(N,{size:"sm",style:{backgroundColor:d},children:"Setup"})}):r?e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-xs font-bold text-white",style:{backgroundColor:d},children:a+1}):null]})},t.id)})}),l.length>1&&e.jsxs("p",{className:"text-center text-xs text-muted-foreground","data-testid":"text-multi-dog-order",children:[l.length," dogs selected â they will be groomed back-to-back in the numbered order."]})]}),p==="services"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full mx-auto mb-3 flex items-center justify-center",style:{backgroundColor:`${d}15`},children:e.jsx(He,{className:"h-8 w-8",style:{color:d}})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Select Services"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:l.length>1?"Choose services for each dog â they'll be groomed one after the other":`Choose grooming services for ${$==null?void 0:$.name}`})]}),e.jsxs("div",{className:"sticky top-[102px] z-[5] -mx-4 px-4 py-3 bg-[#f6f1e7]/95 backdrop-blur-sm space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none","aria-hidden":"true"}),e.jsx("input",{type:"search",value:O,onChange:t=>V(t.target.value.slice(0,100)),placeholder:"Search services...","aria-label":"Search services","data-testid":"input-service-search",className:"w-full min-h-[48px] rounded-xl border-2 border-[#ece2d2] bg-white pl-11 pr-10 text-base focus:outline-none focus:border-[#C88165] placeholder:text-muted-foreground"}),O&&e.jsx("button",{onClick:()=>V(""),"aria-label":"Clear search","data-testid":"button-service-search-clear",className:"absolute right-3 top-1/2 -translate-y-1/2 p-1 rounded-full text-muted-foreground hover:text-foreground hover:bg-[#f3e6da]",children:e.jsx(Ue,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex gap-2 overflow-x-auto no-scrollbar",role:"group","aria-label":"Filter services by category",children:[{key:"all",label:"All"},{key:"main",label:"Main services"},{key:"addon",label:"Add-ons"},{key:"special",label:"Special"}].map(({key:t,label:s})=>e.jsx("button",{"aria-pressed":E===t,onClick:()=>de(t),"data-testid":`tab-service-menu-${t}`,className:`shrink-0 px-4 py-2 rounded-full text-sm font-medium border-2 transition-colors ${E===t?"border-[#C88165] bg-[#C88165] text-white":"border-[#ece2d2] bg-white text-[#756661] hover:border-[#d8c5ac]"}`,children:s},t))})]}),l.map((t,s)=>{const a=Fe(t),r=u[t.id]??[],i=Ie(t,r,j=>Be(t.id,j)),o=O.trim().toLowerCase(),v=a.filter(j=>E!=="all"&&j.category!==E?!1:o?j.name.toLowerCase().includes(o)||(j.description??"").toLowerCase().includes(o):!0),f=v.filter(j=>j.category==="main"),g=v.filter(j=>j.category==="addon"),A=v.filter(j=>j.category==="special"),re=o.length>0||E!=="all";return e.jsxs("div",{className:s>0?"pt-6 mt-2 border-t-2 border-dashed":"",children:[l.length>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center",style:{backgroundColor:`${d}15`},children:e.jsx(R,{className:"h-4 w-4",style:{color:d}})}),e.jsxs("p",{className:"font-semibold",children:[s+1,". ",t.name]})]}),f.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide mb-3",children:"Main Services"}),e.jsx("div",{className:"space-y-3",children:f.map(i)})]}),g.length>0&&e.jsxs("div",{className:"pt-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide mb-3",children:"Add-ons"}),e.jsx("div",{className:"space-y-3",children:g.map(i)})]}),A.length>0&&e.jsxs("div",{className:"pt-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide mb-3",children:"Special Services"}),e.jsx("div",{className:"space-y-3",children:A.map(i)})]}),v.length===0&&e.jsx(C,{children:e.jsxs(k,{className:"p-6 text-center space-y-3",children:[e.jsx("p",{className:"text-muted-foreground","data-testid":"text-no-services",children:a.length===0?"N
1o services available for this dog's size.":o?`No services match "${O.trim()}".`:"No services in this category for this dog."}),re&&a.length>0&&e.jsx("button",{onClick:()=>{V(""),de("all")},"data-testid":"button-clear-service-filters",className:"text-sm font-medium text-[#C88165] underline underline-offset-4",children:"Show all services"})]})})]},(t==null?void 0:t.id)??s)})]}),p==="datetime"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full mx-auto mb-3 flex items-center justify-center",style:{backgroundColor:`${d}15`},children:e.jsx(be,{className:"h-8 w-8",style:{color:d}})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Choose Date & Time"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Your appointment will be approximately ",T(x)]})]}),b.isError&&e.jsxs("div",{role:"alert",className:"rounded-xl border border-[#e1a95f]/50 bg-[#fff6e8] p-3 text-sm text-[#765327]",children:["We couldnât check which Saturdays the groomer has opened. Saturdays will stay unavailable for now; please choose a weekday or try again shortly.",e.jsx("button",{type:"button",className:"ml-1 font-semibold underline",onClick:()=>b.refetch(),children:"Try again"})]}),b.isLoading&&e.jsx("p",{className:"rounded-xl bg-[#faf7f2] p-3 text-sm text-[#756661]",children:"Checking which Saturdays are openâ¦"}),(ue||ge.length>0)&&e.jsxs(C,{children:[e.jsxs(je,{className:"pb-2",children:[e.jsx(ye,{className:"text-base",children:"Next available appointments"}),e.jsxs(Ne,{className:"text-xs",children:["The earliest slots that fit your approx. ",T(x)," groom â tap one to book it"]})]}),e.jsx(k,{children:ue?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-[#C88165]"})}):e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ge.map(t=>{const s=c!==null&&y(c)===t.dateKey&&h===t.time;return e.jsxs("button",{onClick:()=>Ke(t),"data-testid":`button-next-available-${t.dateKey}`,className:`py-2.5 px-3 rounded-xl text-left transition-all border ${s?"text-white border-transparent":"bg-[#faf7f2] hover:bg-[#f3e6da] border-[#ece2d2]"}`,style:s?{backgroundColor:d}:{},children:[e.jsx("p",{className:`text-sm font-semibold ${s?"text-white":""}`,children:Ge(t.dateKey)}),e.jsxs("p",{className:`text-xs mt-0.5 flex items-center gap-1 ${s?"text-white/85":"text-muted-foreground"}`,children:[e.jsx(W,{className:"h-3 w-3"})," ",t.time]})]},`${t.dateKey}-${t.time}`)})})})]}),e.jsx(C,{children:e.jsxs(k,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(N,{variant:"ghost",size:"icon",onClick:()=>X(new Date(S.getFullYear(),S.getMonth()-1)),children:e.jsx(Xe,{className:"h-5 w-5"})}),e.jsx("h3",{className:"font-semibold",children:S.toLocaleDateString("en-GB",{month:"long",year:"numeric"})}),e.jsx(N,{variant:"ghost",size:"icon",onClick:()=>X(new Date(S.getFullYear(),S.getMonth()+1)),children:e.jsx(Ve,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["S","M","T","W","T","F","S"].map((t,s)=>e.jsx("div",{className:"text-center text-xs font-medium text-muted-foreground py-2",children:t},s))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:Oe.map((t,s)=>{if(!t)return e.jsx("div",{className:"aspect-square"},s);const a=pe(t),r=t.getDay()===6&&!b.isError?_(b.data,y(t)):void 0,n=t.toDateString()===new Date().toDateString(),i=(c==null?void 0:c.toDateString())===t.toDateString(),v=!(y(t)<Q(new Date))&&he(t);return e.jsxs("button",{disabled:!a,"aria-label":`${t.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}${r?`, open ${r.openTime} to ${r.closeTime}`:""}`,onClick:()=>{B(t),L(null)},"data-testid":`calendar-day-${y(t)}`,className:`relative aspect-square rounded-lg text-sm font-medium transition-all flex items-center justify-center ${v?"cursor-not-allowed":a?i?"text-white":n?"border-2 border-[#C88165] text-[#C88165]":"hover:bg-[#f3e6da]":"text-[#d8c5ac] cursor-not-allowed"}`,style:i?{backgroundColor:d}:v?{backgroundColor:`${J}26`,color:J}:{},children:[t.getDate(),r&&a&&e.jsx("span",{"aria-hidden":"true",className:"absolute bottom-1.5 h-1 w-1 rounded-full bg-[#52694b]"})]},s)})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 mt-4 pt-3 border-t border-[#ece2d2]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-3.5 w-3.5 rounded border-2 border-[#C88165] inline-block"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Today"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-3.5 w-3.5 rounded inline-block",style:{backgroundColor:d}}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Selected"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-3.5 w-3.5 rounded inline-block",style:{backgroundColor:`${J}26`,border:`1.5px solid ${J}`}}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Salon unavailable"})]})]}),e.jsx("p",{className:"mt-3 text-xs leading-relaxed text-[#756661]",children:"Saturdays are available only when the grooming team has o
1pened that exact date. Sundays are always closed."})]})}),c&&e.jsxs(C,{children:[e.jsxs(je,{className:"pb-2",children:[e.jsxs(ye,{className:"text-base",children:["Recommended Times for ",c.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})]}),e.jsx(Ne,{className:"text-xs",children:I?`Saturday hours are ${I.openTime} to ${I.closeTime}. Your whole appointment must finish by closing.`:"Smart slots to maximize availability for other bookings"})]}),e.jsx(k,{children:ze?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-[#C88165]"})}):Ae?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"We couldn't check this date just now â please try again in a moment."}):fe.length?e.jsx("div",{className:"space-y-2",children:fe.map(t=>e.jsxs("button",{onClick:()=>L(t.time),className:`w-full py-3 px-4 rounded-xl text-left transition-all flex items-center justify-between ${h===t.time?"text-white":"bg-[#faf7f2] hover:bg-[#f3e6da] border border-[#ece2d2]"}`,style:h===t.time?{backgroundColor:d}:{},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{className:`h-4 w-4 ${h===t.time?"text-white":"text-[#756661]"}`}),e.jsx("span",{className:"font-semibold",children:t.time})]}),e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${h===t.time?"bg-white/20 text-white":t.priority===1?"bg-[#C88165]/10 text-[#C88165]":"bg-[#f3e6da] text-[#756661]"}`,children:t.label})]},t.time))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No available slots fit within this dateâs opening hours. Please select another date."})})]})]}),p==="confirm"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full mx-auto mb-3 flex items-center justify-center",style:{backgroundColor:`${d}15`},children:e.jsx(ve,{className:"h-8 w-8",style:{color:d}})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Confirm Booking"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:l.length>1?`One household visit for ${l.length} dogs`:"Review your appointment details"})]}),e.jsx(C,{children:e.jsxs(k,{className:"p-4 space-y-4",children:[l.map((t,s)=>{const a=u[t.id]??[],r=a.reduce((f,g)=>f+Y(t,g),0),n=a.reduce((f,g)=>f+G(t,g),0),i=l.slice(0,s).reduce((f,g)=>f+(u[g.id]??[]).reduce((A,re)=>A+Y(g,re),0),0),o=h?ae(h,i):"",v=o?ae(o,r):"";return e.jsxs("div",{className:s>0?"pt-1":"",children:[e.jsxs("div",{className:"flex items-center gap-3 pb-3 border-b",children:[e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center",style:{backgroundColor:`${d}15`},children:e.jsx(R,{className:"h-6 w-6",style:{color:d}})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.breed})]}),l.length>1&&e.jsxs("span",{className:"ml-auto text-sm font-medium text-[#756661] whitespace-nowrap","data-testid":`text-dog-time-${t.id}`,children:[o,"â",v]})]}),e.jsxs("div",{className:"pt-3 pb-3 border-b",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Services"}),e.jsx("div",{className:"space-y-2",children:a.map(f=>{const g=D.find(A=>A.id===f);return g?e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm",children:g.name}),e.jsxs("span",{className:"text-sm font-medium",children:["£",G(t,f).toFixed(0)]})]},f):null})}),e.jsxs("p",{className:"pt-2 text-xs text-muted-foreground",children:["Approx. ",T(r)," · from £",n.toFixed(0)]})]})]},t.id)}),e.jsxs("div",{className:"pb-3 border-b",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Date & Time"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:c==null?void 0:c.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(W,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:l.length>1&&h?`${h}â${ae(h,x)} (approx. ${T(x)}, back-to-back)`:`${h} (approx. ${T(x)})`})]})]}),e.jsxs("div",{className:"pt-1",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-semibold",children:"Estimated Total"}),e.jsxs("span",{className:"text-2xl font-bold",style:{color:d},children:["from £",xe.toFixed(0)]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Prices are estimates â the final price is confirmed and paid in store. Your booking isn't confirmed until our team confirms it â we'll email and text you."}),l.length>1&&e.jsx("p",{className:"text-xs font-medium text-[#756661] mt-2","data-testid":"text-household-communications",children:"You'll receive one combined confirmation and one reminder for the whole household visit."})]})]})}),l.some(t=>!t.isTrialApproved)&&e.jsx(C,{className:"border-[#e9d0bd] bg-[#faf5ec]",children:e.jsx(k,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ze,{id:"daycare",checked:ce,onCheckedChange:t=>$e(!!t)}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Se,{htmlFor:"daycare",className:"font-medium cursor-pointer text-[#5f3421]",children:"I'm also interested in daycare services"}),e.jsxs("p",{className:"text-xs text-[#7d442c]",children:["We'll contact you about arranging ",l.filter(t=>!t.isTrialApproved).length>1?"daycare trials":"a daycare trial"," for"," ",l.filter(t=>!t.isTrialApproved).map(t=>t.name).join(" and ")]})]})]})})}),e.jsx(C,{children:e.jsxs(k,{className:"p-4",children:[e.jsx(Se,{htmlFor:"notes",className:"text-sm font-medium",children:"Notes for groomer (optional)"}),e.jsx(et,{id:"notes",placeholder:"Any special requests or information about your dog...",value:le,onChange:t=>De(t.target.value),className:"mt-2 min-h-20"})]})})]})]})}),e.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-[#faf7f2] border-t border-[#ece2d2] p-4 safe-area-bottom",children:e.jsxs("div",{className:"max-w-lg mx-auto",children:[Object.values(u).some(t=>t.length>0)&&p==="services"&&e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[Object.values(u).reduce((t,s)=>t+s.length,0)," service",Object.values(u).reduce((t,s)=>t+s.length,0)!==1?"s":"",l.length>1?` (${l.length} dogs)`:""," ⢠approx. ",T(x)]}),e.jsxs("span",{className:"font-bold",style:{color:d},children:["from £",xe.toFixed(0)]})]}),e.jsxs("div",{className:"flex gap-3",children:[z>0&&e.jsx(N,{variant:"outline",onClick:Ye,className:"flex-1 h-12 text-base",children:"Back"}),p==="dog"&&e.jsx(N,{className:"flex-1 h-12 text-base text-white hover:text-white",style:{backgroundColor:d},disabled:!l.length,onClick:()=>P("services"),children:"Continue"}),p==="services"&&e.jsx(N,{className:"flex-1 h-12 text-base text-white hover:text-white",style:{backgroundColor:d},disabled:!l.length||l.some(t=>{var s;return!((s=u[t.id])!=null&&s.length)}),onClick:()=>P("datetime"),children:"Continue"}),p==="datetime"&&e.jsx(N,{className:"flex-1 h-12 text-base text-white hover:text-white",style:{backgroundColor:d},disabled:!c||!h,onClick:()=>P("confirm"),children:"Continue"}),p==="confirm"&&e.jsx(N,{className:"flex-1 h-12 text-base text-white hover:text-white",style:{backgroundColor:d},disabled:se.isPending,onClick:Pe,"data-testid":"button-confirm-booking",children:se.isPending?"Sending...":"Send Booking Request"})]})]})})]})}export{ht 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.