(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[914],{5763:function(e,t,a){"use strict";var s=a(5893);a(7294);var n=a(5346),l=a(3824),i=a.n(l);t.Z=e=>{let{appointment_id:t,onClose:a,appointmentStart:l,appointmentEnd:r}=e,o=e=>e.toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",c=e=>e.toISOString().split(".")[0]+"Z",d=l?o(new Date(l)):"20240101T120000Z",m=r?o(new Date(r)):"20240101T130000Z",u=l?c(new Date(l)):"2024-01-01T12:00:00Z",p=r?c(new Date(r)):"2024-01-01T13:00:00Z",h="BEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nDTSTART:".concat(d,"\nDTEND:").concat(m,"\nSUMMARY:Doctor Appointment\nEND:VEVENT\nEND:VCALENDAR"),v="https://calendar.google.com/calendar/render?action=TEMPLATE&text=Doctor%20Appointment&dates=".concat(d,"/").concat(m),_="https://outlook.office.com/calendar/0/deeplink/compose?subject=Doctor%20Appointment&startdt=".concat(u,"&enddt=").concat(p);return(0,s.jsx)("div",{className:i()["appointment-booked-modal-overlay"],children:(0,s.jsxs)("div",{className:i()["appointment-booked-modal-content"],children:[(0,s.jsx)("h2",{children:"Appointment Booked Successful"}),(0,s.jsx)("p",{children:"Your appointment has been successfully booked"}),(0,s.jsxs)("h4",{children:[(0,s.jsx)(n.IiJ,{})," You can add this appointment in your calendar for reminders by selecting one of your calendars below"]}),(0,s.jsxs)("div",{className:i()["appointment-calendar-buttons"],children:[(0,s.jsxs)("a",{className:i()["appointment-booked-link"],href:"data:text/calendar;charset=utf-8,".concat(h),download:"appointment.ics",children:[(0,s.jsx)(n.oPZ,{})," Add to iCal"]}),(0,s.jsxs)("a",{className:i()["appointment-booked-link"],href:_,target:"_blank",rel:"noopener noreferrer",children:[(0,s.jsx)(n.oV6,{})," Add to Microsoft Calendar"]}),(0,s.jsxs)("a",{className:i()["appointment-booked-link"],href:v,target:"_blank",rel:"noopener noreferrer",children:[(0,s.jsx)(n.ldW,{})," Add to Google Calendar"]})]}),(0,s.jsx)("button",{className:i()["appointment-booked-modal-button"],onClick:a,children:"Close"})]})})}},2984:function(e,t,a){"use strict";var s=a(5893),n=a(7294),l=a(4853),i=a(6256),r=a(3838);t.Z=e=>{var t,a;let{isOpen:o,onClose:c,doctorId:d,doctorName:m}=e,[u,p]=(0,n.useState)(""),[h,v]=(0,n.useState)(""),[_,x]=(0,n.useState)(""),[g,b]=(0,n.useState)(""),[f,y]=(0,n.useState)(""),[j,N]=(0,n.useState)(""),[k,S]=(0,n.useState)(null),[w,D]=(0,n.useState)(!1),[C,E]=(0,n.useState)(null),[P,T]=(0,n.useState)(!1),M=(0,n.useRef)(null),I=async e=>{var t,a,s;if(e.preventDefault(),!P){S("Please accept the disclaimer to continue.");return}if(!C){S("Please complete the reCAPTCHA verification.");return}D(!0),S(null);try{let e=await fetch("".concat(r.sN,"/doctors/").concat(d,"/request-appointment/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({full_name:u,email:h,phone:_,date:F(g),time:L(f),reason:j,recaptcha_token:C})}),s=await e.json();s.status?(S("Appointment request sent successfully! The doctor will contact you soon."),p(""),v(""),x(""),b(""),y(""),N(""),E(null),null===(t=M.current)||void 0===t||t.reset(),setTimeout(()=>c(),2500)):(S(s.message||"Failed to send appointment request."),null===(a=M.current)||void 0===a||a.reset(),E(null))}catch(e){S("Error sending appointment request."),null===(s=M.current)||void 0===s||s.reset(),E(null)}finally{D(!1)}},F=e=>{if(!e)return"";let[t,a,s]=e.split("-");return"".concat(s,"/").concat(a,"/").concat(t)},L=e=>{if(!e)return"";let[t,a]=e.split(":");t=parseInt(t);let s="AM";return 0===t?t=12:12===t?s="PM":t>12&&(t-=12,s="PM"),"".concat(t.toString().padStart(2,"0"),":").concat(a," ").concat(s)},A=(null==m?void 0:null===(a=m.trim())||void 0===a?void 0:null===(t=a.charAt(0))||void 0===t?void 0:t.toUpperCase())||"D";return o?(0,s.jsx)("div",{className:"vt-modal-backdrop",children:(0,s.jsxs)("div",{className:"vt-modal",children:[(0,s.jsx)("button",{type:"button",className:"vt-close-btn",onClick:()=>{var e;S(null),p(""),v(""),x(""),b(""),y(""),N(""),E(null),T(!1),D(!1),null===(e=M.current)||void 0===e||e.reset(),c()},"aria-label":"Close modal",children:"\xd7"}),(0,s.jsxs)("div",{className:"vt-modal-shell",children:[(0,s.jsx)("div",{className:"vt-modal-topbar",children:(0,s.jsx)("div",{className:"vt-topbar-badge",children:"Secure Request"})}),(0,s.jsx)("div",{className:"vt-modal-hero",children:(0,s.jsxs)("div",{className:"vt-modal-hero-copy",children:[(0,s.jsx)("h2",{children:"Request Appointment"}),(0,s.jsxs)("p",{children:["Send an appointment request to"," ",(0,s.jsx)("strong",{children:m||"this practitioner"}),". Once your details are reviewed, you’ll be contacted when availability is confirmed."]})]})}),(0,s.jsxs)("div",{className:"vt-doctor-summary-card",children:[(0,s.jsx)("div",{className:"vt-doctor-summary-avatar",children:A}),(0,s.jsxs)("div",{className:"vt-doctor-summary-content",children:[(0,s.jsx)("div",{className:"vt-doctor-summary-label",children:"Practitioner"}),(0,s.jsx)("div",{className:"vt-doctor-summary-name",children:m||"Verified Practitioner"}),(0,s.jsx)("div",{className:"vt-doctor-summary-meta",children:"Secure booking request • Verified platform flow"})]})]}),(0,s.jsxs)("form",{onSubmit:I,className:"vt-form",children:[(0,s.jsxs)("div",{className:"vt-form-section",children:[(0,s.jsxs)("div",{className:"vt-section-header",children:[(0,s.jsx)("h3",{children:"Your Details"}),(0,s.jsx)("p",{children:"Please provide your basic contact information."})]}),(0,s.jsxs)("div",{className:"vt-field",children:[(0,s.jsx)("label",{htmlFor:"vt-patient-name",children:"Full Name"}),(0,s.jsx)("input",{id:"vt-patient-name",type:"text",placeholder:"Enter your full name",value:u,onChange:e=>p(e.target.value),required:!0,disabled:w})]}),(0,s.jsxs)("div",{className:"vt-grid-2",children:[(0,s.jsxs)("div",{className:"vt-field",children:[(0,s.jsx)("label",{htmlFor:"vt-phone",children:"Phone"}),(0,s.jsx)("input",{id:"vt-phone",type:"tel",placeholder:"Enter your phone number",value:_,onChange:e=>x(e.target.value),required:!0,disabled:w})]}),(0,s.jsxs)("div",{className:"vt-field",children:[(0,s.jsx)("label",{htmlFor:"vt-email",children:"Email"}),(0,s.jsx)("input",{id:"vt-email",type:"email",placeholder:"Enter your email address",value:h,onChange:e=>v(e.target.value),required:!0,disabled:w})]})]})]}),(0,s.jsxs)("div",{className:"vt-form-section",children:[(0,s.jsxs)("div",{className:"vt-section-header",children:[(0,s.jsx)("h3",{children:"Appointment Preferences"}),(0,s.jsx)("p",{children:"Choose your preferred date and time."})]}),(0,s.jsxs)("div",{className:"vt-grid-2",children:[(0,s.jsxs)("div",{className:"vt-field",children:[(0,s.jsx)("label",{htmlFor:"vt-date",children:"Preferred Date"}),(0,s.jsx)("input",{type:"date",value:g,onChange:e=>{b(e.target.value)},required:!0,disabled:w})]}),(0,s.jsxs)("div",{className:"vt-field",children:[(0,s.jsx)("label",{htmlFor:"vt-time",children:"Preferred Time"}),(0,s.jsx)("input",{type:"time",value:f,onChange:e=>{y(e.target.value)},required:!0,disabled:w})]})]})]}),(0,s.jsxs)("div",{className:"vt-form-section",children:[(0,s.jsx)("div",{className:"vt-section-header",children:(0,s.jsx)("h3",{children:"Reason for Appointment"})}),(0,s.jsx)("div",{className:"vt-field",children:(0,s.jsx)("textarea",{id:"vt-reason",placeholder:"Briefly describe the reason for your appointment",value:j,onChange:e=>N(e.target.value),required:!0,disabled:w})})]}),(0,s.jsxs)("div",{className:"vt-form-section vt-form-section-soft",children:[(0,s.jsxs)("div",{className:"vt-disclaimer",children:[(0,s.jsx)("input",{id:"vt-disclaimer",type:"checkbox",checked:P,onChange:e=>T(e.target.checked),disabled:w}),(0,s.jsxs)("label",{htmlFor:"vt-disclaimer",children:[(0,s.jsx)("strong",{children:"Disclaimer:"})," Virtual Triage connects patients with licensed doctors. We do not provide medical advice directly."]})]}),i.K.SITE_KEY&&(0,s.jsx)("div",{className:"vt-captcha",children:(0,s.jsx)(l.Z,{ref:M,sitekey:i.K.SITE_KEY,onChange:e=>E(e)})})]}),(0,s.jsxs)("div",{className:"vt-submit-area",children:[(0,s.jsx)("button",{type:"submit",className:"vt-submit",disabled:w||!C||!P,children:w?"Submitting...":"Request Appointment"}),(0,s.jsx)("p",{className:"vt-submit-note",children:"Secure request • Sent directly through Virtual Triage"})]})]}),k&&(0,s.jsx)("div",{className:"vt-status ".concat(k.includes("success")?"success":"error"),children:k})]})]})}):null}},2917:function(e,t,a){"use strict";a.d(t,{Z:function(){return b}});var s=a(5893),n=a(7294),l=a(3838),i=a(5763),r=a(5346),o=a(6664),c=a(3109);let d=null,m=null,u=async()=>{if(!m){let[e,t]=await Promise.all([a.e(2859).then(a.bind(a,2859)),Promise.resolve().then(a.t.bind(a,6664,23))]);d||(d=e.loadStripe("pk_live_51MkDNUKx0rXRL6v7CPCCeukNvoyvRBJJC8igLsmC1wR3BN4qx9BrAZ6VnZiy7Hqg0E3m4jg0esk8qFejT5HMRN3h00CCt4iMlG")),m={Elements:t.Elements,CardElement:t.CardElement,useStripe:t.useStripe,useElements:t.useElements}}return{stripePromise:d,...m}},p={style:{base:{fontSize:"15px",color:"#1a1f36",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:"400","::placeholder":{color:"#a0aec0"},iconColor:"#6b7c93"},invalid:{color:"#e53e3e",iconColor:"#e53e3e"}},hidePostalCode:!1},h=()=>(0,s.jsx)("svg",{viewBox:"0 0 60 25",className:"spm-stripe-svg",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("path",{d:"M59.64 14.28h-8.06c.19 1.93 1.6 2.55 3.2 2.55 1.64 0 2.96-.37 4.05-.95v3.32a8.33 8.33 0 0 1-4.56 1.1c-4.01 0-6.83-2.5-6.83-7.48 0-4.19 2.39-7.52 6.3-7.52 3.92 0 5.96 3.28 5.96 7.5 0 .4-.04 1.26-.06 1.48zm-5.92-5.62c-1.03 0-2.17.73-2.17 2.58h4.25c0-1.85-1.07-2.58-2.08-2.58zM40.95 20.3c-1.44 0-2.32-.6-2.9-1.04l-.02 4.63-4.12.87V5.57h3.76l.08 1.02a4.7 4.7 0 0 1 3.23-1.29c2.9 0 5.62 2.6 5.62 7.4 0 5.23-2.7 7.6-5.65 7.6zM40 8.95c-.95 0-1.54.34-1.97.81l.02 6.12c.4.44.98.78 1.95.78 1.52 0 2.54-1.65 2.54-3.87 0-2.15-1.04-3.84-2.54-3.84zM28.24 5.57h4.13v14.44h-4.13V5.57zm0-4.7L32.37 0v3.36l-4.13.88V.88zm-4.32 9.35v9.79H19.8V5.57h3.7l.12 1.22c1-1.77 3.07-1.41 3.62-1.22v3.79c-.52-.19-2.7-.55-3.32.87zm-8.55 4.72c0 2.43 2.6 1.68 3.12 1.46v3.36c-.55.3-1.54.54-2.89.54a4.15 4.15 0 0 1-4.27-4.24l.01-13.17 4.02-.86v3.54h3.14V9.1h-3.13v5.85zm-4.91.7c0 2.97-2.31 4.66-5.73 4.66a11.2 11.2 0 0 1-4.46-.93v-3.93c1.38.75 3.1 1.31 4.46 1.31.92 0 1.53-.24 1.53-1C6.26 13.77 0 14.51 0 9.95 0 7.04 2.28 5.3 5.62 5.3c1.36 0 2.72.2 4.09.75v3.92C8.36 9.23 6.8 8.69 5.62 8.69c-.88 0-1.4.38-1.4.98 0 1.84 6.2.95 6.2 6.17z",fill:"#635BFF"})}),v=e=>{let{appointmentData:t,onSuccess:a,onClose:i,StripeHooks:d,embedded:m=!1}=e,u=d.useStripe(),v=d.useElements(),[_,x]=(0,n.useState)(!1),[g,b]=(0,n.useState)(null),[f,y]=(0,n.useState)(!1),[j,N]=(0,n.useState)(""),[k,S]=(0,n.useState)(""),[w,D]=(0,n.useState)(!0),[C,E]=(0,n.useState)([]),[P,T]=(0,n.useState)(!1),[M,I]=(0,n.useState)(null),[F,L]=(0,n.useState)(!1),[A,Z]=(0,n.useState)(15),[B,O]=(0,n.useState)(""),[q,V]=(0,n.useState)(!1),[H,R]=(0,n.useState)(!1),[z,Y]=(0,n.useState)(null),[W,J]=(0,n.useState)(null),[U,K]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{try{let e=localStorage.getItem("savedPaymentMethods");e&&E(JSON.parse(e))}catch(e){console.error("Error fetching saved payment methods:",e)}})()},[]),(0,n.useEffect)(()=>{if(!f)return;Z(15);let e=setInterval(()=>{Z(t=>t<=1?(clearInterval(e),i(),0):t-1)},1e3);return()=>clearInterval(e)},[f]);let G=()=>"initial"===t.appointmentType,X=()=>{var e,a;return G()?(null===(a=t.scheduleData)||void 0===a?void 0:a.initial_appointment_fee)||t.amount:null===(e=t.scheduleData)||void 0===e?void 0:e.follow_up_appointment_fee},$=()=>G()?"Initial Consultation":"Follow-up Consultation",Q=async()=>{var e,a,s,n,i,r;let o=B.trim();if(!o){Y("Please enter a promo code");return}V(!0),Y(null),R(!1),J(null);try{let s=parseFloat(X()),n=await l.ZP.post("/stripe/promo-validator/",{amount:s,promo_code:o},{headers:{Authorization:"Bearer ".concat(t.token)}});if(200===n.status&&(null===(e=n.data)||void 0===e?void 0:e.status)===!0)R(!0),J({promo_code:n.data.promo_code,discount:n.data.discount,final_amount:n.data.final_amount,currency:n.data.currency}),Y(null),c.Z.trackPromoCodeApplied(o,n.data.discount);else throw Error((null===(a=n.data)||void 0===a?void 0:a.message)||"Invalid promo code")}catch(e){R(!1),J(null),Y((null===(n=e.response)||void 0===n?void 0:null===(s=n.data)||void 0===s?void 0:s.message)||(null===(r=e.response)||void 0===r?void 0:null===(i=r.data)||void 0===i?void 0:i.error)||e.message||"Invalid promo code. Please try again.")}finally{V(!1)}},ee=()=>H&&(null==W?void 0:W.final_amount)!==void 0?parseFloat(W.final_amount):parseFloat(X()),et=async e=>{var s,n,i,r,d,m,p;e.preventDefault(),x(!0),b(null),y(!1);try{let e;if(!u||!v)throw Error("Payment system not available. Please refresh and try again.");if(P&&M)e=M;else{let{error:t,paymentMethod:a}=await u.createPaymentMethod({type:"card",card:v.getElement(o.CardElement)});if(t)throw Error(t.message);e=a}let c=B.trim(),p=ee(),h={doctor_id:t.doctor_id||t.Health_Professional_id,appointment_fee:p,appointment_type:$(),date:t.date||t.appointmentDate||t.selectedDate,time:t.time,amount:Math.round(parseFloat(p)),payment_method_id:e.id,schedule_id:null===(s=t.scheduleData)||void 0===s?void 0:s.Schecule_id,duration:null===(n=t.scheduleData)||void 0===n?void 0:n.Appointment_Duration,currency:H&&(null==W?void 0:W.currency)?W.currency:(null===(i=t.scheduleData)||void 0===i?void 0:i.Currency)&&(null===(r=t.scheduleData)||void 0===r?void 0:r.Currency)!==""&&(null===(d=t.scheduleData)||void 0===d?void 0:d.Currency)!=="\xa3"?null===(m=t.scheduleData)||void 0===m?void 0:m.Currency:"gbp",package_info:t.package_info,customer_name:j,customer_email:k,save_payment_method:w,promo_applied:!!H&&!!c,...c&&H?{promo_code:c}:{},gender:t.gender,full_name:t.full_name,age:t.age,weight:t.weight,email:t.email,mobile_number:t.mobile_number,preappointmentdetail_id:t.preappointmentdetail_id,body_chart_image:t.body_chart_image,patient_address:t.patient_address,pre_appointment_details:JSON.stringify(t.pre_appointment_details||[]),body_points:JSON.stringify(t.body_points||[]),page_url:t.page_url},_=await l.ZP.post("/stripe-connect/payment-processing/",h,{headers:{Authorization:"Bearer ".concat(t.token)}});if(200===_.status&&!0===_.data.requires_action){let{error:t,paymentIntent:s}=await u.confirmCardPayment(_.data.client_secret);if(t)throw Error(t.message||"3D Secure authentication failed. Please try again.");if("succeeded"!==s.status)throw Error("Payment was not completed after authentication. Please try again.");y(!0),w&&es(e);let n={success:!0,message:"Payment confirmed after 3D Secure authentication",data:{..._.data,paymentIntent:s},payment_method_id:e.id,paymentIntentId:s.id};setTimeout(()=>a(n),2500)}else if(200===_.status&&!0===_.data.status){y(!0),w&&es(e);let t={success:!0,message:_.data.message||"Payment successful",data:_.data,payment_method_id:e.id,payment_intent_id:_.data.payment_intent_id||null};setTimeout(()=>a(t),2500)}else throw Error(_.data.error||_.data.message||"Payment failed")}catch(e){if(console.error("Payment error:",e),null===(p=e.response)||void 0===p?void 0:p.data){let t=e.response.data,a=t.error||t.message||"Payment failed. Please try again.";if((a.includes("No such PaymentMethod")||a.includes("PaymentMethod"))&&(a="The payment method is invalid or expired. Please enter a new card and try again.",P&&M))try{let e=JSON.parse(localStorage.getItem("savedPaymentMethods")||"[]").filter(e=>e.id!==M.id);localStorage.setItem("savedPaymentMethods",JSON.stringify(e)),E(e),T(!1),I(null)}catch(e){console.error("Error removing invalid payment method:",e)}b(a),c.Z.trackPaymentFailed(a)}else{let t=e.message||"Payment failed. Please try again.";b(t),c.Z.trackPaymentFailed(t)}x(!1)}},ea=()=>{_||i()},es=e=>{try{let t=JSON.parse(localStorage.getItem("savedPaymentMethods")||"[]"),a={id:e.id,card:{brand:e.card.brand,last4:e.card.last4,exp_month:e.card.exp_month,exp_year:e.card.exp_year},customer_email:k,saved_at:new Date().toISOString()};t.find(t=>t.id===e.id)||(t.push(a),localStorage.setItem("savedPaymentMethods",JSON.stringify(t)),E(t))}catch(e){console.error("Error saving payment method:",e)}},en=(()=>{var e;let a=null===(e=t.scheduleData)||void 0===e?void 0:e.Currency;return a&&""!==a&&"\xa3"!==a&&"gbp"!==a?"usd"===a||"$"===a?"$":"eur"===a||"€"===a?"€":"\xa3":"\xa3"})(),el=parseFloat(X()),ei=ee(),er=H&&W&&ei<el;if(f){let e=(0,s.jsx)("div",{className:"spm-modal spm-modal--success".concat(m?" spm-modal--embedded":""),onClick:m?void 0:e=>e.stopPropagation(),children:(0,s.jsxs)("div",{className:"spm-success",children:[(0,s.jsx)("div",{className:"spm-success__icon",children:(0,s.jsx)(r.FJM,{})}),(0,s.jsx)("h2",{className:"spm-success__title",children:"Payment Confirmed"}),(0,s.jsx)("p",{className:"spm-success__subtitle",children:"Your appointment has been booked successfully."}),(0,s.jsxs)("div",{className:"spm-success__card",children:[(0,s.jsxs)("div",{className:"spm-success__row",children:[(0,s.jsx)("span",{children:"Service"}),(0,s.jsx)("span",{children:$()})]}),(0,s.jsxs)("div",{className:"spm-success__row",children:[(0,s.jsx)("span",{children:"Amount charged"}),(0,s.jsxs)("span",{className:"spm-success__amount",children:[en,ei.toFixed(2)]})]}),er&&(0,s.jsxs)("div",{className:"spm-success__row spm-success__row--discount",children:[(0,s.jsx)("span",{children:"Discount applied"}),(0,s.jsxs)("span",{children:["- ",en,(el-ei).toFixed(2)]})]})]}),(0,s.jsx)("p",{className:"spm-success__note",children:"A receipt will be sent to your email."}),(0,s.jsxs)("div",{className:"spm-success__countdown",children:[(0,s.jsxs)("svg",{className:"spm-countdown-ring",viewBox:"0 0 36 36",children:[(0,s.jsx)("circle",{className:"spm-countdown-ring__bg",cx:"18",cy:"18",r:"15.5"}),(0,s.jsx)("circle",{className:"spm-countdown-ring__fill",cx:"18",cy:"18",r:"15.5",strokeDasharray:"97.4",strokeDashoffset:97.4*(1-A/15)})]}),(0,s.jsx)("span",{className:"spm-countdown-num",children:A})]}),(0,s.jsxs)("p",{className:"spm-success__closing-note",children:["Closing automatically in ",(0,s.jsxs)("strong",{children:[A,"s"]})]})]})});return m?e:(0,s.jsx)("div",{className:"spm-overlay",onClick:ea,children:e})}let eo=(0,s.jsxs)("div",{className:"spm-modal".concat(m?" spm-modal--embedded":""),onClick:m?void 0:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"spm-left",children:[(0,s.jsxs)("button",{className:"spm-summary-toggle",onClick:()=>L(e=>!e),"aria-expanded":F,children:[(0,s.jsxs)("span",{className:"spm-summary-toggle__label",children:[(0,s.jsx)(r.ypE,{className:"spm-summary-toggle__icon"}),"Order summary"]}),(0,s.jsxs)("span",{className:"spm-summary-toggle__amount",children:[en,ei.toFixed(2)]}),F?(0,s.jsx)(r.s$2,{className:"spm-summary-toggle__chevron"}):(0,s.jsx)(r.RiI,{className:"spm-summary-toggle__chevron"})]}),(0,s.jsxs)("div",{className:"spm-left__body".concat(F?" spm-left__body--open":""),children:[(0,s.jsxs)("div",{className:"spm-business",children:[(0,s.jsx)("div",{className:"spm-business__avatar",children:(0,s.jsx)(r.ypE,{})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"spm-business__name",children:"Virtual Triage"}),(0,s.jsx)("p",{className:"spm-business__tagline",children:"Appointment Booking"})]})]}),(0,s.jsxs)("div",{className:"spm-line-items",children:[(0,s.jsxs)("div",{className:"spm-line-item",children:[(0,s.jsx)("span",{className:"spm-line-item__label",children:$()}),er?(0,s.jsxs)("span",{className:"spm-line-item__original",children:[en,el.toFixed(2)]}):(0,s.jsxs)("span",{className:"spm-line-item__value",children:[en,el.toFixed(2)]})]}),er&&(0,s.jsxs)("div",{className:"spm-line-item spm-line-item--discount",children:[(0,s.jsxs)("span",{className:"spm-line-item__label",children:[(0,s.jsx)(r.fxx,{className:"spm-tag-icon"}),'Promo "',W.promo_code,'"']}),(0,s.jsxs)("span",{className:"spm-line-item__discount",children:["- ",en,(el-ei).toFixed(2)]})]}),(0,s.jsx)("div",{className:"spm-divider"}),(0,s.jsxs)("div",{className:"spm-line-item spm-line-item--total",children:[(0,s.jsx)("span",{className:"spm-line-item__label",children:"Total due today"}),(0,s.jsxs)("span",{className:"spm-line-item__total",children:[en,ei.toFixed(2)]})]})]}),(0,s.jsxs)("div",{className:"spm-refund",children:[(0,s.jsxs)("div",{className:"spm-refund__header",children:[(0,s.jsx)(r.bri,{className:"spm-refund__icon"}),(0,s.jsx)("span",{className:"spm-refund__title",children:"Full Refund Guarantee"})]}),(0,s.jsxs)("p",{className:"spm-refund__text",children:["You're fully protected. If you have a valid reason — such as a cancellation, technical issue, or unavailability of your practitioner — you will receive a ",(0,s.jsx)("strong",{children:"100% refund"})," with no questions asked, processed within 5–10 business days."]}),(0,s.jsx)("a",{href:"/appointment-terms",target:"_blank",rel:"noopener noreferrer",className:"spm-refund__link",children:"Read our refund terms →"})]}),(0,s.jsxs)("div",{className:"spm-secure-note",children:[(0,s.jsx)(r.kUi,{className:"spm-secure-note__icon"}),(0,s.jsx)("span",{children:"256-bit SSL encrypted & PCI DSS compliant"})]})]})]}),(0,s.jsxs)("div",{className:"spm-right",children:[!m&&(0,s.jsx)("button",{className:"spm-close",onClick:ea,disabled:_,"aria-label":"Close",children:(0,s.jsx)(r.aHS,{})}),(0,s.jsx)("h2",{className:"spm-right__title",children:"Pay with card"}),(0,s.jsx)("p",{className:"spm-right__subtitle",children:"Complete your payment securely below"}),(0,s.jsxs)("form",{className:"spm-form",onSubmit:et,children:[C.length>0&&(0,s.jsxs)("div",{className:"spm-saved",children:[(0,s.jsxs)("p",{className:"spm-label",children:[(0,s.jsx)(r.ceS,{className:"spm-label__icon"}),"Saved cards"]}),(0,s.jsx)("div",{className:"spm-saved__list",children:C.map(e=>(0,s.jsxs)("div",{className:"spm-saved__item".concat((null==M?void 0:M.id)===e.id?" spm-saved__item--selected":""),onClick:()=>{I(e),T(!0)},role:"button",tabIndex:0,children:[(0,s.jsx)(r.ypE,{className:"spm-saved__card-icon"}),(0,s.jsxs)("div",{className:"spm-saved__card-info",children:[(0,s.jsx)("span",{className:"spm-saved__brand",children:e.card.brand}),(0,s.jsxs)("span",{className:"spm-saved__digits",children:["•••• ",e.card.last4]}),(0,s.jsxs)("span",{className:"spm-saved__expiry",children:["Exp ",e.card.exp_month,"/",e.card.exp_year]})]}),(0,s.jsx)("div",{className:"spm-saved__radio",children:(0,s.jsx)("div",{className:"spm-radio".concat((null==M?void 0:M.id)===e.id?" spm-radio--checked":"")})})]},e.id))}),P&&(0,s.jsx)("button",{type:"button",className:"spm-link-btn",onClick:()=>{T(!1),I(null)},children:"+ Use a different card"})]}),(0,s.jsxs)("div",{className:"spm-field-group",children:[(0,s.jsxs)("div",{className:"spm-field",children:[(0,s.jsx)("label",{className:"spm-label",htmlFor:"spm-name",children:"Full name"}),(0,s.jsx)("input",{id:"spm-name",className:"spm-input",type:"text",value:j,onChange:e=>N(e.target.value),placeholder:"Jane Smith",required:!0,autoComplete:"name"})]}),(0,s.jsxs)("div",{className:"spm-field",children:[(0,s.jsx)("label",{className:"spm-label",htmlFor:"spm-email",children:"Email address"}),(0,s.jsx)("input",{id:"spm-email",className:"spm-input",type:"email",value:k,onChange:e=>S(e.target.value),placeholder:"jane@example.com",required:!0,autoComplete:"email"})]})]}),!P&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"spm-field",children:[(0,s.jsx)("label",{className:"spm-label",children:"Card information"}),(0,s.jsxs)("div",{className:"spm-card-element",children:[(0,s.jsx)(o.CardElement,{options:p}),(0,s.jsxs)("div",{className:"spm-card-brands",children:[(0,s.jsx)("span",{className:"spm-brand-badge spm-brand-badge--visa",children:"VISA"}),(0,s.jsx)("span",{className:"spm-brand-badge spm-brand-badge--mc",children:"MC"}),(0,s.jsx)("span",{className:"spm-brand-badge spm-brand-badge--amex",children:"AMEX"})]})]})]}),(0,s.jsxs)("label",{className:"spm-checkbox",children:[(0,s.jsx)("input",{type:"checkbox",checked:w,onChange:e=>D(e.target.checked)}),(0,s.jsx)("span",{className:"spm-checkbox__box"}),(0,s.jsxs)("span",{className:"spm-checkbox__label",children:[(0,s.jsx)(r.TvB,{className:"spm-checkbox__icon"}),"Save card for future appointments"]})]})]}),(0,s.jsxs)("div",{className:"spm-promo",children:[(0,s.jsxs)("button",{type:"button",className:"spm-link-btn spm-promo__toggle",onClick:()=>K(e=>!e),children:[(0,s.jsx)(r.fxx,{className:"spm-tag-icon"}),U?"Hide promo code":"Add promo code"]}),U&&(0,s.jsxs)("div",{className:"spm-promo__row",children:[(0,s.jsx)("input",{className:"spm-input spm-promo__input".concat(H?" spm-input--valid":"").concat(z?" spm-input--error":""),type:"text",value:B,onChange:e=>{O(e.target.value),(H||z)&&(R(!1),Y(null),J(null))},placeholder:"PROMO2024",autoComplete:"off",disabled:_||q}),(0,s.jsx)("button",{type:"button",className:"spm-promo__apply",onClick:Q,disabled:_||q||!B.trim(),children:q?(0,s.jsx)("span",{className:"spm-spinner"}):"Apply"}),B.trim()&&(0,s.jsx)("button",{type:"button",className:"spm-promo__clear",onClick:()=>{O(""),R(!1),Y(null),J(null)},disabled:_||q,children:"✕"})]}),H&&W&&(0,s.jsxs)("div",{className:"spm-alert spm-alert--success",children:[(0,s.jsx)(r.FJM,{}),"Promo ",(0,s.jsxs)("strong",{children:['"',W.promo_code,'"']})," applied —\xa0 you save ",en,(el-ei).toFixed(2),"!"]}),z&&(0,s.jsxs)("div",{className:"spm-alert spm-alert--error",children:[(0,s.jsx)(r.a4m,{}),z]})]}),g&&(0,s.jsxs)("div",{className:"spm-alert spm-alert--error spm-alert--lg",children:[(0,s.jsx)(r.a4m,{}),g]}),(0,s.jsx)("button",{type:"submit",className:"spm-pay-btn",disabled:!u||_||!P&&(!j||!k),children:_?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"spm-spinner spm-spinner--white"}),"Processing…"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.kUi,{className:"spm-pay-btn__lock"}),"Pay ",en,ei.toFixed(2)]})}),(0,s.jsxs)("div",{className:"spm-footer",children:[(0,s.jsxs)("div",{className:"spm-footer__powered",children:[(0,s.jsx)(r.kUi,{className:"spm-footer__lock"}),(0,s.jsx)("span",{children:"Secured by"}),(0,s.jsx)(h,{})]}),(0,s.jsxs)("div",{className:"spm-footer__links",children:[(0,s.jsx)("a",{href:"/terms-and-conditions",target:"_blank",rel:"noopener noreferrer",children:"Terms"}),(0,s.jsx)("span",{className:"spm-footer__sep",children:"\xb7"}),(0,s.jsx)("a",{href:"/privacy-notice",target:"_blank",rel:"noopener noreferrer",children:"Privacy"}),(0,s.jsx)("span",{className:"spm-footer__sep",children:"\xb7"}),(0,s.jsx)("a",{href:"/appointment-terms",target:"_blank",rel:"noopener noreferrer",children:"Refund Policy"})]})]})]})]})]});return m?eo:(0,s.jsx)("div",{className:"spm-overlay",onClick:ea,children:eo})};var _=e=>{let{appointmentData:t,onSuccess:a,onClose:l,isOpen:i,embedded:r=!1}=e,[o,c]=n.useState(null),[d,m]=n.useState(!0);if((0,n.useEffect)(()=>{i&&!o?u().then(e=>{c(e),m(!1)}):i||(c(null),m(!0))},[i,o]),!i)return null;if(d||!o){let e=(0,s.jsx)("div",{className:"spm-modal spm-modal--loading".concat(r?" spm-modal--embedded":""),children:(0,s.jsxs)("div",{className:"spm-loading",children:[(0,s.jsx)("span",{className:"spm-spinner spm-spinner--dark"}),(0,s.jsx)("p",{children:"Loading secure payment…"})]})});return r?e:(0,s.jsx)("div",{className:"spm-overlay",children:e})}let{Elements:p,stripePromise:h}=o;return(0,s.jsx)(p,{stripe:h,children:(0,s.jsx)(v,{StripeHooks:o,appointmentData:t,onSuccess:a,onClose:l,embedded:r})})},x=a(9451),g=a.n(x),b=e=>{var t,a,r,o;let{practitioner:d,selectedSlot:m,selectedDate:u,onClose:p,appointmentType:h,appointmentFee:v,onAppointmentBooked:x,scheduleData:b}=e,[f,y]=(0,n.useState)({fullName:"",email:"",phone:"",age:"",gender:"",weight:"",bodyPoints:[],preappointmentdetail_id:"",pre_appointment_details:[],body_chart_image:"",date:"",time:"",patient_address:""}),j=(0,n.useRef)(null);(0,n.useRef)(null);let N=(0,n.useRef)(null),[k,S]=(0,n.useState)(!1),[w,D]=(0,n.useState)(!1),[C,E]=(0,n.useState)(null),[P,T]=(0,n.useState)(!1),[M,I]=(0,n.useState)({insurancebooking_Id:"",insuarance_number:"",insurance_company_name:"",membership_number:"",reference_number:"",group_number:"",coverage_type:"",date_of_issue:"",date_of_expiry:"",preauth_number:""}),[F,L]=(0,n.useState)({}),[A,Z]=(0,n.useState)(()=>localStorage.getItem("authToken")),[B,O]=(0,n.useState)(h||"initial"),q="initial"===B?null!==(t=null==b?void 0:b.initial_appointment_fee)&&void 0!==t?t:v:null!==(a=null==b?void 0:b.follow_up_appointment_fee)&&void 0!==a?a:v,[V,H]=(0,n.useState)(!1),[R,z]=(0,n.useState)(!0),[Y,W]=(0,n.useState)(!1),[J,U]=(0,n.useState)(null),K=e=>{F[e]&&L(t=>{let a={...t};return delete a[e],a})};if((0,n.useEffect)(()=>{y(e=>({...e,date:u,time:m}))},[u,m]),(0,n.useEffect)(()=>{(null==d?void 0:d.Health_Professional_Id)&&(async()=>{try{let e=await l.ZP.get("/patient/charting/get-charting-details/?doctor_id=".concat(d.Health_Professional_Id));200===e.status&&e.data.status&&y(t=>({...t,preappointmentdetail_id:e.data.data.id,body_chart_image:e.data.data.body_chart_image,pre_appointment_details:e.data.data.questions.map(e=>({id:e.id,question:e.question,answer:""}))}))}catch(e){console.error("Error fetching charting details:",e)}})()},[null==d?void 0:d.Health_Professional_Id]),(0,n.useEffect)(()=>()=>{sessionStorage.removeItem("insuranceData")},[]),(0,n.useEffect)(()=>{c.Z.updateStep(2)},[]),!d)return null;let G=(e,t)=>{y(a=>({...a,pre_appointment_details:a.pre_appointment_details.map(a=>a.id===e?{...a,answer:t}:a)})),F["question-".concat(e)]&&K("question-".concat(e))},X=(e,t,a)=>{y(s=>{let n=[...s.bodyPoints];return n[e]={...n[e],question:t,answer:a},{...s,bodyPoints:n}}),F["point-".concat(e)]&&K("point-".concat(e))},$=()=>f.body_chart_image&&""!==f.body_chart_image.trim()&&"null"!==f.body_chart_image&&"undefined"!==f.body_chart_image,Q=async e=>{if(null==e?void 0:e.success){var t;window.dataLayer=window.dataLayer||[];let a=Number(q)||0,s=(null==e?void 0:e.paymentIntentId)||(null==e?void 0:e.id)||"vt_".concat(Date.now());window.dataLayer.push({event:"purchase",transaction_id:s,value:a,currency:"GBP",doctor_id:(null==d?void 0:d.Health_Professional_Id)||"unknown"}),window.dataLayer.push({event:"vt_purchase",value:a,currency:"GBP"}),c.Z.updateEventName("Payment Successful"),c.Z.eventData["appointment-status"]="paid";let n=sessionStorage.getItem("insuranceData");if(n){try{await l.ZP.post("/api/v1/patient/insurance/send_to_medserve/",JSON.parse(n))}catch(e){console.error("Medserve error:",e)}sessionStorage.removeItem("insuranceData")}E((null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.appointment_id)||null),S(!0),T(!1)}else window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"purchase_failed",reason:(null==e?void 0:e.message)||"unknown"}),console.error("Payment failed:",null==e?void 0:e.message)},ee=e=>{let{name:t,value:a}=e.target;I(e=>({...e,[t]:a})),K(t)},et=async()=>{var e,t;let a={};if((null===(e=M.insurance_company_name)||void 0===e?void 0:e.trim())||(a.insurance_company_name="Insurance company name is required"),(null===(t=M.insuarance_number)||void 0===t?void 0:t.trim())||(a.insuarance_number="Policy number is required"),Object.keys(a).length>0){L(e=>({...e,...a}));return}try{let e=localStorage.getItem("authToken");if(!e){alert("Please log in to save insurance details.");return}let t={insurancebooking_Id:M.insurancebooking_Id||"",insuarance_number:M.insuarance_number,insurance_company_name:M.insurance_company_name,membership_number:M.membership_number||"",reference_number:M.reference_number||"",group_number:M.group_number||"",coverage_type:M.coverage_type||"",date_of_issue:M.date_of_issue||"",date_of_expiry:M.date_of_expiry||"",preauth_number:M.preauth_number||""},a=await l.ZP.post("/patient/insurance/add_insurance/",t,{headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(200===a.status)sessionStorage.setItem("insuranceData",JSON.stringify(t)),U(M),W(!0),H(!1),c.Z.trackInsuranceSaved();else throw Error("Failed to save insurance details")}catch(e){console.error("Error saving insurance details:",e),alert("Error saving insurance details. Please try again.")}},ea=d.Full_Name||d.full_Name||d.full_name||"Practitioner";return(0,s.jsx)("div",{className:g()["book-appointment-modal-overlay"],children:(0,s.jsxs)("div",{className:g()["book-appointment-modal-content"],children:[(0,s.jsx)("button",{className:g()["modal-close-btn"],onClick:()=>{c.Z.trackModalAbandoned(P?3:2),p()},"aria-label":"Close modal",children:"\xd7"}),(0,s.jsxs)("div",{className:g()["bam-summary-bar"],children:[(0,s.jsxs)("div",{className:g()["bam-summary-item"],children:[(0,s.jsx)("span",{className:g()["bam-summary-label"],children:"Practitioner"}),(0,s.jsx)("span",{className:g()["bam-summary-value"],children:ea})]}),(0,s.jsx)("div",{className:g()["bam-summary-divider"]}),(0,s.jsxs)("div",{className:g()["bam-summary-item"],children:[(0,s.jsx)("span",{className:g()["bam-summary-label"],children:"Date & Time"}),(0,s.jsxs)("span",{className:g()["bam-summary-value"],children:[u," at ",m]})]}),(0,s.jsx)("div",{className:g()["bam-summary-divider"]}),(0,s.jsxs)("div",{className:g()["bam-summary-item"],children:[(0,s.jsx)("span",{className:g()["bam-summary-label"],children:"Fee"}),(0,s.jsxs)("span",{className:g()["bam-summary-fee"],children:["\xa3",q]})]})]}),(()=>{let e=k?4:P?3:2,t=["Slot Selection","Appointment Details","Payment"];return(0,s.jsx)("div",{className:g()["bam-progress"],children:t.map((a,l)=>{let i=l+1,r=e>i,o=e===i;return(0,s.jsxs)(n.Fragment,{children:[(0,s.jsxs)("div",{className:"\n                        ".concat(g()["bam-progress-step"],"\n                        ").concat(r?g()["bam-progress-step--done"]:"","\n                        ").concat(o?g()["bam-progress-step--active"]:"","\n                      "),children:[(0,s.jsx)("div",{className:g()["bam-progress-circle"],children:r?(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M20 6L9 17L4 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}):i}),(0,s.jsx)("span",{className:g()["bam-progress-label"],children:a})]}),l<t.length-1&&(0,s.jsx)("div",{className:"\n                        ".concat(g()["bam-progress-line"],"\n                        ").concat(r?g()["bam-progress-line--done"]:"","\n                      ")})]},i)})})})(),(0,s.jsx)("div",{className:g()["bam-body"],children:P?(0,s.jsx)(_,{embedded:!0,isOpen:P,onClose:p,appointmentData:{doctor_id:null==d?void 0:d.Health_Professional_Id,appointmentDate:u,appointmentType:B,amount:q,scheduleData:b||{initial_appointment_fee:v,follow_up_appointment_fee:v,Currency:"\xa3"},package_info:null==b?void 0:b.package_info,token:A,date:(e=>{if(!e)return"Invalid Date";let t=new Date(e);if(isNaN(t))return"Invalid Date";let a=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),n=t.getFullYear();return"".concat(a,"/").concat(s,"/").concat(n)})(u),time:m,gender:f.gender,full_name:f.fullName,age:f.age,weight:f.weight,email:f.email,mobile_number:f.phone,preappointmentdetail_id:f.preappointmentdetail_id,body_chart_image:f.body_chart_image,patient_address:f.patient_address,pre_appointment_details:f.pre_appointment_details,body_points:f.bodyPoints,page_url:window.location.href},onSuccess:Q}):(0,s.jsxs)(s.Fragment,{children:[(f.pre_appointment_details.length>0||$())&&(0,s.jsxs)("div",{className:g()["bam-health-section"],children:[(0,s.jsxs)("button",{type:"button",className:g()["bam-health-toggle"],onClick:()=>z(e=>!e),children:[(0,s.jsxs)("span",{children:["\uD83E\uDE7A Health Assessment ",(0,s.jsx)("span",{className:g()["bam-health-toggle__optional"],children:"(Optional)"})]}),(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",style:{transform:R?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:(0,s.jsx)("path",{d:"M6 9L12 15L18 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),R&&(0,s.jsxs)("div",{className:g()["bam-health-body"],children:[(0,s.jsx)("p",{className:g()["bam-health-desc"],children:"Answer the questions below and optionally mark areas of concern on the body chart."}),f.pre_appointment_details.map(e=>(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"question-".concat(e.id),children:e.question}),(0,s.jsx)("textarea",{id:"question-".concat(e.id),value:e.answer,onChange:t=>G(e.id,t.target.value),placeholder:"Please provide your answer..."})]},e.id)),$()&&(0,s.jsxs)("div",{className:g()["body-chart-container"],children:[(0,s.jsx)("h4",{children:"Click on the body chart to mark areas of concern"}),(0,s.jsxs)("div",{ref:N,className:g()["chart-wrapper"],onClick:e=>{if(!N.current)return;let t=N.current.getBoundingClientRect(),a=(e.clientX-t.left)/t.width,s=(e.clientY-t.top)/t.height,n=Math.max(0,Math.min(1,a)),l=Math.max(0,Math.min(1,s));y(e=>({...e,bodyPoints:[...e.bodyPoints,{x_axis:n,y_axis:l,question:"",answer:""}]}))},children:[(0,s.jsx)("img",{ref:j,src:f.body_chart_image,className:g()["charting-image"],alt:"Body Chart"}),f.bodyPoints.map((e,t)=>{var a,n;return(0,s.jsx)("div",{className:g()["body-point"],style:{top:"".concat(e.y_axis*((null===(a=j.current)||void 0===a?void 0:a.height)||0),"px"),left:"".concat(e.x_axis*((null===(n=j.current)||void 0===n?void 0:n.width)||0),"px")},children:t+1},t)})]})]}),f.bodyPoints.length>0&&(0,s.jsxs)("div",{className:g()["body-chart-explanations"],children:[(0,s.jsx)("h4",{children:"Explain the marked areas"}),f.bodyPoints.map((e,t)=>(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsxs)("label",{htmlFor:"point-".concat(t),children:["Point ",t+1," — Description"]}),(0,s.jsx)("textarea",{id:"point-".concat(t),value:e.answer,onChange:a=>X(t,e.question,a.target.value),placeholder:"Describe the issue or concern at this location..."})]},t))]})]})]}),(0,s.jsxs)("div",{className:g()["bam-insurance-section"],children:[(0,s.jsxs)("button",{type:"button",className:[g()["bam-insurance-toggle"],Y&&g()["bam-insurance-toggle--saved"]].filter(Boolean).join(" "),onClick:()=>{let e=!V;H(e),e&&c.Z.trackInsuranceOpened()},children:[(0,s.jsxs)("span",{children:["\uD83D\uDEE1️"," ",Y?"Insurance details saved ✓":"Add insurance details (Optional)"]}),(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",style:{transform:V?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:(0,s.jsx)("path",{d:"M6 9L12 15L18 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),V&&(0,s.jsxs)("div",{className:g()["bam-insurance-form"],children:[(0,s.jsxs)("div",{className:g()["form-row"],children:[(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"insurancebooking_Id",children:"Insurance ID"}),(0,s.jsx)("input",{id:"insurancebooking_Id",type:"text",name:"insurancebooking_Id",value:M.insurancebooking_Id,onChange:ee,placeholder:"Enter insurance ID"})]}),(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"insuarance_number",children:"Policy Number *"}),(0,s.jsx)("input",{id:"insuarance_number",type:"text",name:"insuarance_number",value:M.insuarance_number,onChange:ee,placeholder:"Enter policy number",className:F.insuarance_number?g().error:"",required:!0}),F.insuarance_number&&(0,s.jsx)("span",{className:g()["error-message"],children:F.insuarance_number})]})]}),(0,s.jsxs)("div",{className:g()["form-row"],children:[(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"insurance_company_name",children:"Insurance Company *"}),(0,s.jsx)("input",{id:"insurance_company_name",type:"text",name:"insurance_company_name",value:M.insurance_company_name,onChange:ee,placeholder:"Enter insurance company name",className:F.insurance_company_name?"error":"",required:!0}),F.insurance_company_name&&(0,s.jsx)("span",{className:g()["error-message"],children:F.insurance_company_name})]}),(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"membership_number",children:"Membership Number *"}),(0,s.jsx)("input",{id:"membership_number",type:"text",name:"membership_number",value:M.membership_number,onChange:ee,placeholder:"Enter membership number",required:!0})]})]}),(0,s.jsxs)("div",{className:g()["form-row"],children:[(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"reference_number",children:"Reference Number"}),(0,s.jsx)("input",{id:"reference_number",type:"text",name:"reference_number",value:M.reference_number,onChange:ee,placeholder:"Enter reference number"})]}),(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"group_number",children:"Group Number"}),(0,s.jsx)("input",{id:"group_number",type:"text",name:"group_number",value:M.group_number,onChange:ee,placeholder:"Enter group number"})]})]}),(0,s.jsxs)("div",{className:g()["form-row"],children:[(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"coverage_type",children:"Coverage Type"}),(0,s.jsx)("input",{id:"coverage_type",type:"text",name:"coverage_type",value:M.coverage_type,onChange:ee,placeholder:"Enter coverage type"})]}),(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"date_of_issue",children:"Effective Date"}),(0,s.jsx)("input",{id:"date_of_issue",type:"date",name:"date_of_issue",value:M.date_of_issue,onChange:ee})]})]}),(0,s.jsxs)("div",{className:g()["form-row"],children:[(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"date_of_expiry",children:"Expiration Date"}),(0,s.jsx)("input",{id:"date_of_expiry",type:"date",name:"date_of_expiry",value:M.date_of_expiry,onChange:ee})]}),(0,s.jsxs)("div",{className:g()["form-field"],children:[(0,s.jsx)("label",{htmlFor:"preauth_number",children:"Pre-Authorization Number"}),(0,s.jsx)("input",{id:"preauth_number",type:"text",name:"preauth_number",value:M.preauth_number,onChange:ee,placeholder:"Enter pre-auth number"})]})]}),(0,s.jsxs)("div",{className:"bam-insurance-form-actions",children:[(0,s.jsx)("button",{type:"button",className:g()["insurance-skip-button"],onClick:()=>H(!1),children:"Cancel"}),(0,s.jsx)("button",{type:"button",className:g()["insurance-save-button"],onClick:et,disabled:!((null===(r=M.insurance_company_name)||void 0===r?void 0:r.trim())!==""&&(null===(o=M.insuarance_number)||void 0===o?void 0:o.trim())!==""),children:"Save Insurance"})]})]})]}),(0,s.jsxs)("div",{className:g()["bam-emergency-disclaimer"],children:[(0,s.jsx)("strong",{children:"⚠️ Not for emergencies."})," Virtual Triage is not a healthcare provider — call 999 if you need urgent help."]}),(0,s.jsx)("div",{className:g()["terms-section"],children:(0,s.jsxs)("div",{className:g()["terms-checkbox"],children:[(0,s.jsx)("input",{type:"checkbox",id:"terms-checkbox",checked:w,onChange:()=>{let e=!w;D(e),c.Z.updateConfirmationCheckbox(e)}}),(0,s.jsxs)("label",{htmlFor:"terms-checkbox",children:["I understand all medical services are provided independently by clinicians and agree to the"," ",(0,s.jsx)("a",{href:"/terms-and-conditions",target:"_blank",rel:"noopener noreferrer",children:"Terms & Conditions"}),","," ",(0,s.jsx)("a",{href:"/privacy-notice",target:"_blank",rel:"noopener noreferrer",children:"Privacy Notice"}),","," ",(0,s.jsx)("a",{href:"/cookie-policy",target:"_blank",rel:"noopener noreferrer",children:"Cookie Policy"})," and"," ",(0,s.jsx)("a",{href:"/appointment-terms",target:"_blank",rel:"noopener noreferrer",children:"Appointment Terms"}),"."]})]})})]})}),(0,s.jsx)("div",{className:g()["step-actions"],children:P?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{className:g()["back-button"],onClick:()=>T(!1),children:"← Back to Details"}),(0,s.jsxs)("div",{className:g()["bam-insurance-refund-note"],children:[(0,s.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,s.jsxs)("span",{children:["If you added insurance details and your claim is accepted, the amount covered by your insurer ",(0,s.jsx)("strong",{children:"will be refunded"})]})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{className:g()["back-button"],onClick:p,children:"Cancel"}),(0,s.jsxs)("div",{className:[g()["proceed-button-wrapper"],!w&&g()["proceed-button-wrapper--blocked"]].filter(Boolean).join(" "),children:[(0,s.jsx)("button",{className:g()["proceed-button"],onClick:()=>{let e=(null==d?void 0:d.Full_Name)||(null==d?void 0:d.full_name)||(null==d?void 0:d.full_Name)||"";c.Z.updatePersonalInfo({...f,doctor_name:e}),c.Z.updateProceedToPayment(),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"checkout_opened"}),c.Z.trackPaymentStepOpened(),T(!0)},disabled:!w,children:"Proceed to Payment →"}),!w&&(0,s.jsx)("div",{className:g()["proceed-tooltip"],children:"⚠ Please accept the Terms & Conditions"})]})]})}),k&&(0,s.jsx)(i.Z,{appointment_id:C,onClose:p,appointmentStart:u+" "+m+":00",appointmentEnd:u+" "+m+":00"})]})})}},914:function(e,t,a){"use strict";a.r(t);var s=a(5893),n=a(7294),l=a(2917),i=a(5763),r=a(2984),o=a(3581),c=a(3838),d=a(9513),m=a(8338),u=a(3109);t.default=e=>{let{isOpen:t,onClose:a,clinicId:p,practitionerEmail:h,practitionerData:v,preSelectedDate:_=null,preSelectedSlot:x=null}=e,[g,b]=(0,n.useState)(null),[f,y]=(0,n.useState)(!1),[j,N]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),[w,D]=(0,n.useState)(null),[C,E]=(0,n.useState)(null),[P,T]=(0,n.useState)(!1),[M,I]=(0,n.useState)(null),[F,L]=(0,n.useState)(null),[A,Z]=(0,n.useState)("initial"),[B,O]=(0,n.useState)(null),[q,V]=(0,n.useState)(!1),[H,R]=(0,n.useState)(!1),[z,Y]=(0,n.useState)(!1),[W,J]=(0,n.useState)(null),[U,K]=(0,n.useState)(""),[G,X]=(0,n.useState)(!1),$=(0,n.useRef)(!1),Q=()=>{let e=new Date,t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(a,"-").concat(s)};(0,n.useEffect)(()=>{t&&($.current||($.current=!0,u.Z.initializeTracking()),!p&&v&&!k&&(et(v),_?I(_):I(Q()),x&&L(x)))},[t,p,v]),(0,n.useEffect)(()=>{if(t&&p){ee();return}},[t,p]),(0,n.useEffect)(()=>{if(g&&g.doctors){let e=null;h&&(e=g.doctors.find(e=>e.Email&&e.Email.toLowerCase()===h.toLowerCase()||e.email&&e.email.toLowerCase()===h.toLowerCase()||e.Health_Professional_Email&&e.Health_Professional_Email.toLowerCase()===h.toLowerCase())),!e&&g.doctors.length>0&&(e=g.doctors[0]),e&&(u.Z.eventData.doctor_name=e.Full_Name||e.full_name||e.full_Name||"",u.Z.sendEvent(),S(e),et(e))}},[g,h,v]),(0,n.useEffect)(()=>{_&&I(_),x&&L(x),k&&(_&&x?(u.Z.trackSlotContinued(),V(!1),R(!0)):_&&V(!0))},[_,x,k]),(0,n.useEffect)(()=>{w&&("initial"===A?O(w.initial_appointment_fee):O(w.follow_up_appointment_fee))},[A,w]),(0,n.useEffect)(()=>{if(!t||!k)return;let e=h||(null==v?void 0:v.email)||(null==k?void 0:k.email)||(null==k?void 0:k.Email)||(null==k?void 0:k.Health_Professional_Email);if(!e)return;let a=new Date;(0,m.nE)(e,a.getFullYear(),a.getMonth()).catch(e=>console.error("Error prefetching schedule:",e))},[k,t]);let ee=async()=>{if(!p){N("Clinic ID is required but was not provided."),y(!1);return}y(!0),N(null);try{let e=await c.ZP.get("/patient/clinics/clinic-details/?id=".concat(p));if(e.data.status){let t=e.data.data[0];b(t)}else N("Failed to fetch clinic details."),d.Am.error("Failed to fetch clinic details.")}catch(e){N("An error occurred while fetching clinic details."),d.Am.error("An error occurred while fetching clinic details.")}finally{y(!1)}},et=async e=>{if(e){S(e),V(!0),I(Q()),E(null),T(!1),D(null);try{let t=e.Health_Professional_Id||e.health_professional_id;if(e.Full_Name,!t){T(!0);return}let a=await c.ZP.get("/patient/doctor/doctor-schedule/?id=".concat(t));a.data.status?(D(a.data.data||{}),T(!1)):(T(!0),D(null))}catch(e){T(!0),D(null)}}},ea=()=>{"Payment Successful"!==u.Z.getState().event_name&&u.Z.trackModalAbandoned(H?2:1),R(!1),V(!1),S(null),I(null),L(null),D(null),E(null),T(!1),O(null),K(""),Y(!1),J(null),$.current=!1,u.Z.reset(),a()},es=async(e,t)=>{let a=(e=>{let t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(a,"-").concat(s)})(t);L(e.startTime),I(a),K(""),u.Z.updateSlotSelection(a,e.startTime)};if(!t)return null;let en=h||(null==v?void 0:v.email)||(null==k?void 0:k.email)||(null==k?void 0:k.Email)||(null==k?void 0:k.Health_Professional_Email);return(0,s.jsxs)(s.Fragment,{children:[f&&(0,s.jsx)("div",{className:"modal-overlay",onClick:e=>e.target===e.currentTarget&&ea(),children:(0,s.jsx)("div",{className:"modal-content",children:(0,s.jsxs)("div",{className:"loading-container",children:[(0,s.jsx)("div",{className:"loading-spinner"}),(0,s.jsx)("p",{children:"Loading clinic details..."})]})})}),j&&!f&&(0,s.jsx)("div",{className:"modal-overlay",onClick:e=>e.target===e.currentTarget&&ea(),children:(0,s.jsx)("div",{className:"modal-content",children:(0,s.jsxs)("div",{className:"error-container",children:[(0,s.jsx)("p",{className:"error",children:j}),(0,s.jsx)("button",{onClick:ea,className:"close-btn",children:"Close"})]})})}),!f&&!j&&!H&&k&&(q||g&&g.doctors&&g.doctors.length>0)&&(0,s.jsx)("div",{className:"modal-direct-booking-overlay",children:(0,s.jsxs)("div",{className:"modal-direct-booking-modal",children:[(0,s.jsxs)("div",{className:"modal-direct-booking-header",children:[(0,s.jsxs)("div",{className:"modal-direct-booking-title-section",children:[(0,s.jsx)("h2",{className:"modal-direct-booking-title",children:"Book Appointment"}),k&&(0,s.jsxs)("p",{className:"modal-direct-booking-subtitle",children:["Schedule your appointment with"," ",(0,s.jsx)("strong",{children:k.full_Name||k.Full_Name||k.full_name||"Practitioner"})]})]}),(0,s.jsx)("button",{className:"modal-direct-booking-close-button",onClick:ea,"aria-label":"Close",children:(0,s.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),(0,s.jsx)("div",{className:"dbm-progress",children:["Slot Selection","Appointment Details","Payment"].map((e,t)=>{let a=t+1,l=1===a;return(0,s.jsxs)(n.Fragment,{children:[(0,s.jsxs)("div",{className:"dbm-progress-step".concat(l?" dbm-progress-step--active":""),children:[(0,s.jsx)("div",{className:"dbm-progress-circle",children:a}),(0,s.jsx)("span",{className:"dbm-progress-label",children:e})]}),t<2&&(0,s.jsx)("div",{className:"dbm-progress-line"})]},a)})}),(0,s.jsx)("div",{className:"modal-direct-booking-content",children:(0,s.jsxs)("div",{className:"modal-direct-booking-step",children:[!P&&(0,s.jsx)("div",{className:"modal-direct-booking-section",children:w?(0,s.jsx)("div",{className:"dbm-type-toggle-row",children:(0,s.jsxs)("div",{className:"dbm-type-toggle",children:[(0,s.jsxs)("button",{type:"button",className:"dbm-type-btn".concat("initial"===A?" dbm-type-btn--active":""),onClick:()=>{Z("initial"),u.Z.updateAppointmentType("initial",w.initial_appointment_fee)},children:["Initial ",(0,s.jsxs)("span",{className:"dbm-type-price",children:["\xa3",w.initial_appointment_fee]})]}),(0,s.jsxs)("button",{type:"button",className:"dbm-type-btn".concat("follow_up"===A?" dbm-type-btn--active":""),onClick:()=>{Z("follow_up"),u.Z.updateAppointmentType("follow_up",w.follow_up_appointment_fee)},children:["Follow-up ",(0,s.jsxs)("span",{className:"dbm-type-price",children:["\xa3",w.follow_up_appointment_fee]})]})]})}):(0,s.jsxs)("div",{className:"modal-direct-booking-schedule-loading",children:[(0,s.jsx)("div",{className:"loading-spinner",style:{width:"24px",height:"24px",borderWidth:"2px"}}),(0,s.jsx)("span",{children:"Loading schedule..."})]})}),(0,s.jsx)("div",{className:"modal-direct-booking-section modal-direct-booking-section--calendar",children:P?(0,s.jsxs)("div",{className:"dbm-no-schedule",children:[(0,s.jsx)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M8 2V6M16 2V6M3 10H21M5 4H19C20.1046 4 21 4.89543 21 6V20C21 21.1046 20.1046 22 19 22H5C3.89543 22 3 21.1046 3 20V6C3 4.89543 3.89543 4 5 4Z",stroke:"#9ca3af",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,s.jsx)("h3",{children:"Schedule Not Available"}),(0,s.jsx)("p",{children:"This doctor has not set up their availability yet. You can send a request and they will get back to you."}),(0,s.jsxs)("button",{className:"modal-direct-booking-proceed-button",onClick:()=>X(!0),children:["Request Appointment",(0,s.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M5 12H19M19 12L12 5M19 12L12 19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]}):_&&x?(0,s.jsxs)("div",{className:"dbm-slot-locked",children:[(0,s.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",children:[(0,s.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"2"}),(0,s.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:_})," at ",(0,s.jsx)("strong",{children:x})]}),(0,s.jsx)("span",{className:"dbm-slot-locked-badge",children:"Pre-selected"})]}):(0,s.jsx)("div",{className:"modal-direct-booking-date-time-selection",children:en?(0,s.jsx)(o.Z,{availableSlots:null,loadingSlots:!1,onDateSelect:e=>{I(e instanceof Date?"".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0"),"-").concat(String(e.getDate()).padStart(2,"0")):e),L(null),K("")},selectedDate:M||new Date().toISOString().split("T")[0],selectedSlot:F,doctorEmail:String(en).trim(),doctor:v||k,onSlotClick:es},"calendar-".concat(en)):(0,s.jsxs)("div",{className:"modal-direct-booking-alert-message",style:{margin:"20px 0",padding:"20px"},children:[(0,s.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M12 9V13M12 17H12.01M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Unable to load calendar: Doctor email not found. Please try again."]})})}),F&&M&&(0,s.jsxs)("div",{className:"modal-direct-booking-slot-selected",children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M20 6L9 17L4 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,s.jsxs)("span",{children:["Selected: ",(0,s.jsx)("strong",{children:M})," at ",(0,s.jsx)("strong",{children:F})]})]}),U&&(0,s.jsxs)("div",{className:"modal-direct-booking-alert-message",children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M12 9V13M12 17H12.01M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),U]}),!P&&(0,s.jsx)("div",{className:"modal-direct-booking-step-navigation",children:(0,s.jsxs)("button",{className:"modal-direct-booking-proceed-button",disabled:!F||!A,onClick:()=>{if(!M){K("Please select a date before proceeding to booking.");return}F&&M&&k?(u.Z.trackSlotContinued(),V(!1),R(!0),K("")):K("Please select a date and time slot before proceeding.")},children:["Continue to Booking",(0,s.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M5 12H19M19 12L12 5M19 12L12 19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]})})]})}),H&&k&&(0,s.jsx)(l.Z,{practitioner:k,selectedDate:M,selectedSlot:F,onClose:ea,appointmentType:A,appointmentFee:B,onAppointmentBooked:e=>{J(e),R(!1),Y(!0)},scheduleData:w,doctorEmail:en}),z&&(0,s.jsx)(i.Z,{appointment_id:W,onClose:()=>Y(!1)}),(0,s.jsx)(r.Z,{isOpen:G,onClose:()=>X(!1),doctorId:(null==k?void 0:k.Health_Professional_Id)||(null==k?void 0:k.health_professional_id),doctorName:(null==k?void 0:k.full_Name)||(null==k?void 0:k.Full_Name)||(null==k?void 0:k.full_name),doctorEmail:en})]})}},3581:function(e,t,a){"use strict";var s=a(5893),n=a(7294),l=a(1163),i=a(5346),r=a(8338),o=a(6658),c=a(2984),d=a(3838);t.Z=e=>{let{availableSlots:t=null,loadingSlots:a=!1,onDateSelect:m,selectedDate:u,selectedSlot:p=null,doctorEmail:h,doctor:v=null,onSlotClick:_=null}=e,x=(0,l.useRouter)(),[g,b]=(0,n.useState)(new Date),[f,y]=(0,n.useState)("month"),[j,N]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),[w,D]=(0,n.useState)(!1),[C,E]=(0,n.useState)(null),[P,T]=(0,n.useState)(null),[M,I]=(0,n.useState)(!1),[F,L]=(0,n.useState)(!1),[A,Z]=(0,n.useState)(null),B=(e,t)=>{let a=new Date(e,t,1),s=new Date(a);s.setDate(s.getDate()-a.getDay());let n=[],l=[],i=new Date(s);for(let e=0;e<42;e++)l.push(new Date(i)),i.setDate(i.getDate()+1),7===l.length&&(n.push([...l]),l=[]);return{weeks:n,type:"month"}},O=e=>({day:new Date(e),type:"day"});(0,n.useEffect)(()=>{h&&(async()=>{D(!0),E(null);try{let e=g.getFullYear(),t=g.getMonth(),a=await (0,r.nE)(h,e,t);S(a);let s=(0,r.iY)(a);s&&0===s.availableDays&&0===s.availableSlots&&E(null),(0,r.Ht)(h,e,t)}catch(t){console.error("Error loading monthly schedule:",t);let e=t.message||String(t);e.includes("404")||e.includes("not found")||e.includes("No slots")?E("Schedule not found"):E(e)}finally{D(!1)}})()},[h,g.getFullYear(),g.getMonth()]),(0,n.useEffect)(()=>{if(!k||P)return;let e=new Date;e.setHours(0,0,0,0);let t=Object.keys(k.days||{}).filter(t=>{let[a,s,n]=t.split("-").map(Number),l=new Date(a,s-1,n);return l.setHours(0,0,0,0),l>=e&&k.days[t].availableSlots>0}).sort()[0];if(t){T(t);let[e,a]=t.split("-").map(Number);if(b(t=>t.getFullYear()!==e||t.getMonth()!==a-1?new Date(e,a-1,1):t),m){let[e,a,s]=t.split("-").map(Number);m(new Date(e,a-1,s))}}},[k]);let q=(0,n.useMemo)(()=>{let e=g.getFullYear(),t=g.getMonth();return"month"===f?B(e,t):O(g)},[g,f]),V=e=>{let t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(a,"-").concat(s)},H=e=>{let a=V(e);if(k&&k.days&&k.days[a]){let e=k.days[a];if(e.slots&&e.slots.starttiming){let t=new Set((e.slots.bookslots||[]).filter(Boolean));return e.slots.starttiming.map((t,s)=>({startTime:t,endTime:e.slots.endtiming[s],isBooked:!1,id:"".concat(a,"-").concat(t)})).filter(e=>!t.has(e.startTime))}}if(t&&t.starttiming&&a===u){let e=new Set((t.bookslots||[]).filter(Boolean));return t.starttiming.map((e,s)=>({startTime:e,endTime:t.endtiming[s],isBooked:!1,id:"".concat(a,"-").concat(e)})).filter(t=>!e.has(t.startTime))}return[]},R=e=>{let t=V(e);return k&&k.days&&k.days[t]?k.days[t].availableSlots>0:H(e).some(e=>!e.isBooked)},z=e=>{let t=new Date;t.setHours(0,0,0,0);let a=new Date(e);return a.setHours(0,0,0,0),a<t},Y=(e,t)=>{let a=V(new Date);if(V(t)!==a)return!1;let s=new Date,[n,l]=e.startTime.split(":").map(Number),i=new Date;return i.setHours(n,l,0,0),i<=s},W=e=>{let t=new Date;return e.toDateString()===t.toDateString()},J=e=>{let t=new Date(g);"month"===f?t.setMonth(t.getMonth()+e):"day"===f?t.setDate(t.getDate()+7*e):t.setDate(t.getDate()+e),b(t)},U=(e,t)=>{!e.isBooked&&_&&_(e,t)},K=async e=>{try{if(!localStorage.getItem("authToken")){console.error("No auth token found after login");return}let t=(await d.ZP.post("patient/appointment/book-appointment/directory/",{doctor_email:e.email})).data;if(!1===t.status&&"Patient not found."===t.message){Z(e),I(!0);return}t.clinic_id?x.push("/clinic-details/".concat(t.clinic_id)):alert("Clinic information not available. Please try again later.")}catch(s){var t,a;console.error("Error getting clinic details after login:",s),(null===(t=s.response)||void 0===t?void 0:t.status)===401||(null===(a=s.response)||void 0===a?void 0:a.status)===403?(localStorage.removeItem("authToken"),localStorage.removeItem("userData"),Z(e),I(!0)):alert("Error getting clinic details. Please try again later.")}},G=e=>e.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"vt-modern-calendar",children:w?(0,s.jsxs)("div",{className:"vt-cal-loading",children:[(0,s.jsx)("div",{className:"vt-loading-spinner",style:{width:"22px",height:"22px",borderWidth:"2px"}}),(0,s.jsx)("p",{children:"Loading available times…"})]}):C&&(C.includes("not found")||C.includes("404")||C.includes("No slots"))||(()=>{if(!k)return!1;let e=(0,r.iY)(k);return e&&0===e.availableDays&&0===e.availableSlots})()?(0,s.jsxs)("div",{className:"vt-no-schedule-message",children:[(0,s.jsx)("div",{className:"vt-no-schedule-icon",children:(0,s.jsx)(i.IiJ,{})}),(0,s.jsx)("h3",{children:"Schedule Not Available"}),(0,s.jsx)("p",{children:"This doctor has not set their schedule or availability yet."}),(0,s.jsx)("button",{className:"vt-request-appointment-btn",onClick:()=>L(!0),children:"Request Appointment"})]}):C?(0,s.jsx)("div",{className:"vt-cal-error",children:(0,s.jsx)("p",{children:"Error loading schedule. Please try again."})}):(0,s.jsxs)("div",{className:"vt-cal-layout",children:[(0,s.jsxs)("div",{className:"vt-mini-cal-panel",children:[(0,s.jsxs)("div",{className:"vt-mini-nav",children:[(0,s.jsx)("button",{className:"vt-mini-nav-btn",onClick:()=>J(-1),"aria-label":"Previous month",children:(0,s.jsx)(i.bUI,{size:10})}),(0,s.jsx)("span",{className:"vt-mini-month-label",children:(()=>{if("month"===f)return g.toLocaleDateString("en-US",{year:"numeric",month:"long"});if("day"!==f)return G(g);{let e=new Date(g);e.setDate(g.getDate()-g.getDay());let t=new Date(e);return(t.setDate(e.getDate()+6),e.getMonth()===t.getMonth())?"".concat(e.toLocaleDateString("en-US",{month:"long"})," ").concat(e.getDate(),"-").concat(t.getDate(),", ").concat(e.getFullYear()):"".concat(e.toLocaleDateString("en-US",{month:"short",day:"numeric"})," - ").concat(t.toLocaleDateString("en-US",{month:"short",day:"numeric"}),", ").concat(e.getFullYear())}})()}),(0,s.jsx)("button",{className:"vt-mini-nav-btn",onClick:()=>J(1),"aria-label":"Next month",children:(0,s.jsx)(i.Dli,{size:10})})]}),(0,s.jsx)("div",{className:"vt-mini-weekdays",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(e=>(0,s.jsx)("div",{className:"vt-mini-wd",children:e},e))}),(0,s.jsx)("div",{className:"vt-mini-days-grid",children:q.weeks&&q.weeks.map((e,t)=>e.map((e,a)=>{let n=R(e),l=e.getMonth()===g.getMonth(),i=V(e),r=P===i,o=W(e),c=z(e),d=n&&!c;return(0,s.jsxs)("button",{className:"vt-mini-day-btn".concat(l||d?"":" vt-other-month").concat(c?" vt-past":"").concat(o&&!r?" vt-today":"").concat(r?" vt-active":"").concat(d?" vt-has-slots":"").concat(!l&&d?" vt-other-month-clickable":""),onClick:()=>{if(d&&(T(i),l||b(new Date(e.getFullYear(),e.getMonth(),1)),m)){let e=i.split("-").map(Number);m(new Date(e[0],e[1]-1,e[2]))}},disabled:!d,children:[(0,s.jsx)("span",{className:"vt-day-num",children:e.getDate()}),d&&(0,s.jsx)("span",{className:"vt-dot"})]},"".concat(t,"-").concat(a))}))})]}),(0,s.jsx)("div",{className:"vt-cal-divider"}),(0,s.jsx)("div",{className:"vt-time-slots-panel",children:P?(()=>{let e=P.split("-").map(Number),t=new Date(e[0],e[1]-1,e[2]),a=H(t),n=a.filter(e=>!e.isBooked).length;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"vt-slots-panel-header",children:[(0,s.jsx)("span",{className:"vt-slots-panel-date-label",children:t.toLocaleDateString("en-US",{weekday:"long",month:"short",day:"numeric"})}),n>0&&(0,s.jsxs)("span",{className:"vt-slots-avail-count",children:[n," slots available"]})]}),a.length>0?(0,s.jsx)("div",{className:"vt-slots-compact-grid",children:a.map((e,a)=>{let n=p&&e.startTime===p&&P===u,l=Y(e,t),i=e.isBooked||l;return(0,s.jsx)("button",{className:"vt-slot-pill".concat(i?l?" vt-slot-past":" vt-slot-booked":" vt-slot-avail").concat(n?" vt-slot-selected":""),onClick:()=>!i&&U(e,t),disabled:i,children:e.startTime},a)})}):(0,s.jsx)("div",{className:"vt-slots-none-msg",children:"No slots available for this date"})]})})():(0,s.jsxs)("div",{className:"vt-slots-empty-state",children:[(0,s.jsx)("svg",{width:"34",height:"34",viewBox:"0 0 24 24",fill:"none",children:(0,s.jsx)("path",{d:"M8 2V6M16 2V6M3 10H21M5 4H19C20.1046 4 21 4.89543 21 6V20C21 21.1046 20.1046 22 19 22H5C3.89543 22 3 21.1046 3 20V6C3 4.89543 3.89543 4 5 4Z",stroke:"#c7c7cc",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,s.jsxs)("p",{children:["Select a date to view",(0,s.jsx)("br",{}),"available times"]})]})})]})}),(0,s.jsx)(c.Z,{isOpen:F,onClose:()=>L(!1),doctorId:null==v?void 0:v._id,doctorName:null==v?void 0:v.full_name,doctorEmail:null==v?void 0:v.email}),(0,s.jsx)(o.default,{isOpen:M,onClose:()=>{I(!1),Z(null)},onLoginSuccess:()=>{A&&(K(A),Z(null))}})]})}},7438:function(e,t,a){"use strict";a.d(t,{ej:function(){return l},ft:function(){return i}});class s{generateKey(e,t){return"".concat(this.cachePrefix).concat(e,"_").concat(t)}isValid(e){if(!e)return!1;let t=Date.now();return e.timestamp+e.ttl>t}get(e,t){let a=this.generateKey(e,t);if(this.memoryCache.has(a)){let e=this.memoryCache.get(a);if(this.isValid(e))return e.data;this.memoryCache.delete(a)}try{let e=localStorage.getItem(a);if(e){let t=JSON.parse(e);if(this.isValid(t))return this.setMemoryCache(a,t),t.data;localStorage.removeItem(a)}}catch(e){}return null}set(e,t,a){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.defaultTTL,n=this.generateKey(e,t),l={data:a,timestamp:Date.now(),ttl:s};this.setMemoryCache(n,l);try{localStorage.setItem(n,JSON.stringify(l))}catch(e){}}setMemoryCache(e,t){if(this.memoryCache.size>=this.maxMemorySize){let e=this.memoryCache.keys().next().value;this.memoryCache.delete(e)}this.memoryCache.set(e,t)}invalidate(e,t){let a=this.generateKey(e,t);this.memoryCache.delete(a);try{localStorage.removeItem(a)}catch(e){}}invalidateType(e){let t="".concat(this.cachePrefix).concat(e,"_");for(let e of this.memoryCache.keys())e.startsWith(t)&&this.memoryCache.delete(e);try{let e=[];for(let a=0;a<localStorage.length;a++){let s=localStorage.key(a);s&&s.startsWith(t)&&e.push(s)}e.forEach(e=>localStorage.removeItem(e))}catch(e){}}clear(){this.memoryCache.clear();try{let e=[];for(let t=0;t<localStorage.length;t++){let a=localStorage.key(t);a&&a.startsWith(this.cachePrefix)&&e.push(a)}e.forEach(e=>localStorage.removeItem(e))}catch(e){}}getStats(){let e=this.memoryCache.size,t=0;try{for(let e=0;e<localStorage.length;e++){let a=localStorage.key(e);a&&a.startsWith(this.cachePrefix)&&t++}}catch(e){}return{memory:e,localStorage:t,total:e+t}}constructor(){this.memoryCache=new Map,this.cachePrefix="vt_blog_",this.defaultTTL=3e5,this.maxMemorySize=50}}let n=new s,l={BLOG_POST:{ttl:6e5,type:"post"},BLOG_LIST:{ttl:3e5,type:"list"},RELATED_POSTS:{ttl:9e5,type:"related"}},i=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0,{type:s,ttl:l}=a,i=e.split("/").pop()||"index",r=n.get(s,i);if(r)return r;try{let a=await fetch(e,{...t,headers:{"Content-Type":"application/json",...t.headers}});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));let r=await a.json();return n.set(s,i,r,l),r}catch(e){throw console.error("Fetch with cache failed:",e),e}}},3109:function(e,t,a){"use strict";var s=a(3838);class n{_generateEventKey(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a={event_name:e,step:this.eventData.step,appointment_type:this.eventData.appointment_type,slot:this.eventData.slot_selected,...t};return"".concat(e,"_").concat(JSON.stringify(a))}_shouldTrack(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=this._generateEventKey(e,t),s=Date.now();return!(this.lastEvent===a&&s-this.lastEventTime<this.eventDebounceTime||this.trackedEvents.has(a))&&(this.lastEvent=a,this.lastEventTime=s,this.trackedEvents.set(a,s),!0)}_cleanupOldEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e5,t=Date.now();for(let[a,s]of this.trackedEvents.entries())t-s>e&&this.trackedEvents.delete(a)}initializeTracking(){let e=this.eventData.doctor_name;this._shouldTrack("initialization")&&(this.eventData={event_type:"Booking Started",event_name:"Booking Modal Opened",step:1,appointment_type:"",appointment_fee:null,slot_selected:"",name:"",email:"",phone:"",age:null,address:"",gender:"",doctor_name:e||"","confirmation&accepted":!1,"appointment-status":"draft"},this.isInitialized=!0)}updateAppointmentType(e,t){this._shouldTrack("appointment_type_".concat(e))&&(this.eventData.appointment_type=e,this.eventData.appointment_fee=t?parseFloat(t):null,this.eventData.event_name="Appointment Type Selected: ".concat(e),this.sendEvent())}updateSlotSelection(e,t){let a="slot_".concat(e,"_").concat(t);this._shouldTrack(a)&&(this.eventData.slot_selected="".concat(e," ").concat(t),this.eventData.event_name="Slot is Selected",this.sendEvent())}trackSlotContinued(){this._shouldTrack("slot_continued")&&(this.eventData.step=2,this.eventData.event_name="Slot Confirmed - Proceeding to Details",this.sendEvent())}updateStep(e){this._shouldTrack("step_".concat(e))&&(this.eventData.step=e,this.eventData.event_name="On Step ".concat(e),this.sendEvent())}updatePersonalInfo(e){let t="".concat(e.fullName||"","_").concat(e.email||"","_").concat(e.phone||"");this._shouldTrack("personal_info_".concat(t))&&(this.eventData.name=e.fullName||"",this.eventData.email=e.email||"",this.eventData.phone=e.phone||"",this.eventData.age=e.age?parseInt(e.age):null,this.eventData.address=e.patient_address||"",this.eventData.gender=e.gender||"",e.doctor_name&&(this.eventData.doctor_name=e.doctor_name),this.eventData.event_name="Patient Details Filled",this.sendEvent())}trackEmailVerificationStarted(e){this._shouldTrack("email_verification_started_".concat(e))&&(this.eventData.email=e||this.eventData.email,this.eventData.event_name="Email Verification Started",this.sendEvent())}trackEmailVerified(){this._shouldTrack("email_verified")&&(this.eventData.event_name="Email Verified",this.sendEvent())}trackEmailVerificationFailed(){this._shouldTrack("email_verification_failed")&&(this.eventData.event_name="Email Verification Failed",this.sendEvent())}trackInsuranceOpened(){this._shouldTrack("insurance_opened")&&(this.eventData.event_name="Insurance Section Opened",this.sendEvent())}trackInsuranceSaved(){this._shouldTrack("insurance_saved")&&(this.eventData.event_name="Insurance Details Saved",this.sendEvent())}updateConfirmationCheckbox(e){this._shouldTrack("terms_".concat(e))&&(this.eventData["confirmation&accepted"]=e,this.eventData.event_name=e?"Terms Accepted":"Terms Unchecked",this.sendEvent())}updateProceedToPayment(){this._shouldTrack("proceed_to_payment")&&(this.eventData.event_name="Patient Details Submitted",this.sendEvent())}trackPaymentStepOpened(){this._shouldTrack("payment_step_opened")&&(this.eventData.step=3,this.eventData.event_name="Payment Step Opened",this.sendEvent())}trackPromoCodeApplied(e,t){let a="promo_".concat(e,"_").concat(t);this._shouldTrack(a)&&(this.eventData.event_name="Promo Code Applied",this.sendEvent({promo_code:e,discount:t}))}trackPaymentFailed(e){let t="payment_failed_".concat(e);this._shouldTrack(t)&&(this.eventData.event_name="Payment Failed",this.eventData["appointment-status"]="payment_failed",this.sendEvent({failure_reason:e}))}updateEventName(e){this._shouldTrack("payment_".concat(e))&&(this.eventData.event_name=e,this.sendEvent())}trackModalAbandoned(e){this._shouldTrack("abandoned_step_".concat(e))&&(this.eventData.event_name="Modal Abandoned at ".concat(1===e?"Slot Selection":2===e?"Appointment Details":3===e?"Payment":"Step ".concat(e)),this.eventData["appointment-status"]="abandoned",this.sendEvent())}async sendEvent(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isInitialized){this._cleanupOldEvents(),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"vt_funnel_event",vt_event_type:this.eventData.event_type,vt_event_name:this.eventData.event_name,vt_step:this.eventData.step,vt_slot:this.eventData.slot_selected,vt_appointment_type:this.eventData.appointment_type,vt_appointment_fee:this.eventData.appointment_fee,doctor_name:this.eventData.doctor_name,vt_status:this.eventData["appointment-status"],...e,timestamp:Date.now()});try{return(await s.ZP.post("/track-event/",{...this.eventData,...e})).data}catch(e){console.error("Tracking error:",e)}}}reset(){this.eventData={event_type:"Book Now",event_name:"",step:1,appointment_type:"",appointment_fee:null,slot_selected:"",name:"",email:"",phone:"",age:null,address:"",gender:"",doctor_name:"","confirmation&accepted":!1,"appointment-status":"draft"},this.isInitialized=!1,this.trackedEvents.clear(),this.lastEvent=null,this.lastEventTime=0}getState(){return{...this.eventData}}registerComponent(e){return!this.componentInstances.has(e)&&(this.componentInstances.set(e,Date.now()),!0)}unregisterComponent(e){this.componentInstances.delete(e)}constructor(){this.eventData={event_type:"Book Now",event_name:"",step:1,appointment_type:"",appointment_fee:null,slot_selected:"",name:"",email:"",phone:"",age:null,address:"",gender:"",doctor_name:"","confirmation&accepted":!1,"appointment-status":"draft"},this.isInitialized=!1,this.lastEvent=null,this.lastEventTime=0,this.eventDebounceTime=500,this.trackedEvents=new Map,this.componentInstances=new Map}}let l=new n;t.Z=l},8338:function(e,t,a){"use strict";a.d(t,{Ht:function(){return u},iY:function(){return m},nE:function(){return o}}),a(7438);var s=a(3838);let n={ttl:18e5,maxAge:72e5},l=new Map,i=new Map,r=(e,t,a)=>"schedule_".concat(e,"_").concat(t,"_").concat(a),o=async(e,t,a)=>{let s=r(e,t,a);if(l.has(s)){let e=l.get(s);if(Date.now()-e.timestamp<n.ttl)return e.data}try{let n=await c(e),r=d(n),m=e=>{let t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(a,"-").concat(s)},u=new Date(t,a+1,0).getDate(),p={year:t,month:a,doctorEmail:e,days:{},availableDays:[],totalSlots:0,availableSlots:0};for(let e=1;e<=u;e++){let s=m(new Date(t,a,e)),n=r[s]||null;if(n){var i,o;let e=(null===(i=n.starttiming)||void 0===i?void 0:i.length)||0,t=(null===(o=n.bookslots)||void 0===o?void 0:o.length)||0,a=e-t;p.days[s]={hasSlots:!0,totalSlots:e,availableSlots:a,slots:n,lastUpdated:Date.now()},a>0&&p.availableDays.push(s),p.totalSlots+=e,p.availableSlots+=a}else p.days[s]={hasSlots:!1,totalSlots:0,availableSlots:0,slots:null,error:"No slots available",lastUpdated:Date.now()}}return l.set(s,{data:p,timestamp:Date.now()}),p}catch(s){return console.error("Error fetching monthly schedule:",s),{year:t,month:a,doctorEmail:e,days:{},availableDays:[],totalSlots:0,availableSlots:0}}},c=async e=>{let t="bulk_".concat(e);if(i.has(t)){let e=i.get(t);if(Date.now()-e.timestamp<n.ttl)return e.data}let a=encodeURIComponent(e),l=(await s.ZP.get("/patient/doctor/doctor-slots-bulk/?doctor_email=".concat(a))).data;return i.set(t,{data:l,timestamp:Date.now()}),l},d=e=>{var t,a,s;let n=null!==(s=null!==(a=null!==(t=null==e?void 0:e.calendar)&&void 0!==t?t:null==e?void 0:e.data)&&void 0!==a?a:null==e?void 0:e.slots)&&void 0!==s?s:e;if(n&&"object"==typeof n&&!Array.isArray(n))return n;if(Array.isArray(n)){let e={};return n.forEach(t=>{(null==t?void 0:t.date)&&(e[t.date]=t)}),e}return{}},m=e=>e?{totalDays:Object.keys(e.days).length,availableDays:e.availableDays.length,totalSlots:e.totalSlots,availableSlots:e.availableSlots,utilizationRate:e.totalSlots>0?((e.totalSlots-e.availableSlots)/e.totalSlots*100).toFixed(1):0}:null,u=async(e,t,a)=>{let s=[];s.push(o(e,0===a?t-1:t,0===a?11:a-1).catch(e=>{})),s.push(o(e,11===a?t+1:t,11===a?0:a+1).catch(e=>{})),Promise.all(s)};setInterval(()=>{let e=Date.now();for(let[t,a]of l.entries())e-a.timestamp>n.maxAge&&l.delete(t);for(let[t,a]of i.entries())e-a.timestamp>n.maxAge&&i.delete(t)},3e5)},3824:function(e){e.exports={"appointment-booked-modal-overlay":"AppointmentBookedModal_appointment-booked-modal-overlay__rFbH1","appointment-booked-modal-content":"AppointmentBookedModal_appointment-booked-modal-content__3xoim","appointment-booked-modal-button":"AppointmentBookedModal_appointment-booked-modal-button__QMA8n","appointment-booked-link":"AppointmentBookedModal_appointment-booked-link__3YsgW","appointment-calendar-buttons":"AppointmentBookedModal_appointment-calendar-buttons__yjbkh"}}}]);