PageSourceSearch

https://app.carenova.ai/static/js/112.72fa6ce2.chunk.js

js carenova.ai collected 2026-10-05 14:31:32 UTC 32,353 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkcarenova_frontend=self.webpackChunkcarenova_frontend||[]).push([[112],{2202(e,t,n){function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GBP",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"en-GB";return new Intl.NumberFormat(n,{style:"currency",currency:t}).format(e/100)}function a(e){const t=e.replace(/[^\d.,-]/g,"").replace(",",".");return!t||Number.isNaN(Number(t))?null:Math.round(100*Number(t))}n.d(t,{sc:()=>a,up:()=>s})},1937(e,t,n){function s(e,t){return"".concat(e.trim()," ").concat(t.trim()).replace(/\s+/g," ").trim()}n.d(t,{Eo:()=>r,Wq:()=>l,YU:()=>s,cK:()=>i,rH:()=>a});function a(e,t){return e.trim()?t.trim()?s(e,t).length>120?"tooLong":null:"lastRequired":"firstRequired"}function i(e){const t=e.trim();return t?/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(t)?null:"invalid":"required"}const l=/^[0-9+\s]*$/;function r(e){if(!e.trim())return"required";if(!l.test(e))return"characters";const t=function(e){const t=e.replace(/\s+/g,"");return t.startsWith("+")?"+".concat(t.slice(1).replace(/\D/g,"")):t.replace(/\D/g,"")}(e),n=t.startsWith("+44")?"0".concat(t.slice(3)):t.startsWith("0044")?"0".concat(t.slice(4)):t.startsWith("0")?t:null;if(null!==n)return/^07\d{9}$/.test(n)?null:"uk";const s=t.replace(/\D/g,"");return t.startsWith("+")?s.length>=8&&s.length<=15?null:"length":"uk"}},112(e,t,n){n.r(t),n.d(t,{default:()=>H});var s=n(5043),a=n(953),i=n(9379),l=n(5544),r=n(3415),c=n(409),o=n(9791),d=n(2202);let u=null;function m(e){const t="string"===typeof e?e.trim():"";t&&(u=t)}var x=n(1937),p=n(579);function h(e){if(!e)return"";const t=new Date("".concat(String(e).slice(0,10),"T12:00:00"));if(Number.isNaN(t.getTime()))return String(e);const n=t.toLocaleDateString("en-GB",{weekday:"long"}),s=t.toLocaleDateString("en-GB",{month:"long"});return"".concat(n," ").concat(t.getDate()," ").concat(s," ").concat(t.getFullYear())}function b(e,t){return e.split(/(\*\*[^*]+\*\*)/g).filter(Boolean).map((e,n)=>e.startsWith("**")&&e.endsWith("**")?(0,p.jsx)("strong",{className:"font-semibold",children:e.slice(2,-2)},"".concat(t,"-").concat(n)):(0,p.jsx)(s.Fragment,{children:e},"".concat(t,"-").concat(n)))}function g(e){let t=e.source,n=e.className,s=void 0===n?"":n;const a=[];let i=[],l=[];const r=()=>{i.length&&a.push((0,p.jsx)("p",{className:"mt-2 first:mt-0",children:b(i.join(" "),"p".concat(a.length))},"p".concat(a.length))),i=[]},c=()=>{l.length&&a.push((0,p.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:l.map((e,t)=>(0,p.jsx)("li",{children:b(e,"l".concat(a.length,"-").concat(t))},t))},"l".concat(a.length))),l=[]};for(const o of t.replace(/\r\n/g,"\n").split("\n")){const e=o.trim(),t=/^(#{1,6})\s+(.*)$/.exec(e);if(e){if(t){r(),c();const e=t[1].length,n=e<=2?"mt-4 text-base font-semibold text-ink first:mt-0":"mt-4 text-sm font-semibold text-ink first:mt-0";a.push((0,p.jsx)("p",{role:"heading","aria-level":Math.min(e+1,6),className:n,children:b(t[2],"h".concat(a.length))},"h".concat(a.length)));continue}/^[-*\u2610]\s+/.test(e)?(r(),l.push(e.replace(/^[-*\u2610]\s+/,""))):e.startsWith(">")?(r(),c(),a.push((0,p.jsx)("p",{className:"mt-2 rounded-md bg-surface-sunken px-3 py-2 text-ink-muted first:mt-0",children:b(e.replace(/^>\s?/,""),"q".concat(a.length))},"q".concat(a.length)))):(c(),i.push(e))}else r(),c()}return r(),c(),(0,p.jsx)("div",{className:"text-sm leading-relaxed text-ink ".concat(s),children:a})}const f=r.A.getFixedT("en","practice");function N(e){return"".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0"),"-").concat(String(e.getDate()).padStart(2,"0"))}function k(e,t){var n,s;return(null===e||void 0===e||null===(n=e.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.error)||t}const j="rounded-2xl border border-line bg-surface p-4",v="w-full rounded-xl border border-line bg-surface px-3 py-3 text-base text-ink focus:outline-none focus:border-accent",y="w-full rounded-xl bg-accent px-4 py-3 text-base font-semibold text-white hover:bg-accent-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed";function S(){var e,t,n,r,o,u,b;
1const g=(0,a.g)().slug,S=void 0===g?"":g,F=(0,s.useState)(null),q=(0,l.A)(F,2),D=q[0],M=q[1],E=(0,s.useState)(!1),P=(0,l.A)(E,2),T=P[0],B=P[1],R=(0,s.useState)(null),W=(0,l.A)(R,2),U=W[0],I=W[1],H=(0,s.useState)(null),L=(0,l.A)(H,2),G=L[0],Y=L[1],K=(0,s.useState)(()=>N(new Date)),z=(0,l.A)(K,2),$=z[0],O=z[1],V=(0,s.useState)(""),_=(0,l.A)(V,2),X=_[0],J=_[1],Q=(0,s.useState)(""),Z=(0,l.A)(Q,2),ee=Z[0],te=Z[1],ne=(0,s.useState)(null),se=(0,l.A)(ne,2),ae=se[0],ie=se[1],le=(0,s.useState)(!1),re=(0,l.A)(le,2),ce=re[0],oe=re[1],de=(0,s.useState)(null),ue=(0,l.A)(de,2),me=ue[0],xe=ue[1],pe=(0,s.useState)({firstName:"",lastName:"",email:"",phone:"",notes:""}),he=(0,l.A)(pe,2),be=he[0],ge=he[1],fe=(0,s.useState)(null),Ne=(0,l.A)(fe,2),ke=Ne[0],je=Ne[1],ve=(0,s.useState)(!1),ye=(0,l.A)(ve,2),Se=ye[0],we=ye[1],Ae=(0,s.useState)(null),Ce=(0,l.A)(Ae,2),Fe=Ce[0],qe=Ce[1],De=(0,s.useState)(null),Me=(0,l.A)(De,2),Ee=Me[0],Pe=Me[1],Te=(0,s.useState)(null),Be=(0,l.A)(Te,2),Re=Be[0],We=Be[1],Ue=(0,s.useState)(null),Ie=(0,l.A)(Ue,2),He=Ie[0],Le=Ie[1];(0,s.useEffect)(()=>{let e=!1;return c.Ay.get("/api/book/".concat(S)).then(t=>{e||(!function(e){const t=e;return!!t&&"object"===typeof t&&"string"===typeof t.slug&&"string"===typeof t.practiceName&&Array.isArray(t.services)}(t.data)?I(f("book.unexpectedShape")):(m(t.data.practiceName),M(t.data)))}).catch(t=>{var n,s;e||(null!==t&&void 0!==t&&null!==(n=t.response)&&void 0!==n&&null!==(s=n.data)&&void 0!==s&&s.closed?B(!0):I(k(t,f("book.loadFailed"))))}),()=>{e=!0}},[S]);const Ge=(0,s.useCallback)(async(e,t)=>{oe(!0),ie(null),xe(null);try{const n=await c.Ay.get("/api/book/".concat(S,"/slots"),{params:(0,i.A)((0,i.A)({date:t,serviceId:e.id},X?{practitionerId:X}:{}),ee?{locationId:ee}:{})});ie(n.data.slots)}catch(n){qe(k(n,f("book.slotsFailed"))),ie([])}finally{oe(!1)}},[S,X,ee]);(0,s.useEffect)(()=>{G&&Ge(G,$)},[G,$,Ge]);const Ye=(0,s.useMemo)(()=>{var e;const t=new Date;return t.setDate(t.getDate()+(null!==(e=null===D||void 0===D?void 0:D.maxDaysAhead)&&void 0!==e?e:60)),N(t)},[D]);return T?(0,p.jsx)(C,{title:f("book.closedTitle"),children:(0,p.jsx)("div",{className:j,children:(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:f("book.closedBody")})})}):U?(0,p.jsx)(C,{title:f("book.notFoundTitle"),children:(0,p.jsx)("div",{className:j,children:(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:U})})}):D?Ee?(0,p.jsx)(C,{title:"".concat(f("book.confirmedTitle")," \xb7 ").concat(Ee.practiceName),children:(0,p.jsxs)("div",{className:"".concat(j," space-y-3"),children:[(0,p.jsx)("p",{className:"text-lg font-semibold text-ink",children:f("book.confirmedTitle")}),(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:f("book.confirmedBody",{practice:Ee.practiceName})}),(0,p.jsxs)("dl",{className:"space-y-1 text-sm",children:[(0,p.jsx)(A,{label:f("book.service"),value:Ee.serviceName}),(0,p.jsx)(A,{label:f("book.when"),value:"".concat(h(Ee.date)," \xb7 ").concat(Ee.time)}),(0,p.jsx)(A,{label:f("book.reference"),value:Ee.reference}),"pending"===Ee.depositStatus&&Ee.depositMinor>0&&(0,p.jsx)(A,{label:f("book.deposit"),value:f("book.depositPending",{amount:(0,d.up)(Ee.depositMinor,Ee.currency)})}),"pending"===Ee.consentStatus&&(0,p.jsx)(A,{label:f("book.consent"),value:f("book.consentPending")})]}),"pending"===Ee.depositStatus&&Ee.depositMinor>0&&(0,p.jsx)("div",{className:"space-y-2 border-t border-line pt-3",children:He?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("a",{href:He,className:"".concat(y," block text-center no-underline"),children:f("book.payDepositNow",{amount:(0,d.up)(Ee.depositMinor,Ee.currency)})}),(0,p.jsx)("p",{className:"text-xs text-ink-subtle",children:f("book.payDepositLater")})]}):(0,p.jsx)("p",{className:"text-xs text-ink-subtle",children:f("book.depositNotOnline",{amount:(0,d.up)(Ee.depositMinor,Ee.currency)})})}),Re&&(0,p.jsx)("p",{className:"text-sm",children:(0,p.jsx)("a",{className:"text-accent underline underline-offset-2",href:Re,children:f("book.manageLink")})}),(0,p.jsx)("p",{className:"text-xs text-ink-subtle",children:f("book.manageHint")})]})}):(0,p.jsxs)(C,{title:"".concat(D.headline||f("book.defaultHeadline")," \xb7 ").concat(D.practiceName),children:[(0,p.jsxs)("header",{className:"mb-4",children:[D.practitioner&&(D.practitioner.displayName||D.practitioner.photoUrl)&&(0,p.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[D.practitioner.photoUrl&&(0,p.jsx)("img",{src:D.practitioner.photoUrl,alt:null!==(e=D.practitioner.displayName)&&void 0!==e?e:D.practiceName,className:"h-16 w-16 shrink-0 rounded-full border border-line object-cover"}),(0,p.jsxs)("div",{className:"min-w-0",children:[D.practitioner.displayName&&(0,p.jsxs)("p",{className:"text-base font-semibold text-ink",children:[D.practitioner.displayName,D.practitioner.qualifications?", ".concat(D.practitioner.qualifications):""]}
1),D.practitioner.gmcNumber&&(0,p.jsx)("p",{className:"text-xs text-ink-subtle",children:f("book.gmcNumber",{number:D.practitioner.gmcNumber})})]})]}),(0,p.jsx)("h1",{className:"font-display text-2xl text-ink",children:D.headline||f("book.defaultHeadline")}),(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:D.practiceName}),D.blurb&&(0,p.jsx)("p",{className:"mt-2 text-sm text-ink-muted",children:D.blurb})]}),(0,p.jsxs)("ol",{className:"space-y-4",children:[(0,p.jsxs)("li",{className:j,children:[(0,p.jsx)("h2",{className:"mb-2 text-sm font-semibold text-ink",children:f("book.step1")}),(0,p.jsxs)("div",{className:"space-y-2",children:[D.services.map(e=>(0,p.jsx)("button",{type:"button",onClick:()=>Y(e),"aria-pressed":(null===G||void 0===G?void 0:G.id)===e.id,className:"w-full rounded-xl border px-3 py-3 text-left transition-colors ".concat((null===G||void 0===G?void 0:G.id)===e.id?"border-accent bg-accent-soft":"border-line hover:bg-surface-sunken"),children:(0,p.jsxs)("span",{className:"flex items-center justify-between gap-3",children:[(0,p.jsxs)("span",{children:[(0,p.jsx)("span",{className:"block text-sm font-medium text-ink",children:e.name}),(0,p.jsxs)("span",{className:"block text-xs text-ink-muted",children:[f("book.minutes",{count:e.durationMinutes}),e.requiresConsent?" \xb7 ".concat(f("book.consentRequired")):""]})]}),(0,p.jsx)("span",{className:"shrink-0 text-sm text-ink",children:e.priceMinor>0?(0,d.up)(e.priceMinor,e.currency):f("book.free")})]})},e.id)),0===D.services.length&&(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:f("book.noServices")})]})]}),G&&(null!==(t=null===(n=D.locations)||void 0===n?void 0:n.length)&&void 0!==t?t:0)>1&&(0,p.jsxs)("li",{className:j,children:[(0,p.jsx)("h2",{className:"mb-2 text-sm font-semibold text-ink",children:f("book.stepLocation")}),(0,p.jsx)("div",{className:"space-y-2",children:(null!==(r=D.locations)&&void 0!==r?r:[]).map(e=>(0,p.jsxs)("button",{type:"button",onClick:()=>{te(e.id),J("")},"aria-pressed":ee===e.id,className:"w-full rounded-xl border px-3 py-3 text-left transition-colors ".concat(ee===e.id?"border-accent bg-accent-soft":"border-line hover:bg-surface-sunken"),children:[(0,p.jsx)("span",{className:"block text-sm font-medium text-ink",children:e.name}),e.address&&(0,p.jsx)("span",{className:"block text-xs text-ink-muted",children:e.address})]},e.id))})]}),G&&(null!==(o=null===(u=D.practitioners)||void 0===u?void 0:u.length)&&void 0!==o?o:0)>1&&(0,p.jsxs)("li",{className:j,children:[(0,p.jsx)("h2",{className:"mb-2 text-sm font-semibold text-ink",children:f("book.stepPractitioner")}),(0,p.jsxs)("div",{className:"space-y-2",children:[(0,p.jsxs)("button",{type:"button",onClick:()=>J(""),"aria-pressed":""===X,className:"w-full rounded-xl border px-3 py-3 text-left transition-colors ".concat(""===X?"border-accent bg-accent-soft":"border-line hover:bg-surface-sunken"),children:[(0,p.jsx)("span",{className:"block text-sm font-medium text-ink",children:f("book.anyPractitioner")}),(0,p.jsx)("span",{className:"block text-xs text-ink-muted",children:f("book.anyPractitionerHint")})]}),(null!==(b=D.practitioners)&&void 0!==b?b:[]).map(e=>(0,p.jsxs)("button",{type:"button",onClick:()=>J(e.id),"aria-pressed":X===e.id,className:"flex w-full items-center gap-3 rounded-xl border px-3 py-3 text-left transition-colors ".concat(X===e.id?"border-accent bg-accent-soft":"border-line hover:bg-surface-sunken"),children:[e.photoUrl&&(0,p.jsx)("img",{src:e.photoUrl,alt:"",className:"h-10 w-10 shrink-0 rounded-full object-cover"}),(0,p.jsxs)("span",{className:"min-w-0",children:[(0,p.jsx)("span",{className:"block text-sm font-medium text-ink",children:e.name}),e.qualifications&&(0,p.jsx)("span",{className:"block text-xs text-ink-muted",children:e.qualifications}),e.gmcNumber&&(0,p.jsxs)("span",{className:"block text-xs text-ink-subtle",children:["GMC ",e.gmcNumber]})]})]},e.id))]})]}),G&&(0,p.jsxs)("li",{className:j,children:[(0,p.jsx)("h2",{className:"mb-2 text-sm font-semibold text-ink",children:f("book.step2")}),(0,p.jsx)("label",{className:"block text-xs font-medium text-ink-subtle mb-1",htmlFor:"pb-date",children:f("book.date")}),(0,p.jsx)("input",{id:"pb-date",type:"date",value:$,min:N(new Date),max:Ye,onChange:e=>O(e.target.value),className:v}),(0,p.jsx)("p",{className:"mt-1 text-xs text-ink-subtle",children:f("book.timezoneNote",{timezone:D.timezone})}),(0,p.jsxs)("div",{className:"mt-3",children:[ce&&(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:f("book.loadingSlots")}),!ce&&ae&&0===ae.length&&(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:f("book.noSlots",{hours:D.minNoticeHours})}),!ce&&ae&&ae.length>0&&(0,p.jsx)("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-4",children:ae.map(e=>(0,p.jsx)("button",{type:"button",onClick:()=>xe(e.time),"aria-pressed":me===e.time,className:"rounded-xl border px-2 py-2.5 text-sm transition-colors ".concat(me===e.time?"border-accent bg-accent-soft text-accent":"border-line text-ink hover:bg-surface-sunken"),children:e.time},e.time))})]})]}),G&&me&&(0,p.jsxs)("li",{className:j,children:[(0,p.jsx)("h2",{className:"mb-2 text-sm font-semibold text-ink",children:f("book.step3")}),(0,p.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),!G||!me)return;je(null);const t=(0,x.rH)(be.firstName,be.lastName);if(t)return void je({field:"lastRequired"===t?"lastName":"firstName",message:f("patientFields.errors.".concat(t))});const n=(0,x.cK)(be.email);if(n)return void je({field:"email",message:f("patientFields.errors.email".concat("required"===n?"Required":"Invalid"))});const s=(0,x.Eo)(be.phone);if(s){return void je({field:"phone",message:f("patientFields.errors.".concat({required:"phoneRequired",characters:"phoneCharacters",uk:"phoneUk",length:"phoneLength"}[s]))})}we(!0),qe(null);try{var a;const e=await c.Ay.post("/api/book/".concat(S),{serviceId:G.id,date:$,time:me,practitionerId:X||null,locationId:ee||null,name:(0,x.YU)(be.firstName,be.lastName),email:be.email.trim(),phone:be.phone.trim(),notes:be.notes||null});Pe(e.data.booking),We(e.data.manageUrl),Le(null!==(a=e.data.paymentUrl)&&void 0!==a?a:null)}catch(i){qe(k(i,f("book.bookingFailed"))),G&&Ge(G,$)}finally{we(!1)}},className:"space-y-3",children:[(0,p.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"mb-1 block text-xs font-medium text-ink-subtle",htmlFor:"pb-first",children:f("patientFields.firstName")}
1),(0,p.jsx)("input",{id:"pb-first",required:!0,value:be.firstName,onChange:e=>ge(t=>(0,i.A)((0,i.A)({},t),{},{firstName:e.target.value})),className:v,autoComplete:"given-name"}),(0,p.jsx)(w,{error:ke,field:"firstName"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"mb-1 block text-xs font-medium text-ink-subtle",htmlFor:"pb-last",children:f("patientFields.lastName")}),(0,p.jsx)("input",{id:"pb-last",required:!0,value:be.lastName,onChange:e=>ge(t=>(0,i.A)((0,i.A)({},t),{},{lastName:e.target.value})),className:v,autoComplete:"family-name"}),(0,p.jsx)(w,{error:ke,field:"lastName"})]})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"mb-1 block text-xs font-medium text-ink-subtle",htmlFor:"pb-email",children:f("patientFields.email")}),(0,p.jsx)("input",{id:"pb-email",required:!0,type:"email",value:be.email,onChange:e=>ge(t=>(0,i.A)((0,i.A)({},t),{},{email:e.target.value})),className:v,autoComplete:"email",inputMode:"email"}),(0,p.jsx)(w,{error:ke,field:"email"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"mb-1 block text-xs font-medium text-ink-subtle",htmlFor:"pb-phone",children:f("patientFields.mobile")}),(0,p.jsx)("input",{id:"pb-phone",required:!0,type:"tel",inputMode:"tel",autoComplete:"tel",value:be.phone,onChange:e=>{x.Wq.test(e.target.value)&&ge(t=>(0,i.A)((0,i.A)({},t),{},{phone:e.target.value}))},className:v}),(0,p.jsx)("p",{className:"mt-1 text-xs text-ink-subtle",children:f("patientFields.mobileHint")}),(0,p.jsx)(w,{error:ke,field:"phone"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-xs font-medium text-ink-subtle mb-1",htmlFor:"pb-notes",children:f("patientFields.notes")}),(0,p.jsx)("textarea",{id:"pb-notes",rows:2,value:be.notes,onChange:e=>ge(t=>(0,i.A)((0,i.A)({},t),{},{notes:e.target.value})),className:v})]}),Fe&&(0,p.jsx)("p",{role:"alert",className:"rounded-xl border border-danger/30 bg-danger-soft px-3 py-2 text-sm text-danger",children:Fe}),(0,p.jsx)("button",{type:"submit",disabled:Se,className:y,children:Se?f("book.booking"):f("book.confirm",{time:me,date:$})}),(0,p.jsx)("p",{className:"text-xs text-ink-subtle",children:f("book.dataNote",{practice:D.practiceName})})]})]})]})]}):(0,p.jsx)(C,{title:"CareNova",children:(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:f("common.loading")})})}function w(e){let t=e.error,n=e.field;return t&&t.field===n?(0,p.jsx)("p",{role:"alert",className:"mt-1 text-xs text-danger",children:t.message}):null}function A(e){let t=e.label,n=e.value;return(0,p.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,p.jsx)("dt",{className:"text-ink-subtle",children:t}),(0,p.jsx)("dd",{className:"text-right text-ink",children:n})]})}function C(e){let t=e.title,n=e.children;return(0,p.jsxs)("main",{className:"min-h-screen bg-surface-page px-4 py-6",children:[(0,p.jsx)(o.A,{title:"".concat(t," | CareNova")}),(0,p.jsxs)("div",{className:"mx-auto w-full max-w-md",children:[n,(0,p.jsx)("p",{className:"mt-6 text-center text-xs text-ink-subtle",children:f("book.poweredBy")})]})]})}const F=r.A.getFixedT("en","practice"),q="rounded-2xl border border-line bg-surface p-4",D="w-full rounded-xl border border-line px-4 py-3 text-base text-ink hover:bg-surface-sunken transition-colors disabled:opacity-50";function M(e,t){var n,s;return(null===e||void 0===e||null===(n=e.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.error)||t}function E(){const e=(0,a.g)().token,t=void 0===e?"":e,n=(0,a.ok)(),i=(0,l.A)(n,1)[0],r=(0,s.useState)(null),o=(0,l.A)(r,2),u=o[0],x=o[1],b=(0,s.useState)(null),g=(0,l.A)(b,2),f=g[0],N=g[1],k=(0,s.use
1State)(!1),j=(0,l.A)(k,2),v=j[0],y=j[1],S=(0,s.useState)(!1),w=(0,l.A)(S,2),A=w[0],E=w[1],P=(0,s.useState)(!1),T=(0,l.A)(P,2),B=T[0],R=T[1],W=(0,s.useState)(""),U=(0,l.A)(W,2),I=U[0],H=U[1],L=(0,s.useState)(null),G=(0,l.A)(L,2),Y=G[0],K=G[1],z=(0,s.useState)(null),$=(0,l.A)(z,2),O=$[0],V=$[1],_=(0,s.useState)(!1),X=(0,l.A)(_,2),J=X[0],Q=X[1],Z=(0,s.useRef)(!0),ee=(0,s.useCallback)(async()=>{try{var e;const n=null===(e=(await c.Ay.get("/api/book/manage/".concat(t))).data)||void 0===e?void 0:e.appointment;return n&&"string"===typeof n.date&&"string"===typeof n.practiceName?(m(n.practiceName),x(n),Z.current&&(H(n.date),Z.current=!1),n):(N(F("manage.notFound")),null)}catch(n){return N(M(n,F("manage.notFound"))),null}},[t]);(0,s.useEffect)(()=>{ee()},[ee]),(0,s.useEffect)(()=>{const e=i.get("deposit");if("cancelled"===e)return void V("cancelled");if("paid"!==e)return;let t,n=!1,s=0;V("checking");const a=async()=>{s+=1;const e=await ee();n||("paid"!==(null===e||void 0===e?void 0:e.depositStatus)?s<3?t=setTimeout(a,2500):V("awaiting"):V("paid"))};return a(),()=>{n=!0,t&&clearTimeout(t)}},[i,ee]);const te=async e=>{if(u){H(e),K(null);try{const t=(await c.Ay.get("/api/book/".concat(u.slug))).data.services.find(e=>e.name===u.serviceName);if(!t)return void K([]);const n=await c.Ay.get("/api/book/".concat(u.slug,"/slots"),{params:{date:e,serviceId:t.id}});K(n.data.slots)}catch(t){K([])}}};return f&&!u?(0,p.jsx)(C,{title:F("manage.title"),children:(0,p.jsx)("div",{className:q,children:(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:f})})}):u?A||"cancelled"===u.status?(0,p.jsx)(C,{title:F("manage.title"),children:(0,p.jsxs)("div",{className:"".concat(q," space-y-2"),children:[(0,p.jsx)("p",{className:"text-lg font-semibold text-ink",children:F("manage.cancelledTitle")}),(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:F("manage.cancelledBody",{practice:u.practiceName})}),(0,p.jsx)("a",{className:"text-sm text-accent underline underline-offset-2",href:"/b/".concat(u.slug),children:F("manage.bookAgain")})]})}):(0,p.jsx)(C,{title:F("manage.title"),children:(0,p.jsxs)("div",{className:"".concat(q," space-y-3"),children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{className:"text-lg font-semibold text-ink",children:u.practiceName}),(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:F("manage.forPatient",{name:u.patientName})})]}),(0,p.jsxs)("dl",{className:"space-y-1 text-sm",children:[(0,p.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,p.jsx)("dt",{className:"text-ink-subtle",children:F("book.service")}),(0,p.jsx)("dd",{className:"text-ink",children:u.serviceName})]}),(0,p.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,p.jsx)("dt",{className:"text-ink-subtle",children:F("book.when")}),(0,p.jsxs)("dd",{className:"text-ink",children:[h(u.date)," \xb7 ",u.time]})]})]}),O&&(0,p.jsx)("p",{role:"status",className:"rounded-xl px-3 py-2 text-sm ".concat("paid"===O?"border border-success/30 bg-success-soft text-success":"border border-line bg-surface-sunken text-ink-muted"),children:F("paid"===O?"manage.depositPaid":"cancelled"===O?"manage.depositCancelled":"checking"===O?"manage.depositChecking":"manage.depositAwaiting")}),f&&(0,p.jsx)("p",{role:"alert",className:"rounded-xl border border-danger/30 bg-danger-soft px-3 py-2 text-sm text-danger",children:f}),"pending"===u.depositStatus&&!!u.depositMinor&&(0,p.jsxs)("div",{className:"space-y-2 border-t border-line pt-3",children:[(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:F("manage.depositDue",{amount:(0,d.up)(u.depositMinor,u.currency||"GBP")})}),(0,p.jsx)("button",{type:"button",onClick:async()=>{Q(!0),N(null);try{var e;const n=await c.Ay.post("/api/book/manage/".concat(t,"/deposit"));if(null===(e=n.data)||void 0===e||!e.url)throw new Error("no url");window.location.assign(n.data.url)}catch(n){N(M(n,F("manage.payDepositFailed"))),Q(!1)}},className:"w-full rounded-xl bg-accent px-4 py-3 text-base font-semibold text-white hover:bg-accent-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:v||J,children:J?F("manage.payDepositOpening"):F("manage.payDeposit",{amount:(0,d.up)(u.depositMinor,u.currency||"GBP")})}),(0,p.jsx)("p",{className:"text-xs text-ink-subtle",children:F("manage.payDepositHint")})]}),B?(0,p.jsxs)("div",{className:"space-y-3",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-xs font-medium text-ink-subtle mb-1",htmlFor:"mb-date",children:F("book.date")}),(0,p.jsx)("input",{id:"mb-date",type:"date",value:I,onChange:e=>te(e.target.value),className:"w-full rounded-xl border border-line bg-surface px-3 py-3 text-base text-ink focus:outline-none focus:border-accent"})]}),null===Y&&(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:F("book.loadingSlots")}),Y&&0===Y.length&&(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:F("manage.noSlots")}),Y&&Y.length>0&&(0,p.jsx)("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-4",children:Y.map(e=>(0,p.jsx)("button",{onClick:()=>(async e=>{y(!0),N(null);try{const n=await c.Ay.post("/api/book/manage/".concat(t,"/reschedule"),{date:I,time:e});x(n.data.appointment),R(!1),K(null)}catch(n){N(M(n,F("manage.moveFailed"))),te(I)}finally{y(!1)}})(e.time),disabled:v,className:"rounded-xl border border-line px-2 py-2.5 text-sm text-ink hover:bg-surface-sunken transition-colors",children:e.time},e.time))}),(0,p.jsx)("button",{onClick:()=>{R(!1),K(null)},className:D,children:F("common.cancel")})]}):(0,p.jsxs)("div",{className:"space-y-2",children:[(0,p.jsx)("button",{onClick:()=>{R(!0),te(u.date)},className:D,disabled:v,children:F("manage.move")}),(0,p.jsx)("button",{onClick:async()=>
1{if(window.confirm(F("manage.cancelConfirm"))){y(!0);try{await c.Ay.post("/api/book/manage/".concat(t,"/cancel")),E(!0)}catch(e){N(M(e,F("manage.cancelFailed")))}finally{y(!1)}}},className:"".concat(D," text-danger"),disabled:v,children:F("manage.cancel")})]})]})}):(0,p.jsx)(C,{title:F("manage.title"),children:(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:F("common.loading")})})}const P=r.A.getFixedT("en","practice");const T="rounded-2xl border border-line bg-surface p-4";function B(e,t,n){if(!e.length)return null;const s=e.filter(e=>e.length>1).map(e=>'<path d="'.concat(e.map((e,t)=>"".concat(0===t?"M":"L").concat(e[0].toFixed(1),",").concat(e[1].toFixed(1))).join(" "),'" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>')).join("");return s?'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.concat(t," ").concat(n,'" width="').concat(t,'" height="').concat(n,'">').concat(s,"</svg>"):null}function R(){const e=(0,a.g)().token,t=void 0===e?"":e,n=(0,s.useState)(null),i=(0,l.A)(n,2),r=i[0],o=i[1],d=(0,s.useState)(null),u=(0,l.A)(d,2),x=u[0],b=u[1],f=(0,s.useState)(""),N=(0,l.A)(f,2),k=N[0],j=N[1],v=(0,s.useState)(!1),y=(0,l.A)(v,2),S=y[0],w=y[1],A=(0,s.useState)(!1),F=(0,l.A)(A,2),q=F[0],D=F[1],M=(0,s.useState)(!1),E=(0,l.A)(M,2),R=E[0],W=E[1],U=(0,s.useRef)(null),I=(0,s.useRef)([]),H=(0,s.useRef)(!1);(0,s.useEffect)(()=>{c.Ay.get("/api/book/consent/".concat(t)).then(e=>{!function(e){const t=e;return!!t&&"object"===typeof t&&"string"===typeof t.practiceName&&!!t.form&&"string"===typeof t.form.name&&"string"===typeof t.form.bodyMd}(e.data)?b(P("consentSign.unexpectedShape")):(m(e.data.practiceName),o(e.data),j(e.data.patientName||""))}).catch(e=>{var t,n;return b((null===e||void 0===e||null===(t=e.response)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.error)||P("consentSign.notFound"))})},[t]);const L=e=>{const t=e.currentTarget.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top]};if(x&&!r)return(0,p.jsx)(C,{title:P("consentSign.title"),children:(0,p.jsx)("div",{className:T,children:(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:x})})});if(!r)return(0,p.jsx)(C,{title:P("consentSign.title"),children:(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:P("common.loading")})});const G=r.signature;var Y,K;return R||G?(0,p.jsx)(C,{title:P("consentSign.title"),children:(0,p.jsxs)("div",{className:"".concat(T," space-y-3"),children:[(0,p.jsx)("p",{className:"text-lg font-semibold text-ink",children:P("consentSign.signedTitle")}),(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:P("consentSign.signedBody",{practice:r.practiceName,version:null!==(Y=null===G||void 0===G?void 0:G.templateVersion)&&void 0!==Y?Y:r.form.version})}),(0,p.jsxs)("details",{className:"rounded-lg border border-line px-3 py-2",children:[(0,p.jsx)("summary",{className:"cursor-pointer text-sm text-ink",children:P("consentSign.readWhatYouSigned")}),(0,p.jsx)(g,{className:"mt-2",source:null!==(K=null===G||void 0===G?void 0:G.bodySnapshot)&&void 0!==K?K:r.form.bodyMd})]})]})}):(0,p.jsx)(C,{title:P("consentSign.title"),children:(0,p.jsxs)("div",{className:"".concat(T," space-y-4"),children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{className:"text-lg font-semibold text-ink",children:r.form.name}),(0,p.jsxs)("p",{className:"text-sm text-ink-muted",children:[r.practiceName," \xb7 ",r.serviceName," \xb7 ",h(r.date),", ",r.time]})]}),(0,p.jsx)("div",{className:"max-h-[60vh] overflow-y-auto rounded-lg border border-line bg-surface-page p-3",children:(0,p.jsx)(g,{source:r.form.bodyMd})}),(0,p.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),D(!0),b(null);try{const e=U.current;await c.Ay.post("/api/book/consent/".concat(t),{patientName:k,agreed:S,signatureSvg:e?B(I.current,e.width,e.height):null}),W(!0)}catch(a){var n,s;b((null===a||void 0===a||null===(n=a.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.error)||P("consentSign.failed"))}finally{D(!1)}},className:"space-y-3",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-xs font-medium text-ink-subtle mb-1",htmlFor:"cs-name",children:P("consentSign.fullName")}
1),(0,p.jsx)("input",{id:"cs-name",required:!0,value:k,onChange:e=>j(e.target.value),className:"w-full rounded-xl border border-line bg-surface px-3 py-3 text-base text-ink focus:outline-none focus:border-accent"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{className:"block text-xs font-medium text-ink-subtle mb-1",children:P("consentSign.signature")}),(0,p.jsx)("canvas",{ref:U,width:320,height:120,className:"w-full touch-none rounded-xl border border-line bg-surface",onPointerDown:e=>{H.current=!0,e.currentTarget.setPointerCapture(e.pointerId),I.current.push([L(e)])},onPointerMove:e=>{if(!H.current)return;const t=I.current[I.current.length-1],n=t[t.length-1],s=L(e);t.push(s),((e,t)=>{var n;const s=null===(n=U.current)||void 0===n?void 0:n.getContext("2d");s&&(s.strokeStyle="#0d2b35",s.lineWidth=2,s.lineCap="round",s.beginPath(),s.moveTo(e[0],e[1]),s.lineTo(t[0],t[1]),s.stroke())})(n,s)},onPointerUp:()=>{H.current=!1},onPointerLeave:()=>{H.current=!1}}),(0,p.jsx)("button",{type:"button",onClick:()=>{var e;I.current=[];const t=U.current;null===t||void 0===t||null===(e=t.getContext("2d"))||void 0===e||e.clearRect(0,0,t.width,t.height)},className:"mt-1 text-xs text-ink-subtle underline underline-offset-2",children:P("consentSign.clear")})]}),(0,p.jsxs)("label",{className:"flex items-start gap-2 text-sm text-ink",children:[(0,p.jsx)("input",{type:"checkbox",checked:S,onChange:e=>w(e.target.checked),className:"mt-0.5 h-5 w-5 shrink-0 accent-accent"}),P("consentSign.agree")]}),x&&(0,p.jsx)("p",{role:"alert",className:"rounded-xl border border-danger/30 bg-danger-soft px-3 py-2 text-sm text-danger",children:x}),(0,p.jsx)("button",{type:"submit",disabled:q||!S||!k.trim(),className:"w-full rounded-xl bg-accent px-4 py-3 text-base font-semibold text-white hover:bg-accent-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:P(q?"consentSign.signing":"consentSign.sign")}),(0,p.jsx)("p",{className:"text-xs text-ink-subtle",children:P("consentSign.copyNote")})]})]})})}const W=r.A.getFixedT("en","practice");class U extends s.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error("[PublicRouteBoundary] a patient-facing page failed to render:",e,t.componentStack)}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}render(){if(!this.state.hasError)return this.props.children;const e=this.props.practiceName;return(0,p.jsx)(C,{title:W("publicError.title"),children:(0,p.jsxs)("div",{className:"rounded-2xl border border-line bg-surface p-4 space-y-3",children:[(0,p.jsx)("p",{className:"text-lg font-semibold text-ink",children:W("publicError.title")}),(0,p.jsx)("p",{className:"text-sm text-ink-muted",children:e?W("publicError.bodyWithPractice",{practice:e}):W("publicError.body")})]})})}}function I(e){let t=e.children;const n=(0,a.zy)();return(0,p.jsx)(U,{resetKey:n.pathname,practiceName:u,children:null!==t&&void 0!==t?t:(0,p.jsx)(a.sv,{})})}function H(){return(0,p.jsx)(a.BV,{children:(0,p.jsxs)(a.qh,{element:(0,p.jsx)(I,{}),children:[(0,p.jsx)(a.qh,{path:"manage/:token",element:(0,p.jsx)(E,{})}),(0,p.jsx)(a.qh,{path:"consent/:token",element:(0,p.jsx)(R,{})}),(0,p.jsx)(a.qh,{path:":slug",element:(0,p.jsx)(S,{})})]})})}}}]);
2//# sourceMappingURL=112.72fa6ce2.chunk.js.map

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.