PageSourceSearch

https://app.homequestors.com/assets/public-redeem-DaBm5AO4.js

js homequestors.com collected 2026-10-05 09:53:22 UTC 16,904 bytes, 1 lines download raw bytes

1import{r as S,j as e}from"./vendor-react-DF9l7Zim.js";import{aj as U,aS as D,a2 as M,$,a4 as te,T as se,aa as ae,ah as ie,a5 as O}from"./index-DIdUq0at.js";import{u as E,b as ne}from"./vendor-query-DvoWqiWG.js";import{S as _,a as B,b as F,c as L,d as Y}from"./select-DUIxizIK.js";import{S as q}from"./skeleton-DPMAdzFp.js";import{C as oe}from"./chevron-left-DnO2z7oY.js";import{f as k,s as re,a as le}from"./format-CJvCYwBh.js";import{a as ce,b as T}from"./isBefore-CDz1OmYk.js";import{s as C,e as me,a as z,i as de}from"./isSameMonth-DAAF0AmZ.js";import{e as xe}from"./endOfMonth-B5dRXaoU.js";import{e as ue}from"./eachDayOfInterval-Dw1FbU3X.js";import{s as K}from"./subMonths-Dm3FYUeN.js";import{i as V}from"./isToday-D0KVdXjT.js";import{C as he}from"./calendar-check-CVseUNWY.js";import{T as Z}from"./ticket-BD482tOA.js";import{C as pe}from"./circle-alert-CklzAB5e.js";import"./vendor-ui-utils-CyvyRcDv.js";import"./index-D17hSi50.js";import"./chevron-up-Kvv9Q6mP.js";import"./en-US-BSHfCU62.js";import"./constructNow-DCdU3fiR.js";function X(t){return/^#[0-9a-fA-F]{6}$/.test(t)}function ee(t,l){if(!X(t))return`rgba(26, 71, 48, ${l})`;const i=parseInt(t.slice(1,3),16),d=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16);return`rgba(${i}, ${d}, ${a}, ${l})`}function P(t){if(!X(t))return"#ffffff";const l=parseInt(t.slice(1,3),16)/255,i=parseInt(t.slice(3,5),16)/255,d=parseInt(t.slice(5,7),16)/255,a=r=>r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4);return .2126*a(l)+.7152*a(i)+.0722*a(d)>.55?"#111111":"#ffffff"}function W(t){return{backgroundColor:t,borderColor:t,color:P(t),boxShadow:`0 10px 24px ${ee(t,.28)}`}}const G="inline-flex items-center justify-center gap-2 w-full rounded-full text-sm font-medium min-h-9 px-4 py-2 border transition-opacity hover:opacity-90";function fe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"America/New_York"}}const H=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Anchorage","Pacific/Honolulu","America/Phoenix","America/Indiana/Indianapolis","America/Detroit","America/Toronto","America/Vancouver","Europe/London","Europe/Paris","Europe/Berlin","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Australia/Sydney","Pacific/Auckland"];function Q(t){try{const l=new Date,i=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(l).find(d=>d.type==="timeZoneName")?.value||"";return`${t.replace(/_/g," ").replace(/\//g," / ")} (${i})`}catch{return t}}function J({calendarMonth:t,setCalendarMonth:l,selectedDate:i,setSelectedDate:d,brandColor:a,maxBookingDays:b=60,isEmbed:r,dayAvailability:p}){const m=re(new Date),h=ce(m,b),o=C(t),n=xe(t),y=le(o,{weekStartsOn:0}),f=me(n,{weekStartsOn:0}),v=ue({start:y,end:f}),g=!T(C(K(t)),C(m));return e.jsxs("div",{role:"grid","aria-label":"Calendar",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-4",children:[e.jsx($,{variant:"ghost",size:"icon",onClick:()=>l(K(t)),disabled:!g,"data-testid":"button-prev-month","aria-label":"Previous month",children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx("h3",{className:"text-sm font-semibold","data-testid":"text-calendar-month",children:k(t,"MMMM yyyy")}),e.jsx($,{variant:"ghost",size:"icon",onClick:()=>l(z(t,1)),disabled:T(h,C(z(t,1))),"data-testid":"button-next-month","aria-label":"Next month",children:e.jsx(M,{className:"h-4 w-4"})})]}),e.jsx("div",{className:r?"grid grid-cols-7 gap-0 sm:gap-1 mb-2":"grid grid-cols-7 gap-0 mb-1",role:"row",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(c=>e.jsx("div",{className:r?"text-center font-semibold uppercase tracking-wide text-muted-foreground py-1":"text-center text-xs font-medium text-muted-foreground py-2",style:r?{fontSize:"clamp(11px, 2.6vw, 13px)"}:void 0,role:"columnheader",children:r?c.toUpperCase():c},c))}),e.jsx("div",{className:r?"grid grid-cols-7 gap-0 sm:gap-1":"grid grid-cols-7 gap-0",children:v.map(c=>{const s=k(c,"yyyy-MM-dd"),x=T(c,m)&&!V(c),u=T(h,c),A=de(c,t),R=p?.[s]===!1,N=x||u||!A||R,j=i===s,I=V(c);return r?e.jsx("button",{type:"button",onClick:()=>!N&&d(s),disabled:N,className:`bk-day ${j?"bk-day-sel":N?"bk-day-disabled":`bk-day-avail${I?" bk-day-today":""}`}`,style:j?{backgroundColor:a,color:P(a)}:void 0,"data-testid":`button-date-${s}
1`,"aria-label":k(c,"EEEE, MMMM d, yyyy"),"aria-selected":j,children:k(c,"d")},s):e.jsxs($,{variant:"ghost",size:"icon",onClick:()=>!N&&d(s),disabled:N,className:`relative w-full text-sm ${A?"":"text-muted-foreground/30"} ${(x||u||R)&&A?"text-muted-foreground/40":""} ${j?"text-white font-semibold no-default-hover-elevate no-default-active-elevate":""}`,style:j?{backgroundColor:a}:void 0,"data-testid":`button-date-${s}`,"aria-label":k(c,"EEEE, MMMM d, yyyy"),"aria-selected":j,children:[k(c,"d"),I&&!j&&e.jsx("span",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 h-1 w-1 rounded-full",style:{backgroundColor:a}})]},s)})})]})}function be({calendarMonth:t,setCalendarMonth:l,selectedDate:i,setSelectedDate:d,selectedSlot:a,setSelectedSlot:b,slots:r,slotsLoading:p,leadTimezone:m,setLeadTimezone:h,mt:o,brandColor:n,onContinue:y,maxBookingDays:f,isEmbed:v,continueLabel:g="Continue",dayAvailability:c}){return v?e.jsxs("div",{className:"flex flex-col min-[700px]:flex-row min-[700px]:flex-1 min-[700px]:min-h-0",children:[e.jsx("div",{className:"px-5 py-5 min-[700px]:flex-1 min-[700px]:min-w-0 min-[700px]:h-full min-[700px]:min-h-0 min-[700px]:flex min-[700px]:flex-col min-[700px]:justify-center min-[700px]:px-7 min-[700px]:py-6",children:e.jsxs("div",{className:"w-full mx-auto max-w-[440px] min-[700px]:max-w-none",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-foreground mb-3","data-testid":"text-select-datetime",children:"Select a Date"}),e.jsx("div",{className:"rounded-2xl border border-border/70 p-4 shadow-[0_1px_2px_rgba(0,0,0,0.03)]",children:e.jsx(J,{calendarMonth:t,setCalendarMonth:l,selectedDate:i,setSelectedDate:d,brandColor:n,maxBookingDays:f||o?.maxBookingDays||60,isEmbed:!0,dayAvailability:c})}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs(_,{value:m,onValueChange:h,children:[e.jsx(B,{className:"h-9 text-[13px]","data-testid":"select-timezone","aria-label":"Select timezone",children:e.jsx(F,{})}),e.jsx(L,{children:H.map(s=>e.jsx(Y,{value:s,children:Q(s)},s))})]})]})]})}),e.jsx("div",{className:`${i?"block":"hidden"} px-5 pb-5 pt-5 border-t border-border/60 min-[700px]:flex min-[700px]:w-[200px] min-[700px]:shrink-0 min-[700px]:h-full min-[700px]:min-h-0 min-[700px]:flex-col min-[700px]:border-t-0 min-[700px]:border-l min-[700px]:px-4 min-[700px]:py-6`,children:i?e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-[12px] font-semibold uppercase tracking-wide text-muted-foreground mb-3 shrink-0","data-testid":"text-available-times",children:new Date(i+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"short",day:"numeric"})}),p?e.jsx("div",{className:"space-y-2 flex-1 min-h-0 overflow-y-auto bk-thin pr-1",children:[...Array(6)].map((s,x)=>e.jsx(q,{className:"h-10 w-full"},x))}):r.length===0?e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center text-center px-1",children:[e.jsx(D,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-no-slots",children:"No times available"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Try another date"})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1 md:gap-2 bk-reveal min-[700px]:block min-[700px]:space-y-2 min-[700px]:flex-1 min-[700px]:min-h-0 min-[700px]:overflow-y-auto min-[700px]:bk-thin min-[700px]:pr-1",role:"listbox","aria-label":"Available time slots",children:r.map((s,x)=>{const u=a?.startUtc===s.startUtc;return e.jsx("button",{type:"button",onClick:()=>b(s),className:`bk-slot w-full rounded-xl border py-2.5 text-[13px] font-medium tabular-nums ${u?"bk-sel":"text-foreground border-border"}`,style:u?{backgroundColor:n,borderColor:n,color:P(n),boxShadow:`0 0 0 3px ${ee(n,.16)}`}:{animationDelay:`${x*20}ms`},"data-testid":`button-slot-${s.start}`,"aria-selected":u,"aria-label":`${s.start} to ${s.end}`,children:s.start},s.startUtc)})},i),a&&e.jsxs("button",{type:"button",className:`${G} shrink-0 mt-3`,onClick:y,style:W(n),"data-testid":"button-continue-to-detail
1s","aria-label":g,children:[g,e.jsx(M,{className:"h-4 w-4 ml-1"})]})]}):e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center text-center px-2",children:[e.jsx(D,{className:"h-8 w-8 text-muted-foreground/40 mb-3"}),e.jsx("p",{className:"text-[13px] text-muted-foreground",children:"Pick a date to see available times"})]})})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-1","data-testid":"text-select-datetime",children:"Select a Date & Time"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5",children:"Choose your preferred date and time below."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(J,{calendarMonth:t,setCalendarMonth:l,selectedDate:i,setSelectedDate:d,brandColor:n,maxBookingDays:f||o?.maxBookingDays||60,dayAvailability:c}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t",children:[e.jsx(U,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs(_,{value:m,onValueChange:h,children:[e.jsx(B,{className:"text-xs","data-testid":"select-timezone","aria-label":"Select timezone",children:e.jsx(F,{})}),e.jsx(L,{children:H.map(s=>e.jsx(Y,{value:s,children:Q(s)},s))})]})]})]}),i&&e.jsxs("div",{className:"sm:w-48 shrink-0",children:[e.jsx("h4",{className:"text-sm font-medium mb-3","data-testid":"text-available-times",children:new Date(i+"T12:00:00").toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}),p?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((s,x)=>e.jsx(q,{className:"h-10 w-full"},x))}):r.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx(D,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-no-slots",children:"No times available"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Try another date"})]}):e.jsx("div",{className:"space-y-2 max-h-[320px] overflow-y-auto pr-1",role:"listbox","aria-label":"Available time slots",children:r.map(s=>{const x=a?.startUtc===s.startUtc;return e.jsx($,{variant:x?"default":"outline",onClick:()=>b(s),className:`w-full text-sm font-medium ${x?"no-default-hover-elevate no-default-active-elevate":""}`,style:x?{backgroundColor:n,borderColor:n}:void 0,"data-testid":`button-slot-${s.start}`,"aria-selected":x,"aria-label":`${s.start} to ${s.end}`,children:s.start},s.startUtc)})}),a&&e.jsxs("button",{type:"button",className:`${G} mt-4`,onClick:y,style:W(n),"data-testid":"button-continue-to-details","aria-label":g,children:[g,e.jsx(M,{className:"h-4 w-4 ml-1"})]})]})]})]})}function ye({bookingUsername:t,meetingSlug:l,mt:i,brandColor:d,maxBookingDays:a,continueLabel:b,onSlotSelected:r}){const[p,m]=S.useState(new Date),[h,o]=S.useState(null),[n,y]=S.useState(null),[f,v]=S.useState(fe),{data:g,isLoading:c}=E({queryKey:["/api/public/booking",t,l,"availability",h,f],queryFn:async()=>{const u=await fetch(`/api/public/booking/${t}/${l}/availability?date=${h}&tz=${encodeURIComponent(f)}`);if(!u.ok)throw new Error("Failed to load availability");return u.json()},enabled:!!h}),s=k(p,"yyyy-MM"),{data:x}=E({queryKey:["/api/public/booking",t,l,"availability-month",s,f],queryFn:async()=>{const u=await fetch(`/api/public/booking/${t}/${l}/availability-month?month=${s}&tz=${encodeURIComponent(f)}`);if(!u.ok)throw new Error("Failed to load month availability");return u.json()}});return e.jsx(be,{calendarMonth:p,setCalendarMonth:m,selectedDate:h,setSelectedDate:u=>{o(u),y(null)},selectedSlot:n,setSelectedSlot:y,slots:g?.slots||[],slotsLoading:c,leadTimezone:f,setLeadTimezone:v,mt:i,brandColor:d,onContinue:()=>{n&&r(n)},maxBookingDays:a,continueLabel:b,dayAvailability:x?.available})}const w={code:"link_replaced",title:"This booking link was replaced",instruction:"Your sessions are on another booking link we emailed you. Open that one, or contact the business and ask for your booking link."},ge="#1a4730";function Le(){const{token:t}=te(),{toast:l}=se(),[i,d]=S.useState(null),{data:a,isLoading:b,error:r}=E({queryKey:["/api/public/redeem",t],queryFn:async()=>{const o=await fetch(`/api/public/redeem/${t}`);if(!o.ok){const n=await o.json().catch(()=>null);throw new Error(n?.code===w.code?w.code:"invalid")}return o.json()}}),p=ne({mutationFn:async o=>{const n=await fetch(`/api/public/redeem/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({startUtc:o.startUtc,endUtc:o.endUtc})});if(!n.ok){const y=await n.json().catch(()=>({message:"Could not book your session"}));throw new Error(y.message)}return n.json()},onSuccess:o=>d({creditsRemaining:o.creditsRemaining??0}),onError:o=>l({title:"Couldn't book your session",description:o.message,variant:"destructive",duration:1e4})}),m=o=>e.jsx("div",{className:"min-h-screen bg-muted/30 flex items-center justify-center p-4",children:e.jsx(ae,{className:"w-full max-w-2xl",children:e.jsx(ie,{className:"p-6",children:o})})});if(b)return m(e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(O,{className:"h-6 w-6 animate-spin"})}));if(r?.message===w.code)return m(e.jsxs("div",{className:"text-center py-8 space-y-2","data-testid":"redeem-link-replaced",children:[e.jsx(Z,{className:"h-8 w-8 mx-auto text-muted-foreground"}),e.jsx("h2",{className:"text-lg font-semibold",children:w.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:w.instruction})]}));if(r||!a)return m(e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(pe,{className:"h-8 w-8 mx-auto text-muted-foreground"}),e.jsx("h2",{className:"text-lg font-semibold",children:"This booking link is invali
1d or has expired"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Check your email for the latest link, or contact your coach."})]}));if(p.isPending)return m(e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx(O,{className:"h-6 w-6 animate-spin"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Booking your session..."})]}));if(i)return m(e.jsxs("div",{className:"text-center py-8 space-y-3",children:[e.jsx("div",{className:"mx-auto h-12 w-12 rounded-full flex items-center justify-center",style:{backgroundColor:"hsl(var(--primary))"},children:e.jsx(he,{className:"h-6 w-6 text-white"})}),e.jsx("h2",{className:"text-xl font-semibold",children:"You are booked"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Your ",a.meetingType.name," session is confirmed. A confirmation is on its way to your email."]}),i.creditsRemaining>0?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm",children:["You have ",e.jsx("strong",{children:i.creditsRemaining})," session",i.creditsRemaining===1?"":"s"," left on this link."]}),e.jsx($,{onClick:()=>d(null),style:{backgroundColor:"hsl(var(--primary))"},"data-testid":"button-book-another",children:"Book another session"})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"That was your last session on this link."})]}));if(a.creditsRemaining<1)return m(e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(Z,{className:"h-8 w-8 mx-auto text-muted-foreground"}),e.jsx("h2",{className:"text-lg font-semibold",children:"No sessions left to book"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You have used all the sessions on this link. Purchase another package to book more."})]}));if(!a.bookingUsername)return m(e.jsx("p",{className:"text-center text-sm text-muted-foreground py-8",children:"This session type is no longer available for booking."}));const h={id:"",name:a.meetingType.name,slug:a.meetingType.slug,duration:a.meetingType.duration,meetingMethod:a.meetingType.meetingMethod,location:null,description:null,color:null,intakeQuestions:[]};return m(e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold","data-testid":"text-redeem-meeting-name",children:a.meetingType.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("strong",{"data-testid":"text-credits-remaining",children:a.creditsRemaining})," session",a.creditsRemaining===1?"":"s"," to book. Pick a time below."]})]}),e.jsx(ye,{bookingUsername:a.bookingUsername,meetingSlug:a.meetingType.slug,mt:h,brandColor:ge,continueLabel:"Book this session",onSlotSelected:o=>p.mutate(o)})]}))}export{Le 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.