1import{a as r,j as e}from"./vendor-react-BieOFGTO.js";import{u as Z,b as G}from"./vendor-query-Bf7VLrsv.js";import{C as X}from"./calendar-BsJqPhfI.js";import{u as ee,a2 as te,o as $,p as M,r as E,s as I,ac as se,t as ae,i as ne,C as w,j as P,U as _,B as g,k as S,I as C}from"./index-Bca1piM7.js";import{T as ie}from"./textarea-DwgfvJTR.js";import{A as re,a as le,b as oe}from"./avatar-COe6k_jA.js";import{M as ce}from"./message-square-D62d3MmK.js";import"./vendor-utils-Uev4__JX.js";import"./vendor-radix-Cx3Dvb0S.js";import"./vendor-motion-B4SuNsHa.js";function Ne({slug:p}){const{toast:b}=ee(),{updateSEO:L}=te(),[o,O]=r.useState(void 0),[c,B]=r.useState(null),[f,F]=r.useState(""),[h,U]=r.useState(""),[k,H]=r.useState(""),[T,z]=r.useState(""),[R,q]=r.useState(!1),[j,D]=r.useState(!1),N=r.useRef(null),{data:t,isLoading:Y,error:J}=Z({queryKey:[`/api/public/schedule/${p}`],enabled:!!p});r.useEffect(()=>{if(!t)return;const s=t.businessName||t.user?.businessName||t.user?.name,a=t.meetingTitle,n=a?`${a}${s?` · ${s}`:""} | Book Online`:s?`Book an Appointment with ${s} | AIChecklist.io`:"Book an Appointment | AIChecklist.io",i=t.meetingDescription||`Schedule an appointment${s?` with ${s}`:""} online. Choose a date and time that works for you and confirm in seconds.`;L({title:n,description:i})},[t]);const y=G({mutationFn:async()=>{if(!o||!c)return;const[s,a]=c.split(":"),n=new Date(o);n.setHours(parseInt(s),parseInt(a),0,0);const i=new Date(n);i.setMinutes(i.getMinutes()+(t?.slotDuration||30));const d=T.split(",").map(l=>l.trim()).filter(l=>l.length>0),v=-n.getTimezoneOffset(),u=Intl.DateTimeFormat().resolvedOptions().timeZone,x=await fetch(`/api/public/schedule/${p}/book`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attendeeName:f,attendeeEmail:h,attendeeNotes:k,additionalEmails:d.length>0?d:void 0,startTime:n.toISOString(),endTime:i.toISOString(),timezone:u,timezoneOffset:v})});if(!x.ok){const l=await x.json();throw new Error(l.message||"Failed to book appointment")}return x.json()},onSuccess:()=>{q(!0),b({title:"Success!",description:"Appointment confirmed"})},onError:s=>{b({title:"Booking failed",description:s.message||"Please try again",variant:"destructive"})}}),K=s=>{if(j)return s;const[a,n]=s.split(":").map(Number),i=a>=12?"PM":"AM";return`${a===0?12:a>12?a-12:a}:${n.toString().padStart(2,"0")} ${i}`};r.useEffect(()=>{c&&N.current&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth",block:"start"})},200)},[c]);const Q=()=>{if(!o||!t)return[];const s=o.toLocaleDateString("en-US",{weekday:"long"}).toLowerCase(),a=t.availability[s];if(!a?.enabled||!a.slots?.length)return[];const n=[];return a.slots.forEach(i=>{const[d,v]=i.start.split(":").map(Number),[u,x]=i.end.split(":").map(Number);let l=d,m=v;for(;l<u||l===u&&m<x;){const W=`${l.toString().padStart(2,"0")}:${m.toString().padStart(2,"0")}`;n.push(W),m+=t.slotDuration||30,m>=60&&(l+=Math.floor(m/60),m=m%60)}}),n},V=()=>{if(!f||!h||!o||!c){b({title:"Missing information",description:"Please fill in all required fields",variant:"destructive"});return}y.mutate()};if(Y)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-green-600"})});if(J||!t)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center p-4",children:e.jsx($,{className:"max-w-md w-full",children:e.jsxs(M,{children:[e.jsx(E,{className:"text-red-600",children:"Scheduling Not Available"}),e.jsx(I,{children:"This scheduling link is not currently active or does not exist."})]})})});if(R)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center p-4",children:e.jsxs($,{className:"max-w-md w-full border-green-600",children:[e.jsxs(M,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-green-100 flex items-center justify-center",children:e.jsx(se,{className:"h-10 w-10 text-green-600"})}),e.jsx(E,{className:"text-2xl text-green-600",children:"APPOINTMENT CONFIRMED"}),e.jsxs(I,{children:["Your appointment has been successfully scheduled with ",t.hostName]})]}),e.jsxs(ae,{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 text-gray-500"}),e.jsx("span",{children:o?.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{className:"h-4 w-4 text-gray-500"}),e.jsx("span",{children:c})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"h-4 w-4 text-gray-500"}),e.jsxs("span",{children:["Confirmation sent to ",h]})]})]})]})});const A=Q();return e.jsx("div",{className:"min-h-screen bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto p-4 md:p-8",children:[e.jsxs("div",{className:"text-center mb-8 pb-6 border-b border-gray-200",children:[e.jsxs("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:[t.businessName||t.hostName,t.meetingTitle?` â ${t.meetingTitle}`:""]}),e.jsx("p",{className:"text-gray-600",children:"Appointment Scheduling"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr_320px] gap-6",children:[e.jsx("div",{className:"space-y-6",children:t.showBranding?e.jsxs("div",{className:"space-y-4",children:[t.brandingLogoUrl&&e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:t.brandingLogoUrl,alt:t.businessName||"Business Logo",className:"h-24 w-24 object-contain rounded-lg","data-testid":"branding-logo"})}),t.businessName&&e.jsx("h2",{className:"font-bold text-xl text-center","data-testid":"business-name",children:t.businessName}),t.businessPhone&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-gray-600",children:[e.jsx(_,{className:"h-4 w-4 text-green-600"}),e.jsx("a",{href:`tel:${t.businessPhone}`,className:"hover:text-green-600","data-testid":"business-phone",children:t.businessPhone})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx("p",{className:"text-gray-600 text-sm font-medium",children:t.meetingTitle}),e.jsxs("div",{className:"flex items-center gap-2 mt-2 text-sm text-gray-600",children:[e.jsx(w,{className:"h-4 w-4 text-green-600"}),e.jsxs("span",{children:[t.slotDuration," min"]})]}),t.meetingDescription&&e.jsx("p",{className:"text-sm leading-relaxed mt-3 text-gray-600",children:t.meetingDescription})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs(re,{className:"h-16 w-16 border-2 border-green-600",children:[e.jsx(le,{src:t.hostProfilePicture,alt:t.hostName}),e.jsx(oe,{className:"bg-green-100 text-green-700 text-xl",children:t.hostName?.charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-lg",children:t.hostName}),e.jsx("p",{className:"text-gray-600 text-sm",children:t.meetingTitle})]})]}),e.jsxs("div",{className:"space-y-3 text-sm text-gray-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{className:"h-4 w-4 text-green-600"}),e.jsxs("span",{children:[t.slotDuration," min"]})]}),t.meetingDescription&&e.jsx("p",{className:"text-sm leading-relaxed",children:t.meetingDescription})]})]})}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("h3",{className:"text-xl font-semibold mb-4 text-white",children:"Select a Date & Time"}),e.jsx(X,{mode:"single",selected:o,onSelect:O,disabled:s=>{const a=s.toLocaleDateString("en-US",{weekday:"long"}).toLowerCase(),n=t.availability[a],i=s<new Date(new Date().setHours(0,0,0,0)),d=s>new Date(Date.now()+t.bookingWindowDays*24*60*60*1e3);return i||d||!n?.enabled||!n.slots?.length},className:"rounded-md border border-gray-200 p-4",classNames:{caption_label:"text-lg font-semibold text-gray-900",caption:"flex justify-center pt-1 relative items-center mb-4",nav:"space-x-1 flex items-center",n
1av_button:"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 border rounded hover:bg-gray-100",nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",head_cell:"text-gray-600 font-medium text-sm w-9",cell:"h-9 w-9 text-center text-sm p-0 relative",day:"h-9 w-9 p-0 font-medium text-gray-900 hover:bg-gray-100 rounded-md",day_selected:"bg-green-600 text-white hover:bg-green-700 font-bold",day_today:"bg-green-50 text-green-900 font-bold border border-green-600",day_disabled:"text-gray-300 opacity-50",day_outside:"text-gray-400 opacity-40"},"data-testid":"calendar-picker"})]}),e.jsx("div",{className:"space-y-4",children:o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm mb-3 text-gray-700",children:o.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"})}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsx(g,{variant:"outline",size:"sm",className:`flex-1 text-xs ${j?"border-gray-300 hover:border-green-600":"bg-green-600 text-white hover:bg-green-700 border-green-600"}`,onClick:()=>D(!1),"data-testid":"button-standard-time",children:"Standard Time"}),e.jsx(g,{variant:"outline",size:"sm",className:`flex-1 text-xs ${j?"bg-green-600 text-white hover:bg-green-700 border-green-600":"border-gray-300 hover:border-green-600"}`,onClick:()=>D(!0),"data-testid":"button-military-time",children:"Military Time"})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:A.length===0?e.jsx("p",{className:"text-sm text-gray-500",children:"No available times for this day"}):A.map(s=>e.jsx(g,{variant:c===s?"default":"outline",className:`w-full justify-center ${c===s?"bg-green-600 hover:bg-green-700 text-white":"border-gray-300 hover:border-green-600"}`,onClick:()=>B(s),"data-testid":`time-slot-${s}`,children:K(s)},s))})]}),c&&e.jsxs("div",{ref:N,className:"space-y-4 pt-4 border-t",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"name",children:"Name *"}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{className:"absolute left-3 top-3 h-4 w-4 text-gray-400"}),e.jsx(C,{id:"name",value:f,onChange:s=>F(s.target.value),placeholder:"Your name",className:"pl-9","data-testid":"input-name"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"email",children:"Email *"}),e.jsxs("div",{className:"relative",children:[e.jsx(P,{className:"absolute left-3 top-3 h-4 w-4 text-gray-400"}),e.jsx(C,{id:"email",type:"email",value:h,onChange:s=>U(s.target.value),placeholder:"[email protected]",className:"pl-9","data-testid":"input-email"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"notes",children:"Notes (optional)"}),e.jsxs("div",{className:"relative",children:[e.jsx(ce,{className:"absolute left-3 top-3 h-4 w-4 text-gray-400"}),e.jsx(ie,{id:"notes",value:k,onChange:s=>H(s.target.value),placeholder:"Anything we should know?",className:"pl-9",rows:3,"data-testid":"input-notes"})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx(C,{id:"additional-emails",type:"text",value:T,onChange:s=>z(s.target.value),placeholder:"Share with others: [email protected], [email protected]",className:"text-sm","data-testid":"input-additional-emails"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Add additional emails to share this appointment (comma-separated)"})]})]}),e.jsx(g,{onClick:V,disabled:y.isPending,className:"w-full bg-green-600 hover:bg-green-700 text-white font-medium","data-testid":"button-confirm",children:y.isPending?"Booking...":"Confirm"})]})]})})]})]})})}export{Ne as PublicScheduling,Ne 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.