1import{j as e,ex as Me,bs as Ae,R as De,l as Le,b as xe,r as u,t as S,c as z,A as q,d as ge,f as b,is as ye,it as be,cV as _e}from"./index-QW0Z3Qxf.js";import{C as Ue}from"./constants-BNKWEC-2.js";import{N as Ye,T as Be,u as $e}from"./TermsAndConditionsNotice-xVFJZtbX.js";import{P as Fe}from"./lib-CuMiUjfd.js";/* empty css */import{S as de}from"./react-select.esm-BrU0Fymq.js";import{L as Ve}from"./LogoContainer-Dz5wu8F_.js";import{V as He}from"./VirtualOfficeAppointmentModal-CmDigHEa.js";import"./useStateManager-7e1e8489.esm-DByOQtpx.js";import"./use-isomorphic-layout-effect.browser.esm-BTBZIb0h.js";import"./Type-D-05_EJD.js";import"./SpinnerIcon-jW6whWeS.js";const G=5e3,K=5e5,We=()=>{const l=new Date,t=l.getFullYear(),T=String(l.getMonth()+1).padStart(2,"0"),r=String(l.getDate()).padStart(2,"0");return`${t}-${T}-${r}`},ze=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],qe=[{value:"2026 Summer",label:"2026 Summer"},{value:"2026 Fall",label:"2026 Fall"},{value:"2027",label:"2027"},{value:"2028 & Later",label:"2028 & Later"}],D={control:l=>({...l,borderRadius:"0.5rem",borderColor:"#E5E7EB",minHeight:"40px",whiteSpace:"nowrap"}),valueContainer:l=>({...l,overflowX:"hidden"}),placeholder:l=>({...l,fontSize:"14px"}),dropdownIndicator:l=>({...l,display:"none"}),indicatorSeparator:l=>({...l,display:"none"})};function Ge({formData:l,setFormData:t,handleSubmit:T,submitFromModal:r,handleOpenScheduler:Y,showScheduler:v,setShowScheduler:w,isRescheduling:ue,existingLead:x,handleOpenExistingSpace:X,handleOpenReschedulePanel:J,availableDates:C,generateTimeSlots:B,isLoading:g,errors:i,showSuccessModal:Q,successMeetLink:L,successScheduledSlot:$,handleModalContinue:Z,allCountries:ee,isOtpSent:O,otpValue:F,setOtpValue:te,isSendingOtp:P,isVerifyingOtp:V,isPhoneVerifiedLocal:I,canResendOtp:H,resendCountdown:ne,useWhatsApp:R,handleSendOtp:E,handleVerifyOtp:se,handleResendOtp:oe,toggleOtpMethod:W,countryCode:le,userProfile:f,isEmailPrefilledFromProfile:y}){const _=()=>{if(!Q)return null;const a=l.hasOfferLetter==="No",h=!!$;let A="Thank You for Your Interest!",N="Our accommodation team is reviewing your preferences and will reach out shortly.";return a?N="Accommodation support is available once you have a confirmed offer letter. Come back and we'll help you find the right place to stay.":h&&(A="Consultation booked",N=`Your accommodation consultation is confirmed for ${$}. A UniAcco counsellor will reach out at that time via your Nbyula Space.`),De.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 p-4",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl bg-white p-8 text-center shadow-2xl",children:[e.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-full bg-blue-100",children:e.jsx("svg",{className:"h-8 w-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h2",{className:"mb-3 text-xl font-bold text-gray-900",children:A}),e.jsx("p",{className:"mb-6 text-gray-600",children:N}),!h&&!a&&L&&e.jsx("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"mb-3 block w-full rounded-lg bg-indigo-600 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-indigo-700",children:"Join Meeting Now"}),e.jsx("button",{onClick:Z,className:`w-full rounded-lg px-6 py-3 text-sm font-medium transition-colors ${!h&&!a&&L?"border border-indigo-600 bg-white text-indigo-600 hover:bg-indigo-50":"bg-indigo-600 text-white hover:bg-indigo-700"}`,children:"Continue"})]})}),document.getElementById("modal")||document.body)};return e.jsxs("div",{className:"flex min-h-screen",children:[e.jsx("div",{className:"fixed top-0 left-0 right-0 z-10 bg-gradient-to-br from-indigo-50 to-purple-200 p-4 lg:hidden",children:e.jsxs("div",{className:"mx-auto max-w-lg",children:[e.jsx("center",{children:e.jsx(Ye,{dark:!0,className:"mb-4 h-8"})}),e.jsx("h1",{className:"mb-2 text-center text-xl font-bold text-gray-900",children:"Find your student accommodation abroad"}),e.jsx("p",{className:"text-center text-sm text-gray-600",children:"Verified rooms, zero brokerage, and the best prices guaranteed"})]})}),e.jsx("div",{className:"hidden w-1/2 bg-gradient-to-br from-indigo-50 to-purple-200 p-8 lg:block",children:e.jsxs("div",{className:"mx-auto max-w-lg",children:[e.jsx("center",{children:e.jsx(Ve,{dark:!0,className:"mb-12 h-8"})}),e.jsx("h1",{className:"mb-3 text-center text-3xl font-bold text-gray-900",children:"Find your student accommodation abroad"}),e.jsx("p",{className:"mb-12 text-center text-gray-600",children:"Verified rooms, zero brokerage, and the best prices guaranteed"}),e.jsx("div",{className:"relative",children:e.jsx("div",{className:"relative h-96",children:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-md",children:e.jsx("img",{src:"/planner/slide-1.webp",alt:"Student Accommodation",className:"h-full w-full rounded-lg object-contain"})})})}),e.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2 rounded-full bg-gradient-to-r from-indigo-600 to-purple-600 px-4 py-2 text-white",children:e.jsx("span",{className:"text-sm font-medium",children:"ð¥ Trusted by 200k+ aspirants"})}),e.jsx("div",{className:"flex items-center gap-2 rounded-full bg-gradient-to-r from-indigo-600 to-purple-600 px-4 py-2 text-white",children:e.jsx("span",{className:"text-sm font-medium",children:"â Average rating 4.6 stars"})})]})]})}),e.jsx("div",{className:"mt-32 w-full bg-white p-6 lg:mt-0 lg:w-1/2 lg:overflow-y-auto lg:p-12",children:e.jsxs("div",{className:"mx-auto max-w-lg",children:[e.jsx("h2",{className:"mb-6 text-lg font-semibold text-gray-800",children:x?"Your accommodation enquiry":"Tell us about your stay
1so we can find verified options:"}),x&&e.jsx(M,{}),!x&&e.jsxs("form",{onSubmit:T,className:"space-y-5",noValidate:!0,children:[e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["Do you have a college offer letter?"," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(de,{options:ze,styles:{...D,control:a=>({...D.control(a),borderColor:i.hasOfferLetter?"#ef4444":"#E5E7EB"})},placeholder:"Select",value:l.hasOfferLetter?{label:l.hasOfferLetter,value:l.hasOfferLetter}:null,onChange:a=>t("hasOfferLetter",a?a.value:"")}),i.hasOfferLetter&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.hasOfferLetter})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["Which country will you be studying in?"," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(de,{isSearchable:!0,styles:{...D,control:a=>({...D.control(a),borderColor:i.studyCountry?"#ef4444":"#E5E7EB"})},placeholder:"Start typing to search",options:ee,onChange:a=>t("studyCountry",a?a.value:""),value:l.studyCountry?{label:l.studyCountry,value:l.studyCountry}:null,isClearable:!0,className:"text-sm",noOptionsMessage:({inputValue:a})=>a?"No countries found":"Start typing to search..."}),i.studyCountry&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.studyCountry})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["Which city will you be studying in?"," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:l.studyCity,onChange:a=>t("studyCity",a.target.value),className:`w-full rounded-lg border px-4 py-2.5 text-sm ${i.studyCity?"border-red-500":"border-gray-300"}`,placeholder:"e.g., London"}),i.studyCity&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.studyCity})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["Which intake are you targeting?"," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(de,{options:qe,styles:{...D,control:a=>({...D.control(a),borderColor:i.intake?"#ef4444":"#E5E7EB"})},placeholder:"Select intake",value:l.intake?{label:l.intake,value:l.intake}:null,onChange:a=>t("intake",a?a.value:"")}
1),i.intake&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.intake})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["When do you plan to move to the destination country?"," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"date",value:l.plannedMoveDate,onChange:a=>t("plannedMoveDate",a.target.value),min:We(),className:`w-full rounded-lg border px-4 py-2.5 text-sm ${i.plannedMoveDate?"border-red-500":"border-gray-300"}`}),i.plannedMoveDate&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.plannedMoveDate})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["Approximate monthly accommodation budget (in INR)"," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",min:G,max:K,step:"1000",value:l.monthlyBudgetINR,onChange:a=>t("monthlyBudgetINR",a.target.value),className:`w-full rounded-lg border px-4 py-2.5 text-sm ${i.monthlyBudgetINR?"border-red-500":"border-gray-300"}`,placeholder:"e.g., 60000"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:["Between â¹",G.toLocaleString("en-IN")," and â¹",K.toLocaleString("en-IN")," per month"]}),i.monthlyBudgetINR&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.monthlyBudgetINR})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:l.fullName,onChange:a=>t("fullName",a.target.value),className:`w-full rounded-lg border px-4 py-2.5 text-sm focus:ring-indigo-500 ${i.fullName?"border-red-500 focus:border-red-500":"border-gray-300 focus:border-indigo-500"}`,placeholder:"Enter your full name"}),i.fullName&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:i.fullName})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["Mobile Number ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Fe,{excludeCountries:Me,country:le.toLowerCase()||"in",value:l.phone,onChange:a=>t("phone",a),containerClass:"w-full",inputStyle:{width:"100%",height:"40px",fontSize:"14px",borderRadius:"0.5rem",borderColor:i.phone?"#EF4444":"#D1D5DB"},buttonStyle:{borderRadius:"0.5rem 0 0 0.5rem",borderColor:i.phone?"#EF4444":"#D1D5DB"},disabled:I,countryCodeEditable:!1}),i.phone&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:i.phone}),!I&&e.jsx("div",{className:"mt-3 space-y-3",children:O?e.jsxs("div",{className:"space-y-3 rounded-lg border border-indigo-100 bg-indigo-50 p-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:"Enter 6-digit OTP"}),e.jsx("input",{type:"text",value:F,onChange:a=>{const h=a.target.value.replace(/\D/g,"");h.length<=6&&te(h)},maxLength:6,className:"w-full rounded-lg border border-indigo-200 px-4 py-2.5 text-center text-lg font-semibold tracking-widest focus:border-indigo-500 focus:ring-indigo-500",placeholder:"000000",autoFocus:!0})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"button",onClick:se,disabled:V||F.length!==6,className:"flex-1 rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white transition-colors duration-200 hover:bg-indigo-700 disabled:opacity-50",children:V?"Verifying...":"Verify OTP"}),e.jsx("button",{type:"button",onClick:oe,disabled:!H||P,className:"flex-1 rounded-lg border border-indigo-600 bg-white px-4 py-2 text-sm font-medium text-indigo-600 transition-colors duration-200 hover:bg-indigo-50 disabled:opacity-50",children:H?P?"Sending...":"Resend OTP":`Resend in ${ne}s`})]}),e.jsxs("p",{className:"text-xs text-gray-600",children:["OTP sent to +",l.phone," via"," ",R?"WhatsApp":"SMS"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:E,disabled:P||!l.phone||l.phone.length<10||i.phone,className:"w-full rounded-lg border border-indigo-600 bg-white px-4 py-2 text-sm font-medium text-indigo-600 transition-colors duration-200 hover:bg-indigo-50 disabled:cursor-not-allowed disabled:opacity-50",children:P?"Sending OTP...":R?"Send OTP via WhatsApp":"Send OTP via SMS"}),e.jsx(Ae,{}),W&&e.jsxs("div",{className:"text-center text-xs",children:[e.jsxs("span",{className:"text-gray-600",children:[R?"Prefer SMS?":"Prefer WhatsApp?"," "]}),e.jsx("button",{type:"button",onClick:W,className:"font-medium text-purple-600 hover:underline",children:R?"Get OTP via SMS":"Get OTP via WhatsApp"})]})]})}),I&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-sm text-green-600",children:[e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"font-medium",children:"Phone number verified"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-gray-900",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:l.email,onChange:a=>t("email",a.target.value),disabled:y,className:`w-full rounded-lg border px-4 py-2.5 text-sm focus:ring-indigo-500 ${i.email?"border-red-500 focus:border-red-500":y?"cursor-not-allowed border-gray-200 bg-gray-50 text-gray-500":"border-gray-300 focus:border-indigo-500"}`,placeholder:"Enter your email address"}),i.email&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:i.email})]}),(()=>{const a=l.hasOfferLetter==="No",h=((f==null?void 0:f.phone)||"").replace(/\D/g,""),A=(l.phone||"").replace(/\D/g,""),N=!!(f!=null&&f._id)&&!!(f!=null&&f.isPhoneVerified)&&h.length>
10&&h===A,U=!a&&!I&&!N;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-6",children:[e.jsx("button",{type:"submit",disabled:g||U,className:"w-full rounded-lg bg-indigo-600 py-3 text-sm font-medium text-white transition-colors duration-200 hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50",children:g?"Please wait...":"Submit"}),e.jsx(Be,{})]}),!a&&e.jsx("div",{className:"mt-3 text-center",children:e.jsx("button",{type:"button",onClick:Y,disabled:g||U,className:"text-sm font-medium text-indigo-600 underline hover:text-indigo-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Or schedule a call for later"})}),U&&e.jsx("p",{className:"mt-2 text-center text-xs text-gray-500",children:"Please verify your phone number to continue"})]})})()]})]})}),e.jsx(He,{showScheduler:v,setShowScheduler:w,availableDates:C,generateTimeSlots:B,formData:l,setFormData:t,handleSubmit:r||T,isLoading:g,isQualified:!1}),e.jsx(_,{})]});function M(){if(!x)return null;const a=x.type==="scheduled"&&!!x.scheduledDate,h=a?new Date(x.scheduledDate).toLocaleString("en-IN",{timeZone:"Asia/Kolkata",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}):null;return e.jsxs("div",{className:"mb-6 rounded-lg border border-indigo-200 bg-gradient-to-r from-indigo-50 via-white to-purple-50 p-5",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 text-indigo-600",children:[e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-sm font-semibold",children:a?"Your consultation is booked":"We already have your enquiry"})]}),e.jsx("p",{className:"mb-4 text-sm text-gray-600",children:a?`A UniAcco counsellor will reach out to you on ${h} IST via your Nbyula Space. You can open the Space now to share anything up-front, or reschedule the slot if it no longer works.`:"Our accommodation team has your details and is looking at verified options for you. Open your Space to pick up where you left off."}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx("button",{type:"button",onClick:X,disabled:g||!x.conversationId,className:"flex-1 rounded-lg bg-indigo-600 px-4 py-2.5 text-sm font-medium text-white transition-colors hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Open your Space"}),a&&e.jsx("button",{type:"button",onClick:J,disabled:g,className:"flex-1 rounded-lg border border-indigo-600 bg-white px-4 py-2.5 text-sm font-medium text-indigo-600 transition-colors hover:bg-indigo-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Reschedule"})]})]})}}const Ke=30,Xe=10,Je=0,Qe=19,Ze=0,et=10,tt=30,nt=19,st=0,ve=[],ce=l=>l?l.length===46&&l.startsWith("phone")&&l.endsWith("mail.nbyula.com"):!1;function xt(){const l=Le(),t=xe(s=>{var n;return s==null||(n=s.user)===null||n===void 0?void 0:n.profile}),T=xe(s=>{var n,o;return(s==null||(n=s.payments)===null||n===void 0||(o=n.location)===null||o===void 0?void 0:o.countryCode)||""}),[r,Y]=u.useState({fullName:t!=null&&t.firstName&&t!==null&&t!==void 0&&t.lastName?`${t.firstName} ${t.lastName}`.trim():(t==null?void 0:t.firstName)||"",phone:(t==null?void 0:t.phone)||"",email:t!=null&&t.email&&!ce(t==null?void 0:t.email)?t.email:"",hasOfferLetter:"",studyCountry:"",studyCity:"",intake:"",plannedMoveDate:"",monthlyBudgetINR:"",selectedDate:null,selectedTimeSlot:null}),[v,w]=u.useState(!1),[ue,x]=u.useState(""),[X,J]=u.useState(""),[C,B]=u.useState(null),[g,i]=u.useState(!1),{isOtpSent:Q,otpValue:L,setOtpValue:$,isSendingOtp:Z,isVerifyingOtp:ee,isPhoneVerifiedLocal:O,canResendOtp:F,resendCountdown:te,useWhatsApp:P,handleSendOtp:V,handleVerifyOtp:I,handleResendOtp:H,toggleOtpMethod:ne}=$e(r.phone,r.fullName),[R,E]=u.useState({}),[se,oe]=u.useState((t==null?void 0:t.email)&&!ce(t==null?void 0:t.email)),W=async()=>{const s=await V();s!=null&&s.requiresName&&E(n=>({...n,fullName:"Please enter your full name"}))},le=async()=>{const s=await H();s!=null&&s.requiresName&&E(n=>({...n,fullName:"Please enter your full name"}))},f=u.useRef(!1),y=u.useRef(!1),[_,M]=u.useState(!1),[a,h]=u.useState(!1),[A,N]=u.useState([]),[U]=u.useState(()=>{const s=[];let n=S(),o=0;for(;s.length<5&&o<14;){const d=n.day()===0,c=ve.includes(n.format("YYYY-MM-DD"));!d&&!c&&Ne(n)&&s.push(n.clone()),n=n.add(1,"day"),o+=1}return s});function Ne(s){const n=me(s);return!!n&&n.length>0}function me(s){if(ve.includes(s.format("YYYY-MM-DD")))return null;const n=S(),o=s.day()===6,d=o?et:Xe,c=o?tt:Je,p=o?nt:Qe,k=o?st:Ze,m=[];let j=S(s).hour(d).minute(c);const Ee=S(s).hour(p).minute(k);for(;j<=Ee;)j.isAfter(n)&&m.push(j.clone()),j.add(Ke,"minutes");return m.length>0?m:null}const je=s=>me(s),he=async({phone:s,gamePlayerId:n}={})=>{const o=s??r.phone??(t==null?void 0:t.phone)??"",d=n??(t==null?void 0:t._id)??"";if(!o&&!d)return null;try{const{data:c}=await z.post(`${q}/v1/virtual-office/accommodation/check-lead-status`,{phone:o,gamePlayerId:d}),p=(c==null?void 0:c.existingLead)||null;return B(p),p}catch(c){return ge(c,{extra:{message:"Accommodation check-lead-status failed"}}),null}},fe=u.useRef(!1);u.useEffect(()=>{if(fe.current)return;const s=t==null?void 0:t.phone,n=t==null?void 0:t._id;!s&&!n||(fe.current=!0,he({phone:s,gamePlayerId:n}))},[t==null?void 0:t.phone,t==null?void 0:t._id]);const ae=u.useRef(!1);u.useEffect(()=>{if(!O){ae.current=!1;return}ae.current||r.phone&&(ae.current=!0,he({phone:r.phone}))},[O,r.phone]),u.useEffect(()=>{(async()=>{try{const{data:n}=await z.get(`${q}/v1/program-finder/program/attributes`);if(n){const d=n.country.map(c=>({value:c.key,label:c.key}));N(d)}}catch(n){N(Ue),ge(n,{extra:{message:"Could not fetch attributes - countries, using the cache data"}})}})()},[]),u.useEffect(()=>{if(t){const s=t!=null&&t.firstName&&t!==null&&t!==void 0&&t.lastName?`${t.firstName} ${t.lastName}`.trim():(t==null?void 0:t.firstName)||"",n=t!=null&&t.email&&!ce(t==null?void 0:t.email)?t.email:"";Y(o=>({...o,fullName:s||o.fullName,phone:(t==null?void 0:t.phone)||o.phone,email:n||o.email})),oe(!!n)}},[t]);const pe=(s,n)=>{switch(s){case"fullName":return!n||n.trim().length<2?"Please enter your full name":"";case"phone":return!n||n.length<10?"Please enter a valid phone number":"";case"email":return!n||n.trim().length===0?"Please enter your email address":/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?"":"Please enter a valid email address";case"hasOfferLetter":return n?"":"Please select if you have an offer letter";case"studyCountry":return n?"":"Please select the country you'll be studying in";case"studyCity":return!n||n.trim().length===0?"Please enter your city of study":"";case"intake":return n?"":"Please select your intake";
1case"plannedMoveDate":{if(!n)return"Please select your planned move date";const o=n.split("-").map(Number);if(o.length!==3||o.some(isNaN))return"Please enter a valid date";const[d,c,p]=o,k=new Date(d,c-1,p);if(isNaN(k.getTime()))return"Please enter a valid date";const m=new Date;return m.setHours(0,0,0,0),k<m?"Please choose a future move date":""}case"monthlyBudgetINR":{if(!n)return"Please enter your monthly accommodation budget";const o=Number(n);return isNaN(o)?"Please enter a valid amount":o<G?`Please enter a budget of at least â¹${G.toLocaleString("en-IN")}`:o>K?`Please enter a budget under â¹${K.toLocaleString("en-IN")}`:""}default:return""}},Se=new Set(["fullName","studyCity"]),we=(s,n)=>{Se.has(s)&&(f.current=!1),Y(o=>({...o,[s]:n})),E(o=>({...o,[s]:pe(s,n)}))},re=({q1Only:s=!1}={})=>{const n=s?["hasOfferLetter"]:["fullName","phone","email","hasOfferLetter","studyCountry","studyCity","intake","plannedMoveDate","monthlyBudgetINR"],o={};return n.forEach(d=>{o[d]=pe(d,r[d])}),E(o),!Object.values(o).some(d=>d)},Ce=async()=>{const s=[{value:r.fullName,key:"fullName",message:"Please enter a valid name",serviceName:ye.VIRTUAL_OFFICE_NAME,contentType:be.PROFILE.VIRTUAL_OFFICE_NAME},{value:r.studyCity,key:"studyCity",message:"Please enter a valid city",serviceName:ye.VIRTUAL_OFFICE_CITY,contentType:be.VIRTUAL_OFFICE.CITY}];return Promise.all(s.filter(({value:n})=>n==null?void 0:n.trim()).map(({value:n,serviceName:o,contentType:d})=>_e(n,o,d,{},null,!0))).catch(n=>console.error("UGC challenge failed:",n)),f.current=!0,!0},ie=async s=>{if(s&&s.preventDefault&&s.preventDefault(),_||y.current)return;if(r.hasOfferLetter==="No"){if(!re({q1Only:!0}))return;h(!0);return}if(!re()){b.error("Please fill in all required fields");return}const n=(t==null?void 0:t.phone)||"",o=r.phone||"",d=!!(t!=null&&t._id)&&!!n&&!!(t!=null&&t.isPhoneVerified)&&n.replace(/\D/g,"")===o.replace(/\D/g,"");if(!O&&!d){b.error("Please verify your phone number before proceeding");return}if(v&&(!r.selectedDate||!r.selectedTimeSlot)){b.error("Please choose a date and time slot");return}y.current=!0,M(!0);try{if(!f.current&&!await Ce())return;const c={fullName:r.fullName,phone:r.phone,email:r.email,hasOfferLetter:r.hasOfferLetter,studyCountry:r.studyCountry,studyCity:r.studyCity,intake:r.intake,plannedMoveDate:r.plannedMoveDate,monthlyBudgetINR:Number(r.monthlyBudgetINR),type:v?"scheduled":"immediate",page_link:window.location.href};if(v){const j=S(r.selectedDate).hour(r.selectedTimeSlot.hour()).minute(r.selectedTimeSlot.minute()).second(0).millisecond(0).toDate();c.scheduledDate=j.toISOString()}const k=new URLSearchParams(window.location.search).get("fbclid");if(k){const j=Date.now();c.fbclid=`fb.1.${j}.${k}`}const{data:m}=await z.post(`${q}/v1/virtual-office/accommodation/submit`,c);if(!v&&m!==null&&m!==void 0&&m.conversationId){l.push(`/conversations/${m.conversationId}`);return}v&&m!==null&&m!==void 0&&m.scheduledDate&&J(S(m.scheduledDate).utcOffset("+05:30").format("D MMM, h:mm A [IST]")),m!=null&&m.meetLink&&x(m.meetLink),h(!0),w(!1)}catch(c){console.error("Accommodation form submit failed:",c),b.error("Something went wrong. Please try again later.")}finally{y.current=!1,M(!1)}},Oe=()=>{h(!1),l.push("/")},ke=()=>{C!=null&&C.conversationId&&l.push(`/conversations/${C.conversationId}`)},Te=()=>{i(!0),w(!0)},Pe=async s=>{if(s&&s.preventDefault&&s.preventDefault(),!(_||y.current)){if(!r.selectedDate||!r.selectedTimeSlot){b.error("Please choose a date and time slot");return}y.current=!0,M(!0);try{const d=S(r.selectedDate).hour(r.selectedTimeSlot.hour()).minute(r.selectedTimeSlot.minute()).second(0).millisecond(0).toDate(),{data:c}=await z.post(`${q}/v1/virtual-office/accommodation/reschedule-outbound`,{phone:r.phone||(t==null?void 0:t.phone)||void 0,gamePlayerId:(t==null?void 0:t._id)||void 0,scheduledTime:d.toISOString()});b.success(`Rescheduled to ${S(c.scheduledDate).utcOffset("+05:30").format("D MMM, h:mm A [IST]")}`),B(p=>p&&{...p,type:"scheduled",scheduledDate:c.scheduledDate}),w(!1),i(!1)}catch(d){var n,o;console.error("Reschedule error:",d),b.error((d==null||(n=d.response)===null||n===void 0||(o=n.data)===null||o===void 0?void 0:o.message)||"Could not reschedule. Please try again.")}finally{y.current=!1,M(!1)}}},Ie=s=>g?Pe(s):ie(s),Re=()=>{if(r.hasOfferLetter==="No"){ie();return}if(!re()){b.error("Please fill in all required fields before scheduling");return}const s=(t==null?void 0:t.phone)||"",n=r.phone||"",o=!!(t!=null&&t._id)&&!!s&&s.replace(/\D/g,"")===n.replace(/\D/g,"");if(!O&&!o){b.error("Please verify your phone number before scheduling");return}w(!0)};return e.jsx(Ge,{formData:r,setFormData:we,handleSubmit:ie,submitFromModal:Ie,handleOpenScheduler:Re,showScheduler:v,setShowScheduler:w,isRescheduling:g,existingLead:C,handleOpenExistingSpace:ke,handleOpenReschedulePanel:Te,availableDates:U,generateTimeSlots:je,isLoading:_,errors:R,showSuccessModal:a,successMeetLink:ue,successScheduledSlot:X,handleModalContinue:Oe,allCountries:A,isOtpSent:Q,otpValue:L,setOtpValue:$,isSendingOtp:Z,isVerifyingOtp:ee,isPhoneVerifiedLocal:O,canResendOtp:F,resendCountdown:te,useWhatsApp:P,handleSendOtp:W,handleVerifyOtp:I,handleResendOtp:le,toggleOtpMethod:ne,countryCode:T,userProfile:t,isEmailPrefilledFromProfile:se})}export{xt as default}; 2//# sourceMappingURL=AccommodationVirtualOfficeContainer-iYjTBwwC.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.