1import{r as f,j as e,H as Nt}from"./react-vendor-Bmz6tUQp.js";import{s as z,L as Ce,t as Le,ak as E,a as vt,q as cs,b as Dt,ah as Ge,O as Ot,P as us,G as ms,S as xs,h as ps,i as hs,j as fs,bH as gs,bI as bs,k as wt,av as js,bG as ys,a_ as Ns,d$ as vs,bC as ws,o as ks,u as Ss,z as Cs}from"./index-yGQYYxOL.js";import{a as ue}from"./react-query-CqJKaf_6.js";import{u as Is}from"./usePublicClassOffer-0GqaMrup.js";import{c as _,P as Xe,l as $s,f as As,p as kt,a as Ke}from"./identity-C8W_F3zf.js";import{c as Bt}from"./classSchedule-Bc86J00A.js";import{f as Q,P as V,L as H,T as _s,M as Be,A as Rt,S as Ze}from"./ui-DJHd4_3u.js";import{C as Ts}from"./cake-DCFZBD7z.js";import{G as Ps}from"./gift-DPC0uSzX.js";import{W as Fs}from"./wand-sparkles-CG94jv32.js";import{E as Ls,u as Es,a as Ds,P as Os,l as Bs}from"./stripe-4dsDpqVd.js";import{C as Rs}from"./credit-card-DVHhs4a_.js";import{T as Ms}from"./tag-VQ_d03WQ.js";import{g as Ws,r as Us}from"./websiteThemes-D_MfvKIa.js";import{u as qs}from"./useResolvedWebsite-WjuqtQ3e.js";import"./supabase-CPi6FgBv.js";import"./posthog-B4nvxm9K.js";import"./radix-ui-ZQ4NEGId.js";import"./twilio-C1U8FCrE.js";import"./charts-DLQlTo8W.js";import"./date-utils-Ds47y5fu.js";const I=t=>`$${Number.isInteger(t)?t.toLocaleString("en-US"):t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`;function Ie(t,s){if(!s||s<=0)return null;const n=t/s,a=Math.round(n*100)/100;return`${I(a)} per class`}function ze(t){return!t||t.min==null&&t.max==null?"Adults":t.min!=null&&t.max!=null?t.min===t.max?`Age ${t.min}`:`Ages ${t.min}â${t.max}`:t.min!=null?`Ages ${t.min}+`:`Up to age ${t.max}`}function Ee(t,s){const n=Q(t),a=Q(s);if(!n)return a;if(!a)return n;const[i,o]=n.split(" "),[r,l]=a.split(" ");return o===l?`${i}â${r} ${l}`:`${n}â${a}`}const Ve=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Ys(t){const[s,n,a]=t.split("-").map(Number);return!s||!n||!a?null:Ve[new Date(s,n-1,a).getDay()]??null}function Gs(t){const s=new Set;for(const i of t){const o=Ys(i);o&&s.add(Ve.indexOf(o))}const n=[...s].sort((i,o)=>i-o).map(i=>Ve[i]);if(n.length===0)return null;if(n.length===1)return`${n[0]}s`;if(n.length===2)return`${n[0]}s & ${n[1]}s`;const a=n.map(i=>i.slice(0,3));return`${a.slice(0,-1).join(", ")} & ${a[a.length-1]}`}function de(t){const[s,n,a]=t.split("-").map(Number);return new Date(s,n-1,a).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}function et(t){const[s,n,a]=t.split("-").map(Number);return new Date(s,n-1,a).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function St(t){return!t||t<=0?null:t%365===0?`${t/365} year${t===365?"":"s"}`:t%30===0&&t>=60?`${t/30} months`:t===30?"1 month":`${t} days`}function Ks(t){const s=t.split(/\s+/).filter(Boolean);return s.length===1?s[0].slice(0,3).toUpperCase():s.slice(0,3).map(n=>n[0].toUpperCase()).join("")}function De(t){return{id:t.id,name:t.name,slug:t.slug??"",logoUrl:t.logo_url??null,timezone:t.timezone??null,canCharge:!!t.stripe_account_id&&t.stripe_charges_enabled===!0,websiteTheme:t.website_theme??null,brandColor:t.brand_color??null,location:t.location??null}}async function Hs(t){const s=new Map;if(t.length===0)return s;const{data:n}=await z.from("program_classes").select("class_id, level_id").in("class_id",t).is("deleted_at",null),a=[...new Set((n||[]).map(r=>r.level_id).filter(Boolean))];if(a.length===0)return s;const{data:i}=await z.from("program_levels").select("id, min_age, max_age").in("id",a),o=new Map((i||[]).map(r=>[r.id,{min:r.min_age??null,max:r.max_age??null}]));for(const r of n||[]){const l=o.get(r.level_id);if(!l)continue;const d=s.get(r.class_id);d?s.set(r.class_id,{min:d.min==null||l.min==null?null:Math.min(d.min,l.min),max:d.max==null||l.max==null?null:Math.max(d.max,l.max)}):s.set(r.class_id,{...l})}return s}function zs(t,s){const n=Is(t,s),{data:a}=ue({queryKey:["public-booking-class-ages",s],enabled:!!s&&!!n.cls,staleTime:5*60*1e3,queryFn:()=>Hs([s])});return f.useMemo(()=>{var D,T;if(n.loading)return{status:"loading"};if(!n.studio||!n.cls)return{status:"not_found",studio:n.studio?De(n.studio):null,reason:n.reason??"class_not_found"};const i={...De(n.studio),canCharge:n.studio.stripe_charges_enabled===!0},o=n.cls,r=(a==null?void 0:a.get(o.id))??null,l=n.sessions,u=[Gs(l.map(g=>
1g.session_date))??Bt({recurringDays:(D=o.recurring_pattern)==null?void 0:D.days,nextSessionDate:((T=l[0])==null?void 0:T.session_date)??null}),Ee(o.start_time,o.end_time)].filter(Boolean).join(" · "),p=[o.room,i.name].filter(Boolean).join(" · "),v=[u?{k:"When",v:u}:null,p?{k:"Where",v:p}:null,n.teacher?{k:"Teacher",v:n.teacher.full_name}:null].filter(Boolean),j=n.introOffers.map(g=>({id:g.id,name:g.name,price:Number(g.price)||0,classLimit:g.class_limit||1,description:null})),w=j.length?Math.min(...j.map(g=>g.price)):null,h=o.drop_in_enabled&&o.drop_in_price!=null?Number(o.drop_in_price):null,m=[];if(j.length&&m.push({title:"Ways to try it",rows:j.map(g=>({id:g.id,title:g.name,sub:[`${g.classLimit} class${g.classLimit>1?"es":""}`,Ie(g.price,g.classLimit)].filter(Boolean).join(" · "),right:g.price===0?"Free":I(g.price)}))}),l.length){const g=l.slice(0,3);m.push({title:"Next sessions",rows:g.map(Y=>({id:Y.id,title:de(Y.session_date),sub:Ee(Y.start_time,Y.end_time)})),footnote:l.length>3?`+ ${l.length-3} more through ${et(l[l.length-1].session_date)}`:null})}const x=w!=null?j.length>1?`From ${I(w)}`:I(w):h!=null?I(h):"â",S=w!=null?"New students":h!=null?"Drop-in":"",$=w!=null?"Book a trial":h!=null?"Book a class":"Get started",k=w!=null?[j.length>1?`${j.map(g=>g.classLimit).sort((g,Y)=>g-Y).join(" or ")} intro classes`:`${j[0].classLimit} intro class${j[0].classLimit>1?"es":""}`,"No membership required"]:h!=null?["Pay per class","No membership required"]:[];return{status:"ready",model:{kind:"class",studio:i,eyebrow:`Class · ${ze(r)}`,title:o.name,description:o.description,facts:v,price:x,priceNote:S,cta:$,highlights:k,sections:m,classId:o.id,offerId:null,packageId:null,introOffers:j,classAges:r}}},[n,a])}function Vs(t,s){const n=ue({queryKey:["public-booking-intro-landing",t,s],enabled:!!t&&!!s,staleTime:6e4,retry:!1,queryFn:async()=>{let a;try{a=await _("landing",{studioSlug:t,kind:"intro",id:s})}catch(v){if(v instanceof Xe&&v.status===404)return{status:"not_found",studio:null,reason:"studio_not_found"};throw v}const i=De(a.studio),o=a.offer;if(!o)return{status:"not_found",studio:i,reason:"offer_not_found"};const r=a.eligibleCount,l=Number(o.price)||0,d=o.class_limit||1,u=Ie(l,d),p=[{k:"Price",v:l===0?"Free":[I(l),u].filter(Boolean).join(" · ")},o.valid_until?{k:"Valid",v:`Until ${et(o.valid_until)}`}:null,{k:"Classes",v:r>0?`Pick any ${d} of ${r} weekly class${r===1?"":"es"}`:`${d} class${d>1?"es":""}`}].filter(Boolean);return{status:"ready",model:{kind:"intro",studio:i,eyebrow:"Intro offer · New students",title:o.name,description:o.description??null,facts:p,price:l===0?"Free":I(l),priceNote:["Intro offer",u].filter(
1Boolean).join(" · "),cta:"Get started",highlights:[`${d} group class${d>1?"es":""}`,"Matched to your dancer's age","No membership or commitment"],sections:[],classId:null,offerId:o.id,packageId:null,introOffers:[{id:o.id,name:o.name,price:l,classLimit:d,description:o.description??null}],classAges:null}}}});return n.isLoading||!n.data&&!n.error?{status:"loading"}:n.error||!n.data?{status:"not_found",studio:null,reason:"error"}:n.data}function Qs(t,s){return ue({queryKey:["public-booking-punch-landing",t,s],enabled:!!t&&!!s,staleTime:60*1e3,retry:!1,queryFn:async()=>{let n;try{n=await _("landing",{studioSlug:t,kind:"punch",id:s})}catch(m){if(m instanceof Xe&&m.status===404)return{state:{status:"not_found",studio:null,reason:"studio_not_found"},classes:[]};throw m}const a=De(n.studio),i=n.pkg;if(!i)return{state:{status:"not_found",studio:a,reason:"package_not_found"},classes:[]};const o=n.programName,r=n.classes.map(m=>({id:m.id,name:m.name,startTime:m.start_time,endTime:m.end_time,teacherName:m.teacher_name,days:Bt({recurringDays:m.recurring_days,nextSessionDate:m.next_session_date,fallbackSchedule:m.schedule}),ages:m.ages})).sort((m,x)=>m.name.localeCompare(x.name)),l=n.siblings.map(m=>({id:m.id,name:m.name,price:Number(m.price??0),count:m.number_of_classes??null,expiresInDays:m.expires_in_days??null})).sort((m,x)=>(m.count??m.price)-(x.count??x.price)).slice(0,4),d=Number(i.price)||0,u=i.number_of_classes||0,p=Ie(d,u),v=St(i.expires_in_days),j=i.expires_on?`On ${et(i.expires_on)}`:v?`${v} after purchase`:null,w=[{k:"Price",v:[I(d),p].filter(Boolean).join(" · ")},j?{k:"Expires",v:j}:null,r.length?{k:"Booking",v:"Drop in to any class below"}:null].filter(Boolean),h=[];return r.length&&h.push({title:"Classes it covers",rows:r.map(m=>({id:m.id,title:m.name,sub:[m.days?m.days.endsWith("s")?m.days:`${m.days}s`:null,Ee(m.startTime,m.endTime),m.teacherName].filter(Boolean).join(" · ")}))}),l.length&&h.push({title:"Other passes",rows:l.map(m=>({id:m.id,title:m.name,sub:[Ie(m.price,m.count),St(m.expiresInDays)].filter(Boolean).join(" · "),right:I(m.price)}))}),{classes:r,state:{status:"ready",model:{kind:"punch",studio:a,eyebrow:`Punch pass${o?` · ${o}`:""}`,title:i.name,description:i.description??null,facts:w,price:I(d),priceNote:["One-time",p].filter(Boolean).join(" · "),cta:"Buy pass",highlights:[u?`${u} class${u===1?"":"es"}${o?` · ${o}`:""}`:i.name,j?`Expires ${j.charAt(0).toLowerCase()}${j.slice(1)}`:"No expiry","Drop in to any class"],sections:h,classId:null,offerId:null,packageId:i.id,introOffers:[],classAges:null}}}}})}function Js(t,s,n){const a=zs(t==="class"?s:void 0,t==="class"?n:void 0),i=Vs(t==="intro"?s:void 0,t==="intro"?n:void 0),o=Qs(t==="punch"?s:void 0,t==="punch"?n:void 0);return t==="class"?{state:a,punchClasses:[]}:t==="intro"?{state:i,punchClasses:[]}:o.isLoading||!o.data&&!o.error?{state:{status:"loading"},punchClasses:[]}:o.error||!o.data?{state:{status:"not_found",studio:null,reason:"error"},punchClasses:[]}:{state:o.data.state,punchClasses:o.data.classes}}function Oe({studio:t,desktop:s,signedInName:n,onSignIn:a}){return e.jsxs("div",{className:s?"flex items-center gap-2.5 border-b border-border px-10 py-3.5":"flex items-center gap-2.5 border-b border-border px-5 pb-3 pt-2.5",children:[t.logoUrl?e.jsx("img",{src:t.logoUrl,alt:t.name,className:"h-[34px] w-[34px] shrink-0 rounded-md bg-white object-contain"}):e.jsx("div",{className:"flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-md bg-[#0A0A0A] text-[11px] font-bold tracking-[0.3px] text-white",children:Ks(t.name)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[11px] leading-none text-muted-foreground",children:"Hosted by"}),e.jsxs(Ce,{to:`/s/${t.slug}`,className:"block truncate text-[14.5px] font-bold text-foreground",children:[t.name,t.location?` · ${t.location}`:""]})]}),n?e.jsx("div",{className:"max-w-[40%] truncate text-[14px] font-semibold","data-testid":"pb-signed-in",children:n}):a?e.jsx("button",{type:"button",onClick:a,className:"min-h-[44px] text-[14px] font-semibold text-foreground","data-testid":"pb-sign-in",children:"Sign in"}):e.jsx(Ce,{to:`/s/${t.slug}/login`,className:"flex min-h-[44px] items-center text-[14px] font-semibold text-foreground","data-testid":"pb-sign-in",children:"Sign in"})]})}const Xs="(min-width: 1024px)";function tt(){const[t]=f.useState(()=>typeof window<"u"?window.matchMedia(Xs).matches:!1);return t}
1function Zs({studio:t,content:s,price:n,priceNote:a,cta:i,highlights:o,onStart:r,disabled:l,signedInName:d,onSignIn:u}){return tt()?e.jsxs("div",{className:"min-h-[100dvh]","data-testid":"pb-landing",children:[e.jsx(Oe,{studio:t,desktop:!0,signedInName:d,onSignIn:u}),e.jsxs("div",{className:"mx-auto grid max-w-[1040px] grid-cols-[minmax(0,1fr)_340px] items-start gap-14 px-10 pb-16 pt-12",children:[e.jsx("div",{children:s}),e.jsxs("div",{className:"sticky top-6 rounded-2xl border border-border p-6",children:[e.jsx("div",{className:"text-[30px] font-bold tracking-[-0.5px]","data-testid":"pb-price",children:n}),e.jsx("div",{className:"mb-[18px] text-[13.5px] text-muted-foreground",children:a}),e.jsx(V,{onClick:r,disabled:l,"data-testid":"pb-start",children:i}),o.length>0&&e.jsx("div",{className:"mt-[18px] grid gap-2 border-t border-border pt-4",children:o.map(v=>e.jsxs("div",{className:"flex items-start gap-2.5 text-[14.5px] text-foreground/80",children:[e.jsx(Le,{className:"mt-0.5 h-[15px] w-[15px] shrink-0 text-[hsl(var(--success))]",strokeWidth:2.4}),v]},v))})]})]})]}):e.jsxs("div",{className:"flex min-h-[100dvh] flex-col","data-testid":"pb-landing",children:[e.jsx(Oe,{studio:t,signedInName:d,onSignIn:u}),e.jsx("div",{className:"flex-1 px-5 pb-6 pt-[22px]",children:s}),e.jsx("div",{className:"sticky bottom-0 border-t border-border bg-background px-5 pt-3",style:{paddingBottom:"max(26px, env(safe-area-inset-bottom))"},children:e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("div",{className:"text-[20px] font-bold tracking-[-0.3px]","data-testid":"pb-price",children:n}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:a})]}),e.jsx(V,{className:"flex-1",onClick:r,disabled:l,"data-testid":"pb-start",children:i})]})})]})}const en="mb-2 mt-[26px] text-[11.5px] font-bold uppercase tracking-[0.8px] text-muted-foreground";function tn({title:t,sub:s,right:n,last:a,to:i}){const o=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[15px] font-semibold",children:t}),s&&e.jsx("div",{className:"mt-0.5 text-[13px] text-muted-foreground",children:s})]}),n&&e.jsx("div",{className:"text-[15.5px] font-bold",children:n})]}),r=`flex min-h-[44px] items-center gap-3 py-[13px] ${a?"":"border-b border-border"}`;return i?e.jsx(Ce,{to:i,className:r,children:o}):e.jsx("div",{className:r,children:o})}function sn({model:t,onStart:s,signedInName:n,onSignIn:a}){const i=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[13px] font-semibold text-[hsl(var(--gold))]","data-testid":"pb-eyebrow",children:t.eyebrow}),e.jsx("h1",{className:"my-1 text-[28px] font-bold tracking-[-0.5px] lg:mb-2 lg:text-[40px] lg:tracking-[-0.8px]",style:{textWrap:"balance"},"data-testid":"pb-title","data-pb-heading":!0,children:t.title}),t.description&&e.jsx("p",{className:"mb-4 max-w-[560px] text-[14px] leading-[1.45] text-muted-foreground lg:text-[16px]",style:{textWrap:"pretty"},children:t.description}),e.jsx("div",{"data-testid":"pb-facts",children:t.facts.map((o,r)=>e.jsx("div",{className:r===t.facts.length-1?"[&>div]:border-b-0":"",children:e.jsx(H,{k:o.k,v:o.v})},o.k))}),t.sections.map(o=>e.jsxs("div",{children:[e.jsx("div",{className:en,children:o.title}),o.rows.map((r,l)=>e.jsx(tn,{title:r.title,sub:r.sub,right:r.right,last:l===o.rows.length-1,to:o.title==="Other passes"?`/s/${t.studio.slug}/shop/${r.id}`:void 0},r.id)),o.footnote&&e.jsx("div",{className:"mt-1 text-[13px] text-muted-foreground",children:o.footnote})]},o.title)),!t.studio.canCharge&&e.jsx("div",{className:"mt-6 rounded-xl bg-muted px-3.5 py-3 text-[13.5px] text-foreground/80",children:"Online payments are not set up for this studio yet. Contact the front desk to book."})]});return e.jsx(Zs,{studio:t.studio,content:i,price:t.price,priceNote:t.priceNote,cta:t.cta,highlights:t.highlights,onStart:s,disabled:!t.studio.canCharge&&t.price!=="Free",signedInName:n,onSignIn:a})}function nn(t){const{studioId:s,offerId:n,leadId:a,auth:i,enabled:o=!0}=t;return ue({queryKey:["public-booking-sessions",s,n,a??null,i?"auth":"anon"],enabled:o&&!!s&&!!n,staleTime:60*1e3,retry:!1,queryFn:async()=>(await _("sessions",{studioId:s,offerId:n,leadId:a??null},{auth:!!i})).sessions??[]})}function an({studio:t,title:s,step:n,total:a,onBack:i,eyebrow:o,banner:r,children:l,aside:d,cta:u,ctaDisabled:p,ctaBusy:v,onCta:j,footer:w,hideCta:h,signedInName:m,hideProgress:x}){const S=f.useRef(null);f.useEffect(()=>{var T;window.scrollTo({top:0}),(T=S.current)==null||T.scrollTo({top:0})},[n,s]);const $=!x&&e.jsx("div",{className:"flex gap-1","aria-hidden":!0,
1children:Array.from({length:a},(T,g)=>e.jsx("div",{className:E("h-[3px] flex-1 rounded-full",g<=n?"bg-[#0A0A0A]":"bg-border")},g))}),k=w??e.jsx(V,{onClick:j,disabled:p||v,"data-testid":"pb-cta",children:v?"One momentâ¦":u});return tt()?e.jsxs("div",{className:"min-h-[100dvh]","data-testid":"pb-step","data-step":s,children:[e.jsx(Oe,{studio:t,desktop:!0,signedInName:m}),e.jsxs("div",{className:"mx-auto grid max-w-[1040px] grid-cols-[minmax(0,1fr)_340px] items-start gap-14 px-10 pb-16 pt-10",children:[e.jsxs("div",{className:"max-w-[560px]",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2.5",children:[e.jsxs("button",{type:"button",onClick:i,className:"flex min-h-[36px] items-center gap-1 text-[14px] font-semibold text-foreground","data-testid":"pb-back",children:[e.jsx(vt,{className:"h-[18px] w-[18px]"}),"Back"]}),e.jsx("div",{className:"flex-1"}),!x&&e.jsxs("div",{className:"text-[13px] text-muted-foreground",children:["Step ",n+1," of ",a," · ",s]})]}),e.jsx("div",{className:"mb-8",children:$}),o&&e.jsx("div",{className:"text-[13px] font-semibold text-[hsl(var(--gold))]",children:o}),l,!h&&e.jsx("div",{className:"mt-7 flex justify-end border-t border-border pt-5",children:e.jsx("div",{className:"min-w-[220px]",children:k})})]}),e.jsxs("div",{className:"sticky top-6",children:[r,d]})]})]}):e.jsxs("div",{className:"flex min-h-[100dvh] flex-col","data-testid":"pb-step","data-step":s,children:[e.jsxs("div",{className:"flex min-h-[44px] items-center gap-2 px-5 pb-2.5",style:{paddingTop:"max(10px, calc(env(safe-area-inset-top) + 6px))"},children:[e.jsx("button",{type:"button",onClick:i,"aria-label":"Back",className:"-ml-1.5 flex h-11 w-11 items-center text-foreground","data-testid":"pb-back",children:e.jsx(vt,{className:"h-[22px] w-[22px]"})}),e.jsx("div",{className:"flex-1 text-[17px] font-bold tracking-[-0.3px]",children:s}),!x&&e.jsxs("div",{className:"text-[13px] text-muted-foreground",children:[n+1," of ",a]})]}),e.jsx("div",{className:"px-5",children:$}),e.jsxs("div",{ref:S,className:"flex-1 px-5 pb-6 pt-[22px]",children:[r,o&&e.jsx("div",{className:"text-[13px] font-semibold text-[hsl(var(--gold))]",children:o}),l]}),!h&&e.jsx("div",{className:"sticky bottom-0 border-t border-border bg-background px-5 pt-3",style:{paddingBottom:"max(26px, env(safe-area-inset-bottom))"},children:k})]})}function rn({expiresAt:t,onExpired:s}){const[n,a]=f.useState(Date.now());f.useEffect(()=>{const l=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(l)},[]);const i=Math.max(0,Math.floor((new Date(t).getTime()-n)/1e3));f.useEffect(()=>{i===0&&(s==null||s())},[i===0]);const o=Math.floor(i/60),r=String(i%60).padStart(2,"0");return e.jsxs("div",{className:"mb-[18px] flex items-center gap-2 rounded-[10px] bg-[hsl(var(--gold-soft))] px-3 py-2.5 text-[13.5px] font-semibold text-[hsl(var(--gold))]","data-testid":"pb-hold",children:[e.jsx(cs,{className:"h-4 w-4"}),i>0?`Your spots are held for ${o}:${r}`:"Your hold ended â spots are first come, first served"]})}const on="my-1 mb-1.5 text-[22px] font-bold tracking-[-0.4px]",ln="mb-4 text-[14px] leading-[1.45] text-muted-foreground",ce="mb-2 mt-[26px] text-[11.5px] font-bold uppercase tracking-[0.8px] text-muted-foreground",U="mb-1.5 text-[12px] font-semibold tracking-[0.2px] text-muted-foreground";function J({children:t,className:s}){return e.jsx("div",{className:E(on,s),"data-pb-heading":!0,children:t})}function $e({children:t,className:s}){return e.jsx("div",{className:E(ln,s),style:{textWrap:"pretty"},children:t})}function be({label:t,half:s,className:n,invalid:a,...i}){return e.jsxs("label",{className:E("mb-3.5 block min-w-0",s&&"flex-1"),children:[t&&e.jsx("div",{className:U,children:t}),e.jsx("input",{...i,className:E("h-12 w-full rounded-xl border bg-card px-3.5 text-[15.5px] font-medium text-foreground outline-none placeholder:text-muted-foreground/60 focus:border-[#0A0A0A]",a?"border-destructive":"border-border",n)})]})}function ge({on:t,onClick:s,title:n,sub:a,disabled:i,testId:o,icon:r}){return e.jsx("div",{className:E(i&&"opacity-50"),children:e.jsxs(_s,{on:t,onClick:()=>!i&&s(),testId:o,className:"flex w-full items-center gap-2.5 py-2.5",children:[r??e.jsx(Be,{on:t}),e.jsxs("span",{className:"min-w-0 flex-1",children:[n,a&&e.jsx("span",{className:"mt-0.5 block text-[13px] font-medium text-muted-foreground",children:a})]})]})})}const dn=[3,4,5,6,7,8,9,10,11,12,13,14,15,16,"17+"];function Ct({age:t,onChange:s}
1){return e.jsx("div",{className:"grid grid-cols-5 gap-2","data-testid":"pb-age-grid",children:dn.map(n=>{const a=n==="17+"?17:n,i=t===a;return e.jsx("button",{type:"button",onClick:()=>s(a),"aria-pressed":i,className:E("h-11 rounded-[10px] border-[1.5px] text-[15px] font-semibold",i?"border-[#0A0A0A] bg-[#0A0A0A] text-white":"border-border bg-card text-foreground"),children:n},String(n))})})}function cn({on:t,children:s,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:E("h-[34px] whitespace-nowrap rounded-full border px-3.5 text-[13.5px] font-semibold",t?"border-[#0A0A0A] bg-[#0A0A0A] text-white":"border-border bg-card text-foreground"),children:s})}function Qe({title:t,sub:s,right:n,last:a}){return e.jsxs("div",{className:E("flex min-h-[44px] items-center gap-3 py-[13px]",!a&&"border-b border-border"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[15px] font-semibold",children:t}),s&&e.jsx("div",{className:"mt-0.5 text-[13px] text-muted-foreground",children:s})]}),n]})}function le({children:t,tone:s="soft"}){return e.jsx("div",{className:E("mt-2.5 rounded-[10px] px-3 py-2.5 text-[13.5px] leading-[1.45]",s==="gold"&&"bg-[hsl(var(--gold-soft))] text-foreground",s==="soft"&&"bg-muted text-foreground/80",s==="error"&&"bg-destructive/10 text-destructive"),children:t})}function Mt({on:t,onToggle:s,children:n,testId:a}){return e.jsxs("button",{type:"button",onClick:s,"aria-pressed":t,"data-testid":a,className:"mb-4 flex items-start gap-2.5 text-left text-[14px] leading-[1.4] text-foreground",children:[e.jsx(Be,{on:t,multi:!0}),e.jsx("span",{children:n})]})}function un({studioName:t,trial:s,status:n,useRemembered:a,remembered:i,onNew:o,onReturning:r,onContinueAs:l}){return e.jsxs(e.Fragment,{children:[i&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:l,"data-testid":"pb-continue-as",className:`mb-[22px] flex w-full items-center gap-3 rounded-[14px] border-[1.5px] bg-card px-4 py-3.5 text-left ${a?"border-[#0A0A0A]":"border-border"}`,children:[e.jsx(Rt,{name:i.familyName,size:40}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-[15.5px] font-bold",children:["Continue as ",i.contactName]}),e.jsxs("span",{className:"block text-[13px] text-muted-foreground",children:[i.familyName," · this device"]})]}),e.jsx(Dt,{className:"h-[18px] w-[18px] text-muted-foreground"})]}),e.jsx("div",{className:`${ce} mt-0`,children:"Not you?"})]}),!i&&e.jsxs(J,{children:["Have you danced with ",t," before?"]}),!i&&e.jsx($e,{children:s?`Intro offers are for dancers new to ${t}. Returning families can sign in to book with a saved dancer.`:"Returning dancers can sign in to use saved details and cards."}),e.jsxs("div",{className:"grid gap-2.5",children:[e.jsx(ge,{on:n==="new",onClick:o,title:`I'm new to ${t}`,sub:"First time booking",testId:"pb-start-new"}),e.jsx(ge,{on:n==="returning"&&!a,onClick:r,title:i?"Use a different account":"I've been here before",sub:"Sign in with email or phone",testId:"pb-start-returning"})]})]})}function mn({s:t,update:s,onFind:n,onSendCode:a,onForgot:i}){var l;const o=$s(t.identifier),r=f.useRef(null);return f.useEffect(()=>{var d;t.mode==="code"&&((d=r.current)==null||d.focus())},[t.mode]),e.jsxs(e.Fragment,{children:[e.jsx(J,{children:"Welcome back"}),t.mode==="id"&&e.jsxs(e.Fragment,{children:[e.jsx($e,{children:"Enter the email or mobile number on your account."}),e.jsx(be,{label:"Email or mobile",value:t.identifier,onChange:d=>s({identifier:d.target.value,error:null}),placeholder:"[email protected]",autoComplete:"username",inputMode:"email","data-testid":"pb-signin-id",onKeyDown:d=>d.key==="Enter"&&t.identifier.trim()&&n()}),e.jsx(Ze,{onClick:n,disabled:!t.identifier.trim()||t.busy,className:t.identifier.trim()?"":"opacity-40","data-testid":"pb-find-account",children:t.busy?"Lookingâ¦":"Find my account"}),t.error&&e.jsx(le,{tone:"error",children:t.error})]}),t.mode!=="id"&&t.lookup&&e.jsxs("div",{className:"my-2 mb-[18px] flex items-center gap-3 rounded-xl bg-muted px-3.5 py-3",children:[e.jsx(Rt,{name:t.lookup.masked,size:36}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[15px] font-bold",children:"Account found"}),e.jsx("div",{className:"truncate text-[13px] text-muted-foreground",children:t.lookup.masked})]}),e.jsx("button",{type:"button",onClick:()=>s({mode:"id",password:"",code:"",error:null,codeSent:!1}),className:"min-h-[44px] text-[13.5px] font-semibold underline",children:"Change"})]}),t.mode==="pw"&&e.jsxs(e.Fragment,{children:[e.jsx(be,{label:"Password",type:"password",value:t.password,onChange:d=>s({password:d.target.value,error:null}),placeholder:"Your password",autoComplete:"current-password","data-testid":"pb-signin-password"}),e.jsxs("div",{className:"-mt-1 flex justify-between gap-3 text-[13.5px]",children:[e.jsx("button",{type:"button",onClick:a,className:"font-semibold underline","data-testid":"pb-send-code",children:o?"Text me a code instead":"Email me a code instead"}),e.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground",children:"Forgot password?"})]}),t.error&&e.jsx(le,{tone:"error",children:t.error})]}),t.mode==="code"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:U,children:["Code ",o?"texted":"emailed"," to ",((l=t.lookup)==null?void 0:l.masked)??t.identifier]}),e.jsx("input",{ref:r,value:t.code,onChange:d=>s({code:d.target.value.replace(/\D/g,"").slice(0,6),error:null}),inputMode:"numeric",autoComplete:"one-time-code","aria-label":"Verification code",className:"sr-only","data-testid":"pb-code-input"}),e.jsx("div",{className:"grid grid-cols-6 gap-2",onClick:()=>{var d;return(d=r.current)==null?void 0:d.focus()},role:"presentation",children:[0,1,2,3,4,5].map(d=>e.jsx("div",{className:`flex h-[52px] items-center justify-center rounded-xl border-[1.5px] text-[20px] font-bold ${t.code[d]?"border-[#0A0A0A]":"border-border"}`,children:t.code[d]||""},d))}),e.jsxs("div",{className:"mt-3 flex justify-between gap-3 text-[13.5px]",children:[e.jsx("span",{className:"text-muted-foreground",children:t.codeSent?t.code.length===6?"Checkingâ¦":"Enter the 6-digit code":"Sendingâ¦"}),e.jsx("button",{type:"button",onClick:()=>s({mode:"pw",code:"",error:null}),className:"font-semibold underline",children:"Use password"})]}),e.jsx("button",{type:"button",onClick:a,disabled:t.busy,className:"mt-2 text-[13.5px] text-muted-foreground underline",children:"Send again"}),t.error&&e.jsx(le,{tone:"error",children:t.error})]}),t.mode!=="id"&&e.jsx("div",{className:"mt-5",children:e.jsx(Mt,{on:t.remember,onToggle:()=>s({remember:!t.remember}),testId:"pb-remember",children:"Remember this device"})})]})}const ke="__other__",xn={parentName:"",first:"",last:"",email:"",ph
1one:"",programId:"",otherProgram:"",heardAbout:"",referralCode:""};function pn(t){const s=t.trim().split(/\s+/).filter(Boolean);return{first:s[0]??"",last:s.slice(1).join(" ")}}function hn(t){return ue({queryKey:["public-sub-programs",t],enabled:!!t,staleTime:5*60*1e3,queryFn:async()=>{const{data:s,error:n}=await z.rpc("get_studio_public_programs",{p_studio_id:t});if(n)throw n;return s??[]}})}const se="h-12 w-full rounded-xl border border-border bg-card pl-10 pr-3.5 text-[15.5px] font-medium text-foreground outline-none placeholder:text-muted-foreground/60 focus:border-[#0A0A0A]",fe=()=>e.jsx("span",{className:"text-destructive",children:" *"});function ne({icon:t,children:s}){return e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 text-muted-foreground [&>svg]:h-4 [&>svg]:w-4",children:t}),s]})}function fn({c:t,update:s,d:n,updateDancer:a,punch:i,duplicate:o,trial:r,studioId:l,studioName:d,onSignInInstead:u,error:p}){const{data:v=[]}=hn(l),j=f.useMemo(()=>{var m;const h=new Map;for(const x of v){const S=((m=x.parent_program_name)==null?void 0:m.trim())||"Programs";h.has(S)||h.set(S,[]),h.get(S).push(x)}return[...h.entries()]},[v]),w=n.who==="me";return e.jsxs(e.Fragment,{children:[e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"h-5 w-5"}),"Tell Us About You"]}),e.jsx($e,{children:"We'll create your account in the next step."}),e.jsxs("label",{className:"mb-3.5 block",children:[e.jsxs("div",{className:U,children:["Parent/Guardian Name",e.jsx(fe,{})]}),e.jsx(ne,{icon:e.jsx(Ge,{}),children:e.jsx("input",{className:se,value:t.parentName,onChange:h=>s({parentName:h.target.value,...pn(h.target.value)}),placeholder:"John Doe",autoComplete:"name","data-testid":"pb-parent-name"})})]}),e.jsxs("label",{className:"mb-2 block",children:[e.jsxs("div",{className:U,children:["Student First Name",e.jsx(fe,{})]}),e.jsx(ne,{icon:e.jsx(Ge,{}),children:e.jsx("input",{className:se,value:w?t.first:n.name,onChange:h=>a({name:h.target.value,who:"child"}),placeholder:"Emma",readOnly:w,"data-testid":"pb-dancer-name"})})]}),e.jsx(Mt,{on:w,onToggle:()=>a(w?{who:"child",name:"",age:null}:{who:"me",name:"",age:null}),testId:"pb-dancer-me",children:i?"The pass is for me (adult)":"I'm the dancer (adult)"}),!w&&!i&&e.jsxs("label",{className:"mb-3.5 block",children:[e.jsx("div",{className:U,children:"Dancer's Age"}),e.jsx(ne,{icon:e.jsx(Ts,{}),children:e.jsx("input",{className:se,type:"number",min:1,max:99,inputMode:"numeric",value:n.age??"",onChange:h=>a({age:h.target.value===""?null:Math.max(0,Math.min(99,Math.round(Number(h.target.value))))}),placeholder:"7","data-testid":"pb-dancer-age"})})]}),e.jsxs("label",{className:"mb-3.5 block",children:[e.jsxs("div",{className:U,children:["Email",e.jsx(fe,{})]}),e.jsx(ne,{icon:e.jsx(Ot,{}),children:e.jsx("input",{className:se,type:"email",value:t.email,onChange:h=>s({email:h.target.value}),placeholder:"[email protected]",autoComplete:"email",inputMode:"email","data-testid":"pb-email"})})]}),o&&e.jsxs("div",{className:"-mt-1.5 mb-3.5 rounded-xl bg-[hsl(var(--gold-soft))] px-3.5 py-3","data-testid":"pb-duplicate",children:[e.jsxs("div",{className:"text-[14px] font-bold",children:["This email already has a ",d," account"]}),e.jsxs("div",{className:"mt-0.5 text-[13px] leading-[1.45] text-foreground/80",children:["Sign in to book with your saved dancers.",r?" Intro offers are one per family.":""]}),e.jsx(V,{onClick:u,className:"mt-2.5 h-10 text-[14px]","data-testid":"pb-sign-in-instead",children:"Sign in instead"})]}),e.jsxs("label",{className:"mb-3.5 block",children:[e.jsxs("div",{className:U,children:["Phone",e.jsx(fe,{})]}),e.jsx(ne,{icon:e.jsx(us,{}),children:e.jsx("input",{className:se,type:"tel",value:t.phone,onChange:h=>s({phone:As(h.target.value)}),placeholder:"+1 (555) 000-0000",autoComplete:"tel",inputMode:"tel","data-testid":"pb-phone"})})]}),e.jsxs("div",{className:"mb-3.5",children:[e.jsxs("div",{className:U,children:["Program Interest",v.length>0&&e.jsx(fe,{})]}),e.jsx(ne,{icon:e.jsx(ms,{}),children:e.jsxs(xs,{value:t.programId,onValueChange:h=>s({programId:h}),children:[e.jsx(ps,{className:"h-12 rounded-xl border-border bg-card pl-10 text-[15.5px] font-medium","data-testid":"pb-program",children:e.jsx(hs,{placeholder:"Select a program"})}),e.jsxs(fs,{children:[j.map(([h,m])=>e.jsxs(gs,{children:[e.jsx(bs,{children:h}),m.map(x=>e.jsx(wt,{value:x.id,children:x.name},x.id))]},h)),e.jsx(wt,{value:ke,children:"Other"})]})]})}),t.programId===ke&&e.jsx("input",{className:E(se,"mt-2 pl-3.5"),value:t.otherProgram,onChange:h=>s({otherProgram:h.target.value}),placeholder:"What are you looking for?","aria-label":"Tell us what you're looking for"})]}),e.jsxs("label",{className:"mb-3.5 block",children:[e.jsxs("div",{className:U,children:["How did you hear about us?",e.jsx(fe,{})]}),e.jsx(ne,{icon:e.jsx(js,{}),children:e.jsx("input",{className:se,value:t.heardAbout,onChange:h=>s({heardAbout:h.target.value}),placeholder:"Instagram, a friend, drove pastâ¦","data-testid":"pb-heard"})})]}),e.jsxs("label",{className:"mb-3.5 block",children:[e.jsxs("div",{className:U,children:["Referral code ",e.jsx("span",{className:"font-medium text-muted-foreground
1/60",children:"optional"})]}),e.jsx(ne,{icon:e.jsx(Ps,{}),children:e.jsx("input",{className:se,value:t.referralCode,onChange:h=>s({referralCode:h.target.value.toUpperCase()}),placeholder:"A friend referred me",autoComplete:"off","data-testid":"pb-referral"})})]}),p&&e.jsx("div",{className:"text-[13.5px] text-destructive",children:p}),e.jsx("div",{className:"mt-1 text-center text-[12.5px] text-muted-foreground",children:"Next: pick your classes and pay · you'll set a password after booking"})]})}function gn({d:t,update:s,punch:n,trial:a,family:i,studioName:o,offerName:r}){const l=n?"Who's this pass for?":"Who's dancing?",d=t.who==="child"||t.who==="add";if(i)return e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"mb-[18px]",children:l}),e.jsxs("div",{className:"grid gap-2.5",children:[i.dancers.map(p=>{const v=a&&p.enrolled,j=v?`Already a ${o} dancer · intro offers are for new dancers`:p.isAdultSelf?"You · account holder":p.age!=null?`Age ${p.age}${p.enrolled?" · enrolled":""}`:p.enrolled?"Enrolled":"No classes yet";return e.jsx(ge,{on:t.who==="saved"&&t.savedStudentId===p.id,disabled:v,onClick:()=>s({who:"saved",savedStudentId:p.id,name:p.name,age:p.age}),title:p.name,sub:j,testId:"pb-dancer-saved"},p.id)}),e.jsx(ge,{on:t.who==="add",onClick:()=>s({who:"add",savedStudentId:null,name:"",age:null}),title:"Add a dancer",icon:e.jsx(ys,{className:"h-4 w-4"}),testId:"pb-dancer-add"})]}),t.who==="add"&&e.jsxs("div",{className:"mt-5",children:[e.jsx(be,{label:"Dancer's first name",value:t.name,onChange:p=>s({name:p.target.value}),placeholder:"e.g. Olivia","data-testid":"pb-dancer-name"}),!n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:U,children:"How old are they?"}),e.jsx(Ct,{age:t.age,onChange:p=>s({age:p})})]})]}),a&&i.dancers.some(p=>p.enrolled)&&e.jsx("div",{className:"mt-5 text-[13.5px] leading-[1.45] text-muted-foreground",children:"Booking for an enrolled dancer? Drop-ins and packages are in your family account."})]});const u=n?[["me","Myself"],["child","Someone else"]]:[["child","My child"],["me","Myself (adult)"]];return e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"mb-[18px]",children:l}),e.jsx("div",{className:"grid gap-2.5",children:u.map(([p,v])=>e.jsx(ge,{on:t.who===p,onClick:()=>s({who:p,savedStudentId:null}),title:v,testId:`pb-dancer-${p}`},p))}),d&&e.jsxs("div",{className:"mt-5",children:[e.jsx(be,{label:n?"Their first name":"Dancer's first name",value:t.name,onChange:p=>s({name:p.target.value}),placeholder:"e.g. Olivia","data-testid":"pb-dancer-name"}),!n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:U,children:"How old are they?"}),e.jsx(Ct,{age:t.age,onChange:p=>s({age:p})})]})]}),r&&t.who==="me"&&!n&&e.jsxs("div",{className:"mt-5 text-[13.5px] leading-[1.45] text-muted-foreground",children:[r," works for adult classes too."]})]})}function bn({offers:t,offerId:s,onPick:n,dancerName:a,usedOfferIds:i}){const o=t.length>1?t.reduce((r,l)=>r.price/r.classLimit<=l.price/l.classLimit?r:l):null;return e.jsxs(e.Fragment,{children:[e.jsx(J,{children:"Choose a new-student offer"}),e.jsxs($e,{children:["Use your classes on any class that fits ",a,"."]}),t.map(r=>{const l=s===r.id,d=i.includes(r.id);return e.jsxs("button",{type:"button",disabled:d,onClick:()=>n(r.id),"data-testid":"pb-offer",className:E("mb-2.5 flex w-full items-start gap-3 rounded-[14px] border-[1.5px] bg-card px-4 py-3.5 text-left",l?"border-[#0A0A0A]":"border-border",d&&"opacity-45"),children:[e.jsx("span",{className:"mt-0.5",children:e.jsx(Be,{on:l})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[16px] font-bold",children:r.name}),o&&o.id===r.id&&e.jsx("span",{className:"rounded-full bg-[hsl(var(--gold-soft))] px-[7px] py-0.5 text-[11px] font-bold text-[hsl(var(--gold))]",children:"Best value"})]}),e.jsx("span",{className:"mt-0.5 block text-[13.5px] text-muted-foreground",children:d?"Already used by this dancer":[`${r.classLimit} class${r.classLimit>1?"es":""}`,Ie(r.price,r.classLimit),r.description].filter(Boolean).join(" · ")})]}),e.jsx("span",{className:E("text-[16px] font-bold",r.price===0&&"text-[hsl(var(--success))]"),children:r.price===0?"Free":I(r.price)})]},r.id)})]})}function jn(t,s,n){const a=!t||t.min==null&&t.max==null;return n?a||t.min!=null&&t.min>=16:a||s==null?!0:!(t.min!=null&&s<t.min||t.max!=null&&s>t.max)}function It(t,s,n){const a=[],i=[];for(const o of t)(jn(o.ages,s,n)?a:i).push(o);return{fits:a,others:i}}const Wt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Ut(t){const[s,n,a]=t.split("-").map(Number);return Wt[new Date(s,n-1,a).getDay()]}function yn(t){const s=new Set(t.map(n=>Ut(n.sessionDate)));return["All",...Wt.filter(n=>s.has(n))]}function $t(t,s){return s==="All"?t:t.filter(n=>Ut(n.sessionDate)===s)}function Se(t){return[...t].sort((s,n)=>s.sessionDate.localeCompare(n.sessionDate)||s.startTime.localeCompare(n.startTime))}function Nn(t,s,n=[]){const a=d=>d.spotsLeft===null||d.spotsLeft>0,i=new Set,o=[];for(const d of[...Se(n),...Se(t)])i.has(d.sessionId)||!a(d)||(i.add(d.sessionId),o.push(d));const r=[],l=new Set;for(const d of o){if(r.length>=s)break;l.has(d.classId)||(r.push(d.sessionId),l.add(d.classId))}for(const d of o){if(r.length>=s)break;r.includes(d.sessionId)||r.push(d.sessionId)}return r}function vn({sessions:t,loading:s,count:n,picks:a,onPicks:i,age:o,adult:r,dancerName:l,linkedClassId:d,linkedClassName:u}){const[p,v]=f.useState("All"),[j,w]=f.useState(!1),h=d?t.filter(y=>y.classId===d):[],m=h.length>0&&It(h,o,r).fits.length>0,x=m?Se(h):[],S=t.filter(y=>!(m&&y.classId===d)),{fits:$,others:k}=It(S,o,r),D=yn(S),T=Se($t($,p)),g=Se($t(k,p)),Y=y=>{a.includes(y)?i(a.filter(R=>R!==y)):n===1?i([y]):a.length<n&&i([...a,y])},C=()=>i(Nn($,n,x)),ae=({s:y,i:R,len:re,showName:A,tagAge:M})=>{const O=a.includes(y.sessionId),me=y.spotsLeft!==null&&y.spotsLeft<=0,X=!O&&n>1&&a.length>=n,Ae=me||X;return e.jsxs("button",{type:"button",disabled:Ae,onClick:()=>Y(y.sessionId),"data-testid":"pb-session","data-session-id":y.sessionId,className:E("flex w-full items-center gap-3 py-[13px] text-left",R<re-1&&"border-b border-border",Ae&&"opacity-40"),children:[e.jsx(Be,{on:O,multi:n>1}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[15.5px] font-semibold",children:A?y.className:de(y.sessionDate)}
1),M&&e.jsx("span",{className:"rounded-full bg-muted px-[7px] py-0.5 text-[11.5px] font-semibold text-foreground/80",children:ze(y.ages)})]}),e.jsx("span",{className:"block truncate text-[13px] text-muted-foreground",children:[Q(y.startTime)+(y.endTime?`â${Q(y.endTime)}`:""),y.room,y.teacherName].filter(Boolean).join(" · ")})]}),me?e.jsx("span",{className:"text-[12px] font-semibold text-muted-foreground",children:"Full"}):y.spotsLeft!==null&&y.spotsLeft<=4?e.jsxs("span",{className:"whitespace-nowrap text-[12px] font-bold text-[hsl(var(--gold))]",children:[y.spotsLeft," spot",y.spotsLeft===1?"":"s"," left"]}):null]})},N=({list:y,tagAge:R})=>{const re=[];for(const A of y){const M=de(A.sessionDate),O=re.find(me=>me.k===M);O?O.items.push(A):re.push({k:M,items:[A]})}return e.jsx(e.Fragment,{children:re.map(A=>e.jsxs("div",{children:[e.jsx("div",{className:"pt-4 text-[13px] font-bold text-foreground/80",children:A.k}),A.items.map((M,O)=>e.jsx(ae,{s:M,i:O,len:A.items.length,showName:!0,tagAge:R},M.sessionId))]},A.k))})};return e.jsxs(e.Fragment,{children:[e.jsxs(J,{children:["Pick ",n===1?"a class":`${n} classes`]}),e.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 text-[14px] text-muted-foreground",children:[a.length," of ",n," selected · ",r?"adult classes":o!=null?`best for age ${o}`:"all ages"]}),e.jsxs("button",{type:"button",onClick:C,disabled:s||$.length+x.length===0,"data-testid":"pb-pick-soonest",className:"flex h-9 items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-3 text-[13.5px] font-semibold text-foreground disabled:opacity-40",children:[e.jsx(Fs,{className:"h-[15px] w-[15px]"}),"Pick soonest"]})]}),s?e.jsx("div",{className:"space-y-3 py-3",children:[1,2,3].map(y=>e.jsx("div",{className:"h-12 animate-pulse rounded-xl bg-muted"},y))}):t.length===0?e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No upcoming classes in the next 30 days. Text the front desk and we'll find one."}):e.jsxs(e.Fragment,{children:[d&&!m&&!r&&h.length>0&&e.jsxs(le,{children:[u," is for ",ze(h[0].ages).toLowerCase(),". These classes are a better fit for ",l,"."]}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ce,children:u}),x.map((y,R)=>e.jsx(ae,{s:y,i:R,len:x.length,showName:!1},y.sessionId)),e.jsx("div",{className:ce,children:"Other classes that fit"})]}),e.jsx("div",{className:E("-mx-5 flex gap-2 overflow-x-auto px-5 pb-1",x.length?"":"mt-3.5"),style:{scrollbarWidth:"none"},children:D.map(y=>e.jsx(cn,{on:p===y,onClick:()=>v(y),children:y},y))}),T.length?e.jsx(N,{list:T}):e.jsxs("div",{className:"py-4 text-[14px] text-muted-foreground",children:["No matching classes",p!=="All"?` on ${p}`:"","."]}),g.length>0&&e.jsxs("div",{className:"mt-[18px] border-t border-border pt-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>w(!j),"data-testid":"pb-show-others",className:"flex min-h-[44px] w-full items-center gap-2 text-left text-[14.5px] font-semibold",children:[e.jsxs("span",{className:"flex-1",children:[j?"Hide":"Show"," classes for younger or older dancers",e.jsxs("span",{className:"font-medium text-muted-foreground",children:[" · ",g.length]})]}),e.jsx(Dt,{className:E("h-4 w-4 transition-transform",j&&"rotate-90")})]}),j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[13px] leading-[1.45] text-muted-foreground",children:"The teacher will confirm placement at the first class."}),e.jsx(N,{list:g,tagAge:!0})]})]})]})]})}function wn({classes:t,usualId:s,onPick:n}){return e.jsxs(e.Fragment,{children:[e.jsx(J,{children:"Which class will you usually take?"}),e.jsx($e,{children:"Optional. We'll send reminders for it. Your pass still works in any class it covers."}),t.length===0?e.jsx("div",{className:"py-4 text-[14px] text-muted-foreground",children:"This pass works across the studio's classes â pick one at the desk or in your account."}):e.jsx("div",{className:"grid gap-2.5",children:t.map(a=>e.jsx(ge,{on:s===a.id,onClick:()=>n(s===a.id?null:a.id),title:a.name,sub:[a.days,Ee(a.startTime,a.endTime),a.teacherName].filter(
1Boolean).join(" · "),testId:"pb-usual"},a.id))})]})}function kn({value:t,onChange:s,printedName:n,label:a}){const i=f.useRef(null),[o,r]=f.useState(!t);f.useEffect(()=>{const u=i.current;!t||!u||!u.isEmpty()||(u.fromDataURL(t),r(!1))},[t]);const l=()=>{var u;(u=i.current)==null||u.clear(),r(!0),s("")},d=()=>{const u=i.current;!u||u.isEmpty()||(r(!1),s(u.toDataURL("image/png")))};return e.jsxs("div",{className:"mt-3","data-testid":"pb-signature-field",children:[e.jsxs("div",{className:"mb-1.5 flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:a}),!o&&e.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-[12.5px] font-semibold text-muted-foreground","data-testid":"pb-signature-clear",children:[e.jsx(Ns,{className:"h-3 w-3"}),"Clear"]})]}),e.jsxs("div",{className:"relative rounded-xl border border-dashed border-border bg-card","data-testid":"pb-signature-pad",children:[e.jsx(vs,{ref:i,onEnd:d,clearOnResize:!1,backgroundColor:"rgba(0,0,0,0)",penColor:"#111111",canvasProps:{className:"w-full h-[110px] cursor-crosshair touch-none rounded-xl"}}),o&&e.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center text-[13.5px] text-muted-foreground/70",children:"Sign here with your finger"})]}),n.trim()&&e.jsxs("div",{className:"mt-1.5 text-[12.5px] text-muted-foreground",children:["Signing as ",n.trim()]})]})}const At=new Map;function Sn(t){let s=At.get(t);return s||(s=Bs(t),At.set(t,s)),s}function Cn(t){var r;const[s,n]=f.useState(!1),a=f.useMemo(()=>t.publishableKey?Sn(t.publishableKey):null,[t.publishableKey]),i=((r=t.quote)==null?void 0:r.total)??0,o=t.free||i<=0?"Confirm booking":`Pay ${I(i)}`;return e.jsxs(e.Fragment,{children:[e.jsx(J,{children:"Review and pay"}),e.jsx(Qe,{title:t.dancerLine,sub:t.dancerSub,last:t.chosen.length===0}),t.chosen.map((l,d)=>e.jsx(Qe,{title:`${de(l.sessionDate)} · ${l.className}`,sub:[Q(l.startTime)+(l.endTime?`â${Q(l.endTime)}`:""),l.room].filter(Boolean).join(" · "),last:d===t.chosen.length-1},l.sessionId)),!t.free&&i>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ce,children:"Pay with"}),t.returningCard?e.jsxs("div",{className:"flex min-h-[52px] items-center gap-3 rounded-xl border-[1.5px] border-[#0A0A0A] px-3.5","data-testid":"pb-card-on-file",children:[e.jsx(Rs,{className:"h-5 w-5"}),e.jsxs("div",{className:"flex-1 text-[15px] font-semibold capitalize",children:[t.returningCard.brand," â¢â¢â¢â¢ ",t.returningCard.last4]}),e.jsx("span",{className:"text-[12.5px] text-muted-foreground",children:"On file"})]}):t.clientSecret&&a?e.jsx(Ls,{stripe:a,options:{clientSecret:t.clientSecret,appearance:{theme:"stripe",variables:{colorPrimary:"#0A0A0A",colorText:"#0A0A0A",borderRadius:"12px",fontFamily:"'Hanken Grotesk', system-ui, sans-serif",fontSizeBase:"15.5px"},rules:{".Input":{border:"1px solid #e5e5e5",boxShadow:"none",padding:"13px 14px"},".Tab":{borderRadius:"12px"}}}},children:e.jsx($n,{total:i,onPaid:t.onPaid,busy:t.busy,error:t.error,blocked:t.acceptRequired&&!t.signature,promoSlot:e.jsx(_t,{...t,promoOpen:s,setPromoOpen:n}),totalsSlot:e.jsx(Tt,{...t})})},t.clientSecret):e.jsxs("div",{className:"space-y-3 py-2",children:[t.error?e.jsx(le,{tone:"error",children:t.error}):e.jsx("div",{className:"h-12 animate-pulse rounded-xl bg-muted"}),!t.error&&e.jsx("div",{className:"text-[13px] text-muted-foreground",children:"Setting up secure paymentâ¦"})]})]}),(t.returningCard||t.free||i<=0||!t.clientSecret)&&e.jsxs(e.Fragment,{children:[e.jsx(_t,{...t,promoOpen:s,setPromoOpen:n}),e.jsx(Tt,{...t}),(t.returningCard||t.free||i<=0)&&e.jsxs("div",{className:"mt-4",children:[e.jsx(V,{onClick:()=>t.returningCard&&i>0?t.onChargeCardOnFile():t.onPaid(null),disabled:t.busy||t.quoteLoading||t.starting||t.acceptRequired&&!t.signature,"data-testid":"pb-pay",children:t.busy?"Processingâ¦":o}),t.error&&e.jsx(le,{tone:"error",children:t.error})]})]})]})}function _t(t){var n,a;const s=((n=t.quote)==null?void 0:n.promo)??null;return e.jsxs("div",{className:"mt-1.5",children:[!t.promoOpen&&!s&&e.jsxs("button",{type:"button",onClick:()=>t.setPromoOpen(!0),"data-testid":"pb-promo-open",className:"flex min-h-[44px] items-center gap-2 text-[14px] font-semibold",children:[e.jsx(Ms,{className:"h-4 w-4"}),"Add promo or referral code"]}
1),t.promoOpen&&!s&&e.jsxs("div",{className:"mt-1.5 flex items-start gap-2",children:[e.jsx(be,{half:!0,placeholder:"Code",value:t.promo,onChange:i=>t.onPromo(i.target.value.toUpperCase()),autoComplete:"off","data-testid":"pb-promo",onKeyDown:i=>i.key==="Enter"&&t.onApplyPromo()}),e.jsx(Ze,{onClick:t.onApplyPromo,disabled:!t.promo.trim()||t.quoteLoading,className:`w-auto px-[18px] ${t.promo.trim()?"":"opacity-40"}`,"data-testid":"pb-promo-apply",children:t.quoteLoading?"â¦":"Apply"})]}),((a=t.quote)==null?void 0:a.promoError)&&!s&&e.jsx("div",{className:"text-[13px] text-destructive",children:t.quote.promoError}),s&&e.jsxs("div",{className:"flex min-h-[44px] items-center gap-2 text-[14px] font-semibold text-[hsl(var(--success))]","data-testid":"pb-promo-applied",children:[e.jsx(Le,{className:"h-4 w-4",strokeWidth:2.4}),e.jsxs("span",{className:"flex-1",children:[s.code," applied · ",s.label]}),e.jsx("button",{type:"button",onClick:t.onRemovePromo,className:"font-medium text-muted-foreground underline",children:"Remove"})]})]})}function In(t){if(!t.acceptRequired)return null;const s=t.documents.length?t.documents:[{id:"fallback",title:"Liability waiver & studio policies",content:"Dance involves physical activity and a risk of injury. I confirm the dancer is in good health and I accept these risks. I authorize studio staff to seek emergency medical care if I can't be reached. I agree to the studio's attendance, late-pickup and media policies."}],n=a=>/<[a-z][\s\S]*>/i.test(a);return e.jsxs("div",{className:"mt-4","data-testid":"pb-waiver",children:[e.jsx("div",{className:ce,children:s.length===1?s[0].title:`Waiver & policies · ${s.length} documents`}),e.jsx("div",{className:"mb-3 max-h-[160px] overflow-y-auto rounded-xl bg-muted px-3.5 py-3 text-[13px] leading-[1.55] text-foreground/80","data-testid":"pb-waiver-text",children:s.map((a,i)=>e.jsxs("div",{className:i>0?"mt-4 border-t border-border pt-3":"",children:[s.length>1&&e.jsx("div",{className:"mb-1 text-[13px] font-bold text-foreground",children:a.title}),n(a.content)?e.jsx("div",{className:"[&_p]:mb-2",dangerouslySetInnerHTML:{__html:a.content}}):e.jsx("div",{className:"whitespace-pre-wrap",children:a.content})]},a.id))}),e.jsxs("div",{className:"text-[14px] leading-[1.45] text-foreground",children:["By signing below I accept the ",s.length===1?"waiver and studio policies":`${s.length} documents above`," on behalf of my family."]}),e.jsx(kn,{value:t.signature,onChange:t.onSign,printedName:t.signerName,label:"Your signature"})]})}function Tt(t){var n;const s=t.quote;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ce,children:"Today"}),e.jsxs("div",{className:"flex justify-between gap-3 py-1 text-[15px]",children:[e.jsx("span",{className:"text-foreground/80",children:t.title}),e.jsx("span",{children:s?I(s.base):"â"})]}),s&&s.discount>0&&e.jsxs("div",{className:"flex justify-between gap-3 py-1 text-[15px]",children:[e.jsxs("span",{className:"text-foreground/80",children:["Code ",(n=s.promo)==null?void 0:n.code]}),e.jsxs("span",{className:"text-[hsl(var(--success))]",children:["â",I(s.discount)]})]}),s&&s.fee>0&&e.jsxs("div",{className:"flex justify-between gap-3 py-1 text-[15px]",children:[e.jsx("span",{className:"text-foreground/80",children:"Processing fee"}),e.jsx("span",{children:I(s.fee)})]}),e.jsxs("div",{className:"mt-2 flex justify-between border-t border-border py-3 text-[17px] font-bold","data-testid":"pb-total",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:s?s.total<=0?"Free":I(s.total):"â"})]}),e.jsxs("div",{className:"flex gap-2 text-[13px] leading-[1.5] text-muted-foreground",children:[e.jsx(ws,{className:"mt-0.5 h-[15px] w-[15px] shrink-0"}),"One-time charge. No subscription."]}),e.jsx(In,{...t})]})}function $n({total:t,onPaid:s,busy:n,error:a,blocked:i,promoSlot:o,totalsSlot:r}){const l=Es(),d=Ds(),[u,p]=f.useState(!1),[v,j]=f.useState(null),[w,h]=f.useState(!1);f.useEffect(()=>j(null),[t]);const m=async()=>{if(!l||!d){j("Payment form is still loading â try again in a moment.");return}h(!0),j(null);try{const{error:x,paymentIntent:S}=await l.confirmPayment({elements:d,redirect:"if_required",confirmParams:{return_url:window.location.href}});if(console.debug("[public-booking] confirmPayment",(x==null?void 0:x.code)??(S==null?void 0:S.status)),x)throw new Error(x.message||"That card didn't go through.");
1if(!S||!["succeeded","processing","requires_capture"].includes(S.status))throw new Error("That card didn't go through. Try another card.");await s(S.id)}catch(x){j((x==null?void 0:x.message)||"Payment failed")}finally{h(!1)}};return e.jsxs("div",{children:[e.jsx("div",{"data-testid":"pb-payment-element",children:e.jsx(Os,{onReady:()=>p(!0),options:{layout:"tabs",wallets:{applePay:"auto",googlePay:"auto"}}})}),o,r,e.jsxs("div",{className:"mt-4",children:[e.jsx(V,{onClick:m,disabled:!u||n||w||i,"data-testid":"pb-pay","data-stripe-ready":u?"1":"0",children:w||n?"Processingâ¦":`Pay ${I(t)}`}),(v||a)&&e.jsx(le,{tone:"error",children:v||a})]})]})}const He=t=>t.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\n/g,"\\n"),Pt=(t,s)=>`${t.replace(/-/g,"")}T${s.slice(0,8).replace(/:/g,"").padEnd(6,"0")}`;function An(t){const[s,n]=t.split(":").map(Number);return`${String((s+1)%24).padStart(2,"0")}:${String(n||0).padStart(2,"0")}:00`}function _n(t,s){const n=["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//StudioFlow//Public Booking//EN",`X-WR-CALNAME:${He(s)}`];for(const a of t)n.push("BEGIN:VEVENT",`UID:${a.sessionId}@studioflow.dance`,`DTSTART:${Pt(a.sessionDate,a.startTime)}`,`DTEND:${Pt(a.sessionDate,a.endTime||An(a.startTime))}`,`SUMMARY:${He(a.className)}`,...a.location?[`LOCATION:${He(a.location)}`]:[],"END:VEVENT");return n.push("END:VCALENDAR"),n.join(`\r 2`)+`\r 3`}function Tn({studio:t,result:s,title:n,total:a,returning:i,onSetPassword:o,passwordBusy:r,passwordError:l,accountReady:d,onDone:u}){const[p,v]=f.useState(""),j=tt(),w=!!s.pass,h=[...new Set(s.sessions.map(k=>k.teacherName).filter(Boolean))].join(", "),m=s.dancerName.split(" ")[0],x=()=>{const k=_n(s.sessions.map(g=>({...g,location:[g.room,t.name].filter(Boolean).join(" · ")})),t.name),D=URL.createObjectURL(new Blob([k],{type:"text/calendar"})),T=document.createElement("a");T.href=D,T.download=`${t.name.replace(/\s+/g,"-")}-classes.ics`,T.click(),setTimeout(()=>URL.revokeObjectURL(D),5e3)},S=e.jsxs(e.Fragment,{children:[s.sessions.length>0&&e.jsxs(Ze,{onClick:x,"data-testid":"pb-add-calendar",children:[e.jsx(ks,{className:"h-[18px] w-[18px]"}),"Add to calendar"]}),e.jsx(V,{onClick:u,"data-testid":"pb-done",children:"Done"})]}),$=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-5 pb-2 pt-9",children:[e.jsx("div",{className:"mb-4 flex h-[52px] w-[52px] items-center justify-center rounded-full bg-[hsl(var(--success-soft))] text-[hsl(var(--success))]",children:e.jsx(Le,{className:"h-[26px] w-[26px]",strokeWidth:2.4})}),e.jsx("div",{className:"text-[26px] font-bold tracking-[-0.5px]","data-testid":"pb-booked-title","data-pb-heading":!0,children:w?"Your pass is ready":`${m} is booked`}),e.jsxs("div",{className:"mt-1.5 text-[15px] text-muted-foreground",children:["Receipt and details sent to ",s.email||"your email","."]})]}),e.jsxs("div",{className:"px-5 pb-5 pt-3.5",children:[e.jsx(H,{k:w?"Pass":"Offer",v:`${n} · ${a<=0?"Free":I(a)}`}),e.jsx(H,{k:"Where",v:t.name}),w?e.jsxs(e.Fragment,{children:[e.jsx(H,{k:"Classes",v:`${s.pass.classes} left${s.pass.expiresAt?` · expires ${de(s.pass.expiresAt.slice(0,10))}`:""}`}),e.jsx("div",{className:"[&>div]:border-b-0",children:e.jsx(H,{k:"Usual class",v:s.pass.usualClassName??"Not set · drop in anytime"})})]}):e.jsx("div",{className:"[&>div]:border-b-0",children:e.jsx(H,{k:"Teacher",v:h||"See class details"})}),s.sessions.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:ce,children:["Your ",s.sessions.length===1?"class":`${s.sessions.length} classes`]}),s.sessions.map((k,D)=>e.jsx(Qe,{title:`${de(k.sessionDate)} · ${k.className}`,sub:[Q(k.startTime)+(k.endTime?`â${Q(k.endTime)}`:""),k.room].filter(Boolean).join(" · "),last:D===s.sessions.length-1},k.sessionId))]}),!w&&s.upsell&&e.jsxs("div",{className:"mt-[22px] rounded-[14px] border-[1.5px] border-[#0A0A0A] p-[18px]","data-testid":"pb-upsell",children:[e.jsx("div",{className:"text-[13px] font-semibold text-[hsl(var(--gold))]",children:"After the trial"}),e.jsxs("div",{className:"my-1 text-[18px] font-bold tracking-[-0.3px]",children:["Keep ",s.dancerName==="You"?"dancing":`${m} dancing`," in ",s.upsell.programName]}),e.jsxs("div",{className:"mb-3.5 text-[14px] leading-[1.45] text-muted-foreground",children:[s.upsell.fromMonthly?e.jsxs(e.Fragment,{children:["Classes begin at ",e.jsxs("b",{className:"text-foreground",children:[I(s.upsell.fromMonthly)," a month"]}),". "]}):null,"Enroll anytime from your family account."]}),e.jsx(Ce,{to:`/s/${t.slug}/program/${s.upsell.levelId}`,children:e.jsx(V,{className:"h-11",children:"See enrollment options"})})]}),i||d?e.jsxs("div",{className:`mt-3.5 flex gap-3 rounded-[14px] p-4 ${d?"bg-[hsl(var(--success-soft))]":"bg-muted"}`,"data-testid":"pb-account-state",children:[e.jsx("span",{className:`mt-0.5 ${d?"text-[hsl(var(--success))]":"text-foreground
3/80"}`,children:d?e.jsx(Le,{className:"h-5 w-5",strokeWidth:2.4}):e.jsx(Ot,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-bold",children:i?`Added to ${s.familyName}`:"Your family account is ready"}),e.jsx("div",{className:"mt-0.5 text-[13.5px] leading-[1.45] text-muted-foreground",children:i?"Manage, reschedule or book more from the app.":`Sign in with ${s.email||"your email"} to manage, reschedule or book more.`})]})]}):s.canSetPassword?e.jsxs("div",{className:"mt-3.5 rounded-[14px] bg-muted p-[18px]","data-testid":"pb-finish-account",children:[e.jsx("div",{className:"text-[16px] font-bold",children:"Finish your family account"}),e.jsx("div",{className:"mb-3.5 mt-0.5 text-[13.5px] leading-[1.45] text-muted-foreground",children:"Set a password to reschedule, see your classes and book more."}),e.jsx("div",{className:"mb-2 text-[13px] text-foreground/80",children:s.email}),e.jsx(be,{type:"password",value:p,onChange:k=>v(k.target.value),placeholder:"Create a password · 8+ characters",autoComplete:"new-password","data-testid":"pb-password"}),e.jsx(V,{onClick:()=>p.length>=8&&o(p),disabled:p.length<8||r,className:"h-11","data-testid":"pb-create-account",children:r?"Creatingâ¦":"Create account"}),l&&e.jsx("div",{className:"mt-2 text-[13px] text-destructive",children:l})]}):null]})]});return j?e.jsxs("div",{className:"min-h-[100dvh]","data-testid":"pb-booked",children:[e.jsx(Oe,{studio:t,desktop:!0}),e.jsxs("div",{className:"mx-auto max-w-[600px] px-10 pb-10 pt-6",children:[$,e.jsx("div",{className:"flex gap-2.5 px-5",children:S})]})]}):e.jsxs("div",{className:"flex min-h-[100dvh] flex-col","data-testid":"pb-booked",children:[e.jsx("div",{className:"flex-1",children:$}),e.jsx("div",{className:"sticky bottom-0 border-t border-border bg-background px-5 pt-3",style:{paddingBottom:"max(26px, env(safe-area-inset-bottom))"},children:e.jsx("div",{className:"grid gap-2.5",children:S})})]})}function Pn({title:t,studioName:s,dancer:n,punch:a,usualClassName:i,count:o,chosen:r,quote:l}){return e.jsxs("div",{className:"rounded-2xl border border-border p-6","data-testid":"pb-summary",children:[e.jsx("div",{className:"mb-1.5 text-[12px] font-semibold tracking-[0.2px] text-muted-foreground",children:"Your booking"}),e.jsx("div",{className:"mt-0.5 text-[17px] font-bold",children:t}),e.jsx("div",{className:"mt-0.5 text-[13.5px] text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-3.5 border-t border-border",children:[e.jsx(H,{k:"Dancer",v:n}),a?e.jsx("div",{className:"[&>div]:border-b-0",children:e.jsx(H,{k:"Usual class",v:i??"Any class it covers"})}):e.jsx("div",{className:r.length?"":"[&>div]:border-b-0",children:e.jsx(H,{k:"Classes",v:`${r.length} of ${o} picked`})}),r.map(d=>e.jsxs("div",{className:"py-1.5 pl-24 text-[13.5px] text-foreground/80",children:[de(d.sessionDate)," · ",d.className," · ",Q(d.startTime)]},d.sessionId))]}),(l==null?void 0:l.promo)&&l.discount>0&&e.jsxs("div",{className:"flex justify-between pt-2.5 text-[14px] text-[hsl(var(--success))]",children:[e.jsxs("span",{children:["Code ",l.promo.code]}),e.jsxs("span",{children:["â",I(l.discount)]})]}),e.jsxs("div",{className:"mt-2.5 flex justify-between border-t border-border pt-3.5 text-[17px] font-bold",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:l?l.total<=0?"Free":I(l.total):"â"})]})]})}const Fn={start:"Get started",signin:"Sign in",info:"Your info",dancer:"Dancer",offer:"Offer",classes:"Classes",usual:"Class",waiver:"Waiver",pay:"Pay"};function Ln(t){const s=t.status==="returning",n=t.kind==="class"?["offer","classes"]:t.kind==="intro"?["classes"]:["usual"],a=s?["dancer",...n]:n;return["start",...s&&!t.remembered?["signin"]:[],...s?[]:["info"],...a,"pay"]}function Ft(t,s){const n=t.indexOf(s);return n>=0&&n<t.length-1?t[n+1]:null}function En(t,s){const n=t.indexOf(s);return n>0?t[n-1]:null}const Je="sf.publicBooking.remembered";function Dn(t){if(typeof window>"u"||!t)return null;try{const s=window.localStorage.getItem(Je);if(!s)return null;const n=JSON.parse(s);return n&&n.studioId===t?n:null}catch{return null}}function Lt(t){if(!(typeof window>"u"))try{t?window.localStorage.setItem(Je,JSON.stringify(t)):window.localStorage.removeItem(Je)}catch{}}
3const On={emergencyName:"",emergencyPhone:"",medicalNotes:"",signature:"",signatureImage:"",agreed:!1},Fe=(t,s)=>({...t,agreed:!!t.signatureImage,signature:t.signatureImage?s:""});function Bn({model:t,punchClasses:s,onExit:n,signedIn:a=null,initialStep:i="start"}){var yt;const o=Ss(),r=t.studio,l=t.kind==="punch",d=!l,[u,p]=f.useState(i==="signin"?"signin":"start"),[v,j]=f.useState(i==="signin"?"returning":null),[w]=f.useState(()=>a?{familyId:a.familyId,familyName:a.familyName,contactName:a.contactName,identifier:a.email??"",studioId:r.id}:Dn(r.id)),[h,m]=f.useState(!1),[x,S]=f.useState(xn),[$,k]=f.useState(!1),[D,T]=f.useState(null),[g,Y]=f.useState({identifier:"",mode:"id",lookup:null,password:"",code:"",remember:!0,busy:!1,error:null,codeSent:!1}),[C,ae]=f.useState(null),[N,y]=f.useState({who:null,savedStudentId:null,name:"",age:null}),[R,re]=f.useState(t.kind==="intro"?t.offerId:((yt=t.introOffers[0])==null?void 0:yt.id)??null),[A,M]=f.useState([]),[O,me]=f.useState(null),[X,Ae]=f.useState(On),[q,qt]=f.useState(null),[st,Yt]=f.useState(null),[nt,at]=f.useState(""),[je,rt]=f.useState(null),[ie,it]=f.useState(null),[ot,lt]=f.useState(!1),[_e,dt]=f.useState(null),[Gt,xe]=f.useState(null),[ct,Z]=f.useState(!1),[ut,Kt]=f.useState(null),[Ht,mt]=f.useState(!1),[zt,xt]=f.useState(null),[pt,Vt]=f.useState(!1),[W,ht]=f.useState(null),P=v==="returning",F=t.introOffers.find(c=>c.id===R)??null,pe=l?0:(F==null?void 0:F.classLimit)??1,Te=l?Number(t.price.replace(/[^0-9.]/g,""))||0:(F==null?void 0:F.price)??0,ye=l?t.title:(F==null?void 0:F.name)??t.title,G=(C==null?void 0:C.dancers.find(c=>c.id===N.savedStudentId))??null,Qt=N.who==="me"||N.who==="saved"&&!!(G!=null&&G.isAdultSelf),B=N.who==="child"||N.who==="add"||N.who==="saved"&&!(G!=null&&G.isAdultSelf),Ne=B?N.name||"Your dancer":P?(C==null?void 0:C.contactFirstName)||"You":x.first||"You",he=P?N.who==="add"||!(C!=null&&C.waiverSigned):!0,ve=f.useMemo(()=>Ln({kind:t.kind,status:v,remembered:h,needsWaiver:he}),[t.kind,v,h,he]),Jt=Math.max(0,ve.indexOf(u)),oe={kind:t.kind,id:t.kind==="class"?t.classId:t.kind==="intro"?t.offerId:t.packageId,offerId:l?null:R},Re=nn({studioId:r.id,offerId:l?null:R,leadId:(q==null?void 0:q.leadId)??null,auth:P,enabled:["classes","waiver","pay"].includes(u)}),Me=Re.data??[],We=f.useMemo(()=>Me.filter(c=>A.includes(c.sessionId)),[Me,A]),we=s.find(c=>c.id===O)??null;f.useEffect(()=>{u==="start"||W||_("context",{studioId:r.id}).then(ht).catch(()=>ht({publishableKey:null,waiver:null,feesNote:null}))},[u,W,r.id]),f.useEffect(()=>{if(u!=="info")return;const c=x.email.trim(),b=kt(x.phone);if(!Ke(c)&&!b){k(!1);return}const ee=setTimeout(()=>{_("check",{studioId:r.id,email:Ke(c)?c:null,phone:x.phone||null}).then(te=>k(!!te.duplicate)).catch(()=>k(!1))},500);return()=>clearTimeout(ee)},[u,x.email,x.phone,r.id]);const Ue=`${oe.id}|${oe.offerId??""}|${je??""}|${P?"r":"n"}`,qe=f.useRef(null);f.useEffect(()=>{if(u!=="pay"||qe.current===Ue)return;qe.current=Ue;let c=!1;return(async()=>{lt(!0),xe(null);try{if(P){const b=await _("quote",{studioId:r.id,item:oe,promoCode:je},{auth:!0});c||it(b)}else{if(!q)throw new Error("Please go back and enter your details.");const b=await _("pay-start",{studioId:r.id,...q,item:oe,sessionIds:A,promoCode:je,dancer:{who:B?"child":"me",firstName:B?N.name:x.first,age:B?N.age:null},waiver:{...Fe(X,x.parentName.trim()),signatureImage:""},usualClassId:O,contact:x});c||(it(b.quote),dt(b))}}catch(b){c||xe((b==null?void 0:b.message)||"Could not set up payment.")}finally{c||lt(!1)}})(),()=>{c=!0}},[u,Ue]);const ft=async(c,b)=>{const{error:ee}=await z.auth.setSession({access_token:c.access_token,refresh_token:c.refresh_token});if(ee)throw ee;const te=await _("family-context",{studioId:r.id},{auth:!0});return ae(te),j("returning"),Lt(b?{familyId:te.familyId,familyName:te.familyName,contactName:te.contactName,identifier:te.email??"",studioId:r.id}:null),te},L=c=>Y(b=>({...b,...c})),Xt=async()=>{L({busy:!0,error:null});try{const c=await _("lookup",{studioId:r.id,identifier:g.identifier.trim()});if(!c.found){L({busy:!1,error:"We couldn't find an account with that email or mobile. New here? Go back and choose I'm new."});return}L({busy:!1,lookup:c,mode:c.hasPassword?"pw":"code"}),c.hasPassword||gt(c)}catch(c){L({busy:!1,error:(c==null?void 0:c.message)||"Something went wrong."})}},gt=async c=>{L({mode:"code",code:"",codeSent:!1,error:null,busy:!0}
3);try{await _("send-code",{studioId:r.id,identifier:g.identifier.trim()}),L({codeSent:!0,busy:!1,lookup:c??g.lookup})}catch(b){L({busy:!1,codeSent:!0,error:(b==null?void 0:b.message)||"Could not send a code."})}},Zt=f.useCallback(async c=>{L({busy:!0,error:null});try{const b=await _("verify-code",{studioId:r.id,identifier:g.identifier.trim(),code:c});await ft(b.tokens,g.remember),L({busy:!1}),p("dancer")}catch(b){L({busy:!1,error:(b==null?void 0:b.message)||"That code didn't match.",code:""})}},[g.identifier,g.remember,r.id]);f.useEffect(()=>{u==="signin"&&g.mode==="code"&&g.code.length===6&&!g.busy&&Zt(g.code)},[g.code,g.mode,u]);const es=async()=>{L({busy:!0,error:null});try{const c=await _("password-login",{studioId:r.id,identifier:g.identifier.trim(),password:g.password});await ft(c.tokens,g.remember),L({busy:!1}),p("dancer")}catch(c){L({busy:!1,error:c instanceof Xe&&c.status===401?"That password didn't match.":(c==null?void 0:c.message)||"Sign-in failed."})}},ts=async()=>{m(!0),j("returning");try{if(a){ae(a),p("dancer");return}const{data:c}=await z.auth.getSession();if(!c.session)throw new Error("expired");const b=await _("family-context",{studioId:r.id},{auth:!0});ae(b),p("dancer")}catch{m(!1),L({identifier:(w==null?void 0:w.identifier)??"",mode:"id"}),p("signin")}},ss=()=>{j("returning"),m(!1),L({identifier:x.email.trim()||x.phone.trim(),mode:"id",lookup:null,password:"",code:"",error:null}),p("signin")},bt={start:!!v,signin:g.mode==="pw"?g.password.length>=4:!1,info:!!x.first.trim()&&Ke(x.email)&&!!kt(x.phone)&&!$&&!!x.heardAbout.trim()&&(x.programId!==ke||!!x.otherProgram.trim())&&!!N.who&&(N.who==="me"||!!N.name.trim()),dancer:!!N.who&&(N.who==="me"||N.who==="saved"&&!!N.savedStudentId||!!N.name.trim())&&(l||!B||N.age!=null||N.who==="saved"),offer:!!F,classes:A.length===pe,usual:!0,waiver:!0,pay:!he||!!X.signatureImage};let Pe="Continue";u==="classes"&&!bt.classes&&(Pe=`Pick ${pe-A.length} more`),u==="usual"&&!O&&(Pe="Skip for now"),u==="signin"&&(Pe=g.mode==="pw"?"Sign in":"Continue");const Ye=c=>{c?p(c):n()},ns=()=>{if(u==="start"||u==="signin"&&i==="signin")return n();if(u==="dancer"&&P&&h)return j(null),m(!1),p("start");Ye(En(ve,u))},as=async()=>{if(u==="signin")return es();if(u==="info"){Z(!0),T(null);try{const c=await _("lead",{studioId:r.id,...x,item:oe,programId:x.programId&&x.programId!==ke?x.programId:null,otherProgram:x.programId===ke?x.otherProgram:null,dancer:{who:B?"child":"me",firstName:B?N.name:x.first,age:B?N.age:null}});if(c.duplicate===!0){k(!0);return}qt({leadId:c.leadId,leadToken:c.leadToken}),Ye(Ft(ve,u))}catch(c){T((c==null?void 0:c.message)||"Could not save your details.")}finally{Z(!1)}return}if(u==="classes"){Z(!0);try{const c=await _("hold",{studioId:r.id,sessionIds:A,...q??{}},{auth:P});if(c.unavailable.length){M(b=>b.filter(ee=>!c.unavailable.includes(ee))),Re.refetch(),T("One of those classes just filled up â pick another.");return}Yt(c.expiresAt),T(null),q&&_("lead-update",{studioId:r.id,...q,picks:A,dancer:{who:B?"child":"me",firstName:B?N.name:x.first,age:N.age},offerId:R}).catch(()=>{})}catch{}finally{Z(!1)}}dt(null),qe.current=null,Ye(Ft(ve,u))},jt=async c=>{Z(!0),xe(null);try{const b=P?{studioId:r.id,paymentIntentId:c,item:oe,sessionIds:A,dancer:{who:B?"child":"me",firstName:N.name,age:N.age,studentId:N.savedStudentId},waiver:he?Fe(X,(C==null?void 0:C.contactName)??""):null,usualClassId:O,promoCode:je}:{studioId:r.id,...q,paymentIntentId:c,waiver:Fe(X,x.parentName.trim())},ee=await _("finalize",b,{auth:P});Kt(ee)}catch(b){xe((b==null?void 0:b.message)||"We took the payment but could not finish the booking. The studio has been notified.")}finally{Z(!1)}},rs=async()=>{Z(!0),xe(null);try{const c=await _("pay-start",{studioId:r.id,item:oe,sessionIds:A,promoCode:je,dancer:{who:B?"child":"me",firstName:N.name,age:N.age,studentId:N.savedStudentId},waiver:he?{...Fe(X,(C==null?void 0:C.contactName)??""),signatureImage:""}:null,usualClassId:O},{auth:!0});await jt(c.paymentIntentId)}catch(c){xe((c==null?void 0:c.message)||"That card didn't go through."),Z(!1)}},is=async c=>{if(q){mt(!0),xt(null);try{const b=await _("set-password",{studioId:r.id,...q,password:c});await z.auth.setSession(b.tokens),Vt(!0)}catch(b){xt((b==null?void 0:b.message)||"Could not set the password.")}finally{mt(!1)}}},os=async()=>{P&&!g.remember&&!h&&await z.auth.signOut().catch(()=>{}),pt||P&&(g.remember||h)?o(`/studiohub/${r.slug}`):n()};if(ut)return e.jsx(Tn,{studio:r,result:ut,title:ye,total:(ie==null?void 0:ie.total)??Te,returning:P,onSetPassword:is,passwordBusy:Ht,passwordError:zt,accountReady:pt,onDone:os});const ls=["start","signin","dancer","info"].includes(u)?void 0:l?`${t.title} · ${t.price}`:u==="offer"?`${t.title} · trial`:`${ye} · ${Te===0?"Free":I(Te)}`,ds=st&&We.length>0&&u==="pay"?e.jsx(rn,{expiresAt:st}):void 0;let K=null;return u==="start"?K=e.jsx(un,{studioName:r.name,trial:d,status:v,useRemembered:h,remembered:w,onNew:()=>
3{j("new"),m(!1),ae(null),y({who:null,savedStudentId:null,name:"",age:null})},onReturning:()=>{j("returning"),m(!1),y({who:null,savedStudentId:null,name:"",age:null})},onContinueAs:ts}):u==="signin"?K=e.jsx(mn,{s:g,update:L,onFind:Xt,onSendCode:()=>gt(),onForgot:()=>o(`/s/${r.slug}/login`)}):u==="info"?K=e.jsx(fn,{c:x,update:c=>S(b=>({...b,...c})),d:N,updateDancer:c=>{y(b=>({...b,...c})),M([])},punch:l,duplicate:$,trial:d,studioId:r.id,studioName:r.name,onSignInInstead:ss,error:D}):u==="dancer"?K=e.jsx(gn,{d:N,update:c=>{y(b=>({...b,...c})),M([])},punch:l,trial:d,family:P?C:null,studioName:r.name,offerName:(F==null?void 0:F.name)??null}):u==="offer"?K=e.jsx(bn,{offers:t.introOffers,offerId:R,onPick:c=>{re(c),M([])},dancerName:Ne,usedOfferIds:(G==null?void 0:G.usedOfferIds)??[]}):u==="classes"?K=e.jsxs(e.Fragment,{children:[D&&e.jsx("div",{className:"mb-2 text-[13.5px] text-destructive",children:D}),e.jsx(vn,{sessions:Me,loading:Re.isLoading,count:pe,picks:A,onPicks:M,age:N.age,adult:Qt,dancerName:Ne,linkedClassId:t.kind==="class"?t.classId:null,linkedClassName:t.kind==="class"?t.title:null})]}):u==="usual"?K=e.jsx(wn,{classes:s,usualId:O,onPick:me}):u==="pay"&&(K=e.jsx(Cn,{title:ye,dancerLine:l?`${Ne} · ${t.facts.find(c=>c.k==="Price")?t.title:ye}`:`${Ne}${N.age!=null&&B?` · age ${N.age}`:""}`,dancerSub:l?we?we.name:"Any class it covers":`${pe} class${pe>1?"es":""} · ${r.name}`,chosen:We,quote:ie,quoteLoading:ot,promo:nt,onPromo:at,onApplyPromo:()=>rt(nt.trim()||null),onRemovePromo:()=>{at(""),rt(null)},returningCard:P?(C==null?void 0:C.card)??null:null,clientSecret:(_e==null?void 0:_e.mode)==="client_secret"?_e.clientSecret:null,publishableKey:(W==null?void 0:W.publishableKey)??null,starting:ot,error:Gt,onPaid:jt,onChargeCardOnFile:rs,busy:ct,free:Te===0||ie!=null&&ie.total<=0,documents:(W==null?void 0:W.waivers)??(W!=null&&W.waiver?[{id:"legacy",...W.waiver}]:[]),acceptRequired:he,signature:X.signatureImage,onSign:c=>Ae(b=>({...b,signatureImage:c,agreed:!!c})),signerName:P?(C==null?void 0:C.contactName)??"":x.parentName})),e.jsx(an,{studio:r,title:Fn[u],step:Jt,total:ve.length,onBack:ns,eyebrow:ls,banner:ds,cta:Pe,ctaDisabled:!bt[u]&&u!=="usual",ctaBusy:ct||u==="signin"&&g.busy,onCta:as,hideCta:u==="pay"||u==="signin"&&g.mode!=="pw",signedInName:P?(C==null?void 0:C.contactName)??null:null,aside:e.jsx(Pn,{title:l?t.title:t.kind==="class"?`${t.title} · ${(F==null?void 0:F.name)??"trial"}`:ye,studioName:r.name,dancer:N.who?B?`${N.name||"â"}${N.age!=null&&!l?` · age ${N.age}`:""}`:Ne:"â",punch:l,usualClassName:(we==null?void 0:we.name)??null,count:pe,chosen:We,quote:ie}),children:K})}const Et=new Set;function Rn(t){if(!t||typeof document>"u"||Et.has(t)||(Et.add(t),document.querySelector(`link[href="${t}"]`)))return;const s=document.createElement("link");s.rel="stylesheet",s.href=t,document.head.appendChild(s)}function Mn(t){const s=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!s)return"#ffffff";const n=parseInt(s[1],16),a=n>>16&255,i=n>>8&255,o=n&255;return(.299*a+.587*i+.114*o)/255>.62?"#0A0A0A":"#ffffff"}function Wn(t){const{data:s}=qs(t==null?void 0:t.id),{data:n}=ue({queryKey:["public-booking-studio-theme",t==null?void 0:t.id],enabled:!!(t!=null&&t.id)&&t.websiteTheme==null&&t.brandColor==null,staleTime:10*60*1e3,retry:!1,queryFn:async()=>{const{data:a}=await z.from("studios").select("brand_color, website_theme").eq("id",t.id).maybeSingle();return a??null}});return f.useMemo(()=>{const a=(s==null?void 0:s.website_theme)??(t==null?void 0:t.websiteTheme)??(n==null?void 0:n.website_theme)??null,i=Ws(a),o=Us(a,(t==null?void 0:t.brandColor)??(n==null?void 0:n.brand_color)??null),r=/^#[0-9a-f]{6}$/i.test(o.primary)?o.primary:"#0A0A0A";return{primary:r,primaryFg:o.textOnPrimary||Mn(r),primarySoft:`${r}14`,headingFont:i.fonts.heading,bodyFont:"'Hanken Grotesk', -apple-system, system-ui, sans-serif",googleImport:i.fonts.googleImport??null,themeId:i.id}},[s==null?void 0:s.website_theme,t==null?void 0:t.websiteTheme,t==null?void 0:t.brandColor,n==null?void 0:n.website_theme,n==null?void 0:n.brand_color])}function Un(t){f.useEffect(()=>Rn(t.googleImport),[t.googleImport])}function qn(t){return{"--pb-primary":t.primary,"--pb-primary-fg":t.primaryFg,"--pb-primary-soft":t.primarySoft,"--pb-heading-font":t.headingFont,fontFamily:t.bodyFont}}function Yn(t){return ue({queryKey:["public-booking-signed-in-family",t],enabled:!!t,staleTime:60*1e3,retry:!1,queryFn:async()=>{const{data:s}=await z.auth.getSession();if(!s.session)return null;try{return await _("family-context",{studioId:t},{auth:!0})}catch{return null}}})}function xa({entry:t}){const{studioSlug:s,classId:n,offerId:a,packageId:i}=Cs(),o=t==="class"?n:t==="intro"?a:i,{state:r,punchClasses:l}
3=Js(t,s,o),[d,u]=f.useState("landing"),[p,v]=f.useState(0),[j,w]=f.useState("start"),h=r.status==="ready"?r.model.studio:r.status==="not_found"?r.studio:null,m=Wn(h);Un(m);const{data:x}=Yn(h==null?void 0:h.id),S=k=>e.jsx("div",{className:"studiohub-theme pb-theme min-h-[100dvh] bg-background text-foreground",style:qn(m),children:k});if(r.status==="loading")return S(e.jsxs("div",{className:"mx-auto max-w-[560px] px-5 pt-16",children:[e.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-muted"}),e.jsx("div",{className:"mt-3 h-8 w-3/4 animate-pulse rounded bg-muted"}),e.jsx("div",{className:"mt-3 h-4 w-full animate-pulse rounded bg-muted"}),e.jsx("div",{className:"mt-8 space-y-3",children:[1,2,3].map(k=>e.jsx("div",{className:"h-11 animate-pulse rounded-xl bg-muted"},k))})]}));if(r.status==="not_found")return S(e.jsxs("div",{className:"mx-auto max-w-[560px] px-5 pt-16 text-center",children:[e.jsx(Nt,{children:e.jsx("title",{children:"Not available"})}),e.jsx("div",{className:"text-[22px] font-bold tracking-[-0.4px]",children:"This link isn't available right now"}),e.jsx("div",{className:"mt-2 text-[14px] text-muted-foreground",children:r.studio?`Check with ${r.studio.name} for their current offers and schedule.`:"The studio could not be found."}),r.studio&&e.jsxs(Ce,{to:`/s/${r.studio.slug}`,className:"mt-6 inline-flex h-12 items-center justify-center rounded-xl bg-[#0A0A0A] px-6 text-[15px] font-semibold text-white",children:["Go to ",r.studio.name]})]}));const{model:$}=r;return S(e.jsxs(e.Fragment,{children:[e.jsxs(Nt,{children:[e.jsx("title",{children:`${$.title} · ${$.studio.name}`}),$.description&&e.jsx("meta",{name:"description",content:$.description})]}),d==="landing"?e.jsx(sn,{model:$,signedInName:(x==null?void 0:x.contactName)??null,onStart:()=>{w("start"),v(k=>k+1),u("flow")},onSignIn:()=>{w("signin"),v(k=>k+1),u("flow")}}):e.jsx(Bn,{model:$,punchClasses:l,signedIn:x??null,initialStep:j,onExit:()=>u("landing")},p)]}))}export{xa 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.