1import{Q as V,j as e,ao as $,G as X,V as H,a9 as M,aw as Q,au as Y,r as u,aG as W,B as U,b2 as ee,b as te,ax as se,J as ae,aK as re}from"./index-ByYYWl6V.js";import{u as R}from"./useQuery-yGeh6Hp2.js";import{u as ne}from"./useMutation-BJQUmqJw.js";import{S as k}from"./skeleton-Dgkec9Dl.js";import{g as ie,c as oe,a as le}from"./booking-api-DEe9SXlv.js";import{A as ce,b as de,a as me}from"./avatar-DfyiTc_8.js";import{S as z}from"./separator-DYEmDTsQ.js";import{L as ue}from"./LanguageSwitcher-DnKojN5t.js";import{C as xe}from"./clock-CUm8QZGC.js";import{P as Z,B as J}from"./phone-DRfvr5iu.js";import{M as K}from"./map-pin-54GgpTKZ.js";import{A as he,a as pe,S as ge}from"./alert-DGF00XtO.js";import{L as I}from"./label-Dast61oh.js";import{S as je,a as fe,b as ve,c as be,d as Ne}from"./select-B7Jb7eSA.js";import{C as Se}from"./chevron-left-yeSSr-Cv.js";import"./supabase-functions-CBdNz-q5.js";import"./index-C4Lchjjk.js";import"./dropdown-menu-BZRKspBv.js";import"./index-CnBNeFET.js";import"./chevron-right-X_hlXzqd.js";import"./circle-DcpkfI2n.js";import"./calendar-gUz01k4g.js";import"./en-US-D0KhEKBm.js";import"./TimezoneCombobox-B6WIg4UO.js";import"./command-gvn-Bze4.js";import"./popover-iAHc-IZW.js";
1import"./earth-BpZZJNQg.js";import"./chevron-up-DJ99KL3C.js";const we={virtual:H,phone:Z,in_person:J,custom:K};function ye(a){if(!a)return"?";const c=a.trim().split(/\s+/);return c.length===1?c[0].slice(0,2).toUpperCase():(c[0][0]+c[c.length-1][0]).toUpperCase()}function ke({eventType:a,organizerName:c,organizerAvatarUrl:m,attendeeTimezone:d,children:l,selectedSlotISO:t,hideBranding:n}){const{td:i}=V(),x=we[a.location_kind],r=a.color??void 0;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-background to-muted/20 text-foreground",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-6 sm:py-10 lg:py-16",children:[e.jsxs("div",{className:"bg-card border rounded-xl shadow-sm overflow-hidden",children:[e.jsx("div",{className:"h-1.5",style:{background:r??"linear-gradient(to right, hsl(var(--primary)), hsl(var(--primary) / 0.6))"}}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[340px_1fr]",children:[e.jsxs("aside",{className:"p-4 sm:p-6 lg:p-8 lg:border-r border-b lg:border-b-0 space-y-5 bg-muted/10",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[e.jsx($,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"truncate",children:a.title})]}),e.jsx(ue,{})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(ce,{className:"h-10 w-10",children:[m?e.jsx(de,{src:m,alt:c??""}):null,e.jsx(me,{className:"text-xs font-semibold",style:r?{backgroundColor:r,color:"white"}:void 0,children:ye(c)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:c??i("calendar.user")}),e.jsx("div",{className:"font-semibold leading-tight truncate",children:a.title})]})]}),a.description?e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line leading-relaxed",children:a.description}):null,e.jsx(z,{}),e.jsxs("ul",{className:"space-y-2.5 text-sm",children:[e.jsxs("li",{className:"flex items-center gap-2.5",children:[e.jsx(xe,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{children:i("calendar.minutes",{n:a.duration_minutes})})]}),e.jsxs("li",{className:"flex items-center gap-2.5",children:[e.jsx(x,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{children:i(`calendar.location.${a.location_kind}`)})]}),e.jsxs("li",{className:"flex items-center gap-2.5",children:[e.jsx(X,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate",children:d})]})]}),t?e.jsxs(e.Fragment,{children:[e.jsx(z,{}),e.jsxs("div",{className:"rounded-md border bg-background p-3 space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:i("calendar.selectedTime")}),e.jsx("div",{className:"text-sm font-semibold",children:new Date(t).toLocaleString(void 0,{weekday:"long",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:d})})]})]}):null]}),e.jsx("section",{className:"p-4 sm:p-6 lg:p-8",children:l})]})]}),!n&&e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs("a",{href:"/booking-landing",className:"inline-flex items-center gap-1.5 rounded-full border border-border/60 bg-background/60 px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:text-foreground hover:border-border transition-colors",children:[e.jsx($,{className:"h-3 w-3","aria-hidden":!0}),i("calendar.poweredBy")]})})]})})}function Ce({fields:a,values:c,errors:m,onChange:d,onBlur:l}){return a.length===0?null:e.jsx(e.Fragment,{children:a.map(t=>{const n=c[t.id]??"",i=m[t.id]??null,x=`cf-${t.id}`;return e.jsxs("div",{className:"space-y-2",children:[t.type!=="checkbox"?e.jsxs(I,{htmlFor:x,children:[t.label,t.required?e.jsx("span",{className:"text-destructive ml-1",children:"*"}):null]}):null,t.type==="short_text"||t.type==="phone"?e.jsx(M,{id:x,type:t.type==="phone"?"tel":"text",value:n,onChange:r=>d(t.id,r.target.value),onBlur:()=>l(t.id),placeholder:t.placeholder??void 0,"aria-invalid":!!i,required:t.required}):null,t.type==="long_text"?e.jsx(Q,{id:x,rows:3,value:n,onChange:r=>d(t.id,r.target.value),onBlur:()=>l(t.id),placeholder:t.placeholder??void 0,"aria-invalid":!!i,required:t.required}):null,t.type==="dropdown"?e.jsxs(je,{value:n,onValueChange:r=>{d(t.id,r),l(t.id)},children:[e.jsx(fe,{id:x,"aria-invalid":!!i,children:e.jsx(ve,{placeholder:t.placeholder??"Chooseâ¦"})}),e.jsx(be,{children:(t.options??[]).map(r=>e.jsx(Ne,{value:r,children:r},r))})]}):null,t.type==="checkbox"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{id:x,checked:n==="true",onCheckedChange:r=>{d(t.id,r?"true":"false"),l(t.id)}}),e.jsxs(I,{htmlFor:x,className:"cursor-pointer font-normal",children:[t.label,t.required?e.jsx("span",{className:"text-destructive ml-1",children:"*"}):null]})]}):null,i?e.jsx("p",{className:"text-xs text-destructive",children:i}):null]},t.id)})})}const _e=/^[+0-9()\-\s]{3,40}$/;function Ee(a,c,m,d){const l={};for(const t of a){const i=(c[t.id]??"").trim();if(t.type==="checkbox"){t.required&&i!=="true"?l[t.id]=m:l[t.id]=null;continue}if(t.required&&!i){l[t.id]=m;continue}if(!i){l[t.id]=null;continue}if(t.type==="phone"&&!_e.test(i)){l[t.id]=d;continue}if(t.type==="dropdown"&&!(t.options??[]).some(r=>r.toLowerCase()===i.toLowerCase())){l[t.id]=m;continue}l[t.id]=null}return l}const Fe={virtual:H,phone:Z,in_person:J,custom:K};function Ie({onSubmit:a,submitting:c,error:m,locationKind:d,locationDetail
1s:l,customFields:t=[]}){const{td:n}=V(),[i,x]=u.useState(""),[r,O]=u.useState(""),[p,P]=u.useState(""),[C,b]=u.useState({}),[N,T]=u.useState({}),[_,D]=u.useState({}),E=n("calendar.attendee.required"),L=n("calendar.attendee.invalidPhone"),A=u.useMemo(()=>Ee(t,N,E,L),[t,N,E,L]),g={};for(const[o,f]of Object.entries(A))g[o]=_[o]?f:null;const S=Object.values(A).every(o=>!o),w=C.name&&!i.trim()?E:null,F=/^\S+@\S+\.\S+$/.test(r),j=C.email&&!F?n("calendar.attendee.invalidEmail"):null,y=i.trim().length>0&&F&&S&&!c,s=d?Fe[d]:null,h=d?n(`calendar.location.${d}`):"";return e.jsxs("form",{className:"space-y-5",onSubmit:o=>{o.preventDefault(),b({name:!0,email:!0});const f={};for(const v of t)f[v.id]=!0;if(D(f),!y)return;const q=t.map(v=>{const B=(N[v.id]??"").trim();return v.type==="checkbox"?{field_id:v.id,value:B==="true"?"true":"false"}:B?{field_id:v.id,value:B}:null}).filter(v=>v!==null);a({name:i.trim(),email:r.trim(),notes:p.trim(),customFieldResponses:q})},children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:"name",children:[n("calendar.attendee.name")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(M,{id:"name",value:i,onChange:o=>x(o.target.value),onBlur:()=>b(o=>({...o,name:!0})),"aria-invalid":!!w,required:!0}),w?e.jsx("p",{className:"text-xs text-destructive",children:w}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:"email",children:[n("calendar.attendee.email")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(M,{id:"email",type:"email",value:r,onChange:o=>O(o.target.value),onBlur:()=>b(o=>({...o,email:!0})),"aria-invalid":!!j,required:!0}),j?e.jsx("p",{className:"text-xs text-destructive",children:j}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"notes",children:n("calendar.attendee.notes")}),e.jsx(Q,{id:"notes",rows:3,value:p,onChange:o=>P(o.target.value),placeholder:n("calendar.attendee.notesPlaceholder")})]}),e.jsx(Ce,{fields:t,values:N,errors:g,onChange:(o,f)=>T(q=>({...q,[o]:f})),onBlur:o=>D(f=>({...f,[o]:!0}))}),d&&s?e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 flex items-start gap-3 text-sm",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium",children:h}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:l||n("calendar.page.locationDetailsFallback")})]})]}):null,m?e.jsxs(he,{variant:"destructive",children:[e.jsx(W,{className:"h-4 w-4"}),e.jsx(pe,{children:m})]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:n("calendar.attendee.consent")}),e.jsx("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2 pt-2 border-t",children:e.jsx(U,{type:"submit",disabled:!y,className:"sm:w-auto",children:n(c?"calendar.attendee.submitting":"calendar.attendee.submit")})})]})}const G="vsble.booking.timeFormat";function nt(){const{slug:a=""}=ee(),c=te(),{td:m,locale:d}=V(),[l]=se(),{setTheme:t}=ae(),n=l.get("theme");u.useEffect(()=>{(n==="light"||n==="dark")&&t(n)},[n,t]);const[i,x]=u.useState(()=>{const s=new Date;return s.setHours(0,0,0,0),s}),[r,O]=u.useState(()=>{const s=new Date;return s.setDate(1),s.setHours(0,0,0,0),s}),[p,P]=u.useState(null),[C,b]=u.useState("pick"),[N,T]=u.useState(null),[_,D]=u.useState(()=>Intl.DateTimeFormat().resolvedOptions().timeZone),[E,L]=u.useState(()=>typeof window>"u"?"12h":window.localStorage.getItem(G)??"12h"),A=s=>{L(s);try{window.localStorage.setItem(G,s)}catch{}},g=R({queryKey:["publicEventType",a],queryFn:()=>le(a),enabled:!!a}),S=u.useMemo(()=>{const s=new Date(r),h=new Date(r);h.setMonth(h.getMonth()+1),h.setDate(0),h.setHours(23,59,59,999);const o=new Date;return s.getTime()<o.getTime()&&s.setTime(o.getTime()),{start:s,end:h}},[r]),w=R({queryKey:["publicSlots",a,S.start.toISOString(),S.end.toISOString()],queryFn:()=>ie(a,S.start.toISOString(),S.end.toISOString()),enabled:!!a&&!!g.data}),F=ne({mutationFn:async s=>{if(!p)throw new Error("no slot selected");return oe({slug:a,start_at:p,attendee:{name:s.name,email:s.email,timezone:_,locale:d},notes:s.notes||void 0,custom_field_responses:s.customFieldResponses})},onSuccess:s=>{c(`/b/${a}/confirmed/${s.id}?token=${s.reschedule_token}`)},onError:s=>{const h=s instanceof Error?s.message:String(s);
1T(h),re.error(h)}});if(g.isLoading)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-background to-muted/20 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-5xl bg-card border rounded-xl p-8 grid grid-cols-1 lg:grid-cols-[340px_1fr] gap-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{className:"h-4 w-24"}),e.jsx(k,{className:"h-10 w-full"}),e.jsx(k,{className:"h-16 w-full"}),e.jsx(k,{className:"h-3 w-32"}),e.jsx(k,{className:"h-3 w-40"})]}),e.jsx("div",{className:"space-y-3",children:e.jsx(k,{className:"h-72 w-full"})})]})});if(g.isError||!g.data)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs("div",{className:"max-w-md text-center space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:m("calendar.page.unavailableTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("calendar.page.unavailableDesc")})]})});const{eventType:j,organizer:y}=g.data;return e.jsx(ke,{eventType:j,organizerName:y.display_name,organizerAvatarUrl:y.avatar_url,attendeeTimezone:_,selectedSlotISO:C==="confirm"?p:null,hideBranding:y.hide_branding,children:C==="pick"?e.jsxs("div",{className:"space-y-6",children:[e.jsx(ge,{slots:w.data??[],isLoading:w.isLoading,selectedDate:i,onDateChange:s=>{x(s),P(null)},selectedSlot:p,onSelectSlot:P,attendeeTimezone:_,onTimezoneChange:D,timeFormat:E,onTimeFormatChange:A,visibleMonth:r,onMonthChange:O}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsx(U,{disabled:!p,onClick:()=>b("confirm"),children:m("calendar.page.continue")})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{type:"button",onClick:()=>b("pick"),className:"inline-flex items-center text-xs text-muted-foreground hover:text-foreground -ml-1",children:[e.jsx(Se,{className:"h-3.5 w-3.5 mr-1"})," ",m("calendar.page.pickAnother")]}),e.jsx(Ie,{onSubmit:s=>{T(null),F.mutate(s)},onBack:()=>b("pick"),submitting:F.isPending,error:N,locationKind:j.location_kind,locationDetails:j.location_details,customFields:j.custom_fields??[]})]})})}export{nt 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.