@eka-care/abha 0.1.52 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -143,4 +143,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
143
143
  pds2-transition-colors pds2-duration-200
144
144
  `,tabIndex:-1,ref:et,children:jsxRuntimeExports.jsx("p",{className:`${$?"pds2-text-text-brand Body2Semibold":"pds2-text-text-01 Body2Medium"}`,children:a})})}const CreateEkaProfileScreen=()=>{const a=useAuthAbhaStore(xt=>xt.screen),_=useAuthAbhaStore(xt=>xt.selectedAbhaAddress),$=useAuthAbhaStore(xt=>xt.setBottomsheetErrorInfo),_e=useAuthAbhaStore(xt=>xt.clearAbhaAuthStore),et=useAuthAbhaStore(xt=>xt.goBackLoginScreen),[tt,rt]=reactExports.useState(LOADING_STATE.IDLE),[nt,it]=reactExports.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),[at,st]=reactExports.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),[ut,ot]=reactExports.useState(null),{mutateAsync:pt}=usePostProfileSwitch(),[ht,ft]=reactExports.useState(!1),vt=useAuthAbhaStore(xt=>xt.ekaProfileInfo),lt=useAuthAbhaStore(xt=>xt.setEkaProfileInfo),dt=useAuthAbhaStore(xt=>xt.setScreen),ct=a[a.length-1],mt=useAuthAbhaStore(xt=>xt.aadhaarVerificationSkipStateStatus),yt=queryClient.getQueryData(["abdmProfilePhrResponse"]),Et=useAuthAbhaStore(xt=>xt.abhaAuthFlowMethod);reactExports.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),useAuthAbhaStore(xt=>xt.isDocAppRequest);const St=useAuthAbhaStore(xt=>xt.clientId),bt=useAuthAbhaStore(xt=>xt.isEkaAppLogin),kt=useAuthAbhaStore(xt=>xt.isNewLoginOrCreateFlow),Ot=useAuthAbhaStore(xt=>xt.txnId),Rt=GET_EXTRA_HEADERS(),[Pt,Dt]=reactExports.useState(null),Mt=useAuthAbhaStore(xt=>xt.abhaAuthFlowMethod),Tt=({name:xt,data:Ct={}})=>{var It,Lt;const Nt={...{login_platform:St,is_eka_app_login:bt?"true":"false",is_new_login_or_create_flow:kt?"true":"false",txn_id:Ot||"missing txnId",oid:Rt!=null&&Rt["X-User-ID"]?"true":"false",access_token:Rt!=null&&Rt.auth?"true":"false",flow:Mt??""},...Ct};handleSendEvent({eventName:xt,eventData:Nt}),(Lt=(It=window.curio)==null?void 0:It.pushToMixpanel)==null||Lt.call(It,xt,Nt)};reactExports.useEffect(()=>{Tt({name:"page_view",data:{page_view:"create_profile_screen"}})},[St]),reactExports.useEffect(()=>{var xt;if((xt=window.EkaAbha)!=null&&xt.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var Ct,wt;(Ct=window.EkaAbha)!=null&&Ct.changeStatusBarColor&&((wt=window==null?void 0:window.EkaAbha)==null||wt.changeStatusBarColor("#FFFFFF"))}},[]),reactExports.useEffect(()=>{if(yt){const{first_name:xt,last_name:Ct,gender:wt,pincode:Nt,day_of_birth:It,month_of_birth:Lt,year_of_birth:Bt}=yt,$t=It===0?1:It,jt=`${Bt}-${String(Lt===0?1:Lt).padStart(2,"0")}-${String($t).padStart(2,"0")}`;Tt({name:"profile_data_set_from_phr_cache",data:{source:"phr_cache",date_of_birth:jt,firstname:xt??"missing",lastname:Ct??"missing",gender:wt??"missing",pincode:Nt??"missing",dob_day:It??"missing",dob_month:Lt??"missing",dob_year:Bt??"missing",flow:Mt??""}}),it({firstname:xt,lastname:Ct,gender:wt,pincode:Nt,date_of_birth:jt});return}if(vt){let xt="1983",Ct="01",wt="01";if(vt.date_of_birth){const It=vt.date_of_birth.split("-");xt=It[0],Ct=It[1]==="00"||!It[1]?"01":It[1],wt=It[2]==="00"||!It[2]?"01":It[2]}const Nt=`${xt}-${String(Ct).padStart(2,"0")}-${String(wt).padStart(2,"0")}`;it({firstname:vt.firstname,lastname:vt.lastname,gender:vt.gender,pincode:vt.pincode,date_of_birth:Nt,oid:vt.oid}),Tt({name:"profile_data_set_from_eka_profile",data:{source:"eka_profile",date_of_birth:(vt==null?void 0:vt.date_of_birth)??"missing",firstname:(vt==null?void 0:vt.firstname)??"missing",lastname:(vt==null?void 0:vt.lastname)??"missing",gender:(vt==null?void 0:vt.gender)??"missing",pincode:(vt==null?void 0:vt.pincode)??"missing",oid:(vt==null?void 0:vt.oid)??"missing"}})}},[yt,vt]);const _t=reactExports.useMemo(()=>!!(nt.firstname&&!at.firstname&&nt.date_of_birth&&!at.date_of_birth&&nt.pincode&&!at.pincode&&nt.gender&&!at.gender),[nt,at]),At=async()=>{var Ct,wt,Nt,It;const xt={firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""};if(st(xt),nt.firstname.trim()||(xt.firstname="Enter Name"),nt.lastname.trim()||(xt.lastname="This field is required"),nt.date_of_birth||(xt.date_of_birth="Enter DOB"),nt.gender||(xt.gender="Select Gender"),nt.pincode||(xt.pincode="Enter Valid Pincode"),!!_t){if(Tt({name:"create_profile_screen_clicks",data:{type:"create_profile"}}),rt(LOADING_STATE.LOADING),ct===SCREEN_NAMES.CREATE_EKA_PROFILE){if(Tt({name:"navigate_to_create_abha_address_screen",data:{type:"next",pincode_entered:(nt==null?void 0:nt.pincode)??"unknown",eka_profile_info_pincode:(vt==null?void 0:vt.pincode)??"unknown",flow_type:Et||"unknown_method"}}),Et===ABHA_AUTH_FLOW_METHOD.MOBILE){const Lt=await getPincodeDetails({pincode:Number(nt.pincode)});if(Lt!=null&&Lt.error){Dt(Lt!=null&&Lt.error?"Invalid Pincode":null),rt(LOADING_STATE.REJECTED),Tt({name:"pincode_api_failed",data:{type:"error",error:Lt==null?void 0:Lt.error}});return}if(Tt({name:"pincode_api_success",data:{type:"verify",pincode_received:!!Lt.pincode,txn_id:Ot}}),Lt!=null&&Lt.pincode){ot(null),lt(nt),Tt({name:"eka_profile_info_set",data:{firstname:nt==null?void 0:nt.firstname,lastname:nt==null?void 0:nt.lastname,gender:nt==null?void 0:nt.gender,pincode:nt==null?void 0:nt.pincode,date_of_birth:nt==null?void 0:nt.date_of_birth}}),dt(SCREEN_NAMES.CREATE_ABHA_ADDRESS);return}Tt({name:"no_action_on_pincode",data:{type:"verify",pincode_entered:!!Lt.pincode,txn_id:Ot}});return}else if(Et===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER){lt(nt),Tt({name:"eka_profile_info_set",data:{firstname:nt==null?void 0:nt.firstname,lastname:nt==null?void 0:nt.lastname,gender:nt==null?void 0:nt.gender,pincode:nt==null?void 0:nt.pincode,date_of_birth:nt==null?void 0:nt.date_of_birth}}),dt(SCREEN_NAMES.CREATE_ABHA_ADDRESS);return}}if(ct===SCREEN_NAMES.CREATE_PHR_EKA_PROFILE){if(!_){Tt({name:"abha_create_eka_profile_abha_address_missing",data:{platform:St}});return}const[Lt,Bt,$t]=nt.date_of_birth?(Ct=nt==null?void 0:nt.date_of_birth)==null?void 0:Ct.split("-"):["","",""],Xt={abha_address:_,day_of_birth:parseInt($t),first_name:nt.firstname,gender:nt.gender,last_name:nt.lastname||"",month_of_birth:parseInt(Bt),pincode:nt.pincode,year_of_birth:parseInt(Lt)};Tt({name:"profile_eka_process_started",data:{platform:St,date_of_birth:(nt==null?void 0:nt.date_of_birth)||null,dob_day:$t||null,dob_month:Bt||null,dob_year:Lt||null}});const{error:jt,eka:Ht,action:Vt}=await postAbdmProfileEka({...Xt});if(Vt){Tt({name:"profile_eka_process_failed",data:{platform:St,error_message:((wt=Vt==null?void 0:Vt.cta)==null?void 0:wt.title)||"unknown_error",error_message_exists:!!((Nt=Vt==null?void 0:Vt.cta)!=null&&Nt.title)}}),$(Vt);return}if(jt||!Ht||!Ht.oid){Tt({name:"profile_process_failed",data:{platform:St,error_message:jt||"Unknown error",eka_oid:(Ht==null?void 0:Ht.oid)||"missing",eka_exists:!!Ht,date_of_birth:(nt==null?void 0:nt.date_of_birth)||"missing",dob_day:$t||"missing",dob_month:Bt||"missing",dob_year:Lt||"missing",parsed_date_valid:!!(parseInt($t)&&parseInt(Bt)&&parseInt(Lt)),firstname:(nt==null?void 0:nt.firstname)||"missing",gender:(nt==null?void 0:nt.gender)||"missing",pincode:(nt==null?void 0:nt.pincode)||"missing"}}),rt(LOADING_STATE.REJECTED),ot(jt||"Something went wrong. Please try again.");return}Tt({name:"profile_eka_process_success",data:{platform:St,eka:Ht}}),Tt({name:"profile_switch_process_started",data:{platform:St,error_message:jt,eka:Ht}});const Yt=await pt({oid:Ht.oid});if(Yt.error){Tt({name:"profile_switch_process_failed",data:{platform:St,error_message:Yt.error||"Something went wrong, please try again",error_message_exists:!!Yt.error}}),rt(LOADING_STATE.REJECTED),ot(((It=Yt.error)==null?void 0:It.message)||"Something went wrong, please try again");return}Tt({name:"profile_switch_process_success",data:{platform:St,eka:Ht}}),rt(LOADING_STATE.RESOLVED);return}}},gt=()=>{et();const xt=useAuthAbhaStore.getState().isEkaAppLogin;_e(),useAuthAbhaStore.setState({isEkaAppLogin:xt})};return jsxRuntimeExports.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-bg-bg-01 pds2-h-full",children:[jsxRuntimeExports.jsx(Pds2Header,{title:"Create ABHA Address",prefixIcon:jsxRuntimeExports.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>ft(!0),children:jsxRuntimeExports.jsx(n$2,{className:""})}),className:"pds2-bg-bg-white"}),jsxRuntimeExports.jsx(AbhaStepper,{}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-flex-1 pds2-p-8 pds2-overflow-y-auto",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-items-center pds2-justify-between"}),jsxRuntimeExports.jsx(UserDetailsForm,{profileData:nt,setProfileData:it,error:at,setError:st,pincodeApiError:Pt})]}),ut&&jsxRuntimeExports.jsx("div",{className:"pds2-p-16 pds2-text-text-error pds2-text-center",children:ut}),jsxRuntimeExports.jsxs("div",{className:"pds2-sticky pds2-bottom-0 pds2-bg-bg-white pds2-w-full",children:[_&&mt===ABHA_V3_SKIP_STATES.ABHA_END?jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-items-center pds2-justify-between pds2-w-full pds2-px-16 pds2-py-6 pds2-bg-border-brand-02",children:[jsxRuntimeExports.jsxs("div",{className:"",children:[jsxRuntimeExports.jsx("span",{className:"pds2-text-text-03 Body2Regular",children:"Creating for: "}),jsxRuntimeExports.jsx("span",{className:"pds2-text-text-01 Body2Semibold",children:_})]}),jsxRuntimeExports.jsx("button",{onClick:et,className:"Body2Semibold pds2-text-text-brand pds2-rounded-full ripple pds2-px-8 pds2-py-2",children:"Change"})]}):null,jsxRuntimeExports.jsx("div",{className:"pds2-p-16 pds2-w-full",children:jsxRuntimeExports.jsx(Pds2Button,{className:"pds2-w-full",title:"Create Profile",state:tt===LOADING_STATE.LOADING?"disabled":"enabled",onClick:At,isLoading:tt===LOADING_STATE.LOADING})})]}),jsxRuntimeExports.jsx(AbhaErrorBottomSheet,{onSubmitClick:gt}),jsxRuntimeExports.jsx(ExitPopup,{open:ht,setOpen:ft})]})},genders=[{id:"M",name:"Male"},{id:"F",name:"Female"},{id:"O",name:"Other"}],UserDetailsForm=({profileData:a,setProfileData:_,error:$,setError:_e,pincodeApiError:et})=>{const tt=({event:st,name:ut})=>{const ot=st.target.value;let pt="";switch(ut){case"firstname":ot.trim()?pt="":pt="This field is required";break;case"lastname":!ot||ot.length<0?pt="This field is required":pt="";break;case"pincode":!ot||isNaN(Number(ot))||ot.length!=6?pt="Pincode must consist of exactly 6 digits":pt="";break;case"date_of_birth":!ot||ot>new Date().toISOString().split("T")[0]?pt="Date of Birth is invalid":pt="";break}_e({...$,[ut]:pt}),_({...a,[ut]:ot})},rt=st=>{_({...a,gender:st}),_e({...$,gender:""})},nt=(st,ut)=>ut!=null&&ut.pincode||!((st.firstname??"").trim()!==""&&(st.gender??"").trim()!==""&&(st.date_of_birth??"").trim()!=="")?!1:!st.pincode||(st.pincode+"").length!==6,it=useAuthAbhaStore(st=>st.ekaProfileInfo),at=useAuthAbhaStore(st=>st.abhaAuthFlowMethod);return jsxRuntimeExports.jsxs("form",{className:"pds2-flex pds2-flex-col pds2-space-y-32 pds2-pt-16 pds2-px-16",children:[jsxRuntimeExports.jsxs("label",{className:"pds2-space-y-8",children:[jsxRuntimeExports.jsxs("div",{className:"Body3Medium pds2-text-text-04",children:["Your name",jsxRuntimeExports.jsx("span",{className:"pds2-text-text-error Body3Semibold",children:"*"})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-gap-8",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-col",children:[jsxRuntimeExports.jsx(Pds2InputField,{isMandatory:!0,textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:"focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2",placeholder:"Firstname",value:a.firstname,onChange:st=>tt({event:st,name:"firstname"}),autoCapitalize:"on",disabled:!!(it!=null&&it.firstname)&&at===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER,error:$.firstname}),$.firstname&&jsxRuntimeExports.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-4",children:$.firstname})]}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(Pds2InputField,{textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:"focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2",placeholder:"Lastname",value:a.lastname,onChange:st=>tt({event:st,name:"lastname"}),autoCapitalize:"on",disabled:!!(it!=null&&it.lastname)&&at===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER})})]})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-space-y-8",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-space-y-4",children:[jsxRuntimeExports.jsxs("div",{className:"Body3Medium pds2-text-text-04",children:["Gender",jsxRuntimeExports.jsx("span",{className:"pds2-text-text-error Body3Semibold",children:"*"})]}),jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-gap-16",children:genders.map((st,ut)=>jsxRuntimeExports.jsx("div",{className:`${$.gender?"pds2-border-2 pds2-rounded-12 pds2-border-text-error placeholder:pds2-text-text-error":"focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2 placeholder:pds2-text-text-04"}`,children:jsxRuntimeExports.jsx(Pds2SingleInputChip,{isSelected:st.id===a.gender,title:st.name,onSelect:()=>rt(st.id)})},ut))}),$.gender&&jsxRuntimeExports.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-2",children:$.gender})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-col",children:[jsxRuntimeExports.jsx(Pds2InputField,{label:"Date of Birth",isMandatory:!0,textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:"focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2",value:a.date_of_birth,disabled:!!(it!=null&&it.date_of_birth)&&at===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER,onChange:st=>tt({event:st,name:"date_of_birth"}),type:"date",maxDate:new Date().toISOString().split("T")[0],error:$.date_of_birth}),$.date_of_birth&&jsxRuntimeExports.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-2",children:$.date_of_birth})]})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-space-y-4",children:[jsxRuntimeExports.jsx(Pds2InputField,{label:"Pincode",isMandatory:!0,textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:nt(a,it)||et?"pds2-border-1 pds2-border-text-error":"",value:a.pincode,placeholder:"Enter Pincode",disabled:!!(it!=null&&it.pincode)&&at===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER,onChange:st=>{st.target.value.length>6||tt({event:st,name:"pincode"})},type:"number",error:nt(a,it)?$.pincode:"",textStyle:nt(a,it)||et?"placeholder:pds2-text-text-error":"placeholder:pds2-text-text-04"}),et||$.pincode&&jsxRuntimeExports.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-4",children:$.pincode})]})]})},useGetProfilesPhrUser=()=>useQuery({queryKey:["profilesPhrUserResponse"],queryFn:async()=>{const a=await getProfilePhrUser();var _;return Array.isArray(a)?_=a==null?void 0:a.filter(_e=>!_e["health-ids"]||_e["health-ids"].length===0):_=[],{profiles:_}}}),GetAllProfilesScreen=()=>{const a=useAuthAbhaStore(ft=>ft.setScreen);useAuthAbhaStore(ft=>ft.screen),useAuthAbhaStore(ft=>ft.goBackLoginScreen),useAuthAbhaStore(ft=>ft.clearAbhaAuthStore);const[_,$]=reactExports.useState(!1);reactExports.useState("");const _e=useAuthAbhaStore(ft=>ft.clientId),et=useAuthAbhaStore(ft=>ft.aadhaarVerificationSkipStateStatus),tt=useAuthAbhaStore(ft=>ft.isEkaAppLogin),rt=useAuthAbhaStore(ft=>ft.isNewLoginOrCreateFlow),nt=useAuthAbhaStore(ft=>ft.txnId),it=GET_EXTRA_HEADERS(),at=useAuthAbhaStore(ft=>ft.abhaAuthFlowMethod),st=({name:ft,data:vt={}})=>{var ct,mt;const dt={...{login_platform:_e,is_eka_app_login:tt?"true":"false",is_new_login_or_create_flow:rt?"true":"false",txn_id:nt||"missing txnId",oid:it!=null&&it["X-User-ID"]?"true":"false",access_token:it!=null&&it.auth?"true":"false",flow:at??""},...vt};handleSendEvent({eventName:ft,eventData:dt}),(mt=(ct=window.curio)==null?void 0:ct.pushToMixpanel)==null||mt.call(ct,ft,dt)};reactExports.useEffect(()=>{if(_e==="doctor"){st({name:"page_view",data:{platform:_e,page_view:"get-all-profiles-screen"}}),st({name:"redirect_to_create_eka_profile_screen",data:{type:"next"}}),a(SCREEN_NAMES.CREATE_EKA_PROFILE);return}},[_e]);let ut=!1;tt?ut=!1:tt||(_e==="doctor"?ut=!1:ut=!0);const{data:ot,error:pt,isLoading:ht}=ut?useGetProfilesPhrUser():{data:null,error:null,isLoading:!1};return reactExports.useEffect(()=>{if(_e==="doctor")return;(async()=>{!ht&&ot&&($(!0),await new Promise(vt=>setTimeout(vt,2e3)),$(!1),!ot.profiles||ot.profiles.length<1?et===ABHA_V3_SKIP_STATES.ABHA_END?(st({name:"redirect_to_create_phr_eka_profile_screen",data:{type:"next",skip_state:et}}),a(SCREEN_NAMES.CREATE_PHR_EKA_PROFILE)):(st({name:"redirect_to_create_eka_profile_screen",data:{type:"next",skip_state:et}}),a(SCREEN_NAMES.CREATE_EKA_PROFILE)):(st({name:"redirect_to_select_eka_profile_screen",data:{type:"next",skip_state:et}}),a(SCREEN_NAMES.SELECT_EKA_PROFILE)))})()},[ht,ot]),_?jsxRuntimeExports.jsx(AbhaVerificationStatus,{loading:!0,loadingText:"In progress...",successText:""}):null},usePostAbdmProfileLoginPhr=()=>{const a=useAuthAbhaStore(_=>_.setSelectedAbhaAddress);return useMutation({mutationFn:({txn_id:_,phr_address:$})=>postAbdmProfileLoginPhr({txn_id:_,phr_address:$}),onSuccess(_){_.profile&&(queryClient.setQueryData(["abdmProfilePhrResponse"],_.profile),a(_.profile.abha_address))}})},SelectAbhaFromListScreen=()=>{var Xt;const[a,_]=reactExports.useState(null),$=useAuthAbhaStore(jt=>jt.setScreen),_e=useAuthAbhaStore(jt=>jt.goBackLoginScreen),et=useAuthAbhaStore(jt=>jt.txnId),tt=useAuthAbhaStore(jt=>jt.authTxnId),rt=useAuthAbhaStore(jt=>jt.abhaAddressList),nt=useAuthAbhaStore(jt=>jt.setBottomsheetErrorInfo),it=useAuthAbhaStore(jt=>jt.clearAbhaAuthStore),at=useAuthAbhaStore(jt=>jt.setSelectedAbhaAddress),st=useAuthAbhaStore(jt=>jt.abhaAuthFlowMethod);useAuthAbhaStore(jt=>jt.loginIdentifierValue);const[ut,ot]=reactExports.useState(""),[pt,ht]=reactExports.useState(!1),ft=useAuthAbhaStore(jt=>jt.setEkaProfileInfo),vt=useAuthAbhaStore(jt=>jt.setAbhaAuthFlowMethod),lt=useAuthAbhaStore(jt=>jt.setAadhaarVerificationSkipStateStatus),dt=useAuthAbhaStore(jt=>jt.identifierValue),[ct,mt]=reactExports.useState(LOADING_STATE.IDLE),yt=["M","F","O","U"],{mutateAsync:Et}=usePostAuthVerifyV2(),{mutateAsync:St}=usePostAbdmProfileLoginPhr();useAuthAbhaStore(jt=>jt.ekaProfileInfo),useAuthAbhaStore(jt=>jt.registrationType);const bt=useAuthAbhaStore(jt=>jt.clientId),kt=useAuthAbhaStore(jt=>jt.isEkaAppLogin),Ot=useAuthAbhaStore(jt=>jt.setRegistrationType),Rt=useAuthAbhaStore(jt=>jt.abhaAuthFlowMethod),Pt=useAuthAbhaStore(jt=>jt.identityValue),Dt=useAuthAbhaStore(jt=>jt.setMobileInitResponse),[Mt,Tt]=reactExports.useState({aadhaar:LOADING_STATE.IDLE,mobile:LOADING_STATE.IDLE}),_t=useAuthAbhaStore(jt=>jt.setAadhaarInitResponse),At=useAuthAbhaStore(jt=>jt.setSelectedAbhaFlow),gt=useAuthAbhaStore(jt=>jt.isNewLoginOrCreateFlow),xt=GET_EXTRA_HEADERS(),Ct=useAuthAbhaStore(jt=>jt.setLoginIdentifierValue),[wt,Nt]=reactExports.useState(!1),It=({name:jt,data:Ht={}})=>{var Kt,Wt;const Yt={...{login_platform:bt,is_eka_app_login:kt?"true":"false",is_new_login_or_create_flow:gt?"true":"false",txn_id:et||"missing txnId",oid:xt!=null&&xt["X-User-ID"]?"true":"false",access_token:xt!=null&&xt.auth?"true":"false",flow:Rt??""},...Ht};handleSendEvent({eventName:jt,eventData:Yt}),(Wt=(Kt=window.curio)==null?void 0:Kt.pushToMixpanel)==null||Wt.call(Kt,jt,Yt)},Lt=async()=>{It({name:"abha_login_select_abha_init_started",data:{method:Rt,platform:bt}});const jt=(Ht,Vt)=>{Tt(Yt=>({...Yt,[Ht]:Vt}))};if(Ot(REGISTRATION_TYPE.CREATE),Rt===ABHA_AUTH_FLOW_METHOD.MOBILE){const{txn_id:Ht,hint:Vt,error:Yt,action:Kt}=await postRegisterMobileInit({mobile_number:Pt});if(Ht&&Vt){It({name:"abha_login_select_abha_mobile_init_success",data:{method:Rt,platform:bt,txn_id:Ht}}),Dt({authTxnId:tt,txnId:Ht,mobileOtpSentToHint:Vt}),At("mobile"),jt("mobile",LOADING_STATE.RESOLVED),Ot(REGISTRATION_TYPE.CREATE),$(SCREEN_NAMES.ABHA_PHONE_NUMBER_VERIFICATION);return}It({name:"abha_login_select_abha_init_failed",data:{method:Rt,platform:bt,reason:Yt||"unknown",reason_exists:!!Yt}}),jt("mobile",LOADING_STATE.REJECTED),Kt?nt(Kt):ot(Yt||"Something went wrong")}else if(Rt===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER){It({name:"abha_fetching_profiles",data:{method:Rt,platform:bt}}),$(SCREEN_NAMES.GET_ALL_PROFILES);return}},Bt=async()=>{var Ut,Qt,er,hr,ir,rr;if(st===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER&&a){mt(LOADING_STATE.LOADING),setIndividualEnv({extraHeaders:{auth:""}}),kt||await postAuthLogoutV2()||It({name:"logout_api_failed_before_init_on_continue_click",data:{method:Rt,platform:bt,reason:"logout_api_response_false"}});const{txn_id:Gt,error:zt,action:sr,hint:ur}=await postAbdmLoginInit({method:ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS,identifier:a.abha_address});if(It({name:"abha_abdm_login_init_triggered",data:{flow_step_type:"init",authTxnId:tt,ndhmTxnId:Gt,method:Rt}}),console.log("after postAbdmLoginInit",sr),console.log("after postAbdmLoginInit",sr),sr){It({name:"abha_abdm_login_init_abha_error_action",data:{method:Rt,platform:bt,action:((Ut=sr==null?void 0:sr.cta)==null?void 0:Ut.title)||"unknown",action_exists:!!((Qt=sr==null?void 0:sr.cta)!=null&&Qt.title)}}),nt(sr);return}if(zt){It({name:"abha_abdm_login_init_failed",data:{method:Rt,platform:bt,reason:zt||"unknown",reason_exists:!!zt}}),mt(LOADING_STATE.REJECTED),ot(zt||"Something went wrong. Please try again.");return}if(!Gt){ot("Something went wrong. Please try again.");return}It({name:"abha_login_init_success",data:{flow_step_type:"init",authTxnId:tt,ndhmTxnId:Gt,hint:ur}}),_t({authTxnId:tt,txnId:Gt,aadhaarOtpSentToHint:ur||null}),mt(LOADING_STATE.RESOLVED),Ct(a.abha_address),vt(ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS),$(SCREEN_NAMES.VERIFY_OTP_LOGIN_WITH_ABHA);return}if(!a)return;if(at(a.abha_address),console.log(ct,"from abha"),!et){It({name:"abha_login_select_abha_txnId_not_found",data:{platform:bt,reason:"txnId missing",reason_exists:!0}});return}mt(LOADING_STATE.LOADING),It({name:"abha_login_select_abha_verify_start",data:{platform:bt,txn_id:et}});const{error:jt,eka:Ht,profile:Vt,action:Yt,skip_state:Kt}=await St({txn_id:et,phr_address:a.abha_address});if(Yt){It({name:"abha_login_select_abha_error_action",data:{platform:bt,txn_id:et,action:((er=Yt==null?void 0:Yt.cta)==null?void 0:er.title)||"unknown",action_exists:!!((hr=Yt==null?void 0:Yt.cta)!=null&&hr.title)}}),nt(Yt);return}if(jt||!Ht){It({name:"abha_login_select_abha_abdm_error",data:{platform:bt,txn_id:et,error_message:jt||"eka object missing",error_exists:!!jt}}),mt(LOADING_STATE.REJECTED),ot(jt);return}if(!Kt){ot("skip State is missing");return}if(It({name:"abha_login_select_abha_verify_success",data:{platform:bt,txn_id:et,skip_state:Kt}}),lt(Kt),Vt&&(It({name:"abha_login_select_abha_profile_received",data:{platform:bt}}),ft({date_of_birth:`${Vt.year_of_birth}-${String(Vt.month_of_birth).padStart(2,"0")}-${String(Vt.day_of_birth).padStart(2,"0")}`,firstname:Vt.first_name,lastname:Vt.last_name,pincode:Vt.pincode,gender:Vt.gender,name:Vt.first_name+" "+Vt.last_name,mobile:Vt.mobile,oid:Ht==null?void 0:Ht.oid,middlename:Vt.middle_name,abha_address:Vt.abha_address,abha_number:Vt.abha_number}),at(Vt.abha_address)),kt){if(!Ht.oid){It({name:"abha_login_select_abha_oid_null",data:{platform:bt,oid:(Ht==null?void 0:Ht.oid)??"null_or_undefined"}}),mt(LOADING_STATE.REJECTED);return}const Gt=yt.includes(Vt==null?void 0:Vt.gender)?Vt==null?void 0:Vt.gender:void 0,zt={oid:(Ht==null?void 0:Ht.oid)||"",fln:(Vt==null?void 0:Vt.first_name)+" "+(Vt==null?void 0:Vt.last_name),dob:`${Vt==null?void 0:Vt.year_of_birth}-${String(Vt==null?void 0:Vt.month_of_birth).padStart(2,"0")}-${String(Vt==null?void 0:Vt.day_of_birth).padStart(2,"0")}`,gen:Gt,mobile:Vt==null?void 0:Vt.mobile,at:"",fn:(Vt==null?void 0:Vt.first_name)||"",mn:(Vt==null?void 0:Vt.middle_name)||"",ln:(Vt==null?void 0:Vt.last_name)||"","health-ids":Vt!=null&&Vt.abha_address?[Vt.abha_address]:void 0,abha_number:(Vt==null?void 0:Vt.abha_number)||""},sr=getMockAuthVerifyResponse(zt);if(mt(LOADING_STATE.RESOLVED),It({name:"abha_login_select_abha_inside_app_success",data:{platform:bt,oid:Ht.oid}}),window.EkaAbha&&window.EkaAbha.onAbhaSuccess){(ir=window.EkaAbha)==null||ir.onAbhaSuccess(JSON.stringify({response:sr}));return}onAbhaSuccess({response:sr}),unMount();return}if(!Ht.min_token||!tt){It({name:"abha_login_select_abha_min_token_missing",data:{platform:bt,oid:(Ht==null?void 0:Ht.oid)??"missing_oid",min_token:(Ht==null?void 0:Ht.min_token)??"missing_min_token",auth_txnId:tt??"missing_authTxnId"}}),mt(LOADING_STATE.REJECTED),ot(jt||"Something went wrong. Please try again.");return}const Wt=await Et({txn_id:tt,token:Ht.min_token,...Ht.oid?{oid:Ht.oid}:null});if(!Wt.data){It({name:"abha_login_select_abha_auth_verify_failed",data:{platform:bt,oid:(Ht==null?void 0:Ht.oid)??"missing_oid",min_token:(Ht==null?void 0:Ht.min_token)??"missing_min_token",auth_txnId:tt??"missing_authTxnId"}}),mt(LOADING_STATE.REJECTED),ot(((rr=Wt.error)==null?void 0:rr.message)||"Something went wrong, please try again");return}mt(LOADING_STATE.RESOLVED),It({name:"abha_login_select_abha_auth_verify_success",data:{platform:bt,oid:Ht.oid,min_token:Ht==null?void 0:Ht.min_token,auth_txnId:tt}})},$t=()=>{const jt=useAuthAbhaStore.getState().initAbhaAppMobileNumber,Ht=useAuthAbhaStore.getState().isEkaAppLogin;_e(),it(),useAuthAbhaStore.setState({initAbhaAppMobileNumber:jt}),useAuthAbhaStore.setState({isEkaAppLogin:Ht})};return reactExports.useEffect(()=>{if(!(rt!=null&&rt.length))return;const jt=rt.find(Ht=>Ht.kyc_verified==="VERIFIED");_(jt??null)},[]),jsxRuntimeExports.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-h-full pds2-bg-bg-01",children:[jsxRuntimeExports.jsx(Pds2Header,{title:"Select ABHA to continue",prefixIcon:jsxRuntimeExports.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>ht(!0),children:jsxRuntimeExports.jsx(n$2,{})}),suffixIcon:((Xt=rt==null?void 0:rt[0])==null?void 0:Xt.kyc_verified)&&jsxRuntimeExports.jsx(e$1,{onClick:()=>Nt(jt=>!jt),className:"pds2-w-20 pds2-h-20 pds2-text-icon-03 pds2-text-[2rem] hover:pds2-cursor-pointer"}),className:"pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white"}),jsxRuntimeExports.jsx(AbhaStepper,{}),wt&&jsxRuntimeExports.jsx("div",{onMouseLeave:()=>Nt(!1),className:"pds2-absolute pds2-right-10 pds2-top-45 pds2-mt-2 pds2-z-50 pds2-animate-fade-in",children:jsxRuntimeExports.jsx(TooltipContent,{})}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex-1 pds2-overflow-y-auto pds2-flex pds2-flex-col pds2-p-16 pds2-space-y-16",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-text-text-03 Body1Regular pds2-text-center",children:["We found ",rt==null?void 0:rt.length," ABHA addresses ",jsxRuntimeExports.jsx("br",{})," select one you want to log in with"]}),jsxRuntimeExports.jsx(AbhaList,{list:rt,selectedAbha:a,setSelectedAbha:_,handleContinueClick:Bt}),((rt==null?void 0:rt.length)??0)<6&&(st===ABHA_AUTH_FLOW_METHOD.MOBILE||st===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-gap-16",children:[jsxRuntimeExports.jsx(TextSeparator,{title:"or"}),jsxRuntimeExports.jsx(Pds2CustomButton,{title:"Create new ABHA Address",prefixIcon:jsxRuntimeExports.jsx(l$6,{}),className:"pds2-justify-center pds2-text-text-brand pds2-bg-border-brand-02 pds2-border-border-03 Body1Semibold",onClick:Lt})]})]}),st===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER&&jsxRuntimeExports.jsxs("div",{className:"pds2-text-center pds2-bg-bg-02 pds2-py-8",children:[jsxRuntimeExports.jsx("span",{className:"pds2-text-text-03 Body2Regular",children:"Your ABHA No: "}),jsxRuntimeExports.jsx("span",{className:"pds2-text-text-01 Body2Semibold",children:dt==null?void 0:dt.abha_number})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-bg-bg-white pds2-shadow-lg pds2-w-full pds2-sticky pds2-bottom-0 pds2-border-border-brand-02 pds2-p-16 z-10",children:[ut&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-4",children:ut}),jsxRuntimeExports.jsx(Pds2Button,{title:"Continue",state:a===null||ct===LOADING_STATE.LOADING?"disabled":"enabled",isLoading:ct===LOADING_STATE.LOADING,className:"pds2-w-full",onClick:Bt})]}),jsxRuntimeExports.jsx(AbhaErrorBottomSheet,{onSubmitClick:$t}),jsxRuntimeExports.jsx(ExitPopup,{open:pt,setOpen:ht})]})},AbhaList=({list:a,selectedAbha:_,setSelectedAbha:$,handleContinueClick:_e})=>jsxRuntimeExports.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-brand-02 pds2-w-full pds2-relative",children:a==null?void 0:a.map((et,tt)=>jsxRuntimeExports.jsxs(React.Fragment,{children:[jsxRuntimeExports.jsxs("label",{className:"pds2-p-16 pds2-flex pds2-space-x-8",children:[jsxRuntimeExports.jsx("input",{className:"pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14 pds2-p-2 checked:pds2-accent-text-brand",type:"radio",value:et.abha_address,checked:(_==null?void 0:_.abha_address)===et.abha_address,onChange:()=>{$(et)},onKeyDown:rt=>rt.key==="Enter"&&_e()}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-space-y-4 pds2-flex-1",children:[jsxRuntimeExports.jsxs("div",{className:"TitlesSubheadline pds2-text-text-primary pds2-flex pds2-flex-row pds2-items-center pds2-justify-between",children:[jsxRuntimeExports.jsx("div",{children:et==null?void 0:et.abha_address}),jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-flex-row pds2-items-center",children:(et==null?void 0:et.kyc_verified)&&(et.kyc_verified==="VERIFIED"?jsxRuntimeExports.jsx("div",{className:"Label1Bold pds2-rounded-full pds2-h-full",children:jsxRuntimeExports.jsx(t$1,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-success-02 pds2-text-[2rem]"})}):jsxRuntimeExports.jsx("div",{className:"Label1Bold pds2-rounded-full pds2-h-full",children:jsxRuntimeExports.jsx(s$3,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-orange-300 pds2-text-[2rem]"})}))})]}),jsxRuntimeExports.jsx("div",{className:"pds2-text-text-03 Body3Regular pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-4",children:(et==null?void 0:et.name)&&jsxRuntimeExports.jsx("div",{className:"Body3Regular pds2-text-text-03",children:et.name})})]})]}),tt!==a.length-1&&jsxRuntimeExports.jsx("div",{className:"pds2-px-16",children:jsxRuntimeExports.jsx("div",{className:"pds2-bg-border-03 pds2-h-1 pds2-w-full"})})]},et.abha_address))}),TooltipContent=()=>jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-py-14 pds2-bg-bg-purple-800 pds2-rounded-16 pds2-w-150 pds2-animate-slide-up",children:[jsxRuntimeExports.jsxs("div",{className:" pds2-px-16 pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-py-6",children:[jsxRuntimeExports.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-full",children:jsxRuntimeExports.jsx(s$3,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-orange-400"})}),jsxRuntimeExports.jsx("div",{className:"pds2-text-text-invert",children:"Non KYC"})]}),jsxRuntimeExports.jsxs("div",{className:" pds2-px-16 pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-py-6 pds2-border-t-1 pds2-border-[#FFFFFF4D]",children:[jsxRuntimeExports.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-full",children:jsxRuntimeExports.jsx(t$1,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-success-02"})}),jsxRuntimeExports.jsx("div",{className:"pds2-text-text-invert",children:"KYC"})]})]}),SelectEkaProfileScreen=()=>{var Dt;const a=useAuthAbhaStore(Mt=>Mt.setScreen),_=useAuthAbhaStore(Mt=>Mt.setEkaProfileInfo),$=useAuthAbhaStore(Mt=>Mt.registrationType),_e=useAuthAbhaStore(Mt=>Mt.goBackLoginScreen),[et,tt]=reactExports.useState(null),rt=useAuthAbhaStore(Mt=>Mt.setBottomsheetErrorInfo),nt=useAuthAbhaStore(Mt=>Mt.clearAbhaAuthStore),[it,at]=reactExports.useState(LOADING_STATE.IDLE),[st,ut]=reactExports.useState(!1),[ot,pt]=reactExports.useState(null),ht=useAuthAbhaStore(Mt=>Mt.selectedAbhaAddress),ft=useAuthAbhaStore(Mt=>Mt.aadhaarVerificationSkipStateStatus),{mutateAsync:vt}=usePostProfileSwitch(),lt=queryClient.getQueryData(["profilesPhrUserResponse"]),dt=useAuthAbhaStore(Mt=>Mt.clientId),ct=useAuthAbhaStore(Mt=>Mt.isEkaAppLogin),mt=useAuthAbhaStore(Mt=>Mt.isNewLoginOrCreateFlow),yt=useAuthAbhaStore(Mt=>Mt.txnId),Et=GET_EXTRA_HEADERS(),St=useAuthAbhaStore(Mt=>Mt.abhaAuthFlowMethod),bt=({name:Mt,data:Tt={}})=>{var gt,xt;const At={...{login_platform:dt,is_eka_app_login:ct?"true":"false",is_new_login_or_create_flow:mt?"true":"false",txn_id:yt||"missing txnId",oid:Et!=null&&Et["X-User-ID"]?"true":"false",access_token:Et!=null&&Et.auth?"true":"false",flow:St??""},...Tt};handleSendEvent({eventName:Mt,eventData:At}),(xt=(gt=window.curio)==null?void 0:gt.pushToMixpanel)==null||xt.call(gt,Mt,At)};reactExports.useEffect(()=>{bt({name:"choose_eka_profile_screen",data:{platform:dt,type:"select"}})},[dt]);const kt=()=>{if(bt({name:"create_family_profile_clicks",data:{platform:dt,type:"create",skip_state:ft}}),ft===ABHA_V3_SKIP_STATES.ABHA_END){bt({name:"navigate_to_create_phr_profile_screen",data:{platform:dt}}),a(SCREEN_NAMES.CREATE_PHR_EKA_PROFILE);return}bt({name:"navigate_to_create_eka_profile_screen",data:{platform:dt}}),a(SCREEN_NAMES.CREATE_EKA_PROFILE)},Ot=async({profile:Mt})=>{bt({name:"select_profile_clicks",data:{platform:dt,oid:Mt.oid}}),tt(Mt.oid)},Rt=async()=>{var gt,xt,Ct,wt;if(bt({name:"continue_click_on_choose_eka_profile",data:{platform:dt,selectedProfileOid:et,registrationType:$,skip_state:ft}}),et&&ft===ABHA_V3_SKIP_STATES.ABHA_CREATE){const Nt=lt==null?void 0:lt.profiles.find(It=>It.oid===et);if(!Nt){bt({name:"continue_click_profile_not_found",data:{platform:dt,oid:et||"unknown_oid",oid_exists:!!et}});return}bt({name:"navigate_to_create_eka_profile_screen_from_abha_create",data:{platform:dt,oid:Nt.oid}}),_({oid:Nt.oid,date_of_birth:Nt.dob,firstname:Nt.fn,lastname:Nt.ln,pincode:"",gender:Nt.gen,mobile:Nt.mobile,name:Nt.fln,middlename:Nt.mn,abha_address:(gt=Nt==null?void 0:Nt["health-ids"])==null?void 0:gt[0],abha_number:Nt.abha_number}),a(SCREEN_NAMES.CREATE_EKA_PROFILE);return}if(!ht||!et){bt({name:"continue_click_missing_profile_or_abha",data:{platform:dt,oid:et||"missing_oid",oid_exists:!!et}});return}bt({name:"linking_abha_to_profile_start",data:{platform:dt,oid:et||"missing_oid",oid_exists:!!et}}),at(LOADING_STATE.LOADING);const{error:Mt,action:Tt,eka:_t}=await postAbdmProfileEkaLinkPhr({abha_address:ht,oid:et});if(Tt){bt({name:"linking_abha_to_profile_error_action",data:{platform:dt,oid:et||"missing_oid",oid_exists:!!et}}),rt(Tt);return}if(Mt||!_t||!_t.oid){bt({name:"linking_abha_to_profile_failed",data:{platform:dt,oid:et||"missing_oid",oid_exists:!!et,error:Mt||"No EKA/OID",error_exists:!!Mt}}),at(LOADING_STATE.REJECTED),pt(Mt||"Something went wrong. Please try again.");return}const At=await vt({oid:_t.oid});if(At.error){bt({name:"profile_switch_failed_after_link",data:{platform:dt,oid:(_t==null?void 0:_t.oid)||"missing_oid",oid_exists:!!(_t!=null&&_t.oid),error:((xt=At.error)==null?void 0:xt.message)||"unknown_error",error_exists:!!((Ct=At.error)!=null&&Ct.message)}}),at(LOADING_STATE.REJECTED),pt(((wt=At.error)==null?void 0:wt.message)||"Something went wrong, please try again");return}bt({name:"linking_abha_to_profile_success",data:{platform:dt,oid:_t.oid}}),at(LOADING_STATE.RESOLVED)},Pt=()=>{_e();const Mt=useAuthAbhaStore.getState().isEkaAppLogin;nt(),useAuthAbhaStore.setState({isEkaAppLogin:Mt})};return jsxRuntimeExports.jsxs("div",{className:"pds2-w-full pds2-h-full pds2-flex pds2-flex-col pds2-bg-bg-01",children:[jsxRuntimeExports.jsx(Pds2Header,{title:"Select Eka Profile",prefixIcon:jsxRuntimeExports.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>ut(!0),children:jsxRuntimeExports.jsx(n$2,{})}),className:"pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white"}),jsxRuntimeExports.jsx(AbhaStepper,{}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-relative pds2-bg-bg-01 pds2-overflow-y-auto",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-flex-1 pds2-overflow-y-auto pds2-px-16 pds2-pt-24 pds2-pb-32",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-space-y-16 pds2-flex pds2-flex-col pds2-items-center pds2-text-center",children:[jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp",alt:"link-abha-to-eka-icon",className:"pds2-w-163"}),jsxRuntimeExports.jsxs("div",{className:"pds2-space-y-4",children:[jsxRuntimeExports.jsx("div",{className:"pds2-text-text-01 Heading3Semibold",children:"Choose an Eka Profile"}),jsxRuntimeExports.jsx("span",{className:"Body1Regular pds2-text-text-03",children:"Select the person for whom you want to create an ABHA address."})]})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-justify-center pds2-space-y-12 pds2-mt-24",children:[jsxRuntimeExports.jsx("div",{className:"pds2-text-text-03 Body2Medium pds2-text-center",children:"Select Eka Profile"}),jsxRuntimeExports.jsx("div",{className:"pds2-space-y-8",children:(Dt=lt==null?void 0:lt.profiles)==null?void 0:Dt.map(Mt=>{const Tt=et===Mt.oid;return jsxRuntimeExports.jsxs("label",{className:`pds2-flex pds2-items-center pds2-gap-x-8 pds2-cursor-pointer pds2-p-16 pds2-rounded-16 pds2-bg-bg-white pds2-border
