1import{r as s,t as le,at as K,u as de,T as ie,au as me,av as xe,aw as ue,ax as pe,j as e,L as D,S as B,g as he}from"./index-CCj0ga3e.js";import{u as M}from"./useQuery-DmMfJTcD.js";import{u as m}from"./useServerFn-B1wyxN8L.js";import{g as ge,C as fe}from"./CloverCardForm-BKS0D2S9.js";import{m as x,a as je,e as Ne}from"./format-DDEOghfb.js";import{C as be}from"./clock-0kJwWkgq.js";import{L as ve}from"./loader-circle-ktUqzD0D.js";import{C as ye}from"./calendar-days-d2nPjLZ5.js";function Ie(){s.useEffect(()=>{le("start_ticket_checkout")},[]);const{slug:c}=K.useParams(),{t:r,q:n}=K.useSearch(),y=de(),g=m(ie),k=m(me),H=m(xe),O=m(ue),z=m(pe),Q=m(ge),C=s.useRef(null),{data:f,isLoading:U}=M({queryKey:["event",c],queryFn:()=>g({data:{slug:c}}),staleTime:3e4}),{data:u}=M({queryKey:["clover-cfg"],queryFn:()=>Q()}),[l,p]=s.useState("info"),[j,Y]=s.useState(null),[N,G]=s.useState(null),[J,V]=s.useState(Date.now()),[b,o]=s.useState(null),[w,W]=s.useState(""),[S,X]=s.useState(""),[E,Z]=s.useState(""),[T,ee]=s.useState(""),[v,te]=s.useState(""),[R,se]=s.useState(""),[_,ae]=s.useState(!1),[A,re]=s.useState(!1),[P,ne]=s.useState(!1),{data:a,refetch:ke}=M({queryKey:["event-quote",r,n,v],queryFn:()=>O({data:{items:[{ticketTypeId:r,quantity:n}],promoCode:v||null}}),staleTime:5e3});s.useEffect(()=>{const t=setInterval(()=>V(Date.now()),1e3);return()=>clearInterval(t)},[]);const q=s.useRef(null);s.useEffect(()=>{q.current=j},[j]),s.useEffect(()=>()=>{const t=q.current;t&&H({data:{holdId:t}}).catch(()=>{})},[]);const F=N?Math.max(0,new Date(N).getTime()-J):0,I=!!N&&F<=0,L=s.useMemo(()=>f?.ticketTypes.find(t=>t.id===r),[f,r]);async function oe(t){if(t.preventDefault(),o(null),!w.trim()||!S.trim()||!E.trim()||!T.trim()){o("Please complete all required fields.");return}if(!P){o("Please accept the terms to continue.");return}try{const i=Ne(),$=await k({data:{ticketTypeId:r,quantity:n,sessionId:i}});Y($.holdId),G($.expiresAt),p("payment")}catch(i){o(i?.message??"Could not reserve tickets. Please try again.")}}async function ce(){if(j&&(o(null),!!C.current)){p("processing");try{const t=await C.current.tokenize();if("error"in t){o(t.error),p("payment");return}const i=await z({data:{holdId:j,items:[{ticketTypeId:r,quantity:n}],firstName:w.trim(),lastName:S.trim(),email:E.trim(),phone:T.trim(),promoCode:v||null,marketingConsent:_,ageConfirmed:A,termsAccepted:P,customerNotes:R||void 0,token:t.token,cardMeta:{brand:t.brand,last4:t.last4}}});q.current=null,y({to:"/orders/$orderNumber",params:{orderNumber:i.orderNumber},search:{token:i.accessToken}})}catch(t){o(t?.message??"Payment failed. Please try again."),p("payment")}}}if(U||!f)return e.jsx("main",{className:"min-h-screen grid place-items-center pt-40",children:e.jsx("p",{className:"text-sm uppercase tracking-[0.22em] text-muted-foreground",children:"Loadingâ¦"})});if(!L)return e.jsx("main",{className:"min-h-screen grid place-items-center pt-40 text-center",children:e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl text-cream",children:"Ticket unavailable"}),e.jsx(D,{to:"/events/$slug",params:{slug:c},className:"mt-6 inline-block text-sm uppercase tracking-[0.22em] text-gold",children:"Back to event"})]})});const d=f.event;return e.jsx("main",{className:"min-h-screen pt-32 pb-24",children:e.jsxs("div",{className:"mx-auto grid max-w-6xl gap-10 px-6 lg:grid-cols-3 lg:px-10",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-8",children:[e.jsxs("div",{children:[e.jsx(D,{to:"/events/$slug",params:{slug:c},className:"text-xs uppercase tracking-[0.22em] text-muted-foreground hover:text-gold",children:"â Back to event"}),e.jsx("h1",{className:"mt-4 font-display text-4xl text-cream md:text-5xl",children:"Checkout"})]}),N&&e.jsx("div",{className:`rounded-sm border p-4 text-sm ${I?"border-red-500/60 bg-red-500/10 text-red-300":"border-border/60 bg-card/40 text-cream/90"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4 text-gold"}),I?e.jsx("span",{children:"Your ticket hold has expired."}):e.jsxs("span",{children:["Tickets held for"," ",e.jsxs("strong",{className:"text-gold",children:[Math.floor(F/6e4),":",String(Math.floor(F%6e4/1e3)).padStart(2,"0")]})]})]})}),l==="info"&&e.jsxs("form",{onSubmit:oe,className:"space-y-5",children:[e.jsx("h2",{className:"font-display text-2xl text-cream",children:"Your information"}),e.jsxs("div",{className:"rounded-sm border border-gold/40 bg-gold/10 p-3 text-xs text-cream/90",children:[e.jsx("p",{className:"font-medium",children:"Event questions or inquiries?"}),e.jsxs("p",{className:"mt-1",children:["Text us at"," ",e.jsx("a",{href:`sms:${B.textPhoneRaw}`,className:"text-gold underline",children:B.textPhone}),". ",e.jsx("span",{className:"uppercase tracking-wide text-gold",children:"Text only"})," â this number does not accept phone calls."]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(h,{label:"First name",value:w,onChange:W,required:!0}),e.jsx(h,{label:"Last name",value:S,onChange:X,required:!0}),e.jsx(h,{label:"Email",type:"email",value:E,onChange:Z,required:!0}),e.jsx(h,{label:"Phone",type:"tel",value:T,onChange:ee,required:!0})]}
1),e.jsx(h,{label:"Promo code (optional)",value:v,onChange:te}),a?.promoError&&e.jsx("p",{className:"text-xs text-red-400",children:a.promoError}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"eyebrow",children:"Notes (optional)"}),e.jsx("textarea",{value:R,onChange:t=>se(t.target.value),rows:3,className:"mt-2 w-full rounded-sm border border-border bg-background px-3 py-2 text-sm text-cream focus:border-gold focus:outline-none"})]}),e.jsxs("div",{className:"space-y-3 text-sm",children:[d.minimum_age&&e.jsxs("label",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:t=>re(t.target.checked),className:"mt-0.5"}),e.jsxs("span",{className:"text-cream/90",children:["I confirm I am ",d.minimum_age," or older."]})]}),e.jsxs("label",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>ae(t.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-cream/90",children:"Send me occasional emails about future events."})]}),e.jsxs("label",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:P,onChange:t=>ne(t.target.checked),className:"mt-0.5",required:!0}),e.jsxs("span",{className:"text-cream/90",children:["I agree to the"," ",e.jsx(D,{to:"/terms-of-service",className:"text-gold hover:underline",children:"terms of service"})," ","and this event's refund policy."]})]})]}),b&&e.jsx("p",{className:"rounded-sm border border-red-500/60 bg-red-500/10 p-3 text-sm text-red-300",children:b}),e.jsx("button",{type:"submit",className:"rounded-sm bg-gradient-gold px-7 py-3 text-xs font-medium uppercase tracking-[0.22em] text-primary-foreground shadow-gold hover:-translate-y-0.5 transition-transform",children:"Continue to payment"})]}),(l==="payment"||l==="processing")&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("h2",{className:"font-display text-2xl text-cream",children:"Payment"}),u?.configured?e.jsx(fe,{ref:C,sdkUrl:u.sdkUrl,pakmsKey:u.pakmsKey,merchantId:u.merchantId}):e.jsx("p",{className:"rounded-sm border border-red-500/60 bg-red-500/10 p-3 text-sm text-red-300",children:"Card payments are not configured yet. Please contact us to reserve."}),b&&e.jsx("p",{className:"rounded-sm border border-red-500/60 bg-red-500/10 p-3 text-sm text-red-300",children:b}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>p("info"),disabled:l==="processing",className:"text-xs uppercase tracking-[0.22em] text-muted-foreground hover:text-gold disabled:opacity-50",children:"â Back"}),e.jsxs("button",{type:"button",disabled:l==="processing"||I||!u?.configured||!a||!!a.promoError,onClick:ce,className:"ml-auto inline-flex items-center gap-2 rounded-sm bg-gradient-gold px-7 py-3 text-xs font-medium uppercase tracking-[0.22em] text-primary-foreground shadow-gold hover:-translate-y-0.5 transition-transform disabled:cursor-not-allowed disabled:opacity-60",children:[l==="processing"&&e.jsx(ve,{className:"h-4 w-4 animate-spin"}),"Pay ",a?x(a.totalCents):"â¦"]})]})]})]}),e.jsx("aside",{className:"lg:sticky lg:top-32 h-fit",children:e.jsxs("div",{className:"rounded-sm border border-border/60 bg-card p-6 space-y-4",children:[e.jsx("div",{className:"eyebrow",children:"Order summary"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-display text-lg text-cream",children:d.title}),e.jsxs("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"h-3.5 w-3.5 text-gold"}),je(d.starts_at,d.timezone)]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"h-3.5 w-3.5 text-gold"}),d.venue_name]})]})]}),e.jsxs("div",{className:"border-t border-border/60 pt-4 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n," à ",L.name]}),e.jsx("span",{className:"text-cream",children:x(L.price_cents*n)})]}),a&&a.serviceFeeCents>0&&e.jsxs("div",{className:"mt-2 flex justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Service fee"}),e.jsx("span",{className:"text-cream/90",children:x(a.serviceFeeCents)})]}),a&&a.taxCents>0&&e.jsxs("div",{className:"mt-1 flex justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tax"}),e.jsx("span",{className:"text-cream/90",children:x(a.taxCents)})]}),a&&a.discountCents>0&&e.jsxs("div",{className:"mt-1 flex justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Discount ",a.promoCode?`(${a.promoCode})`:""]}),e.jsxs("span",{className:"text-gold",children:["â",x(a.discountCents)]})]}),e.jsxs("div",{className:"mt-4 flex justify-between border-t border-border/60 pt-3",children:[e.jsx("span",{className:"text-cream",children:"Total"}),e.jsx("span",{className:"text-cream",children:a?x(a.totalCents):"â¦"})]})]})]})})]})})}function h({label:c,value:r,onChange:n,type:y="text",required:g}){return e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"eyebrow",children:[c," ",g&&e.jsx("span",{className:"text-gold",children:"*"})]}),e.jsx("input",{type:y,value:r,onChange:k=>n(k.target.value),required:g,className:"mt-2 w-full rounded-sm border border-border bg-background px-3 py-2 text-sm text-cream focus:border-gold focus:outline-none"})]})}
1export{Ie as component};
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.