1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3846],{7460:(e,t,n)=>{n.d(t,{B2:()=>o,PG:()=>a,Pw:()=>u,V5:()=>c,Yu:()=>p,_T:()=>i,aY:()=>h,cR:()=>r,mX:()=>s,yN:()=>m});let l=/^\d{4}-\d{2}-\d{2}$/;function a(e){let t=new URLSearchParams(e.startsWith("?")?e.slice(1):e),n={},a=t.get("date");a&&l.test(a)&&!Number.isNaN(new Date("".concat(a,"T00:00:00")).getTime())&&(n.date=a);let r=function(e){if(null==e)return;if("any"===e||"0"===e)return 0;let t=Number(e);return 1===t||2===t||3===t||4===t?t:void 0}(t.get("players"));void 0!==r&&(n.players=r);let s=Number(t.get("sheet"));Number.isInteger(s)&&s>0&&(n.sheet=s);let i=t.get("waitlist");i&&(n.waitlist=i);let o=t.get("slot");return o&&/^[A-Za-z0-9-]{1,64}$/.test(o)&&(n.slot=o),n}function r(e,t){let n="".concat(e.pathname).concat(s(e.search,t)).concat(e.hash);return"/auth/zitadel/login?return_to=".concat(encodeURIComponent(n))}function s(e,t){let n=new URLSearchParams(e.startsWith("?")?e.slice(1):e);t.date?n.set("date",t.date):n.delete("date"),t.players?n.set("players",String(t.players)):n.delete("players"),t.sheet?n.set("sheet",String(t.sheet)):n.delete("sheet"),t.slot?n.set("slot",t.slot):n.delete("slot");let l=n.toString();return l?"?".concat(l):""}function i(e){return"players"===e||"review"===e||"pay"===e?e:void 0}function o(e){return e&&/^[A-Za-z0-9-]{8,64}$/.test(e)?e:void 0}function d(e){let t=new URLSearchParams;for(let[n,l]of e)null!=l&&""!==l&&0!==l&&t.set(n,String(l));let n=t.toString();return n?"?".concat(n):""}function u(e){return"/book/".concat(e.sheetId,"/").concat(e.date).concat(d([["players",e.players]]))}function c(e){return"/book/".concat(e.sheetId,"/").concat(e.date,"/").concat(encodeURIComponent(e.slotId))+d([["players",e.players],["step",e.step],["session",e.session]])}function m(e){return"/book/confirmation/".concat(encodeURIComponent(e))}function p(e){return"/auth/zitadel/login?return_to=".concat(encodeURIComponent(e))}function h(e){return"".concat(e).concat(e.includes("?")?"&":"?","register=1")}},15361:(e,t,n)=>{n.d(t,{bK:()=>y});var l=n(29064),a=n(34340),r=n(16565),s=n(34154),i=n(66248);function o(e,t){return"card"===e&&t>0}var d=n(34158),u=n(85450);let c="Card payment is not available on this site";function m(){let e=u.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY;return("string"==typeof e?e.trim():"")||null}let p=null,h=(0,a.forwardRef)(function(e,t){let{busy:n=!1,billingName:r,billingEmail:s}=e,i=(0,a.useRef)(null),o=(0,a.useRef)(null),u=(0,a.useRef)(null),[h,x]=(0,a.useState)(null),[f,b]=(0,a.useState)("loading");return((0,a.useEffect)(()=>{let e=!1;return(async()=>{let t=await function(){let e=m();return e?(p||(p=(0,d.c)(e).catch(()=>null)),p):Promise.resolve(null)}();if(!e){if(!t||!i.current)return b("unavailable");try{let e=t.elements().create("card",{hidePostalCode:!0});e.mount(i.current),e.on("change",e=>x(e.error?e.error.message:null)),o.current=t,u.current=e,b("ready")}catch(e){b("unavailable")}}})(),()=>{e=!0;try{var t;null==(t=u.current)||t.unmount()}catch(e){}u.current=null,o.current=null}},[]),(0,a.useEffect)(()=>{try{var e;null==(e=u.current)||e.update({disabled:n})}catch(e){}},[n,f]),(0,a.useImperativeHandle)(t,()=>({async capture(e){let t=o.current,n=u.current;if(!t||!n)throw Error(c);let{error:l,paymentIntent:a}=await t.confirmCardPayment(e,{payment_method:{card:n,billing_details:{...r?{name:r}:{},...s?{email:s}:{}}}});if(l){let e=l.message||"Your card could not be charged.";throw x(e),Error(e)}if(!(null==a?void 0:a.id))throw Error("Your card could not be charged.");return a.id}}),[r,s]),"unavailable"===f)?(0,l.jsxs)("p",{className:"rounded border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800","data-testid":"card-unavailable",children:[c,". Please choose another payment method or contact the club."]}):(0,l.jsxs)("div",{"data-testid":"card-step",children:[(0,l.jsx)("div",{ref:i,"data-testid":"card-element-host",className:"rounded border px-3 py-2 ".concat(n?"opacity-60":""),"aria-busy":n}),"loading"===f&&(0,l.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"Loading secure card fieldâ¦"}),h&&(0,l.jsx)("p",{className:"mt-1 text-sm text-red-700","data-testid":"card-error",role:"alert",children:h}),(0,l.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"Card details are handled by Stripe â this site never sees them."})]})});var x=n(52733),f=n(82326),b=n(29599);let g=e=>"\xa3".concat((e/100).toFixed(2)),y=e=>{var t,n,d,u,p,y,_,v,k,j,w,N,C,S,R,T,E,P,I,Y,B,A,M;let{courseId:L,slot:q,playDate:F,memberName:U,memberUuid:G=null,audie
1nce:O="member",initialPartySize:$,onCancel:H,onConfirmed:W,onPickSlot:Z,onWaitlist:D,chrome:z="modal",controller:J,autoOpen:K,initialPlayers:V,step:X,onStep:Q}=e,ee=(0,s.w)({slotId:q.slot_id,courseId:L}),et=null!=J?J:ee,en=et.state.session,el=et.state.error,ea=et.state.denial,er=et.setError,[es,ei]=(0,a.useState)([]),[eo,ed]=(0,a.useState)(!1),[eu,ec]=(0,a.useState)(null),[em,ep]=(0,a.useState)({}),eh="visitor"===O,[ex,ef]=(0,a.useState)({name:"",email:"",phone:""}),eb=!eh||ex.name.trim().length>1&&/\S+@\S+\.\S+/.test(ex.email.trim())&&ex.phone.replace(/\D/g,"").length>=10,[eg,ey]=(0,a.useState)(eh?"details":"players"),e_=null!=X?X:eg,ev=(0,a.useCallback)(e=>{ey(e),null==Q||Q(e)},[Q]),[ek,ej]=(0,a.useState)(!1),[ew,eN]=(0,a.useState)(null),eC=(0,a.useRef)(null),eS=null!=(w=null==en?void 0:en.quote)?w:null,eR=Math.max(1,Math.min(null!=(C=null!=(N=null==eS||null==(t=eS.guest_policy)?void 0:t.max_players)?N:q.max_players)?C:4,q.available_spots||q.max_players||4)),eT=!eh&&(null==eS||null==(n=eS.guest_policy)?void 0:n.can_add_guest)!==!1,eE=(0,a.useMemo)(()=>[eh?{name:ex.name.trim(),is_guest:!1,email:ex.email.trim(),phone:ex.phone.trim()}:{name:U||"Member",is_guest:!1,golfer_uuid:G},...es.map(e=>"partner"===e.kind?{name:e.name,is_guest:!1,golfer_uuid:e.golfer_uuid}:{name:e.name.trim(),is_guest:!eh,email:e.email.trim()||void 0,phone:e.phone.trim()||void 0}).filter(e=>e.name.trim())],[U,G,eh,ex,es]),eP=(0,a.useRef)(eE);(0,a.useEffect)(()=>{eP.current=eE},[eE]);let eI=(0,a.useRef)(!1),eY=(0,a.useCallback)(e=>{var t,n,l,a,r,s,i,o,d;if(eI.current||!e.booking_id)return;eI.current=!0;let u=null!=(s=null==(t=e.quote)?void 0:t.payment_options)?s:[];u.length>0&&ec(null!=(i=u[0])?i:null);let c=(null!=V?V:[]).filter(e=>(e.name||"").trim());if(c.length>0)return void ei(c.slice(1).map(e=>e.golfer_uuid&&!0!==e.is_guest?{kind:"partner",golfer_uuid:e.golfer_uuid,name:(e.name||"").trim()}:{kind:"guest",name:(e.name||"").trim(),email:e.email||"",phone:e.phone||""}));let m=Math.min(null!=$?$:1,null!=(d=null!=(o=null==(l=e.quote)||null==(n=l.guest_policy)?void 0:n.max_players)?o:q.max_players)?d:4,q.available_spots||4);m>1&&(eh||(null==(r=e.quote)||null==(a=r.guest_policy)?void 0:a.can_add_guest)!==!1)&&ei(Array.from({length:m-1},()=>({kind:"guest",name:"",email:"",phone:""})))},[V,$,eh,q.max_players,q.available_spots]),eB=(0,a.useRef)(!1),eA=(0,a.useCallback)(async()=>{if(eB.current)return;eB.current=!0,ev("players");let e=await et.open(eP.current);"session"===e.kind&&eY(e.session),"error"===e.kind&&eh&&(eB.current=!1,ev("details"))},[et.open,eh,ev,eY]),eM=null!=K?K:!J;(0,a.useEffect)(()=>{eM&&!eh&&eA()},[]);let eL=et.addressId;(0,a.useEffect)(()=>{en&&eY(en)},[en,eY]);let eq=(0,x.YR)(null!=(S=null==en?void 0:en.hold_expires_at)?S:null),eF=(A=null==eS?void 0:eS.enforcement,(0,i.lT)(A)),eU=es.filter(e=>"partner"===e.kind).map(e=>e.golfer_uuid),eG=1+es.length<eR;async function eO(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return eL?et.patch({players:eE,add_ons:Object.entries(em).filter(e=>{let[,t]=e;return t>0}).map(e=>{let[t,n]=e;return{extras_catalog_id:t,quantity:n}}),...e}):null}async function e$(){if(eL){ej(!0),er(null);try{var e,t,n;let l=await eO(),a=null!=(t=null==l||null==(e=l.quote)?void 0:e.payment_options)?t:[];a.length>0&&!a.find(e=>e.method===(null==eu?void 0:eu.method))&&ec(null!=(n=a[0])?n:null)}catch(t){let e=(0,i.j0)(t);e&&i.Ze.has(e.reason_code)?et.setDenial(e):er((null==e?void 0:e.message)||t.message||"Could not update players.")}finally{ej(!1)}}}async function eH(){if(eL){(0,b.s)("book_click",{product:"tee",play_date:F,tee_time:q.tee_time}),ej(!0),er(null),eN(null);try{var e,t,n,l,a,s,d,u;let c=await eO(eu?{payment_method:eu.method}:{});if(c&&(d=null==(e=c.quote)?void 0:e.enforcement,(0,i.lT)(d))){er((u=null==(t=c.quote)?void 0:t.enforcement,(0,i.R$)(u))),ej(!1);return}let m=null!=(n=null==c?void 0:c.booking_id)?n:eL,p={},h=null!=(l=null==c?void 0:c.quote)?l:eS,x=(null!=(a=null==h?void 0:h.total_pence)?a:0)+(null!=(s=null==h?void 0:h.extras_total_pence)?s:0);if(o(null==eu?void 0:eu.method,x)){let e,t=eC.current;if(!t){er("Enter your card details to pay for this booking."),ej(!1);return}eN("Taking paymentâ¦");try{e=(await (0,r.f)({booking_id:m,slot_id:q.slot_id})).client_secret}catch(e){er(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"We could not start the card payment. Please try again or choose another payment method.",n=null==e?void 0:e.data;return[null==n?void 0:n.detail,null==n?void 0:n.message].find(e=>"string"==typeof e&&e.trim())||t}(e)),ej(!1),eN(null);return}p.stripe_payment_intent_id=await t.capture(e)}eN("Confirmingâ¦");let f=await et.confirm(p);W(f.booking_reference,f.status,eP.current.map(e=>e.name),null!=m?m:void 0)}catch(t){let e=(0,i.j0)(t);er((null==e?void 0:e.message)||t.message||"Could not confirm the booking."),ej(!1),eN(null)}}}function eW(){et.cancel(),H()}function eZ(e,t){ei(n=>n.map((n,l)=>l===e&&"guest"===n.kind?{...n,...t}:n))}function eD(e,t,n){ep(l=>{var a;let r=Math.max(0,Math.min((null!=(a=l[e])?a:0)+t,null!=n?n:99));if(0===r){let{[e]:t,...n}=l;return n}return{...l,[e]:r}})}let ez=null!=(R=null==eS?void 0:eS.payment_options)?R:[],eJ=null!=(T=null==eS?void 0:eS.available_extras)?T:[],eK=null!=(E=null==eS?void 0:eS.extras_total_pence)?E:0,eV=function(e){var t;if(!e)return null;if("non_refundable"===e.rule||"none"===e.refund)return"Non-refundable once booked.";let n=null!=(t=e.window_hours)?t:0;if(n<=0)return"Free cancellation up to the tee time.";let l=e.refund&&"full"!==e.refund?" (".concat(e.refund," refund)"):"";return"Free cancellation up to ".concat(n," hours before your tee time").concat(l,".")}(null==eS?void 0:eS.cancellation_policy),eX=(null!=(P=null==eS?void 0:eS.total_pence)?P:0)+eK,eQ=null!==m(),e0=o(null==eu?void 0:eu.method,eX),e1=e0&&!eQ,e2={background:"var(--color-primary, #009293)"};return(0,l.jsxs)("div",{className:"modal"===z?"px-5 pb-5 pt-2":"",children:[el&&(0,l.jsx)("p",{className:"mb-3 rounded border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700",children:el}),"details"===e_&&(0,l.jsxs)("div",{"data-testid":"lead-details",children:[(0,l.jsx)("p",{className:"mb-2 text-sm text-gray-500",children:"Your details â weâll send the booking to you here."}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("input",{value:ex.name,onChange:e=>ef(t=>({...t,name:e.target.value})),placeholder:"Your name",autoComplete:"name","aria-label":"Your name",className:"w-full rounded border px-2 py-1.5 text-sm"}),(0,l.jsx)("input",{value:ex.email,onChange:e=>ef(t=>({...t,email:e.target.value})),placeholder:"Email",type:"email",autoComplete:"email","aria-label":"Email",className:"w-full rounded border px-2 py-1.5 text-sm"}),(0,l.jsx)("input",{value:ex.phone,onChange:e=>ef(t=>({...t,phone:e.target.value})),placeholder:"Mobile",type:"tel",autoComplete:"tel","aria-label":"Mobile",className:"w-full rounded border px-2 py-1.5 text-sm"})]}),(0,l.jsxs)("div",{className:"mt-4 flex items-center justify-between",children:[(0,l.jsxs)("span",{className:"text-xs text-gray-500",children:["Booking as a visitor \xb7 ",q.tee_time]}),(0,l.jsxs)("div",{className:"flex gap-2",children:["modal"===z&&(0,l.jsx)("button",{onClick:H,className:"rounded border px-3 py-1",children:"Cancel"}),(0,l.jsx)("button",{onClick:()=>void eA(),disabled:!eb,className:"rounded px-3 py-1 text-white disabled:opacity-60",style:e2,"data-testid":"lead-continue",children:"Continue"})]})]})]}),"details"!==e_&&!en&&!el&&!ea&&(0,l.jsx)("p",{className:"py-6 text-center opacity-70",children:"Holding your slotâ¦"}),ea&&(0,l.jsxs)("div",{className:"rounded border border-amber-200 bg-amber-50 px-3 py-3 text-sm text-amber-800","data-testid":"open-denial",children:[i.Ze.has(ea.reason_code)?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium",children:(0,i._0)(ea)}),(0,l.jsx)("p",{className:"mt-1",children:(0,i.I3)(ea)})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium",children:ea.message}),"not_bookable_for_category"===ea.reason_code&&ea.earliest_bookable_time&&(0,l.jsxs)("p",{className:"mt-1",children:["The earliest you can book that day is ",ea.earliest_bookable_time,"."]})]}),(0,l.jsxs)("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[ea.next_available_slot&&Z&&(0,l.jsxs)("button",{onClick:()=>Z(ea.next_available_slot),className:"rounded px-3 py-1 text-white",style:e2,children:[i.Ze.has(ea.reason_code)?"Reserve next available":"Try"," â ",ea.next_available_slot.start_time]}),(null==(d=ea.waitlist)?void 0:d.available)&&ea.waitlist.exact_slot_time&&D&&(0,l.jsxs)("button",{onClick:()=>D(ea.waitlist),className:"rounded border px-3 py-1",children:["Join waiting list for ",ea.waitlist.exact_slot_time]}),(0,l.jsx)("button",{onClick:eW,className:"rounded border px-3 py-1",children:"modal"===z?"Pick another time":"Back"})]})]}),en&&"waitlisted"===en.placement&&(0,l.jsxs)("div",{className:"rounded border border-amber-200 bg-amber-50 px-3 py-3 text-sm text-amber-800",children:["Nothing was free at ",q.tee_time,", so youâve been added to the waiting list","number"==typeof(null==(u=en.waitlist)?void 0:u.position)?" â youâre #".concat(en.waitlist.position):"",". Weâll hold a slot for you before we tell you itâs free.",(0,l.jsx)("div",{className:"mt-3 flex justify-end",children:(0,l.jsx)("button",{onClick:H,className:"rounded border px-3 py-1",children:"modal"===z?"Close"
1:"Back"})})]}),en&&eL&&eq.expired&&!et.state.confirmed&&(0,l.jsxs)("div",{className:"rounded border border-amber-200 bg-amber-50 px-3 py-3 text-sm text-amber-800","data-testid":"hold-expired",children:["Your hold on ",q.tee_time," has expired â the time is back on sale. Pick it again if itâs still free.",(0,l.jsx)("div",{className:"mt-3 flex justify-end",children:(0,l.jsx)("button",{onClick:eW,className:"rounded border px-3 py-1",children:"modal"===z?"Close":"Back"})})]}),eF&&!eq.expired&&(0,l.jsxs)("div",{className:"rounded border border-amber-200 bg-amber-50 px-3 py-3 text-sm text-amber-800","data-testid":"rule-blocked",children:[(M=null==eS?void 0:eS.enforcement,(0,i.R$)(M)),(null==eS||null==(v=eS.enforcement)||null==(_=v.denied_rules)||null==(y=_[0])||null==(p=y.suggested_slot)?void 0:p.start_time)&&Z&&(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsxs)("button",{onClick:()=>Z(eS.enforcement.denied_rules[0].suggested_slot),className:"rounded px-3 py-1 text-white",style:e2,children:["Try ",eS.enforcement.denied_rules[0].suggested_slot.start_time," instead"]})}),(0,l.jsx)("div",{className:"mt-3 flex justify-end",children:(0,l.jsx)("button",{onClick:eW,className:"rounded border px-3 py-1",children:"modal"===z?"Close":"Back"})})]}),en&&eL&&!eF&&!eq.expired&&eq.label&&(0,l.jsxs)("p",{className:"mb-2 text-xs ".concat(eq.low?"font-semibold text-amber-700":"text-gray-500"),title:"Any change to your booking resets the timer","data-testid":"hold-countdown",children:["Held for you â ",eq.label," left"]}),en&&eL&&!eF&&!eq.expired&&"players"===e_&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{className:"mb-2 text-sm text-gray-500",children:["Players (",eE.length,"/",eR,")"]}),(0,l.jsxs)("div",{className:"divide-y rounded-md border",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,l.jsx)("span",{className:"text-sm font-medium",children:eh?ex.name.trim():U||"Member"}),(0,l.jsxs)("span",{className:"text-xs text-gray-500","data-testid":"lead-category",children:["You",(null==eS||null==(j=eS.line_items)||null==(k=j[0])?void 0:k.label)?" \xb7 ".concat(eS.line_items[0].label.toLowerCase()):eh?" \xb7 visitor":""]})]}),es.map((e,t)=>(0,l.jsx)("div",{className:"px-3 py-2",children:"partner"===e.kind?(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("span",{className:"text-sm",children:e.name}),(0,l.jsx)("button",{onClick:()=>ei(e=>e.filter((e,n)=>n!==t)),className:"text-xs text-gray-500 hover:text-red-600",children:"Remove"})]}):(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("input",{value:e.name,onChange:e=>eZ(t,{name:e.target.value}),placeholder:eh?"Player name":"Guest name",className:"flex-1 rounded border px-2 py-1 text-sm"}),(0,l.jsx)("button",{onClick:()=>ei(e=>e.filter((e,n)=>n!==t)),className:"text-xs text-gray-500 hover:text-red-600",children:"Remove"})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("input",{value:e.email,onChange:e=>eZ(t,{email:e.target.value}),placeholder:"Email (optional)",className:"flex-1 rounded border px-2 py-1 text-xs"}),(0,l.jsx)("input",{value:e.phone,onChange:e=>eZ(t,{phone:e.target.value}),placeholder:"Phone (optional)",className:"w-32 rounded border px-2 py-1 text-xs"})]})]})},t))]}),eG&&!eo&&(0,l.jsx)("button",{onClick:()=>eh?ei(e=>[...e,{kind:"guest",name:"",email:"",phone:""}]):ed(!0),className:"mt-2 text-sm font-medium hover:underline",style:{color:"var(--color-primary, #009293)"},children:"+ Add player"}),eG&&eo&&!eh&&(0,l.jsx)(f.y,{excludeUuids:eU,onPick:e=>{ei(t=>[...t,{kind:"partner",golfer_uuid:e.golfer_uuid,name:e.name}]),ed(!1)},onAddGuest:eT?()=>{ei(e=>[...e,{kind:"guest",name:"",email:"",phone:""}]),ed(!1)}:void 0,onClose:()=>ed(!1)}),!eT&&!eh&&eS&&(0,l.jsx)("p",{className:"mt-2 text-xs text-gray-500",children:"Guests can only be added by a member."}),eJ.length>0&&(0,l.jsxs)("div",{className:"mt-4",children:[(0,l.jsx)("p",{className:"mb-1 text-sm text-gray-500",children:"Extras"}),(0,l.jsx)("div",{className:"divide-y rounded-md border",children:eJ.map(e=>{var t;let n=null!=(t=em[e.extras_catalog_id])?t:0;return(0,l.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"text-sm",children:e.name}),(0,l.jsxs)("span",{className:"ml-2 text-xs text-gray-500",children:[g(e.unit_price_pence)," ",e.unit?"/ ".concat(e.unit.replace("per_","")):""]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)("button",{onClick:()=>eD(e.extras_catalog_id,-1),disabled:0===n,"aria-label":"Remove one ".concat(e.name),className:"h-6 w-6 rounded border text-sm leading-none disabled:opacity-40",children:"â"}),(0,l.jsx)("span",{className:"w-5 text-center text-sm",children:n}),(0,l.jsx)("button",{onClick:()=>eD(e.extras_catalog_id,1,e.max_per_booking),"aria-label":"Add one ".concat(e.name),className:"h-6 w-6 rounded border text-sm leading-none",children:"+"})]})]},e.extras_catalog_id)})})]}),(0,l.jsxs)("div",{className:"mt-4 flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"text-sm",children:["Total: ",(0,l.jsx)("strong",{children:g((null!=(I=null==eS?void 0:eS.total_pence)?I:0)+eK)})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:["modal"===z&&(0,l.jsx)("button",{onClick:eW,className:"rounded border px-3 py-1",children:"Cancel"}),(0,l.jsx)("button",{onClick:async()=>{await e$(),ev("payment")},disabled:ek,className:"rounded px-3 py-1 text-white disabled:opacity-60",style:e2,children:ek?"Pricingâ¦":"Continue"})]})]})]}),en&&eL&&!eF&&!eq.expired&&"payment"===e_&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"mb-3 divide-y rounded-md border",children:[(null!=(Y=null==eS?void 0:eS.line_items)?Y:[]).map(e=>(0,l.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[(0,l.jsxs)("span",{children:[e.label,e.is_guest?" (guest)":""]}),(0,l.jsx)("span",{children:g(e.price_pence)})]},e.player_index)),eK>0&&(0,l.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[(0,l.jsx)("span",{children:"Extras"}),(0,l.jsx)("span",{children:g(eK)})]}),(0,l.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 text-sm font-semibold",children:[(0,l.jsx)("span",{children:"Total"}),(0,l.jsx)("span",{children:g((null!=(B=null==eS?void 0:eS.total_pence)?B:0)+eK)})]})]}),eV&&(0,l.jsx)("p",{className:"mb-3 text-xs text-gray-500","data-testid":"cancellation-policy",children:eV}),(0,l.jsx)("p",{className:"mb-1 text-sm text-gray-500",children:"Payment"}),0===ez.length&&(0,l.jsx)("p",{className:"text-sm text-amber-700",children:"No payment method available â please contact the club."}),(0,l.jsx)("div",{className:"mb-4 space-y-1",children:ez.map(e=>{let t="card"===e.method&&o(e.method,eX)&&!eQ;return(0,l.jsxs)("label",{className:"flex items-center gap-2 text-sm ".concat(t?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[(0,l.jsx)("input",{type:"radio",name:"pay",disabled:t,checked:(null==eu?void 0:eu.method)===e.method,onChange:()=>ec(e)}),(0,l.jsxs)("span",{className:"flex-1",children:[e.label,t&&(0,l.jsx)("span",{className:"ml-2 text-xs text-amber-700","data-testid":"card-unavailable",children:c})]}),e.is_deposit&&e.amount_pence>0&&(0,l.jsxs)("span",{className:"text-xs text-gray-500",children:[g(e.amount_pence)," deposit"]})]},e.method)})}),e0&&eQ&&(0,l.jsx)("div",{className:"mb-4",children:(0,l.jsx)(h,{ref:eC,busy:ek,billingName:(eh?ex.name.trim():U)||void 0})}),(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("button",{onClick:()=>ev("players"),className:"rounded border px-3 py-1",children:"Back"}),(0,l.jsx)("button",{onClick:eH,disabled:ek||e1||ez.length>0&&!eu,className:"rounded px-3 py-1 text-white disabled:opacity-60",style:e2,children:ek?ew||"Bookingâ¦":"Confirm booking"})]})]})]})}},16565:(e,t,n)=>{n.d(t,{B_:()=>d,F9:()=>p,RM:()=>c,Rf:()=>u,SF:()=>h,f:()=>o,fA:()=>r,fk:()=>s,jZ:()=>i,lx:()=>m});var l=n(36015);async function a(e,t,n){let l=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:void 0!==n?JSON.stringify(n):void 0}),a=await l.json().catch(()=>({}));if(!l.ok)throw Object.assign(Error((null==a?void 0:a.message)||"Request failed (".concat(l.status,")")),{status:l.status,data:a});return a}function r(e){var t;return a("/api/tee-booking/booking-sessions","POST",{slot_id:e.slot_id,course_id:e.course_id,players:e.players,is_tie:null!=(t=e.is_tie)&&t,auto_place:!1,source_channel:"web",utm:(0,l.hB)()})}function s(e,t){return a("/api/tee-booking/booking-sessions/".concat(e),"PATCH",t)}function i(e,t){return a("/api/tee-booking/booking-sessions/".concat(e,"/confirm"),"POST",t)}function o(e){return a("/api/tee-booking/create-payment-intent","POST",{booking_id:e.booking_id,slot_id:e.slot_id})}function d(e){return a("/api/tee-booking/booking-sessions/".concat(e,"/cancel"),"POST",{})}function u(){return a("/api/tee-booking/me/favourites","GET")}function c(e){return a("/api/tee-booking/player-search?q=".concat(encodeURIComponent(e)),"GET")}function m(e){return a("/api/tee-booking/booking-sessions/".concat(encodeURIComponent(e)),"GET")}function p(e){var t,n,l,a,r,s;return{booking_id:null!=(t=e.booking_id)?t:null,session_id:null!=(n=e.session_id)?n:null,quote:null!=(l=e.quote)?l:null,hold_expires_at:null!=(a=e.hold_expires_at)?a:null,placement:"requested",slot_id:null!=(r=e.slot_id)?r:null,version:null!=(s=e.version)?s:null}}function h(e){return a("/api/tee-booking/booking-sessions/".concat(encodeURIComponent(e),"/confirmation"),"GET")}}
1,29599:(e,t,n)=>{n.d(t,{s:()=>l});function l(e,t){try{let n=window.umami;if(!n||"function"!=typeof n.track)return;if(!t)return void n.track(e);let l={};for(let[e,n]of Object.entries(t))void 0!==n&&(l[e]=n);n.track(e,l)}catch(e){}}},34154:(e,t,n)=>{n.d(t,{w:()=>i});var l=n(34340),a=n(16565),r=n(66248);let s={session:null,phase:"idle",denial:null,error:null,status:null,confirmed:!1};function i(e){var t,n,i,d;let{slotId:u,courseId:c,releaseOnUnmount:m=!0}=e,[p,h]=(0,l.useState)(s),x=(0,l.useRef)(null),f=(0,l.useRef)(!1),b=(0,l.useRef)(!1),g=(0,l.useRef)([]),y=(0,l.useRef)(null),_=(0,l.useCallback)((e,t,n)=>{var l,a;y.current=e,x.current=null!=(a=null!=(l=e.booking_id)?l:e.session_id)?a:x.current,b.current=!1,h(l=>({...l,session:e,phase:t,status:n,denial:null,error:null}))},[]),v=(0,l.useCallback)(async e=>{g.current=e,h(e=>({...e,phase:"working",error:null,denial:null}));try{let t=await (0,a.fA)({slot_id:u,course_id:c,players:e});if("alternate"===t.placement||t.slot_id&&t.slot_id!==u){t.booking_id&&(0,a.B_)(t.booking_id).catch(()=>{});let e={reason_code:"slot_unavailable",message:(0,r.S$)("slot_unavailable"),next_available_slot:null,waitlist:null,earliest_bookable_time:null,alternatives:[]};return h(t=>({...t,phase:"denied",denial:e,session:null})),{kind:"denial",denial:e}}if("waitlisted"===t.placement)return y.current=t,h(e=>({...e,session:t,phase:"waitlisted",denial:null,error:null})),{kind:"waitlisted",session:t};if(!t.booking_id){let e=(0,r.S$)("slot_unavailable");return h(t=>({...t,phase:"error",error:e})),{kind:"error",message:e}}return _(t,"ready","draft"),{kind:"session",session:t}}catch(n){let e=(0,r.j0)(n);if(e)return h(t=>({...t,phase:"denied",denial:e})),{kind:"denial",denial:e};let t=o(n,"Could not start booking.");return h(e=>({...e,phase:"error",error:t})),{kind:"error",message:t}}},[u,c,_]),k=(0,l.useCallback)(async e=>{h(e=>({...e,phase:"working",error:null,denial:null}));try{var t,n,l,r;let s=await (0,a.lx)(e),i="string"==typeof s.status?s.status:"";if("confirmed"===i||"pending_payment"===i){return f.current=!0,x.current=null!=(n=null!=(t=s.booking_id)?t:s.session_id)?n:e,h(e=>({...e,session:(0,a.F9)(s),phase:"settled",status:i,confirmed:!0})),{kind:"settled",status:i,read:s}}if("draft"!==i)return x.current=null,y.current=null,h(e=>({...e,session:null,phase:"gone",status:i,denial:null,error:null})),{kind:"gone"};let o=(0,a.F9)(s);return l=s,g.current=(null!=(r=l.players)?r:[]).map(e=>({name:(e.name||"").trim(),is_guest:!0===e.is_guest,...e.golfer_uuid?{golfer_uuid:e.golfer_uuid}:{},...e.email?{email:e.email}:{},...e.phone?{phone:e.phone}:{},...e.postcode?{postcode:e.postcode}:{}})).filter(e=>e.name.length>0),_(o,"ready","draft"),{kind:"session",session:o,read:s}}catch(n){let e=null==n?void 0:n.status;if(404===e)return x.current=null,h(e=>({...e,session:null,phase:"gone",status:"cancelled"})),{kind:"gone"};let t=o(n,"We could not load your booking.");return h(e=>({...e,phase:"error",error:t})),{kind:"error",message:t,status:e}}},[_]),j=(0,l.useCallback)(async function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=x.current;if(!n)return null;t.players&&(g.current=t.players);let l={...t.players?{players:t.players}:{},...t.add_ons?{add_ons:t.add_ons}:{},...t.payment_method?{payment_method:t.payment_method}:{},...(null==(e=y.current)?void 0:e.version)?{expected_version:y.current.version}:{}};try{let e=await (0,a.fk)(n,l),t={...y.current,...e};return _(t,"ready","draft"),t}catch(e){if((0,r.tf)(e)){let e=await v(g.current);if("session"===e.kind)return e.session}throw e}},[v,_]),w=(0,l.useCallback)(async e=>{let t=x.current;if(!t)throw Error("No booking to confirm.");let n=await (0,a.jZ)(t,e);return f.current=!0,h(e=>({...e,confirmed:!0,phase:"settled",status:n.status})),n},[]),N=(0,l.useCallback)(()=>{let e=x.current;x.current=null,!e||f.current||b.current||(b.current=!0,(0,a.B_)(e).catch(()=>{}))},[]),C=(0,l.useCallback)(()=>{N(),y.current=null,h(e=>({...e,session:null,phase:"idle",denial:null,status:null}))},[N]);(0,l.useEffect)(()=>{if(m)return()=>{let e=x.current;!e||f.current||b.current||(0,a.B_)(e).catch(()=>{})}},[m]);let S=(0,l.useCallback)(e=>{h(t=>({...t,error:e}))},[]),R=(0,l.useCallback)(e=>{h(t=>({...t,denial:e,phase:e?"denied":t.phase}))},[]);return{state:p,addressId:null!=(d=null!=(i=null==(t=p.session)?void 0:t.booking_id)?i:null==(n=p.session)?void 0:n.session_id)?d:x.current,open:v,read:k,patch:j,confirm:w,cancel:C,setError:S,setDenial:R}}function o(e,t){let n=null==e?void 0:e.data;return[null==n?void 0:n.detail,null==n?void 0:n.message].find(e=>"string"==typeof e&&e.trim())||t}},36015:(e,t,n)=>{n.d(t,{DA:()=>s,hB:()=>o,vu:()=>i});let l="nooq_utm",a=[["source","utm_source"],["medium","utm_medium"],["campaign","utm_campaign"],["content","utm_content"]];function r(e){let t=new URLSearchParams(e.startsWith("?")?e.slice(1):e),n={};for(let[e,r]of a){var l;let a=null==(l=t.get(r))?void 0:l.trim();a&&(n[e]=a.slice(0,100))}return n}function s(e,t){return e.source?[e.source,e.medium,e.campaign].filter(
1Boolean).join("/"):t||void 0}function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.search,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"undefined"==typeof document?"":document.referrer;try{if(window.sessionStorage.getItem(l))return;let n={...r(e),referrer:function(e,t){if(!e)return"";try{let n=new URL(e).hostname.toLowerCase().replace(/^www\./,""),l=t.toLowerCase().replace(/^www\./,"");return n&&n!==l?n.slice(0,100):""}catch(e){return""}}(t,window.location.hostname),landing:window.location.pathname.slice(0,200)};window.sessionStorage.setItem(l,JSON.stringify(n))}catch(e){}}function o(){try{let e=window.sessionStorage.getItem(l);if(e)return JSON.parse(e);return r(window.location.search)}catch(e){return{}}}},52733:(e,t,n)=>{n.d(t,{YR:()=>r});var l=n(34340);function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();if(!e)return null;let n=new Date(e).getTime();return Number.isNaN(n)?null:Math.max(0,Math.floor((n-t)/1e3))}function r(e){let[t,n]=(0,l.useState)(()=>a(e));return(0,l.useEffect)(()=>{if(n(a(e)),!e)return;let t=setInterval(()=>{let l=a(e);n(l),(0===l||null==l)&&clearInterval(t)},1e3);return()=>clearInterval(t)},[e]),null==t?{seconds:null,label:null,low:!1,expired:!1}:{seconds:t,label:function(e){let t=Math.floor(e/60);return"".concat(t,":").concat(String(e%60).padStart(2,"0"))}(t),low:t>0&&t<=120,expired:0===t}}},66248:(e,t,n)=>{n.d(t,{I3:()=>m,R$:()=>s,S$:()=>i,Ze:()=>o,_0:()=>c,j0:()=>d,lT:()=>r,tf:()=>p});let l={advance_window_exceeded:"This date is beyond how far ahead your membership can book.",before_release:"Bookings for this date have not been released yet.",slot_in_past:"That tee time has passed.",weekday_not_allowed:"Your membership canât book on this day.",time_outside_bands:"Your membership canât book at this time.",max_bookings_window_reached:"Youâve reached your booking limit for this period.",max_future_bookings_reached:"You already have the maximum number of upcoming bookings.",max_per_day_exceeded:"You already have a round booked that day.",max_per_week_exceeded:"Youâve reached your rounds for this week.",max_per_month_exceeded:"Youâve reached your rounds for this month.",max_slots_per_payer_exceeded:"Thatâs more tee times than one booking can pay for â please split the group.",trade_channel_referral:"Group bookings of this size are arranged through the club â please contact the office.",min_gap_violated:"You have another booking too close to this tee time.",guests_not_allowed:"Guests canât be added under your booking profile.",guests_require_member:"A member must be in the group when guests are playing.",not_bookable_for_category:"Your membership canât book at this time.",slot_full:"That tee time was just taken â please choose another.",slot_unavailable:"That tee time was just taken â please choose another.",booking_in_progress:"Someone is currently booking this tee time â it will free up or fill in a few minutes.",booking_changed:"This booking was changed elsewhere â please review it and try again.",not_priced:"This time isnât priced for your membership.",full:"Fully booked."},a="Your membership isnât eligible to book this slot.";function r(e){return(null==e?void 0:e.allowed)===!1}function s(e){let t=function(e){var t;if(!e||!1!==e.allowed)return null;let n=null==(t=e.denied_rules)?void 0:t.find(e=>e&&(e.code||e.message));return n||(e.reason_code?{code:e.reason_code}:null)}(e);if(!t)return a;let n=(t.message||"").trim();return n||t.code&&l[t.code]||a}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;return e&&l[e]||t}let o=new Set(["slot_full","slot_unavailable","booking_in_progress"]);function d(e){var t;let n=null==e?void 0:e.data;if(!n||"object"!=typeof n||"string"!=typeof n.reason_code)return null;let l=n.next_available_slot;return{reason_code:n.reason_code,message:"string"==typeof n.message?n.message:i(n.reason_code),next_available_slot:l&&"string"==typeof l.slot_id?l:null,waitlist:null!=(t=n.waitlist)?t:null,earliest_bookable_time:"string"==typeof n.earliest_bookable_time?n.earliest_bookable_time:null,alternatives:Array.isArray(n.alternatives)?n.alternatives:[]}}function u(e){return"booking_in_progress"===e.reason_code}function c(e){return u(e)?"Someone is currently booking this tee time":"That tee time was just taken"}function m(e){return u(e)?"Another player is adding their group right now. Hereâs what you can do:":"Someone booked it a moment before you. Hereâs what you can do:"}function p(e){var t,n;if(!e)return!1;if(404===e.status)return!0;
1if(409!==e.status)return!1;let l=[null==(t=e.data)?void 0:t.detail,null==(n=e.data)?void 0:n.message].filter(e=>"string"==typeof e).join(" ");return/cancel|expired|not found/i.test(l)}},82326:(e,t,n)=>{n.d(t,{y:()=>s});var l=n(29064),a=n(34340),r=n(16565);let s=e=>{let{excludeUuids:t,onPick:n,onAddGuest:s,onClose:i}=e,[o,d]=(0,a.useState)([]),[u,c]=(0,a.useState)(""),[m,p]=(0,a.useState)([]),[h,x]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=!1;return(0,r.Rf)().then(t=>{e||d(t.partners||[])}).catch(()=>{e||d([])}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{let e=u.trim();if(e.length<2)return void p([]);let t=!1;x(!0);let n=setTimeout(()=>{(0,r.RM)(e).then(e=>{t||p(e.golfers||[])}).catch(()=>{t||p([])}).finally(()=>{t||x(!1)})},250);return()=>{t=!0,clearTimeout(n)}},[u]);let f=new Set(t),b=o.filter(e=>!f.has(e.golfer_uuid)),g=m.filter(e=>!f.has(e.id));return(0,l.jsxs)("div",{className:"mt-2 rounded-md border p-3 bg-gray-50",style:{border:"1px solid #e5e7eb"},children:[(0,l.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,l.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium",children:[(0,l.jsxs)("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,l.jsx)("circle",{cx:"9",cy:"8",r:"4"}),(0,l.jsx)("path",{d:"M3 20c0-3.3 2.7-6 6-6s6 2.7 6 6"}),(0,l.jsx)("path",{d:"M19 8v6M16 11h6"})]}),"Add a player"]}),(0,l.jsx)("button",{onClick:i,className:"text-xs text-gray-500 hover:text-gray-800",children:"Close"})]}),b.length>0&&(0,l.jsxs)("div",{className:"mb-2",children:[(0,l.jsx)("p",{className:"mb-1 text-xs text-gray-500",children:"Favourites & partners"}),(0,l.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.map(e=>(0,l.jsxs)("button",{onClick:()=>n({golfer_uuid:e.golfer_uuid,name:e.name}),className:"rounded-full border px-2.5 py-1 text-xs hover:border-[#009293] hover:text-[#009293]",style:{border:"1px solid #d1d5db",borderRadius:9999},children:[e.favourite?"â
":"",e.name,null!=e.handicap_index?" (".concat(e.handicap_index,")"):""]},e.golfer_uuid))})]}),(0,l.jsxs)("div",{className:"relative",style:{position:"relative"},children:[(0,l.jsxs)("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[(0,l.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,l.jsx)("path",{d:"m20 20-3.5-3.5"})]}),(0,l.jsx)("input",{type:"search","aria-label":"Search members by name",value:u,onChange:e=>c(e.target.value),placeholder:"Search members by nameâ¦",className:"w-full text-sm",style:{backgroundColor:"#ffffff",border:"1px solid #d1d5db",borderRadius:8,padding:"10px 12px 10px 36px",boxShadow:"0 1px 2px rgba(0,0,0,0.04)"}})]}),h&&(0,l.jsx)("p",{className:"mt-1 text-xs text-gray-400",children:"Searchingâ¦"}),g.length>0&&(0,l.jsx)("div",{className:"mt-2 max-h-48 divide-y overflow-y-auto rounded-md border bg-white",children:g.map(e=>(0,l.jsx)("button",{onClick:()=>n({golfer_uuid:e.id,name:e.name}),className:"block w-full px-3 py-2 text-left text-sm hover:bg-gray-50",children:e.name},e.id))}),s&&(0,l.jsx)("button",{onClick:s,className:"mt-2 text-sm text-[#009293] hover:underline",children:"+ Add a guest instead"})]})}},98083:(e,t,n)=>{n.d(t,{$4:()=>s,Ag:()=>a,DH:()=>d,F6:()=>l,kL:()=>o,qV:()=>r,sN:()=>i});let l={member:"#22C55E",visitor:"#1A5C5C",guest:"#B5861E",masked:"#9ca3af"},a={primary:"#009293",primaryTint:"#00929310",pine:"#247a7a",dark:"#1d4449"},r={"--tee-primary":a.primary,"--tee-primary-tint":a.primaryTint};function s(e,t){return e.name&&t?e.is_guest||"guest"===e.category_code?l.guest:"member"===e.category_code?l.member:l.visitor:l.masked}let i=4;function o(e){return Array.from({length:i},(t,n)=>{var l;return null!=(l=e.players[n])?l:null})}function d(e){return e?"time_outside_bands"===e||"weekday_not_allowed"===e||"not_priced"===e?"Not available for your membership at this time":"before_release"===e?"Not released yet":"slot_in_past"===e?"Time has passed":"full"===e?"Fully booked":"Not available":"Not available"}}}]);
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.