145
145
  pds2-border-border-03 hover:pds2-bg-bg-hover-01
146
- pds2-transition-colors`,children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"ekaProfile",value:Mt.oid,checked:Tt,onChange:()=>Ot({profile:Mt}),className:"pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14",onKeyDown:_t=>_t.key==="Enter"&&Rt()}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-flex-1",children:[jsxRuntimeExports.jsx("div",{className:"TitlesSubheadline pds2-text-text-primary",children:Mt.fln}),jsxRuntimeExports.jsx("span",{className:"pds2-ml-auto pds2-text-text-brand pds2-text-14 pds2-font-600",children:"Link"})]})]},Mt.oid)})}),jsxRuntimeExports.jsx(TextSeparator,{title:"or"}),jsxRuntimeExports.jsx(Pds2CustomButton,{title:"Create new Family Member",prefixIcon:jsxRuntimeExports.jsx(l$6,{}),className:"pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold",onClick:kt})]})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-sticky pds2-bottom-0 pds2-left-0 pds2-right-0 pds2-bg-bg-white pds2-shadow-lg pds2-p-16",children:[ot&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-8",children:ot}),jsxRuntimeExports.jsx(Pds2Button,{title:"Continue",state:et===null||it===LOADING_STATE.LOADING?"disabled":"enabled",isLoading:it===LOADING_STATE.LOADING,className:"pds2-w-full",onClick:Rt})]})]}),jsxRuntimeExports.jsx(AbhaErrorBottomSheet,{onSubmitClick:Pt}),jsxRuntimeExports.jsx(ExitPopup,{open:st,setOpen:ut})]})},LoginorCreateAbhaScreen=()=>{const a=useAuthAbhaStore(_e=>_e.clientId);reactExports.useEffect(()=>{var _e;if((_e=window.EkaAbha)!=null&&_e.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var et,tt;(et=window.EkaAbha)!=null&&et.changeStatusBarColor&&((tt=window==null?void 0:window.EkaAbha)==null||tt.changeStatusBarColor("#FFFFFF"))}},[]);const _=()=>{var _e;(_e=window.EkaAbha)==null||_e.onAbhaClose(),unMount()},$=["eka-web","phr"];return jsxRuntimeExports.jsxs("div",{className:"pds2-h-full pds2-overflow-y-auto",children:[!$.includes(a)&&jsxRuntimeExports.jsx(Pds2Header,{prefixIcon:jsxRuntimeExports.jsx("button",{onClick:_,children:jsxRuntimeExports.jsx(n$2,{})}),title:"",className:"pds2-bg-bg-01"}),jsxRuntimeExports.jsx(LoginOrCreateWithDifferentMethods,{})]})},LoginOrCreateWithDifferentMethods=()=>{const a=useAuthAbhaStore(qt=>qt.abhaAuthFlowMethod||ABHA_AUTH_FLOW_METHOD.MOBILE),_=useAuthAbhaStore(qt=>qt.setAbhaAuthFlowMethod),$=useAuthAbhaStore(qt=>qt.goBackToLogin),_e=useAuthAbhaStore(qt=>qt.setGoBackToLogin);useAuthAbhaStore(qt=>qt.initAbhaAppIdentifierSource);const et=useAuthAbhaStore(qt=>qt.setIdentifierValue),tt=useAuthAbhaStore(qt=>qt.identifierValue),rt=useAuthAbhaStore(qt=>qt.isEkaAppLogin),nt=useAuthAbhaStore(qt=>qt.setSelectedAbhaAddress),it=useAuthAbhaStore(qt=>qt.setLoginIdentifierValue),at=useAuthAbhaStore(qt=>qt.setRegistrationType),st=useAuthAbhaStore(qt=>qt.setAadhaarInitResponse),ut=useAuthAbhaStore(qt=>qt.setMobileInitResponse),ot=useAuthAbhaStore(qt=>qt.initAbhaAppMobileNumber),pt=useAuthAbhaStore(qt=>qt.initAbhaAppIdentifierType),ht=useAuthAbhaStore(qt=>qt.initAbhaAppIdentifier),ft=useAuthAbhaStore(qt=>qt.setInitAbhaAppIdentifier),vt=useAuthAbhaStore(qt=>qt.isDocAppRequest),lt=useAuthAbhaStore(qt=>qt.isNewLoginOrCreateFlow),dt=useAuthAbhaStore(qt=>qt.setIsNewLoginOrCreateFlow),ct=useAuthAbhaStore(qt=>qt.clientId),mt=useAuthAbhaStore(qt=>qt.isInitApiTriggered),yt=useAuthAbhaStore(qt=>qt.setIsInitApiTriggered),Et=useAuthAbhaStore(qt=>qt.setIdentityValue);useAuthAbhaStore(qt=>qt.identityValue);const St=useAuthAbhaStore(qt=>qt.setSelectedAbhaFlow),bt=useAuthAbhaStore(qt=>qt.txnId),[kt,Ot]=reactExports.useState(LOADING_STATE.IDLE),[Rt,Pt]=reactExports.useState(""),Dt=useAuthAbhaStore(qt=>qt.setScreen),[Mt,Tt]=reactExports.useState({aadhaar:LOADING_STATE.IDLE,mobile:LOADING_STATE.IDLE}),[_t,At]=reactExports.useState(tt.mobile||""),[gt,xt]=reactExports.useState(!1),[Ct,wt]=reactExports.useState(!1),[Nt,It]=reactExports.useState(tt.aadhaar_number||""),[Lt,Bt]=reactExports.useState(tt.abha_number||""),[$t,Xt]=reactExports.useState(""),[jt,Ht]=reactExports.useState(tt.phr_address||""),Vt=reactExports.useRef(!1),Yt=GET_EXTRA_HEADERS();reactExports.useEffect(()=>{Kt({name:"abha_login_or_create_screen",data:{flow:a.toString()}})}),reactExports.useEffect(()=>{ht&&pt===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS?(Xt(ht),Ht(ht.split("@")[0]),et({phr_address:ht.split("@")[0]}),Gt(!0),gr(!0),_(ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS)):ht&&pt===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER?(et({abha_number:ht}),Bt(ht),Gt(!0),sr(!0),_(ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER)):ht&&pt===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?(It(ht),wt(!0),et({aadhaar_number:ht}),_(ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)):ht&&pt===ABHA_AUTH_FLOW_METHOD.MOBILE&&(At(ht),et({mobile:ht}),xt(ht.length===10),Pt(null),_(ABHA_AUTH_FLOW_METHOD.MOBILE))},[pt,ht]),reactExports.useEffect(()=>{mt||Vt.current||_t&&_t.length===10&&(yt(!0),Vt.current=!0,ir("auto_submit_mobile"))},[_t]),reactExports.useEffect(()=>{mt||Vt.current||Nt&&Nt.length===12&&(yt(!0),Vt.current=!0,ir("auto_submit_aadhaar"))},[Nt]),reactExports.useEffect(()=>{mt||Vt.current||Lt&&Lt.length===17&&(yt(!0),Vt.current=!0,ir("auto_submit_abha"))},[Lt]),reactExports.useEffect(()=>{mt||Vt.current||$t&&$t.includes("@abdm")&&(yt(!0),Vt.current=!0,ir("auto_submit_phr"))},[$t]);const Kt=({name:qt,data:ar={}})=>{var wr,br;const Er={...{login_platform:ct,is_eka_app_login:rt?"true":"false",is_new_login_or_create_flow:lt?"true":"false",oid:Yt!=null&&Yt["X-User-ID"]?"true":"false",access_token:Yt!=null&&Yt.auth?"true":"false",txn_id:bt||"missing txnId",flow:a??""},...ar};handleSendEvent({eventName:qt,eventData:Er}),(br=(wr=window.curio)==null?void 0:wr.pushToMixpanel)==null||br.call(wr,qt,Er)},Wt=React.useMemo(()=>{switch(a){case ABHA_AUTH_FLOW_METHOD.MOBILE:return"Enter your Mobile Number";case ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER:return"Enter your Aadhaar Number";default:return""}},[a]),Ut=qt=>{Pt("");const ar=qt.target.value;switch(a){case ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS:if(ar.length>20)return;Ht(ar),et({phr_address:ar}),ft(null);break;case ABHA_AUTH_FLOW_METHOD.MOBILE:if(ar&&!/^[0-9]+$/.test(ar)||ar.length>10)return;At(ar),xt(!0),et({mobile:ar}),ft(null);break;case ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER:if(!/^[\d-]*$/.test(ar)||ar.length>17)return;const xr=qt.target.value.replace(/-/g,"");let Er="";return xr.length>0&&(Er+=xr.slice(0,2)),xr.length>2&&(Er+=`-${xr.slice(2,6)}`),xr.length>6&&(Er+=`-${xr.slice(6,10)}`),xr.length>10&&(Er+=`-${xr.slice(10,14)}`),Bt(Er),ft(null),et({abha_number:Er.trim()});case ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER:if(ar&&!/^[0-9]+$/.test(ar)||ar.length>12)return;It(ar),wt(!0),ft(null),et({aadhaar_number:ar});break}};ABHA_AUTH_FLOW_METHOD.MOBILE;const Qt=React.useMemo(()=>{switch(a){case ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS:return tt.phr_address.length>=4&&tt.phr_address.length<=20;case ABHA_AUTH_FLOW_METHOD.MOBILE:return tt.mobile.length===10;case ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER:return tt.abha_number.length===17;case ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER:return tt.aadhaar_number.length===12}},[a,tt]),er=(qt,ar)=>{Tt(xr=>({...xr,[qt]:ar}))},hr=({inputVal:qt})=>{qt.length===12&&(et({aadhaar_number:qt}),It(qt),wt(!0))};reactExports.useEffect(()=>{console.log("selectedMethod changed:==================>",a)},[a]);const ir=async qt=>{var Er,wr,br;dt(!0),Kt({name:"abha_login_next_click",data:{flow_step_type:qt}}),Ot(LOADING_STATE.LOADING),at(REGISTRATION_TYPE.LOGIN);let ar="";if(!rt){const Ir=await postAuthLogoutV2();Kt({name:Ir?"abha_logout_success":"abha_logout_failure",data:{platform:ct}});const{txn_id:Mr,error:kr}=await postAuthInitV2({method:AUTH_METHOD.ABHA});if(!Mr||kr){Kt({name:"abha_auth_init_failure",data:{flow_step_type:"init",authTxnId:ar,error_message:kr||"missing_txnId_or_unknown_error",error_message_exists:!!kr,txn_id_exists:!!Mr}}),Pt((kr==null?void 0:kr.message)||"Something went wrong. Please try again."),Ot(LOADING_STATE.REJECTED);return}ar=Mr,Kt({name:"abha_auth_init_success.",data:{flow_step_type:"init",auth_txnId:ar}})}const xr=a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS?`${tt.phr_address}@abdm`:a===ABHA_AUTH_FLOW_METHOD.MOBILE?tt.mobile:a===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER?tt.abha_number:a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?tt.aadhaar_number:"";if(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER||a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS){const{txn_id:Ir,error:Mr,action:kr,hint:Fr}=await postAbdmLoginInit({method:a,identifier:xr});if(Et(xr),Kt({name:"abha_login_init_triggered",data:{flow_step_type:"init",authTxnId:ar,ndhmTxnId:Ir,method:a}}),a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS&&nt(xr),Mr||!Ir){if(_e(!0),((Er=kr==null?void 0:kr.cta)==null?void 0:Er.pid)==="abha_mobile_enroll"&&a===ABHA_AUTH_FLOW_METHOD.MOBILE){er("mobile",LOADING_STATE.LOADING),at(REGISTRATION_TYPE.CREATE);const{txn_id:Wr,hint:Vr,error:Cr,action:Jr}=await postRegisterMobileInit({mobile_number:tt.mobile});if(Et(tt.mobile),St("mobile"),Wr&&Vr){ut({authTxnId:ar,txnId:Wr,mobileOtpSentToHint:Vr}),Kt({name:"abha_mobile_registration_init_success",data:{flow_step_type:"init",authTxnId:ar,ndhmTxnId:Ir,error_message:Cr,error_action:kr}}),er("mobile",LOADING_STATE.RESOLVED),Ot(LOADING_STATE.RESOLVED),at(REGISTRATION_TYPE.CREATE),Dt(SCREEN_NAMES.ABHA_PHONE_NUMBER_VERIFICATION);return}if(er("mobile",LOADING_STATE.REJECTED),Kt({name:"abha_mobile_registration_init_failure",data:{flow_step_type:"init",authTxnId:ar,error_message:Cr||"unknown_error",error_message_exists:!!Cr,error_action_exists:!!Jr}}),Jr){if((wr=Jr==null?void 0:Jr.cta)!=null&&wr.pid)return Dt(SCREEN_NAMES.LOGIN_OR_CREATE_ABHA)}else Pt(Cr||"Something went wrong");Pt(Cr||"Something went wrong. Please try again."),Ot(LOADING_STATE.REJECTED);return}Kt({name:"abha_login_init_failure",data:{flow_step_type:"init",authTxnId:ar,error_message:Mr||"unknown_error",error_message_exists:!!Mr,error_action_exists:!!kr}}),Pt(Mr||"Something went wrong. Please try again."),Ot(LOADING_STATE.REJECTED);return}Kt({name:"abha_login_init_success",data:{flow_step_type:"init",authTxnId:ar,ndhmTxnId:Ir,hint:Fr}}),st({authTxnId:ar,txnId:Ir,aadhaarOtpSentToHint:Fr||null}),_e(!1),it(xr),Ot(LOADING_STATE.RESOLVED),Dt(SCREEN_NAMES.VERIFY_OTP_LOGIN_WITH_ABHA);return}if(a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER){er("aadhaar",LOADING_STATE.LOADING),Kt({name:"aadhaar_registration_init_start",data:{flow_step_type:"init",authTxnId:ar,aadhaarNumber:tt.aadhaar_number}});const{txn_id:Ir,hint:Mr,error:kr,action:Fr}=await postRegisterAadhaarInit({aadhaar_number:tt.aadhaar_number});if(Et(tt.aadhaar_number),St("aadhaar"),Ir&&Mr){st({authTxnId:ar,txnId:Ir,aadhaarOtpSentToHint:Mr}),Kt({name:"aadhaar_registration_init_success",data:{flow_step_type:"verify",ndhmTxnId:Ir,authTxnId:ar}}),_e(!1),er("aadhaar",LOADING_STATE.RESOLVED),at(REGISTRATION_TYPE.CREATE),Ot(LOADING_STATE.RESOLVED),Dt(SCREEN_NAMES.ABHA_OTP_AND_MOBILE);return}if(Kt({name:"abha_registration_init_failure",data:{error_message:kr||"unknown_error",error_message_exists:!!kr,auth_txn_id:ar,error_action:Fr,error_action_exists:!!Fr}}),er("aadhaar",LOADING_STATE.REJECTED),Ot(LOADING_STATE.REJECTED),Fr||kr){_e(!0),(br=Fr==null?void 0:Fr.cta)!=null&&br.pid?Dt(SCREEN_NAMES.LOGIN_OR_CREATE_ABHA):Pt(kr||"Something went wrong");return}}},[rr,Gt]=reactExports.useState(!1),[zt,sr]=reactExports.useState($&&a===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER),[ur,gr]=reactExports.useState($&&a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"pds2-pt-22 pds2-p-16 pds2-bg-bg-01 pds2-space-y-16 pds2-text-center pds2-rounded-b-24",children:[jsxRuntimeExports.jsx(AbhaStepper,{}),jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-center pds2-items-center pds2-gap-16",children:jsxRuntimeExports.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abdm-icon",className:"pds2-w-64 pds2-h-64"})})}),jsxRuntimeExports.jsx("div",{className:"Heading3Semibold pds2-text-text-black",children:ct==="phr"?"Login or Create your ABHA":vt?"Add Patient via ABHA":"Create your ABHA"}),jsxRuntimeExports.jsx("div",{className:"pds2-text-text-03",style:{marginTop:"4px"},children:a===ABHA_AUTH_FLOW_METHOD.MOBILE?vt?"Enter Patient's Mobile Number":"Enter your Mobile Number":a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?vt?"Enter Patient's Aadhaar Number":"Enter your Aadhaar Number":a===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER?vt?"Enter Patient's ABHA Number":"Enter your ABHA Number":a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS?vt?"Enter Patient's ABHA Address":"Enter your ABHA Address":Wt}),(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsxs("div",{className:"pds2-relative pds2-flex pds2-bg-bg-seperator-dark pds2-rounded-12 pds2-mt-4",children:[jsxRuntimeExports.jsx("div",{className:"pds2-absolute pds2-top-0 pds2-bottom-0 pds2-bg-bg-white pds2-rounded-12 pds2-transition-all pds2-duration-300",style:{left:a===ABHA_AUTH_FLOW_METHOD.MOBILE?0:"50%",width:"50%",boxShadow:"0px 10px 4px -6px #18274B17"}}),jsxRuntimeExports.jsxs("button",{onClick:()=>{_(ABHA_AUTH_FLOW_METHOD.MOBILE),Pt("")},className:"pds2-flex-1 pds2-py-6 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative pds2-z-10",children:[jsxRuntimeExports.jsx(n$1,{className:"pds2-w-14 pds2-h-14 pds2-text-icon-success-02"}),jsxRuntimeExports.jsx("span",{className:`pds2-text-base ${a===ABHA_AUTH_FLOW_METHOD.MOBILE?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:a===ABHA_AUTH_FLOW_METHOD.MOBILE?{fontWeight:700}:{fontWeight:400},children:"Mobile"})]}),jsxRuntimeExports.jsxs("button",{onClick:()=>{_(ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER),Pt("")},className:"pds2-flex-1 pds2-py-6 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative pds2-z-10",children:[jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm5mcdm3h00070tfs9fjkepff.webp",alt:"aadhaar-icon",className:"pds2-w-24 pds2-h-24"}),jsxRuntimeExports.jsx("span",{className:`pds2-text-base ${a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?{fontWeight:700}:{fontWeight:400},children:"Aadhaar"})]})]}),(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsx("div",{className:"pds2-mt-16 pds2-w-full pds2-max-w-md pds2-mx-auto pds2-px-4 pds2-relative",children:a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?jsxRuntimeExports.jsx(SpacedInputComponent,{initialValues:pt===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER&&!$?(ht==null?void 0:ht.match(/.{1,4}/g))??void 0:(Nt==null?void 0:Nt.match(/.{1,4}/g))??void 0,disabled:!$&&pt===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER&&!!ht,numberOfInputs:3,length:4,placeholder:"XXXX",onSubmit:hr,setIsValid:wt,setAadhaarValue:It,setError:Pt}):jsxRuntimeExports.jsx(Pds2InputField,{value:pt===ABHA_AUTH_FLOW_METHOD.MOBILE&&!$?ht||"":_t,disabled:!$&&pt===ABHA_AUTH_FLOW_METHOD.MOBILE&&!!ht,onChange:Ut,type:"tel",autoComplete:"tel-national",placeholder:"Mobile Number",inputMode:"numeric",autoFocus:!0,maxLength:10,PrefixComponent:jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-x-8 pds2-border-r pds2-border-border-brand-02 pds2-pr-24",children:[jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4mlct2900000tg98p8u967s.webp",alt:"indian-flag-icon",className:"pds2-w-24 pds2-h-24"}),jsxRuntimeExports.jsx("span",{className:"pds2-text-text-black pds2-text-sm",children:"+91"})]})})}),Rt&&(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error Body3Regular",children:Rt}),(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsx(Pds2Button,{title:"Next",IconComponent:()=>jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!Qt||kt===LOADING_STATE.LOADING?"disabled":"enabled",isLoading:kt===LOADING_STATE.LOADING,onClick:()=>ir("aadhaar_or_mobile_on_click"),className:"pds2-w-full"})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-m-16 pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-03 pds2-overflow-hidden",children:[jsxRuntimeExports.jsxs("button",{onClick:()=>Gt(!rr),className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-16 pds2-bg-bg-white hover:pds2-bg-bg-02 pds2-transition-colors",children:[jsxRuntimeExports.jsx("span",{className:"pds2-text-text-03",children:vt?"Other add options for ABHA":"Other login options for ABHA"}),jsxRuntimeExports.jsx(c$2,{className:`pds2-w-16 pds2-h-16 pds2-text-text-03 pds2-transition-transform ${rr?"pds2-rotate-180":""}`})]}),jsxRuntimeExports.jsxs("div",{className:`pds2-overflow-hidden pds2-transition-all pds2-duration-300 ${rr?"pds2-max-h-126 pds2-opacity-100":"pds2-max-h-0 pds2-opacity-0"}`,children:[jsxRuntimeExports.jsxs("button",{onClick:()=>{Gt(!1),_(ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER),sr(!0),Pt("")},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[jsxRuntimeExports.jsx("div",{className:"pds2-w-40 pds2-h-40 pds2-rounded-full pds2-bg-bg-02 pds2-flex pds2-items-center pds2-justify-center",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abdm-icon",className:"pds2-w-24 pds2-h-24"})}),jsxRuntimeExports.jsx("span",{className:"Body1Regular pds2-text-text-black",children:vt?"Add patient with ABHA Number":"Login with ABHA Number"})]}),jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]}),jsxRuntimeExports.jsxs("button",{onClick:()=>{Gt(!1),_(ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS),gr(!0),Pt("")},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[jsxRuntimeExports.jsx("div",{className:"pds2-w-40 pds2-h-40 pds2-rounded-full pds2-bg-bg-02 pds2-flex pds2-items-center pds2-justify-center",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA",className:"pds2-w-24 pds2-h-24"})}),jsxRuntimeExports.jsx("span",{className:"Body1Regular pds2-text-text-black",children:vt?"Add patient with ABHA Address":"Login with ABHA Address"})]}),jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]})]})]}),jsxRuntimeExports.jsx(AbhaBottomSheet,{isOpen:zt,setIsOpen:sr,setFlowMethod:_,setError:Pt,children:jsxRuntimeExports.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:jsxRuntimeExports.jsx("button",{onClick:()=>{Pt(null),sr(!1),_(ABHA_AUTH_FLOW_METHOD.MOBILE)},className:"pds2-w-24 pds2-h-24 pds2-flex pds2-items-center pds2-justify-center pds2-text-text-03 hover:pds2-text-text-black",children:"✕"})}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:jsxRuntimeExports.jsx("div",{className:"pds2-w-64 pds2-h-64 pds2-rounded-full pds2-bg-bg-01 pds2-flex pds2-items-center pds2-justify-center",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abdm-icon",className:"pds2-w-48 pds2-h-48"})})}),jsxRuntimeExports.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:vt?"Add Patient with ABHA Number":"Login with ABHA Number"}),jsxRuntimeExports.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:vt?"Enter Patient's 14 digit ABHA Number":"Enter your 14 digit ABHA Number"}),jsxRuntimeExports.jsx(Pds2InputField,{value:pt===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER&&!$?ht||"":Lt,disabled:!$&&pt===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER&&!!ht,onChange:Ut,placeholder:"00-0000-0000-0000",padding:"pds2-p-18",textStyle:"Body2Regular pds2-text-center pds2-text-lg",borderStyle:"focus-within:pds2-border-border-brand-01",type:"tel",autoComplete:"tel-national",inputMode:"numeric",autoFocus:!0,onKeyDown:qt=>{qt.key==="Enter"&&ir("after_enter_abha_number_on_click_by_user")}}),Rt&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error Body3Regular pds2-mt-12",children:Rt}),jsxRuntimeExports.jsx(Pds2Button,{title:"Next",IconComponent:()=>jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!tt||kt===LOADING_STATE.LOADING?"disabled":"enabled",onClick:()=>ir("after_enter_abha_number_on_click_by_user"),className:`pds2-w-full ${Rt?"pds2-mt-12":"pds2-mt-24"}`,isLoading:kt===LOADING_STATE.LOADING})]})]})}),jsxRuntimeExports.jsx(AbhaBottomSheet,{isOpen:ur,setIsOpen:gr,setFlowMethod:_,setError:Pt,children:jsxRuntimeExports.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:jsxRuntimeExports.jsx("button",{onClick:()=>{Pt(null),gr(!1),_(ABHA_AUTH_FLOW_METHOD.MOBILE)},className:"pds2-w-24 pds2-h-24 pds2-flex pds2-items-center pds2-justify-center pds2-text-text-03 hover:pds2-text-text-black",children:"✕"})}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:jsxRuntimeExports.jsx("div",{className:"pds2-w-64 pds2-h-64 pds2-rounded-full pds2-bg-bg-01 pds2-flex pds2-items-center pds2-justify-center",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abdm-icon",className:"pds2-w-48 pds2-h-48"})})}),jsxRuntimeExports.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:vt?"Add Patient with ABHA Address":"Login with ABHA Address"}),jsxRuntimeExports.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:vt?"Enter Patient's ABHA Address below":"Enter your ABHA Address below"}),jsxRuntimeExports.jsxs("div",{className:"pds2-relative",children:[jsxRuntimeExports.jsx(Pds2InputField,{value:pt===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS&&!$?(ht==null?void 0:ht.split("@")[0])||"":jt,disabled:!$&&pt===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS&&!!ht,onChange:Ut,placeholder:"Enter ABHA Address",inputMode:"text",autoFocus:!0,onKeyDown:qt=>{qt.key==="Enter"&&ir("after_enter_abha_address_on_click_by_user")}}),jsxRuntimeExports.jsx("div",{className:"pds2-absolute pds2-right-16 pds2-top-16 Body1Regular pds2-text-text-03",children:"@abdm"})]}),Rt&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error Body3Regular pds2-mt-12",children:Rt}),jsxRuntimeExports.jsx(Pds2Button,{title:"Next",IconComponent:()=>jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!tt||kt===LOADING_STATE.LOADING?"disabled":"enabled",onClick:()=>ir("after_enter_abha_address_on_click_by_user"),className:`pds2-w-full ${Rt?"pds2-mt-12":"pds2-mt-24"}`,isLoading:kt===LOADING_STATE.LOADING})]})]})})]})},AbhaBottomSheet=({isOpen:a,setIsOpen:_,children:$,setFlowMethod:_e,overlayClassName:et="pds2-bg-text-black pds2-bg-opacity-50",setError:tt})=>{const[rt,nt]=reactExports.useState(a);return reactExports.useEffect(()=>{if(a)nt(!0);else{const it=setTimeout(()=>nt(!1),300);return()=>clearTimeout(it)}},[a]),rt?jsxRuntimeExports.jsxs("div",{className:`pds2-absolute pds2-inset-0 pds2-z-50 pds2-flex pds2-items-end pds2-transition-all pds2-duration-300 ${a?"pds2-opacity-100":"pds2-opacity-0 pointer-events-none"}`,children:[jsxRuntimeExports.jsx("div",{className:`pds2-absolute pds2-inset-0 ${et} pds2-transition-opacity pds2-duration-300`,style:{backgroundColor:"rgba(0, 0, 0, 0.5)"},onClick:()=>{tt(null),_(!1),_e(ABHA_AUTH_FLOW_METHOD.MOBILE)}}),jsxRuntimeExports.jsx("div",{className:`pds2-relative pds2-bg-bg-white pds2-rounded-t-24 pds2-w-full pds2-transition-transform pds2-duration-300 ${a?"pds2-translate-y-0":"pds2-translate-y-full"}`,style:{height:"75%",maxHeight:"600px",overflowY:"auto"},children:$})]}):null},ScreenStack=()=>{const a=useAuthAbhaStore($=>$.screen);switch(a[a.length-1]){case SCREEN_NAMES.LOGIN_WITH_ABHA:return jsxRuntimeExports.jsx(LoginorCreateAbhaScreen,{});case SCREEN_NAMES.VERIFY_OTP_LOGIN_WITH_ABHA:return jsxRuntimeExports.jsx(AbhaLoginOtpVerifyScreen,{});case SCREEN_NAMES.CREATE_ABHA_WITH_AADHAAR:return jsxRuntimeExports.jsx(LoginorCreateAbhaScreen,{});case SCREEN_NAMES.ABHA_OTP_AND_MOBILE:return jsxRuntimeExports.jsx(AbhaOtpAndMobileScreen,{});case SCREEN_NAMES.ABHA_PHONE_NUMBER_VERIFICATION:return jsxRuntimeExports.jsx(AbhaPhoneNumberVerificationScreen,{});case SCREEN_NAMES.AADHAAR_VERIFICATION_STATUS:return jsxRuntimeExports.jsx(AbhaAadhaarVerificationStatusScreen,{});case SCREEN_NAMES.ABHA_MOBILE_LINKING_STATUS:return jsxRuntimeExports.jsx(AbhaMobileLinkingStatusScreen,{});case SCREEN_NAMES.SELECT_ABHA_FROM_LIST:return jsxRuntimeExports.jsx(SelectAbhaFromListScreen,{});case SCREEN_NAMES.SELECT_EKA_PROFILE:return jsxRuntimeExports.jsx(SelectEkaProfileScreen,{});case SCREEN_NAMES.CREATE_ABHA_ADDRESS:return jsxRuntimeExports.jsx(CreateAbhaAddressScreen,{});case SCREEN_NAMES.CREATE_EKA_PROFILE:return jsxRuntimeExports.jsx(CreateEkaProfileScreen,{});case SCREEN_NAMES.CREATE_PHR_EKA_PROFILE:return jsxRuntimeExports.jsx(CreateEkaProfileScreen,{});case SCREEN_NAMES.GET_ALL_PROFILES:return jsxRuntimeExports.jsx(GetAllProfilesScreen,{});case SCREEN_NAMES.LOGIN_OR_CREATE_ABHA:return jsxRuntimeExports.jsx(LoginorCreateAbhaScreen,{});default:return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}},queryClient=new QueryClient;function App(){return reactExports.useEffect(()=>()=>{unMount()},[]),jsxRuntimeExports.jsx(QueryClientProvider,{client:queryClient,children:jsxRuntimeExports.jsx("div",{className:"pds2-h-full pds2-w-full pds2-bg-bg-white",style:{borderRadius:GET_CLIENT_ID()==="www-eka"?"1.5rem":void 0,position:"relative",height:GET_CLIENT_ID()==="www-eka"?"75vh":GET_CLIENT_ID()==="doc-web"?"100%":"100vh",overflowY:"auto",paddingTop:GET_CLIENT_ID()==="androiddoc"||GET_CLIENT_ID()==="doctor-app-ios"||GET_CLIENT_ID()==="doctor-ipad-ios"?"1rem":"0rem"},children:jsxRuntimeExports.jsx(ScreenStack,{})})})}const d=[[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],[4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],[8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]],p=[[0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],[9,4,5,3,1,2,6,8,7,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]];function verhoeffValidate(a){let _=0;const $=a.split("").reverse().map(_e=>parseInt(_e,10));for(let _e=0;_e<$.length;_e++)_=d[_][p[_e%8][$[_e]]];return _===0}function isValidAadhaar(a){return/^\d{12}$/.test(a)?verhoeffValidate(a):!1}const abhaRegex=/^[0-9]{14}$/;function luhnCheck(a){let _=0,$=!1;for(let _e=a.length-1;_e>=0;_e--){let et=parseInt(a[_e],10);$&&(et*=2,et>9&&(et-=9)),_+=et,$=!$}return _%10===0}function isValidABHA(a){return!abhaRegex.test(a)||a.split("").every($=>$===a[0])?!1:luhnCheck(a)}const isValidMobile=a=>/^[6-9]\d{9}$/.test(a),setIdentifier=(a,_)=>{useAuthAbhaStore.getState().setInitAbhaAppIdentifierType(a),useAuthAbhaStore.getState().setInitAbhaAppIdentifier(_)},handleIdentifier=(a,_,$)=>{if(a){const _e=a.replace(/[\s-]/g,"");if(_){if(_===ABHA_AUTH_FLOW_METHOD.MOBILE){useAuthAbhaStore.getState().setInitAbhaAppIdentifierSource("existing"),setIdentifier(ABHA_AUTH_FLOW_METHOD.MOBILE,a.slice(-10));return}setIdentifier(_,a),useAuthAbhaStore.getState().setInitAbhaAppIdentifierSource("existing");return}if(_e.endsWith("@abdm")){setIdentifier(ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS,_e);return}if(/^\+91\d{10}$/.test(_e)){const tt=_e.slice(-10);if(tt.length===10&&isValidMobile(tt)){setIdentifier(ABHA_AUTH_FLOW_METHOD.MOBILE,tt);return}}else if(/^\d+$/.test(_e)){const tt=_e.length;if(tt===10&&isValidMobile(_e)){setIdentifier(ABHA_AUTH_FLOW_METHOD.MOBILE,_e);return}if(tt===12&&isValidAadhaar(_e)){setIdentifier(ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER,_e);return}if(tt===14&&isValidABHA(_e)){const rt=`${_e.slice(0,2)}-${_e.slice(2,6)}-${_e.slice(6,10)}-${_e.slice(10,14)}`;setIdentifier(ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER,rt);return}console.warn("Unknown numeric identifier type");return}console.warn("Unknown identifier type")}else console.warn("No identifier provided")};let PopupReactNode=null,unMount,onAbhaSuccess;function initAbhaApp(a){console.log("clear the abha auth store for every sdk invocation",a),useAuthAbhaStore.getState().clearAbhaAuthStore();const{clientId:_,containerId:$,urlParams:_e,method:et,data:tt,appVersion:rt,onSuccess:nt,onError:it,onAbhaClose:at}=a,{mobile:st,accessToken:ut,oid:ot,identifier:pt,identifier_type:ht}=tt||{};console.log("recieved identifier, identifier_type",pt,ht),handleSendEvent({eventName:"recieved_init_identifiers",eventData:{identifier:pt||"",identifier_type:ht||""}});const ft={};ut&&(ft.auth=ut),ot&&(ft["X-User-ID"]=ot),console.log("set headers in headers"),console.log("invoked initAbhaApp",ft);const vt=ft!==null&&("auth"in ft||"X-User-ID"in ft);useAuthAbhaStore.getState().setIsEkaAppLogin(vt),_==="doc-web"&&useAuthAbhaStore.getState().setIsEkaAppLogin(!0),console.log("clientId ",_),console.log("isEkaAppLogin",useAuthAbhaStore.getState().isEkaAppLogin),_==="androiddoc"||_==="doctor-app-ios"||_==="doctor-ipad-ios"||_==="doc-web"?useAuthAbhaStore.getState().setClientId("doctor"):_==="androidp"||_==="patient-app-ios"?useAuthAbhaStore.getState().setClientId("phr"):_==="www-eka"?useAuthAbhaStore.getState().setClientId("eka-web"):(console.log("here"),useAuthAbhaStore.getState().setClientId("phr"));let lt=!1;handleSendEvent({eventName:"init_abha_app",eventData:{platform:_,method:et||"",mobile:st||"",accessToken:ut||"",oid:ot||"",appVersion:rt||"",isEkaAppLogin:vt.toString(),container_id:$}}),onTrack("init_abha_app",{platform:_,method:et||"",mobile:st||"",accessToken:ft.auth||"",oid:ft["X-User-ID"]||"",appVersion:rt||"",isEkaAppLogin:vt.toString(),container_id:$}),(_==="androiddoc"||_==="doctor-app-ios"||_==="doctor-ipad-ios"||_==="doc-web")&&(lt=!0,useAuthAbhaStore.getState().setIsDocAppRequest(lt)),useAuthAbhaStore.getState().setInitAbhaAppMethod(et==="create_abha_with_mobile"?"create_abha_with_mobile":"login_with_abha"),setEnv({clientId:_,env:"PROD",...ft&&{extraHeaders:ft}}),console.log("isProd is",!0);const ct=SCREEN_NAMES.LOGIN_OR_CREATE_ABHA;useAuthAbhaStore.getState().setInitState({screen:[ct],urlParams:_e});const yt=ht&&["mobile","aadhaar_number","abha_number","phr_address"].includes(ht)?ht:void 0;handleIdentifier(pt,yt),useAuthAbhaStore.getState().setAbhaAuthFlowMethod(ABHA_AUTH_FLOW_METHOD.MOBILE);const Et=()=>{useAuthAbhaStore.getState().clearAbhaAuthStore(),queryClient.removeQueries(),PopupReactNode==null||PopupReactNode.unmount(),at()},St=document.getElementById($);if(!St){const bt=`Element with id ${$} not found`;console.error(bt),it({error:bt}),Et();return}return onAbhaSuccess=nt,PopupReactNode=createRoot(St),PopupReactNode.render(jsxRuntimeExports.jsx(App,{})),unMount=Et,window.closeAbhaApp=Et,Et}window.initAbhaApp=initAbhaApp;function onTrack(a,_={}){var et;const $=useAuthAbhaStore.getState().clientId||"unknown-platform",_e={..._,platform:$};console.log("Tracking Event:",a,_e),(et=window.curio)!=null&&et.pushToMixpanel?(console.log("Pushing to Mixpanel:",a,_e),window.curio.pushToMixpanel(a,_e)):(console.log("Curio not available. Queuing event:",a,_e),console.error("Curio not available. Could not push event to Mixpanel."))}
146
+ pds2-transition-colors`,children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"ekaProfile",value:Mt.oid,checked:Tt,onChange:()=>Ot({profile:Mt}),className:"pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14",onKeyDown:_t=>_t.key==="Enter"&&Rt()}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-flex-1",children:[jsxRuntimeExports.jsx("div",{className:"TitlesSubheadline pds2-text-text-primary",children:Mt.fln}),jsxRuntimeExports.jsx("span",{className:"pds2-ml-auto pds2-text-text-brand pds2-text-14 pds2-font-600",children:"Link"})]})]},Mt.oid)})}),jsxRuntimeExports.jsx(TextSeparator,{title:"or"}),jsxRuntimeExports.jsx(Pds2CustomButton,{title:"Create new Family Member",prefixIcon:jsxRuntimeExports.jsx(l$6,{}),className:"pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold",onClick:kt})]})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-sticky pds2-bottom-0 pds2-left-0 pds2-right-0 pds2-bg-bg-white pds2-shadow-lg pds2-p-16",children:[ot&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-8",children:ot}),jsxRuntimeExports.jsx(Pds2Button,{title:"Continue",state:et===null||it===LOADING_STATE.LOADING?"disabled":"enabled",isLoading:it===LOADING_STATE.LOADING,className:"pds2-w-full",onClick:Rt})]})]}),jsxRuntimeExports.jsx(AbhaErrorBottomSheet,{onSubmitClick:Pt}),jsxRuntimeExports.jsx(ExitPopup,{open:st,setOpen:ut})]})},LoginorCreateAbhaScreen=()=>{const a=useAuthAbhaStore(_e=>_e.clientId);reactExports.useEffect(()=>{var _e;if((_e=window.EkaAbha)!=null&&_e.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var et,tt;(et=window.EkaAbha)!=null&&et.changeStatusBarColor&&((tt=window==null?void 0:window.EkaAbha)==null||tt.changeStatusBarColor("#FFFFFF"))}},[]);const _=()=>{var _e;(_e=window.EkaAbha)==null||_e.onAbhaClose(),unMount()},$=["eka-web","phr","www-eka"];return jsxRuntimeExports.jsxs("div",{className:"pds2-h-full pds2-overflow-y-auto",children:[!$.includes(a)&&jsxRuntimeExports.jsx(Pds2Header,{prefixIcon:jsxRuntimeExports.jsx("button",{onClick:_,children:jsxRuntimeExports.jsx(n$2,{})}),title:"",className:"pds2-bg-bg-01"}),jsxRuntimeExports.jsx(LoginOrCreateWithDifferentMethods,{})]})},LoginOrCreateWithDifferentMethods=()=>{const a=useAuthAbhaStore(qt=>qt.abhaAuthFlowMethod||ABHA_AUTH_FLOW_METHOD.MOBILE),_=useAuthAbhaStore(qt=>qt.setAbhaAuthFlowMethod),$=useAuthAbhaStore(qt=>qt.goBackToLogin),_e=useAuthAbhaStore(qt=>qt.setGoBackToLogin);useAuthAbhaStore(qt=>qt.initAbhaAppIdentifierSource);const et=useAuthAbhaStore(qt=>qt.setIdentifierValue),tt=useAuthAbhaStore(qt=>qt.identifierValue),rt=useAuthAbhaStore(qt=>qt.isEkaAppLogin),nt=useAuthAbhaStore(qt=>qt.setSelectedAbhaAddress),it=useAuthAbhaStore(qt=>qt.setLoginIdentifierValue),at=useAuthAbhaStore(qt=>qt.setRegistrationType),st=useAuthAbhaStore(qt=>qt.setAadhaarInitResponse),ut=useAuthAbhaStore(qt=>qt.setMobileInitResponse),ot=useAuthAbhaStore(qt=>qt.initAbhaAppMobileNumber),pt=useAuthAbhaStore(qt=>qt.initAbhaAppIdentifierType),ht=useAuthAbhaStore(qt=>qt.initAbhaAppIdentifier),ft=useAuthAbhaStore(qt=>qt.setInitAbhaAppIdentifier),vt=useAuthAbhaStore(qt=>qt.isDocAppRequest),lt=useAuthAbhaStore(qt=>qt.isNewLoginOrCreateFlow),dt=useAuthAbhaStore(qt=>qt.setIsNewLoginOrCreateFlow),ct=useAuthAbhaStore(qt=>qt.clientId),mt=useAuthAbhaStore(qt=>qt.isInitApiTriggered),yt=useAuthAbhaStore(qt=>qt.setIsInitApiTriggered),Et=useAuthAbhaStore(qt=>qt.setIdentityValue);useAuthAbhaStore(qt=>qt.identityValue);const St=useAuthAbhaStore(qt=>qt.setSelectedAbhaFlow),bt=useAuthAbhaStore(qt=>qt.txnId),[kt,Ot]=reactExports.useState(LOADING_STATE.IDLE),[Rt,Pt]=reactExports.useState(""),Dt=useAuthAbhaStore(qt=>qt.setScreen),[Mt,Tt]=reactExports.useState({aadhaar:LOADING_STATE.IDLE,mobile:LOADING_STATE.IDLE}),[_t,At]=reactExports.useState(tt.mobile||""),[gt,xt]=reactExports.useState(!1),[Ct,wt]=reactExports.useState(!1),[Nt,It]=reactExports.useState(tt.aadhaar_number||""),[Lt,Bt]=reactExports.useState(tt.abha_number||""),[$t,Xt]=reactExports.useState(""),[jt,Ht]=reactExports.useState(tt.phr_address||""),Vt=reactExports.useRef(!1),Yt=GET_EXTRA_HEADERS();reactExports.useEffect(()=>{Kt({name:"abha_login_or_create_screen",data:{flow:a.toString()}})}),reactExports.useEffect(()=>{ht&&pt===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS?(Xt(ht),Ht(ht.split("@")[0]),et({phr_address:ht.split("@")[0]}),Gt(!0),gr(!0),_(ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS)):ht&&pt===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER?(et({abha_number:ht}),Bt(ht),Gt(!0),sr(!0),_(ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER)):ht&&pt===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?(It(ht),wt(!0),et({aadhaar_number:ht}),_(ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)):ht&&pt===ABHA_AUTH_FLOW_METHOD.MOBILE&&(At(ht),et({mobile:ht}),xt(ht.length===10),Pt(null),_(ABHA_AUTH_FLOW_METHOD.MOBILE))},[pt,ht]),reactExports.useEffect(()=>{mt||Vt.current||_t&&_t.length===10&&(yt(!0),Vt.current=!0,ir("auto_submit_mobile"))},[_t]),reactExports.useEffect(()=>{mt||Vt.current||Nt&&Nt.length===12&&(yt(!0),Vt.current=!0,ir("auto_submit_aadhaar"))},[Nt]),reactExports.useEffect(()=>{mt||Vt.current||Lt&&Lt.length===17&&(yt(!0),Vt.current=!0,ir("auto_submit_abha"))},[Lt]),reactExports.useEffect(()=>{mt||Vt.current||$t&&$t.includes("@abdm")&&(yt(!0),Vt.current=!0,ir("auto_submit_phr"))},[$t]);const Kt=({name:qt,data:ar={}})=>{var wr,br;const Er={...{login_platform:ct,is_eka_app_login:rt?"true":"false",is_new_login_or_create_flow:lt?"true":"false",oid:Yt!=null&&Yt["X-User-ID"]?"true":"false",access_token:Yt!=null&&Yt.auth?"true":"false",txn_id:bt||"missing txnId",flow:a??""},...ar};handleSendEvent({eventName:qt,eventData:Er}),(br=(wr=window.curio)==null?void 0:wr.pushToMixpanel)==null||br.call(wr,qt,Er)},Wt=React.useMemo(()=>{switch(a){case ABHA_AUTH_FLOW_METHOD.MOBILE:return"Enter your Mobile Number";case ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER:return"Enter your Aadhaar Number";default:return""}},[a]),Ut=qt=>{Pt("");const ar=qt.target.value;switch(a){case ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS:if(ar.length>20)return;Ht(ar),et({phr_address:ar}),ft(null);break;case ABHA_AUTH_FLOW_METHOD.MOBILE:if(ar&&!/^[0-9]+$/.test(ar)||ar.length>10)return;At(ar),xt(!0),et({mobile:ar}),ft(null);break;case ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER:if(!/^[\d-]*$/.test(ar)||ar.length>17)return;const xr=qt.target.value.replace(/-/g,"");let Er="";return xr.length>0&&(Er+=xr.slice(0,2)),xr.length>2&&(Er+=`-${xr.slice(2,6)}`),xr.length>6&&(Er+=`-${xr.slice(6,10)}`),xr.length>10&&(Er+=`-${xr.slice(10,14)}`),Bt(Er),ft(null),et({abha_number:Er.trim()});case ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER:if(ar&&!/^[0-9]+$/.test(ar)||ar.length>12)return;It(ar),wt(!0),ft(null),et({aadhaar_number:ar});break}};ABHA_AUTH_FLOW_METHOD.MOBILE;const Qt=React.useMemo(()=>{switch(a){case ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS:return tt.phr_address.length>=4&&tt.phr_address.length<=20;case ABHA_AUTH_FLOW_METHOD.MOBILE:return tt.mobile.length===10;case ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER:return tt.abha_number.length===17;case ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER:return tt.aadhaar_number.length===12}},[a,tt]),er=(qt,ar)=>{Tt(xr=>({...xr,[qt]:ar}))},hr=({inputVal:qt})=>{qt.length===12&&(et({aadhaar_number:qt}),It(qt),wt(!0))};reactExports.useEffect(()=>{console.log("selectedMethod changed:==================>",a)},[a]);const ir=async qt=>{var Er,wr,br;dt(!0),Kt({name:"abha_login_next_click",data:{flow_step_type:qt}}),Ot(LOADING_STATE.LOADING),at(REGISTRATION_TYPE.LOGIN);let ar="";if(!rt){const Ir=await postAuthLogoutV2();Kt({name:Ir?"abha_logout_success":"abha_logout_failure",data:{platform:ct}});const{txn_id:Mr,error:kr}=await postAuthInitV2({method:AUTH_METHOD.ABHA});if(!Mr||kr){Kt({name:"abha_auth_init_failure",data:{flow_step_type:"init",authTxnId:ar,error_message:kr||"missing_txnId_or_unknown_error",error_message_exists:!!kr,txn_id_exists:!!Mr}}),Pt((kr==null?void 0:kr.message)||"Something went wrong. Please try again."),Ot(LOADING_STATE.REJECTED);return}ar=Mr,Kt({name:"abha_auth_init_success.",data:{flow_step_type:"init",auth_txnId:ar}})}const xr=a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS?`${tt.phr_address}@abdm`:a===ABHA_AUTH_FLOW_METHOD.MOBILE?tt.mobile:a===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER?tt.abha_number:a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?tt.aadhaar_number:"";if(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER||a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS){const{txn_id:Ir,error:Mr,action:kr,hint:Fr}=await postAbdmLoginInit({method:a,identifier:xr});if(Et(xr),Kt({name:"abha_login_init_triggered",data:{flow_step_type:"init",authTxnId:ar,ndhmTxnId:Ir,method:a}}),a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS&&nt(xr),Mr||!Ir){if(_e(!0),((Er=kr==null?void 0:kr.cta)==null?void 0:Er.pid)==="abha_mobile_enroll"&&a===ABHA_AUTH_FLOW_METHOD.MOBILE){er("mobile",LOADING_STATE.LOADING),at(REGISTRATION_TYPE.CREATE);const{txn_id:Wr,hint:Vr,error:Cr,action:Jr}=await postRegisterMobileInit({mobile_number:tt.mobile});if(Et(tt.mobile),St("mobile"),Wr&&Vr){ut({authTxnId:ar,txnId:Wr,mobileOtpSentToHint:Vr}),Kt({name:"abha_mobile_registration_init_success",data:{flow_step_type:"init",authTxnId:ar,ndhmTxnId:Ir,error_message:Cr,error_action:kr}}),er("mobile",LOADING_STATE.RESOLVED),Ot(LOADING_STATE.RESOLVED),at(REGISTRATION_TYPE.CREATE),Dt(SCREEN_NAMES.ABHA_PHONE_NUMBER_VERIFICATION);return}if(er("mobile",LOADING_STATE.REJECTED),Kt({name:"abha_mobile_registration_init_failure",data:{flow_step_type:"init",authTxnId:ar,error_message:Cr||"unknown_error",error_message_exists:!!Cr,error_action_exists:!!Jr}}),Jr){if((wr=Jr==null?void 0:Jr.cta)!=null&&wr.pid)return Dt(SCREEN_NAMES.LOGIN_OR_CREATE_ABHA)}else Pt(Cr||"Something went wrong");Pt(Cr||"Something went wrong. Please try again."),Ot(LOADING_STATE.REJECTED);return}Kt({name:"abha_login_init_failure",data:{flow_step_type:"init",authTxnId:ar,error_message:Mr||"unknown_error",error_message_exists:!!Mr,error_action_exists:!!kr}}),Pt(Mr||"Something went wrong. Please try again."),Ot(LOADING_STATE.REJECTED);return}Kt({name:"abha_login_init_success",data:{flow_step_type:"init",authTxnId:ar,ndhmTxnId:Ir,hint:Fr}}),st({authTxnId:ar,txnId:Ir,aadhaarOtpSentToHint:Fr||null}),_e(!1),it(xr),Ot(LOADING_STATE.RESOLVED),Dt(SCREEN_NAMES.VERIFY_OTP_LOGIN_WITH_ABHA);return}if(a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER){er("aadhaar",LOADING_STATE.LOADING),Kt({name:"aadhaar_registration_init_start",data:{flow_step_type:"init",authTxnId:ar,aadhaarNumber:tt.aadhaar_number}});const{txn_id:Ir,hint:Mr,error:kr,action:Fr}=await postRegisterAadhaarInit({aadhaar_number:tt.aadhaar_number});if(Et(tt.aadhaar_number),St("aadhaar"),Ir&&Mr){st({authTxnId:ar,txnId:Ir,aadhaarOtpSentToHint:Mr}),Kt({name:"aadhaar_registration_init_success",data:{flow_step_type:"verify",ndhmTxnId:Ir,authTxnId:ar}}),_e(!1),er("aadhaar",LOADING_STATE.RESOLVED),at(REGISTRATION_TYPE.CREATE),Ot(LOADING_STATE.RESOLVED),Dt(SCREEN_NAMES.ABHA_OTP_AND_MOBILE);return}if(Kt({name:"abha_registration_init_failure",data:{error_message:kr||"unknown_error",error_message_exists:!!kr,auth_txn_id:ar,error_action:Fr,error_action_exists:!!Fr}}),er("aadhaar",LOADING_STATE.REJECTED),Ot(LOADING_STATE.REJECTED),Fr||kr){_e(!0),(br=Fr==null?void 0:Fr.cta)!=null&&br.pid?Dt(SCREEN_NAMES.LOGIN_OR_CREATE_ABHA):Pt(kr||"Something went wrong");return}}},[rr,Gt]=reactExports.useState(!1),[zt,sr]=reactExports.useState($&&a===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER),[ur,gr]=reactExports.useState($&&a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"pds2-pt-22 pds2-p-16 pds2-bg-bg-01 pds2-space-y-16 pds2-text-center pds2-rounded-b-24",children:[jsxRuntimeExports.jsx(AbhaStepper,{}),jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-center pds2-items-center pds2-gap-16",children:jsxRuntimeExports.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abdm-icon",className:"pds2-w-64 pds2-h-64"})})}),jsxRuntimeExports.jsx("div",{className:"Heading3Semibold pds2-text-text-black",children:ct==="phr"?"Login or Create your ABHA":vt?"Add Patient via ABHA":"Create your ABHA"}),jsxRuntimeExports.jsx("div",{className:"pds2-text-text-03",style:{marginTop:"4px"},children:a===ABHA_AUTH_FLOW_METHOD.MOBILE?vt?"Enter Patient's Mobile Number":"Enter your Mobile Number":a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?vt?"Enter Patient's Aadhaar Number":"Enter your Aadhaar Number":a===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER?vt?"Enter Patient's ABHA Number":"Enter your ABHA Number":a===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS?vt?"Enter Patient's ABHA Address":"Enter your ABHA Address":Wt}),(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsxs("div",{className:"pds2-relative pds2-flex pds2-bg-bg-seperator-dark pds2-rounded-12 pds2-mt-4",children:[jsxRuntimeExports.jsx("div",{className:"pds2-absolute pds2-top-0 pds2-bottom-0 pds2-bg-bg-white pds2-rounded-12 pds2-transition-all pds2-duration-300",style:{left:a===ABHA_AUTH_FLOW_METHOD.MOBILE?0:"50%",width:"50%",boxShadow:"0px 10px 4px -6px #18274B17"}}),jsxRuntimeExports.jsxs("button",{onClick:()=>{_(ABHA_AUTH_FLOW_METHOD.MOBILE),Pt("")},className:"pds2-flex-1 pds2-py-6 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative pds2-z-10",children:[jsxRuntimeExports.jsx(n$1,{className:"pds2-w-14 pds2-h-14 pds2-text-icon-success-02"}),jsxRuntimeExports.jsx("span",{className:`pds2-text-base ${a===ABHA_AUTH_FLOW_METHOD.MOBILE?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:a===ABHA_AUTH_FLOW_METHOD.MOBILE?{fontWeight:700}:{fontWeight:400},children:"Mobile"})]}),jsxRuntimeExports.jsxs("button",{onClick:()=>{_(ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER),Pt("")},className:"pds2-flex-1 pds2-py-6 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative pds2-z-10",children:[jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm5mcdm3h00070tfs9fjkepff.webp",alt:"aadhaar-icon",className:"pds2-w-24 pds2-h-24"}),jsxRuntimeExports.jsx("span",{className:`pds2-text-base ${a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?{fontWeight:700}:{fontWeight:400},children:"Aadhaar"})]})]}),(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsx("div",{className:"pds2-mt-16 pds2-w-full pds2-max-w-md pds2-mx-auto pds2-px-4 pds2-relative",children:a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER?jsxRuntimeExports.jsx(SpacedInputComponent,{initialValues:pt===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER&&!$?(ht==null?void 0:ht.match(/.{1,4}/g))??void 0:(Nt==null?void 0:Nt.match(/.{1,4}/g))??void 0,disabled:!$&&pt===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER&&!!ht,numberOfInputs:3,length:4,placeholder:"XXXX",onSubmit:hr,setIsValid:wt,setAadhaarValue:It,setError:Pt}):jsxRuntimeExports.jsx(Pds2InputField,{value:pt===ABHA_AUTH_FLOW_METHOD.MOBILE&&!$?ht||"":_t,disabled:!$&&pt===ABHA_AUTH_FLOW_METHOD.MOBILE&&!!ht,onChange:Ut,type:"tel",autoComplete:"tel-national",placeholder:"Mobile Number",inputMode:"numeric",autoFocus:!0,maxLength:10,PrefixComponent:jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-x-8 pds2-border-r pds2-border-border-brand-02 pds2-pr-24",children:[jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4mlct2900000tg98p8u967s.webp",alt:"indian-flag-icon",className:"pds2-w-24 pds2-h-24"}),jsxRuntimeExports.jsx("span",{className:"pds2-text-text-black pds2-text-sm",children:"+91"})]})})}),Rt&&(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error Body3Regular",children:Rt}),(a===ABHA_AUTH_FLOW_METHOD.MOBILE||a===ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER)&&jsxRuntimeExports.jsx(Pds2Button,{title:"Next",IconComponent:()=>jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!Qt||kt===LOADING_STATE.LOADING?"disabled":"enabled",isLoading:kt===LOADING_STATE.LOADING,onClick:()=>ir("aadhaar_or_mobile_on_click"),className:"pds2-w-full"})]}),jsxRuntimeExports.jsxs("div",{className:"pds2-m-16 pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-03 pds2-overflow-hidden",children:[jsxRuntimeExports.jsxs("button",{onClick:()=>Gt(!rr),className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-16 pds2-bg-bg-white hover:pds2-bg-bg-02 pds2-transition-colors",children:[jsxRuntimeExports.jsx("span",{className:"pds2-text-text-03",children:vt?"Other add options for ABHA":"Other login options for ABHA"}),jsxRuntimeExports.jsx(c$2,{className:`pds2-w-16 pds2-h-16 pds2-text-text-03 pds2-transition-transform ${rr?"pds2-rotate-180":""}`})]}),jsxRuntimeExports.jsxs("div",{className:`pds2-overflow-hidden pds2-transition-all pds2-duration-300 ${rr?"pds2-max-h-126 pds2-opacity-100":"pds2-max-h-0 pds2-opacity-0"}`,children:[jsxRuntimeExports.jsxs("button",{onClick:()=>{Gt(!1),_(ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER),sr(!0),Pt("")},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[jsxRuntimeExports.jsx("div",{className:"pds2-w-40 pds2-h-40 pds2-rounded-full pds2-bg-bg-02 pds2-flex pds2-items-center pds2-justify-center",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abdm-icon",className:"pds2-w-24 pds2-h-24"})}),jsxRuntimeExports.jsx("span",{className:"Body1Regular pds2-text-text-black",children:vt?"Add patient with ABHA Number":"Login with ABHA Number"})]}),jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]}),jsxRuntimeExports.jsxs("button",{onClick:()=>{Gt(!1),_(ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS),gr(!0),Pt("")},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[jsxRuntimeExports.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[jsxRuntimeExports.jsx("div",{className:"pds2-w-40 pds2-h-40 pds2-rounded-full pds2-bg-bg-02 pds2-flex pds2-items-center pds2-justify-center",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA",className:"pds2-w-24 pds2-h-24"})}),jsxRuntimeExports.jsx("span",{className:"Body1Regular pds2-text-text-black",children:vt?"Add patient with ABHA Address":"Login with ABHA Address"})]}),jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]})]})]}),jsxRuntimeExports.jsx(AbhaBottomSheet,{isOpen:zt,setIsOpen:sr,setFlowMethod:_,setError:Pt,children:jsxRuntimeExports.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:jsxRuntimeExports.jsx("button",{onClick:()=>{Pt(null),sr(!1),_(ABHA_AUTH_FLOW_METHOD.MOBILE)},className:"pds2-w-24 pds2-h-24 pds2-flex pds2-items-center pds2-justify-center pds2-text-text-03 hover:pds2-text-text-black",children:"✕"})}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:jsxRuntimeExports.jsx("div",{className:"pds2-w-64 pds2-h-64 pds2-rounded-full pds2-bg-bg-01 pds2-flex pds2-items-center pds2-justify-center",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abdm-icon",className:"pds2-w-48 pds2-h-48"})})}),jsxRuntimeExports.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:vt?"Add Patient with ABHA Number":"Login with ABHA Number"}),jsxRuntimeExports.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:vt?"Enter Patient's 14 digit ABHA Number":"Enter your 14 digit ABHA Number"}),jsxRuntimeExports.jsx(Pds2InputField,{value:pt===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER&&!$?ht||"":Lt,disabled:!$&&pt===ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER&&!!ht,onChange:Ut,placeholder:"00-0000-0000-0000",padding:"pds2-p-18",textStyle:"Body2Regular pds2-text-center pds2-text-lg",borderStyle:"focus-within:pds2-border-border-brand-01",type:"tel",autoComplete:"tel-national",inputMode:"numeric",autoFocus:!0,onKeyDown:qt=>{qt.key==="Enter"&&ir("after_enter_abha_number_on_click_by_user")}}),Rt&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error Body3Regular pds2-mt-12",children:Rt}),jsxRuntimeExports.jsx(Pds2Button,{title:"Next",IconComponent:()=>jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!tt||kt===LOADING_STATE.LOADING?"disabled":"enabled",onClick:()=>ir("after_enter_abha_number_on_click_by_user"),className:`pds2-w-full ${Rt?"pds2-mt-12":"pds2-mt-24"}`,isLoading:kt===LOADING_STATE.LOADING})]})]})}),jsxRuntimeExports.jsx(AbhaBottomSheet,{isOpen:ur,setIsOpen:gr,setFlowMethod:_,setError:Pt,children:jsxRuntimeExports.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:jsxRuntimeExports.jsx("button",{onClick:()=>{Pt(null),gr(!1),_(ABHA_AUTH_FLOW_METHOD.MOBILE)},className:"pds2-w-24 pds2-h-24 pds2-flex pds2-items-center pds2-justify-center pds2-text-text-03 hover:pds2-text-text-black",children:"✕"})}),jsxRuntimeExports.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[jsxRuntimeExports.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:jsxRuntimeExports.jsx("div",{className:"pds2-w-64 pds2-h-64 pds2-rounded-full pds2-bg-bg-01 pds2-flex pds2-items-center pds2-justify-center",children:jsxRuntimeExports.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abdm-icon",className:"pds2-w-48 pds2-h-48"})})}),jsxRuntimeExports.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:vt?"Add Patient with ABHA Address":"Login with ABHA Address"}),jsxRuntimeExports.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:vt?"Enter Patient's ABHA Address below":"Enter your ABHA Address below"}),jsxRuntimeExports.jsxs("div",{className:"pds2-relative",children:[jsxRuntimeExports.jsx(Pds2InputField,{value:pt===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS&&!$?(ht==null?void 0:ht.split("@")[0])||"":jt,disabled:!$&&pt===ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS&&!!ht,onChange:Ut,placeholder:"Enter ABHA Address",inputMode:"text",autoFocus:!0,onKeyDown:qt=>{qt.key==="Enter"&&ir("after_enter_abha_address_on_click_by_user")}}),jsxRuntimeExports.jsx("div",{className:"pds2-absolute pds2-right-16 pds2-top-16 Body1Regular pds2-text-text-03",children:"@abdm"})]}),Rt&&jsxRuntimeExports.jsx("div",{className:"pds2-text-text-error Body3Regular pds2-mt-12",children:Rt}),jsxRuntimeExports.jsx(Pds2Button,{title:"Next",IconComponent:()=>jsxRuntimeExports.jsx(c$2,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!tt||kt===LOADING_STATE.LOADING?"disabled":"enabled",onClick:()=>ir("after_enter_abha_address_on_click_by_user"),className:`pds2-w-full ${Rt?"pds2-mt-12":"pds2-mt-24"}`,isLoading:kt===LOADING_STATE.LOADING})]})]})})]})},AbhaBottomSheet=({isOpen:a,setIsOpen:_,children:$,setFlowMethod:_e,overlayClassName:et="pds2-bg-text-black pds2-bg-opacity-50",setError:tt})=>{const[rt,nt]=reactExports.useState(a);return reactExports.useEffect(()=>{if(a)nt(!0);else{const it=setTimeout(()=>nt(!1),300);return()=>clearTimeout(it)}},[a]),rt?jsxRuntimeExports.jsxs("div",{className:`pds2-absolute pds2-inset-0 pds2-z-50 pds2-flex pds2-items-end pds2-transition-all pds2-duration-300 ${a?"pds2-opacity-100":"pds2-opacity-0 pointer-events-none"}`,children:[jsxRuntimeExports.jsx("div",{className:`pds2-absolute pds2-inset-0 ${et} pds2-transition-opacity pds2-duration-300`,style:{backgroundColor:"rgba(0, 0, 0, 0.5)"},onClick:()=>{tt(null),_(!1),_e(ABHA_AUTH_FLOW_METHOD.MOBILE)}}),jsxRuntimeExports.jsx("div",{className:`pds2-relative pds2-bg-bg-white pds2-rounded-t-24 pds2-w-full pds2-transition-transform pds2-duration-300 ${a?"pds2-translate-y-0":"pds2-translate-y-full"}`,style:{height:"75%",maxHeight:"600px",overflowY:"auto"},children:$})]}):null},ScreenStack=()=>{const a=useAuthAbhaStore($=>$.screen);switch(a[a.length-1]){case SCREEN_NAMES.LOGIN_WITH_ABHA:return jsxRuntimeExports.jsx(LoginorCreateAbhaScreen,{});case SCREEN_NAMES.VERIFY_OTP_LOGIN_WITH_ABHA:return jsxRuntimeExports.jsx(AbhaLoginOtpVerifyScreen,{});case SCREEN_NAMES.CREATE_ABHA_WITH_AADHAAR:return jsxRuntimeExports.jsx(LoginorCreateAbhaScreen,{});case SCREEN_NAMES.ABHA_OTP_AND_MOBILE:return jsxRuntimeExports.jsx(AbhaOtpAndMobileScreen,{});case SCREEN_NAMES.ABHA_PHONE_NUMBER_VERIFICATION:return jsxRuntimeExports.jsx(AbhaPhoneNumberVerificationScreen,{});case SCREEN_NAMES.AADHAAR_VERIFICATION_STATUS:return jsxRuntimeExports.jsx(AbhaAadhaarVerificationStatusScreen,{});case SCREEN_NAMES.ABHA_MOBILE_LINKING_STATUS:return jsxRuntimeExports.jsx(AbhaMobileLinkingStatusScreen,{});case SCREEN_NAMES.SELECT_ABHA_FROM_LIST:return jsxRuntimeExports.jsx(SelectAbhaFromListScreen,{});case SCREEN_NAMES.SELECT_EKA_PROFILE:return jsxRuntimeExports.jsx(SelectEkaProfileScreen,{});case SCREEN_NAMES.CREATE_ABHA_ADDRESS:return jsxRuntimeExports.jsx(CreateAbhaAddressScreen,{});case SCREEN_NAMES.CREATE_EKA_PROFILE:return jsxRuntimeExports.jsx(CreateEkaProfileScreen,{});case SCREEN_NAMES.CREATE_PHR_EKA_PROFILE:return jsxRuntimeExports.jsx(CreateEkaProfileScreen,{});case SCREEN_NAMES.GET_ALL_PROFILES:return jsxRuntimeExports.jsx(GetAllProfilesScreen,{});case SCREEN_NAMES.LOGIN_OR_CREATE_ABHA:return jsxRuntimeExports.jsx(LoginorCreateAbhaScreen,{});default:return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}},queryClient=new QueryClient;function App(){return reactExports.useEffect(()=>()=>{unMount()},[]),jsxRuntimeExports.jsx(QueryClientProvider,{client:queryClient,children:jsxRuntimeExports.jsx("div",{className:"pds2-h-full pds2-w-full pds2-bg-bg-white",style:{borderRadius:GET_CLIENT_ID()==="www-eka"?"1.5rem":void 0,position:"relative",height:GET_CLIENT_ID()==="www-eka"?"75vh":GET_CLIENT_ID()==="doc-web"?"100%":"100vh",overflowY:"auto",paddingTop:GET_CLIENT_ID()==="androiddoc"||GET_CLIENT_ID()==="doctor-app-ios"||GET_CLIENT_ID()==="doctor-ipad-ios"?"1rem":"0rem"},children:jsxRuntimeExports.jsx(ScreenStack,{})})})}const d=[[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],[4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],[8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]],p=[[0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],[9,4,5,3,1,2,6,8,7,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]];function verhoeffValidate(a){let _=0;const $=a.split("").reverse().map(_e=>parseInt(_e,10));for(let _e=0;_e<$.length;_e++)_=d[_][p[_e%8][$[_e]]];return _===0}function isValidAadhaar(a){return/^\d{12}$/.test(a)?verhoeffValidate(a):!1}const abhaRegex=/^[0-9]{14}$/;function luhnCheck(a){let _=0,$=!1;for(let _e=a.length-1;_e>=0;_e--){let et=parseInt(a[_e],10);$&&(et*=2,et>9&&(et-=9)),_+=et,$=!$}return _%10===0}function isValidABHA(a){return!abhaRegex.test(a)||a.split("").every($=>$===a[0])?!1:luhnCheck(a)}const isValidMobile=a=>/^[6-9]\d{9}$/.test(a),setIdentifier=(a,_)=>{useAuthAbhaStore.getState().setInitAbhaAppIdentifierType(a),useAuthAbhaStore.getState().setInitAbhaAppIdentifier(_)},handleIdentifier=(a,_,$)=>{if(a){const _e=a.replace(/[\s-]/g,"");if(_){if(_===ABHA_AUTH_FLOW_METHOD.MOBILE){useAuthAbhaStore.getState().setInitAbhaAppIdentifierSource("existing"),setIdentifier(ABHA_AUTH_FLOW_METHOD.MOBILE,a.slice(-10));return}setIdentifier(_,a),useAuthAbhaStore.getState().setInitAbhaAppIdentifierSource("existing");return}if(_e.endsWith("@abdm")){setIdentifier(ABHA_AUTH_FLOW_METHOD.PHR_ADDRESS,_e);return}if(/^\+91\d{10}$/.test(_e)){const tt=_e.slice(-10);if(tt.length===10&&isValidMobile(tt)){setIdentifier(ABHA_AUTH_FLOW_METHOD.MOBILE,tt);return}}else if(/^\d+$/.test(_e)){const tt=_e.length;if(tt===10&&isValidMobile(_e)){setIdentifier(ABHA_AUTH_FLOW_METHOD.MOBILE,_e);return}if(tt===12&&isValidAadhaar(_e)){setIdentifier(ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER,_e);return}if(tt===14&&isValidABHA(_e)){const rt=`${_e.slice(0,2)}-${_e.slice(2,6)}-${_e.slice(6,10)}-${_e.slice(10,14)}`;setIdentifier(ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER,rt);return}console.warn("Unknown numeric identifier type");return}console.warn("Unknown identifier type")}else console.warn("No identifier provided")};let PopupReactNode=null,unMount,onAbhaSuccess;function initAbhaApp(a){console.log("clear the abha auth store for every sdk invocation",a),useAuthAbhaStore.getState().clearAbhaAuthStore();const{clientId:_,containerId:$,urlParams:_e,method:et,data:tt,appVersion:rt,onSuccess:nt,onError:it,onAbhaClose:at}=a,{mobile:st,accessToken:ut,oid:ot,identifier:pt,identifier_type:ht}=tt||{};console.log("recieved identifier, identifier_type",pt,ht),handleSendEvent({eventName:"recieved_init_identifiers",eventData:{identifier:pt||"",identifier_type:ht||""}});const ft={};ut&&(ft.auth=ut),ot&&(ft["X-User-ID"]=ot),console.log("set headers in headers"),console.log("invoked initAbhaApp",ft);const vt=ft!==null&&("auth"in ft||"X-User-ID"in ft);useAuthAbhaStore.getState().setIsEkaAppLogin(vt),_==="doc-web"&&useAuthAbhaStore.getState().setIsEkaAppLogin(!0),console.log("clientId ",_),console.log("isEkaAppLogin",useAuthAbhaStore.getState().isEkaAppLogin),_==="androiddoc"||_==="doctor-app-ios"||_==="doctor-ipad-ios"||_==="doc-web"?useAuthAbhaStore.getState().setClientId("doctor"):_==="androidp"||_==="patient-app-ios"?useAuthAbhaStore.getState().setClientId("phr"):_==="www-eka"?useAuthAbhaStore.getState().setClientId("eka-web"):(console.log("here"),useAuthAbhaStore.getState().setClientId("phr"));let lt=!1;handleSendEvent({eventName:"init_abha_app",eventData:{platform:_,method:et||"",mobile:st||"",accessToken:ut||"",oid:ot||"",appVersion:rt||"",isEkaAppLogin:vt.toString(),container_id:$}}),onTrack("init_abha_app",{platform:_,method:et||"",mobile:st||"",accessToken:ft.auth||"",oid:ft["X-User-ID"]||"",appVersion:rt||"",isEkaAppLogin:vt.toString(),container_id:$}),(_==="androiddoc"||_==="doctor-app-ios"||_==="doctor-ipad-ios"||_==="doc-web")&&(lt=!0,useAuthAbhaStore.getState().setIsDocAppRequest(lt)),useAuthAbhaStore.getState().setInitAbhaAppMethod(et==="create_abha_with_mobile"?"create_abha_with_mobile":"login_with_abha"),setEnv({clientId:_,env:"PROD",...ft&&{extraHeaders:ft}}),console.log("isProd is",!0);const ct=SCREEN_NAMES.LOGIN_OR_CREATE_ABHA;useAuthAbhaStore.getState().setInitState({screen:[ct],urlParams:_e});const yt=ht&&["mobile","aadhaar_number","abha_number","phr_address"].includes(ht)?ht:void 0;handleIdentifier(pt,yt),useAuthAbhaStore.getState().setAbhaAuthFlowMethod(ABHA_AUTH_FLOW_METHOD.MOBILE);const Et=()=>{useAuthAbhaStore.getState().clearAbhaAuthStore(),queryClient.removeQueries(),PopupReactNode==null||PopupReactNode.unmount(),at()},St=document.getElementById($);if(!St){const bt=`Element with id ${$} not found`;console.error(bt),it({error:bt}),Et();return}return onAbhaSuccess=nt,PopupReactNode=createRoot(St),PopupReactNode.render(jsxRuntimeExports.jsx(App,{})),unMount=Et,window.closeAbhaApp=Et,Et}window.initAbhaApp=initAbhaApp;function onTrack(a,_={}){var et;const $=useAuthAbhaStore.getState().clientId||"unknown-platform",_e={..._,platform:$};console.log("Tracking Event:",a,_e),(et=window.curio)!=null&&et.pushToMixpanel?(console.log("Pushing to Mixpanel:",a,_e),window.curio.pushToMixpanel(a,_e)):(console.log("Curio not available. Queuing event:",a,_e),console.error("Curio not available. Could not push event to Mixpanel."))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/abha",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "VITE_APP_MODE=DEBUG vite",