@eka-care/abha-stg 0.0.29 → 0.0.30
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.
- package/dist/sdk/abha/js/abha.js +2 -2
- package/package.json +1 -1
package/dist/sdk/abha/js/abha.js
CHANGED
|
@@ -126,11 +126,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
126
126
|
${e===r?"pds2-border-border-brand-01 pds2-text-text-brand Body2Semibold focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2":"pds2-border-border-03 pds2-text-text-secondary Body3Medium"}
|
|
127
127
|
active:pds2-bg-bg-brand-02 hover:pds2-bg-bg-hover-01
|
|
128
128
|
pds2-transition-colors pds2-duration-200
|
|
129
|
-
`,children:[m.jsx("input",{type:"radio",name:"abha-suggestion",value:r,checked:e===r,onClick:()=>t(e===r?"":r),className:"focus:pds2-outline-none pds2-appearance-none"}),m.jsxs("span",{children:[r,ui()==="DEV"?"@sbx":"@abdm"]})]},r))})]}):null]}),$3=()=>{const[e,t]=p.useState(""),n=O(P=>P.txnId),r=O(P=>P.setSelectedAbhaAddress),a=O(P=>P.goBackLoginScreen),i=O(P=>P.abhaAuthFlowMethod),[s,o]=p.useState(null),l=O(P=>P.authTxnId),[u,c]=p.useState(null),{mutateAsync:d}=em(),f=O(P=>P.setBottomsheetErrorInfo),w=O(P=>P.clearAbhaAuthStore),[x,g]=p.useState([]),[_,h]=p.useState(!1),{mutateAsync:v}=j3(),y=O(P=>P.ekaProfileInfo),b=O(P=>P.registrationType),{mutateAsync:E}=Rm(),A=Cn(),N=O(P=>P.isEkaAppLogin),C=O(P=>P.clientId),$=["M","F","O","U"],H=O(P=>P.isNewLoginOrCreateFlow),F=O(P=>P.abhaAuthFlowMethod||ee.MOBILE),L=({name:P,data:R={}})=>{var D,k;const S={...{login_platform:C,is_eka_app_login:N?"true":"false",is_new_login_or_create_flow:H?"true":"false",txn_id:n||"missing txnId",oid:A!=null&&A["X-User-ID"]?"true":"false",access_token:A!=null&&A.auth?"true":"false",flow:F==null?void 0:F.toString()},...R};qe({eventName:P,eventData:S}),(k=(D=window.curio)==null?void 0:D.pushToMixpanel)==null||k.call(D,P,S)};p.useEffect(()=>{L({name:"page_view",data:{page_view:"choose_abha_address_screen",platform:C}})},[C]),p.useEffect(()=>{async function P(){if(n)try{const{suggestions:R,error:M}=await Yb({txn_id:n,fn:y==null?void 0:y.firstname,ln:y==null?void 0:y.lastname,dob:y==null?void 0:y.date_of_birth});if(M){c(M||"Something went wrong. Please try again.");return}R&&(g(R),R.length>0&&t(R[0]))}catch{}}P()},[]);const B=async()=>{var S,D,k,U,z,I,V,Y,Z,re,q,X,K,oe,ie;if(!e){L({name:"create_abha_address_click_no_selection",data:{platform:C,type:"create",reason:"no_abha_address_selected",abha_address_selected:!1}});return}if(L({name:"create_abha_address_clicks",data:{platform:C,type:"create"}}),o(Q.LOADING),b===ar.CREATE){if(!n||!y)return;const[ce,me,se]=y.date_of_birth?(S=y==null?void 0:y.date_of_birth)==null?void 0:S.split("-"):["","",""];if(i===ee.MOBILE){const xe={abha_address:e,day_of_birth:parseInt(se),first_name:y.firstname,gender:y.gender,last_name:y.lastname,month_of_birth:parseInt(me),pincode:y.pincode,year_of_birth:parseInt(ce),txn_id:n};L({name:"create_abha_process_started",data:{method:"mobile",abha_address:e,platform:C,pincode_sent:xe==null?void 0:xe.pincode,date_of_birth:(y==null?void 0:y.date_of_birth)||"missing date of birth",day_of_birth:(xe==null?void 0:xe.day_of_birth)||"missing day of birth",month_of_birth:(xe==null?void 0:xe.month_of_birth)||"missing month of birth",year_of_birth:(xe==null?void 0:xe.year_of_birth)||"missing year of birth"}});const{error:ne,eka:W,profile:J,action:we}=await v(xe);if(we){L({name:"create_abha_process_error_action",data:{method:"mobile",platform:C,error_message:((D=we==null?void 0:we.cta)==null?void 0:D.title)||"unknown_error_message",error_message_exists:!!((k=we==null?void 0:we.cta)!=null&&k.title)}}),f(we);return}if(ne||!W){L({name:"create_abha_process_failed",data:{method:"mobile",platform:C,error_message:ne||"unknown_error",error_message_exists:!!ne,pincode_received:(J==null?void 0:J.pincode)||"missing_pincode_received",pincode_received_exists:!!(J!=null&&J.pincode),pincode_sent:(y==null?void 0:y.pincode)||"missing_pincode_sent",pincode_sent_exists:!!(y!=null&&y.pincode)}}),o(Q.REJECTED),c(ne||"Something went wrong. Please try again.");return}if(L({name:"abha_address_created",data:{type:"create_abha",platform:C}}),W.oid&&N){o(Q.RESOLVED),L({name:"abha_create_process_started",data:{method:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C}});const be=$.includes(J==null?void 0:J.gender)?J==null?void 0:J.gender:void 0,Ke={oid:(W==null?void 0:W.oid)||"",fln:(J==null?void 0:J.first_name)+" "+(J==null?void 0:J.last_name),dob:`${J==null?void 0:J.year_of_birth}-${String(J==null?void 0:J.month_of_birth).padStart(2,"0")}-${String(J==null?void 0:J.day_of_birth).padStart(2,"0")}`,gen:be,mobile:J==null?void 0:J.mobile,at:"",fn:(J==null?void 0:J.first_name)||"",mn:(J==null?void 0:J.middle_name)||"",ln:(J==null?void 0:J.last_name)||"","health-ids":J!=null&&J.abha_address?[J.abha_address]:void 0,abha_number:(J==null?void 0:J.abha_number)||""},ke=vi(Ke);if(L({name:"abha_create_process_success",data:{method:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C}}),window.EkaAbha&&window.EkaAbha.onAbhaSuccess){(U=window.EkaAbha)==null||U.onAbhaSuccess(JSON.stringify({response:ke}));return}bn({response:ke}),jt();return}}else{L({name:"create_abha_process_started",data:{method:i==null?void 0:i.toLowerCase(),platform:C}});const{error:xe,eka:ne,profile:W,action:J}=await Ub({abha_address:e,txn_id:n});if(J){L({name:"create_abha_process_error_action",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:((z=J==null?void 0:J.cta)==null?void 0:z.title)||"unknown_error_message",error_message_exists:!!((I=J==null?void 0:J.cta)!=null&&I.title)}}),f(J);return}if(xe||!ne){L({name:"create_abha_process_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:xe||"unknown_error",error_message_exists:!!xe,pincode_received:(W==null?void 0:W.pincode)||"missing_pincode_received",pincode_received_exists:!!(W!=null&&W.pincode),pincode_sent:(y==null?void 0:y.pincode)||"missing_pincode_sent",pincode_sent_exists:!!(y!=null&&y.pincode)}}),o(Q.REJECTED),c(xe||"Something went wrong. Please try again.");return}if(L({name:"abha_address_created",data:{type:"create_abha",platform:C}}),ne.oid&&N){o(Q.RESOLVED),L({name:"abha_create_process_started",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,page_view:"choose_abha_address"}});const we=$.includes(W==null?void 0:W.gender)?W==null?void 0:W.gender:void 0,be={oid:(ne==null?void 0:ne.oid)||"",fln:(W==null?void 0:W.first_name)+" "+(W==null?void 0:W.last_name),dob:`${W==null?void 0:W.year_of_birth}-${String(W==null?void 0:W.month_of_birth).padStart(2,"0")}-${String(W==null?void 0:W.day_of_birth).padStart(2,"0")}`,gen:we,mobile:W==null?void 0:W.mobile,at:"",fn:(W==null?void 0:W.first_name)||"",mn:(W==null?void 0:W.middle_name)||"",ln:(W==null?void 0:W.last_name)||"","health-ids":W!=null&&W.abha_address?[W.abha_address]:void 0,abha_number:(W==null?void 0:W.abha_number)||""},Ke=vi(be);if(L({name:"abha_create_process_success",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C}}),window.EkaAbha&&window.EkaAbha.onAbhaSuccess){(V=window.EkaAbha)==null||V.onAbhaSuccess(JSON.stringify({response:Ke}));return}bn({response:Ke}),jt();return}}let ye=y.oid;if(y.oid){L({name:"abha_create_process_link_phr_started",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,page_view:"choose_abha_address"}});const{error:xe,action:ne,eka:W}=await Iy({abha_address:e,oid:y.oid});if(ne){L({name:"abha_create_process_link_phr_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:((Y=ne==null?void 0:ne.cta)==null?void 0:Y.title)||"unknown_error_message",error_message_exists:!!((Z=ne==null?void 0:ne.cta)!=null&&Z.title)}}),f(ne);return}if(xe||!W||!W.oid){L({name:"abha_create_process_link_phr_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:xe||"unknown_error",error_message_exists:!!xe,eka:W||"missing_eka",eka_oid:(W==null?void 0:W.oid)||"missing_oid",eka_oid_exists:!!(W!=null&&W.oid)}}),o(Q.REJECTED),c(xe||"Something went wrong. Please try again.");return}L({name:"abha_create_process_link_phr_success",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,page_view:"choose_abha_address"}})}else{L({name:"abha_create_process_eka_started",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C}});const xe={abha_address:e,day_of_birth:parseInt(se),first_name:y.firstname,gender:y.gender,last_name:y.lastname||"",month_of_birth:parseInt(me),pincode:y.pincode,year_of_birth:parseInt(ce)},{error:ne,eka:W,action:J}=await Ly({...xe});if(J){L({name:"abha_create_process_eka_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:((re=J==null?void 0:J.cta)==null?void 0:re.title)||"unknown_error_message",error_message_exists:!!((q=J==null?void 0:J.cta)!=null&&q.title)}}),f(J);return}if(ne||!W||!W.oid){L({name:"abha_create_process_eka_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",is_eka_app_login:N?"true":"false",platform:C,error_message:ne||"unknown_error",error_message_exists:!!ne,eka_exists:!!W,eka_oid:(W==null?void 0:W.oid)||"missing_oid",eka_oid_exists:!!(W!=null&&W.oid),flow:F??""}}),o(Q.REJECTED),c(ne||"Something went wrong. Please try again.");return}ye=W.oid,L({name:"abha_create_process_eka_success",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,oid:W==null?void 0:W.oid}})}if(!ye){L({name:"abha_create_process_oid_switch_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",is_eka_app_login:N?"true":"false",platform:C,oid:ye||"missing_oid",oid_exists:!!ye}});return}L({name:"abha_create_process_switch_started",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,oid:ye}});const De=await E({oid:ye});if(De.error){L({name:"abha_create_process_switch_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",is_eka_app_login:N?"true":"false",platform:C,oid:ye||"missing_oid",oid_exists:!!ye,error_message:((X=De.error)==null?void 0:X.message)||"unknown_error",error_message_exists:!!((K=De.error)!=null&&K.message)}}),o(Q.REJECTED),c(((oe=De.error)==null?void 0:oe.message)||"Something went wrong, please try again");return}L({name:"abha_create_process_switch_success",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,oid:ye}}),o(Q.RESOLVED);return}r(`${e}${ui()==="DEV"?"@sbx":"@abdm"}`);const{exists:P,error:R,action:M}=await Kb({abha_address:e});if(R){o(Q.REJECTED),c(R||"Something went wrong. Please try again.");return}if(P){o(Q.REJECTED),c("This abha address is already taken.");return}if(i===ee.ABHA_NUMBER){if(!n)return;const{error:ce,eka:me,action:se}=await Gb({abha_address:e,txn_id:n});if(se){f(se);return}if(ce||!me){o(Q.REJECTED),c(ce||"Something went wrong. Please try again.");return}if(A&&A.auth&&N){o(Q.RESOLVED),bn({response:""}),jt();return}(!me.min_token||!l)&&(o(Q.REJECTED),c(ce||"Something went wrong. Please try again."));const ye=await d({txn_id:l||"",token:me.min_token,...me.oid?{oid:me.oid}:null});if(!ye.data){o(Q.REJECTED),c(((ie=ye.error)==null?void 0:ie.message)||"Something went wrong, please try again");return}o(Q.RESOLVED);return}},T=()=>{a();const P=O.getState().isEkaAppLogin;w(),O.setState({isEkaAppLogin:P})};return m.jsxs("div",{className:"pds2-w-full pds2-h-full pds2-flex pds2-flex-col",children:[m.jsx(Ta,{title:"Create ABHA Address",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>h(!0),children:m.jsx(Gr,{})}),className:"pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white pds2-flex-shrink-0"}),H&&m.jsxs("div",{className:"pds2-mx-16 pds2-mt-16 pds2-border-1 pds2-rounded-16 pds2-flex pds2-items-stretch pds2-overflow-hidden pds2-flex-shrink-0",style:{borderColor:"#F0B429",marginTop:"16px"},children:[m.jsx("div",{className:"pds2-bg-bg-warning-03 pds2-p-12 pds2-flex-1 pds2-flex pds2-items-center",children:m.jsx("p",{className:"pds2-text-14 pds2-text-text-03 pds2-font-medium",children:F===ee.MOBILE?"We will create a new ABHA address based on this mobile number":"We will create a new ABHA number and address based on this Aadhaar number."})}),m.jsx("div",{className:"pds2-bg-bg-warning-03 pds2-flex-shrink-0 pds2-flex pds2-items-center pds2-px-16",children:m.jsx("div",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center",children:m.jsx(iw,{className:"pds2-w-14 pds2-h-14",style:{color:"#F0B429"}})})})]}),m.jsx("div",{className:"pds2-p-16 pds2-flex-1 pds2-overflow-auto",children:m.jsx(H3,{address:e,setAddress:t,suggestions:x})}),u&&m.jsx("div",{className:"pds2-p-16 pds2-text-text-error pds2-text-center",children:u}),m.jsx("div",{className:"pds2-p-16 pds2-shadow-elevation-only-top pds2-sticky pds2-bottom-0",children:m.jsx(dn,{title:"Create",state:e.length<8&&e.length>18||s===Q.LOADING?"disabled":"enabled",onClick:B,isLoading:s===Q.LOADING,className:"pds2-w-full"})}),m.jsx(Xr,{onSubmitClick:T}),m.jsx(ml,{open:_,setOpen:h})]})};function V3({title:e,isDisabled:t,isSelected:n,onSelect:r}){const a=p.useRef(null);return m.jsx("div",{onClick:t?void 0:r,className:`pds2-flex pds2-items-center pds2-cursor-pointer pds2-py-12 pds2-px-16 pds2-border-1 pds2-rounded-12 pds2-bg-bg-white
|
|
129
|
+
`,children:[m.jsx("input",{type:"radio",name:"abha-suggestion",value:r,checked:e===r,onClick:()=>t(e===r?"":r),className:"focus:pds2-outline-none pds2-appearance-none"}),m.jsxs("span",{children:[r,ui()==="DEV"?"@sbx":"@abdm"]})]},r))})]}):null]}),$3=()=>{const[e,t]=p.useState(""),n=O(P=>P.txnId),r=O(P=>P.setSelectedAbhaAddress),a=O(P=>P.goBackLoginScreen),i=O(P=>P.abhaAuthFlowMethod),[s,o]=p.useState(null),l=O(P=>P.authTxnId),[u,c]=p.useState(null),{mutateAsync:d}=em(),f=O(P=>P.setBottomsheetErrorInfo),w=O(P=>P.clearAbhaAuthStore),[x,g]=p.useState([]),[_,h]=p.useState(!1),{mutateAsync:v}=j3(),y=O(P=>P.ekaProfileInfo),b=O(P=>P.registrationType),{mutateAsync:E}=Rm(),A=Cn(),N=O(P=>P.isEkaAppLogin),C=O(P=>P.clientId),$=["M","F","O","U"],H=O(P=>P.isNewLoginOrCreateFlow),F=O(P=>P.abhaAuthFlowMethod||ee.MOBILE),L=({name:P,data:R={}})=>{var D,k;const S={...{login_platform:C,is_eka_app_login:N?"true":"false",is_new_login_or_create_flow:H?"true":"false",txn_id:n||"missing txnId",oid:A!=null&&A["X-User-ID"]?"true":"false",access_token:A!=null&&A.auth?"true":"false",flow:F==null?void 0:F.toString()},...R};qe({eventName:P,eventData:S}),(k=(D=window.curio)==null?void 0:D.pushToMixpanel)==null||k.call(D,P,S)};p.useEffect(()=>{L({name:"page_view",data:{page_view:"choose_abha_address_screen",platform:C}})},[C]),p.useEffect(()=>{async function P(){if(n)try{const{suggestions:R,error:M}=await Yb({txn_id:n,fn:y==null?void 0:y.firstname,ln:y==null?void 0:y.lastname,dob:y==null?void 0:y.date_of_birth});if(M){c(M||"Something went wrong. Please try again.");return}R&&(g(R),R.length>0&&t(R[0]))}catch{}}P()},[]);const B=async()=>{var S,D,k,U,z,I,V,Y,Z,re,q,X,K,oe,ie;if(!e){L({name:"create_abha_address_click_no_selection",data:{platform:C,type:"create",reason:"no_abha_address_selected",abha_address_selected:!1}});return}if(L({name:"create_abha_address_clicks",data:{platform:C,type:"create"}}),o(Q.LOADING),b===ar.CREATE){if(!n||!y)return;const[ce,me,se]=y.date_of_birth?(S=y==null?void 0:y.date_of_birth)==null?void 0:S.split("-"):["","",""];if(i===ee.MOBILE){const xe={abha_address:e,day_of_birth:parseInt(se),first_name:y.firstname,gender:y.gender,last_name:y.lastname,month_of_birth:parseInt(me),pincode:y.pincode,year_of_birth:parseInt(ce),txn_id:n};L({name:"create_abha_process_started",data:{method:"mobile",abha_address:e,platform:C,pincode_sent:xe==null?void 0:xe.pincode,date_of_birth:(y==null?void 0:y.date_of_birth)||"missing date of birth",day_of_birth:(xe==null?void 0:xe.day_of_birth)||"missing day of birth",month_of_birth:(xe==null?void 0:xe.month_of_birth)||"missing month of birth",year_of_birth:(xe==null?void 0:xe.year_of_birth)||"missing year of birth"}});const{error:ne,eka:W,profile:J,action:we}=await v(xe);if(we){L({name:"create_abha_process_error_action",data:{method:"mobile",platform:C,error_message:((D=we==null?void 0:we.cta)==null?void 0:D.title)||"unknown_error_message",error_message_exists:!!((k=we==null?void 0:we.cta)!=null&&k.title)}}),f(we);return}if(ne||!W){L({name:"create_abha_process_failed",data:{method:"mobile",platform:C,error_message:ne||"unknown_error",error_message_exists:!!ne,pincode_received:(J==null?void 0:J.pincode)||"missing_pincode_received",pincode_received_exists:!!(J!=null&&J.pincode),pincode_sent:(y==null?void 0:y.pincode)||"missing_pincode_sent",pincode_sent_exists:!!(y!=null&&y.pincode)}}),o(Q.REJECTED),c(ne||"Something went wrong. Please try again.");return}if(L({name:"abha_address_created",data:{type:"create_abha",platform:C}}),W.oid&&N){o(Q.RESOLVED),L({name:"abha_create_process_started",data:{method:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C}});const be=$.includes(J==null?void 0:J.gender)?J==null?void 0:J.gender:void 0,Ke={oid:(W==null?void 0:W.oid)||"",fln:(J==null?void 0:J.first_name)+" "+(J==null?void 0:J.last_name),dob:`${J==null?void 0:J.year_of_birth}-${String(J==null?void 0:J.month_of_birth).padStart(2,"0")}-${String(J==null?void 0:J.day_of_birth).padStart(2,"0")}`,gen:be,mobile:J==null?void 0:J.mobile,at:"",fn:(J==null?void 0:J.first_name)||"",mn:(J==null?void 0:J.middle_name)||"",ln:(J==null?void 0:J.last_name)||"","health-ids":J!=null&&J.abha_address?[J.abha_address]:void 0,abha_number:(J==null?void 0:J.abha_number)||""},ke=vi(Ke);if(L({name:"abha_create_process_success",data:{method:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C}}),window.EkaAbha&&window.EkaAbha.onAbhaSuccess){(U=window.EkaAbha)==null||U.onAbhaSuccess(JSON.stringify({response:ke}));return}bn({response:ke}),jt();return}}else{L({name:"create_abha_process_started",data:{method:i==null?void 0:i.toLowerCase(),platform:C}});const{error:xe,eka:ne,profile:W,action:J}=await Ub({abha_address:e,txn_id:n});if(J){L({name:"create_abha_process_error_action",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:((z=J==null?void 0:J.cta)==null?void 0:z.title)||"unknown_error_message",error_message_exists:!!((I=J==null?void 0:J.cta)!=null&&I.title)}}),f(J);return}if(xe||!ne){L({name:"create_abha_process_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:xe||"unknown_error",error_message_exists:!!xe,pincode_received:(W==null?void 0:W.pincode)||"missing_pincode_received",pincode_received_exists:!!(W!=null&&W.pincode),pincode_sent:(y==null?void 0:y.pincode)||"missing_pincode_sent",pincode_sent_exists:!!(y!=null&&y.pincode)}}),o(Q.REJECTED),c(xe||"Something went wrong. Please try again.");return}if(L({name:"abha_address_created",data:{type:"create_abha",platform:C}}),ne.oid&&N){o(Q.RESOLVED),L({name:"abha_create_process_started",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,page_view:"choose_abha_address"}});const we=$.includes(W==null?void 0:W.gender)?W==null?void 0:W.gender:void 0,be={oid:(ne==null?void 0:ne.oid)||"",fln:(W==null?void 0:W.first_name)+" "+(W==null?void 0:W.last_name),dob:`${W==null?void 0:W.year_of_birth}-${String(W==null?void 0:W.month_of_birth).padStart(2,"0")}-${String(W==null?void 0:W.day_of_birth).padStart(2,"0")}`,gen:we,mobile:W==null?void 0:W.mobile,at:"",fn:(W==null?void 0:W.first_name)||"",mn:(W==null?void 0:W.middle_name)||"",ln:(W==null?void 0:W.last_name)||"","health-ids":W!=null&&W.abha_address?[W.abha_address]:void 0,abha_number:(W==null?void 0:W.abha_number)||""},Ke=vi(be);if(L({name:"abha_create_process_success",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C}}),window.EkaAbha&&window.EkaAbha.onAbhaSuccess){(V=window.EkaAbha)==null||V.onAbhaSuccess(JSON.stringify({response:Ke}));return}bn({response:Ke}),jt();return}}let ye=y.oid;if(y.oid){L({name:"abha_create_process_link_phr_started",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,page_view:"choose_abha_address"}});const{error:xe,action:ne,eka:W}=await Iy({abha_address:e,oid:y.oid});if(ne){L({name:"abha_create_process_link_phr_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:((Y=ne==null?void 0:ne.cta)==null?void 0:Y.title)||"unknown_error_message",error_message_exists:!!((Z=ne==null?void 0:ne.cta)!=null&&Z.title)}}),f(ne);return}if(xe||!W||!W.oid){L({name:"abha_create_process_link_phr_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:xe||"unknown_error",error_message_exists:!!xe,eka:W||"missing_eka",eka_oid:(W==null?void 0:W.oid)||"missing_oid",eka_oid_exists:!!(W!=null&&W.oid)}}),o(Q.REJECTED),c(xe||"Something went wrong. Please try again.");return}L({name:"abha_create_process_link_phr_success",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,page_view:"choose_abha_address"}})}else{L({name:"abha_create_process_eka_started",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C}});const xe={abha_address:e,day_of_birth:parseInt(se),first_name:y.firstname,gender:y.gender,last_name:y.lastname||"",month_of_birth:parseInt(me),pincode:y.pincode,year_of_birth:parseInt(ce)},{error:ne,eka:W,action:J}=await Ly({...xe});if(J){L({name:"abha_create_process_eka_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",platform:C,error_message:((re=J==null?void 0:J.cta)==null?void 0:re.title)||"unknown_error_message",error_message_exists:!!((q=J==null?void 0:J.cta)!=null&&q.title)}}),f(J);return}if(ne||!W||!W.oid){L({name:"abha_create_process_eka_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",is_eka_app_login:N?"true":"false",platform:C,error_message:ne||"unknown_error",error_message_exists:!!ne,eka_exists:!!W,eka_oid:(W==null?void 0:W.oid)||"missing_oid",eka_oid_exists:!!(W!=null&&W.oid),flow:F??""}}),o(Q.REJECTED),c(ne||"Something went wrong. Please try again.");return}ye=W.oid,L({name:"abha_create_process_eka_success",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,oid:W==null?void 0:W.oid}})}if(!ye){L({name:"abha_create_process_oid_switch_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",is_eka_app_login:N?"true":"false",platform:C,oid:ye||"missing_oid",oid_exists:!!ye}});return}L({name:"abha_create_process_switch_started",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,oid:ye}});const De=await E({oid:ye});if(De.error){L({name:"abha_create_process_switch_failed",data:{method:(i==null?void 0:i.toLowerCase())||"unknown_method",is_eka_app_login:N?"true":"false",platform:C,oid:ye||"missing_oid",oid_exists:!!ye,error_message:((X=De.error)==null?void 0:X.message)||"unknown_error",error_message_exists:!!((K=De.error)!=null&&K.message)}}),o(Q.REJECTED),c(((oe=De.error)==null?void 0:oe.message)||"Something went wrong, please try again");return}L({name:"abha_create_process_switch_success",data:{method:i==null?void 0:i.toLowerCase(),is_eka_app_login:N?"true":"false",platform:C,oid:ye}}),o(Q.RESOLVED);return}r(`${e}${ui()==="DEV"?"@sbx":"@abdm"}`);const{exists:P,error:R,action:M}=await Kb({abha_address:e});if(R){o(Q.REJECTED),c(R||"Something went wrong. Please try again.");return}if(P){o(Q.REJECTED),c("This abha address is already taken.");return}if(i===ee.ABHA_NUMBER){if(!n)return;const{error:ce,eka:me,action:se}=await Gb({abha_address:e,txn_id:n});if(se){f(se);return}if(ce||!me){o(Q.REJECTED),c(ce||"Something went wrong. Please try again.");return}if(A&&A.auth&&N){o(Q.RESOLVED),bn({response:""}),jt();return}(!me.min_token||!l)&&(o(Q.REJECTED),c(ce||"Something went wrong. Please try again."));const ye=await d({txn_id:l||"",token:me.min_token,...me.oid?{oid:me.oid}:null});if(!ye.data){o(Q.REJECTED),c(((ie=ye.error)==null?void 0:ie.message)||"Something went wrong, please try again");return}o(Q.RESOLVED);return}},T=()=>{a();const P=O.getState().isEkaAppLogin;w(),O.setState({isEkaAppLogin:P})};return m.jsxs("div",{className:"pds2-w-full pds2-h-full pds2-flex pds2-flex-col pds2-bg-bg-white",children:[m.jsx(Ta,{title:"Create ABHA Address",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>h(!0),children:m.jsx(Gr,{})}),className:"pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white pds2-flex-shrink-0"}),H&&m.jsxs("div",{className:"pds2-mx-16 pds2-mt-16 pds2-border-1 pds2-rounded-16 pds2-flex pds2-items-stretch pds2-overflow-hidden pds2-flex-shrink-0",style:{borderColor:"#F0B429",marginTop:"16px"},children:[m.jsx("div",{className:"pds2-bg-bg-warning-03 pds2-p-12 pds2-flex-1 pds2-flex pds2-items-center",children:m.jsx("p",{className:"pds2-text-14 pds2-text-text-03 pds2-font-medium",children:F===ee.MOBILE?"We will create a new ABHA address based on this mobile number":"We will create a new ABHA number and address based on this Aadhaar number."})}),m.jsx("div",{className:"pds2-bg-bg-warning-03 pds2-flex-shrink-0 pds2-flex pds2-items-center pds2-px-16",children:m.jsx("div",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center",children:m.jsx(iw,{className:"pds2-w-14 pds2-h-14",style:{color:"#F0B429"}})})})]}),m.jsx("div",{className:"pds2-p-16 pds2-flex-1 pds2-overflow-auto pds2-bg-bg-white",children:m.jsx(H3,{address:e,setAddress:t,suggestions:x})}),u&&m.jsx("div",{className:"pds2-p-16 pds2-text-text-error pds2-text-center",children:u}),m.jsx("div",{className:"pds2-p-16 pds2-shadow-elevation-only-top pds2-sticky pds2-bottom-0",children:m.jsx(dn,{title:"Create",state:e.length<8&&e.length>18||s===Q.LOADING?"disabled":"enabled",onClick:B,isLoading:s===Q.LOADING,className:"pds2-w-full"})}),m.jsx(Xr,{onSubmitClick:T}),m.jsx(ml,{open:_,setOpen:h})]})};function V3({title:e,isDisabled:t,isSelected:n,onSelect:r}){const a=p.useRef(null);return m.jsx("div",{onClick:t?void 0:r,className:`pds2-flex pds2-items-center pds2-cursor-pointer pds2-py-12 pds2-px-16 pds2-border-1 pds2-rounded-12 pds2-bg-bg-white
|
|
130
130
|
${n?"pds2-border-border-brand-01":"pds2-border-border-03"}
|
|
131
131
|
focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2
|
|
132
132
|
active:pds2-bg-bg-brand-02 hover:pds2-bg-bg-hover-01
|
|
133
133
|
pds2-transition-colors pds2-duration-200
|
|
134
|
-
`,tabIndex:-1,ref:a,children:m.jsx("p",{className:`${n?"pds2-text-text-brand Body2Semibold":"pds2-text-text-01 Body2Medium"}`,children:e})})}const dy=()=>{const e=O(k=>k.screen),t=O(k=>k.selectedAbhaAddress),n=O(k=>k.setBottomsheetErrorInfo),r=O(k=>k.clearAbhaAuthStore),a=O(k=>k.goBackLoginScreen),[i,s]=p.useState(Q.IDLE),[o,l]=p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),[u,c]=p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),[d,f]=p.useState(null),{mutateAsync:w}=Rm(),[x,g]=p.useState(!1),_=O(k=>k.ekaProfileInfo),h=O(k=>k.setEkaProfileInfo),v=O(k=>k.setScreen),y=e[e.length-1],b=O(k=>k.aadhaarVerificationSkipStateStatus),E=ki.getQueryData(["abdmProfilePhrResponse"]),A=O(k=>k.abhaAuthFlowMethod);p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""});const N=O(k=>k.isDocAppRequest),C=O(k=>k.clientId),$=O(k=>k.isEkaAppLogin),H=O(k=>k.isNewLoginOrCreateFlow),F=O(k=>k.txnId),L=Cn(),[B,T]=p.useState(null),P=O(k=>k.abhaAuthFlowMethod),R=({name:k,data:U={}})=>{var V,Y;const I={...{login_platform:C,is_eka_app_login:$?"true":"false",is_new_login_or_create_flow:H?"true":"false",txn_id:F||"missing txnId",oid:L!=null&&L["X-User-ID"]?"true":"false",access_token:L!=null&&L.auth?"true":"false",flow:P??""},...U};qe({eventName:k,eventData:I}),(Y=(V=window.curio)==null?void 0:V.pushToMixpanel)==null||Y.call(V,k,I)};p.useEffect(()=>{R({name:"page_view",data:{page_view:"create_profile_screen"}})},[C]),p.useEffect(()=>{var k;if((k=window.EkaAbha)!=null&&k.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var U,z;(U=window.EkaAbha)!=null&&U.changeStatusBarColor&&((z=window==null?void 0:window.EkaAbha)==null||z.changeStatusBarColor("#FFFFFF"))}},[]),p.useEffect(()=>{if(E){const{first_name:k,last_name:U,gender:z,pincode:I,day_of_birth:V,month_of_birth:Y,year_of_birth:Z}=E,re=V===0?1:V,X=`${Z}-${String(Y===0?1:Y).padStart(2,"0")}-${String(re).padStart(2,"0")}`;R({name:"profile_data_set_from_phr_cache",data:{source:"phr_cache",date_of_birth:X,firstname:k??"missing",lastname:U??"missing",gender:z??"missing",pincode:I??"missing",dob_day:V??"missing",dob_month:Y??"missing",dob_year:Z??"missing",flow:P??""}}),l({firstname:k,lastname:U,gender:z,pincode:I,date_of_birth:X});return}if(_){let k="1983",U="01",z="01";if(_.date_of_birth){const V=_.date_of_birth.split("-");k=V[0],U=V[1]==="00"||!V[1]?"01":V[1],z=V[2]==="00"||!V[2]?"01":V[2]}const I=`${k}-${String(U).padStart(2,"0")}-${String(z).padStart(2,"0")}`;l({firstname:_.firstname,lastname:_.lastname,gender:_.gender,pincode:_.pincode,date_of_birth:I,oid:_.oid}),R({name:"profile_data_set_from_eka_profile",data:{source:"eka_profile",date_of_birth:(_==null?void 0:_.date_of_birth)??"missing",firstname:(_==null?void 0:_.firstname)??"missing",lastname:(_==null?void 0:_.lastname)??"missing",gender:(_==null?void 0:_.gender)??"missing",pincode:(_==null?void 0:_.pincode)??"missing",oid:(_==null?void 0:_.oid)??"missing"}})}},[E,_]);const M=p.useMemo(()=>!!(o.firstname&&!u.firstname&&o.date_of_birth&&!u.date_of_birth&&o.pincode&&!u.pincode&&o.gender&&!u.gender),[o,u]),S=async()=>{var U,z,I,V;const k={firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""};if(c(k),o.firstname.trim()||(k.firstname="Enter Name"),o.lastname.trim()||(k.lastname="This field is required"),o.date_of_birth||(k.date_of_birth="Enter DOB"),o.gender||(k.gender="Select Gender"),o.pincode||(k.pincode="Enter Valid Pincode"),!!M){if(R({name:"create_profile_screen_clicks",data:{type:"create_profile"}}),s(Q.LOADING),y===ve.CREATE_EKA_PROFILE){if(R({name:"navigate_to_create_abha_address_screen",data:{type:"next",pincode_entered:(o==null?void 0:o.pincode)??"unknown",eka_profile_info_pincode:(_==null?void 0:_.pincode)??"unknown",flow_type:A||"unknown_method"}}),A===ee.MOBILE){const Y=await Xb({pincode:Number(o.pincode)});if(Y!=null&&Y.error){T(Y!=null&&Y.error?"Invalid Pincode":null),s(Q.REJECTED),R({name:"pincode_api_failed",data:{type:"error",error:Y==null?void 0:Y.error}});return}if(R({name:"pincode_api_success",data:{type:"verify",pincode_received:!!Y.pincode,txn_id:F}}),Y!=null&&Y.pincode){f(null),h(o),R({name:"eka_profile_info_set",data:{firstname:o==null?void 0:o.firstname,lastname:o==null?void 0:o.lastname,gender:o==null?void 0:o.gender,pincode:o==null?void 0:o.pincode,date_of_birth:o==null?void 0:o.date_of_birth}}),v(ve.CREATE_ABHA_ADDRESS);return}R({name:"no_action_on_pincode",data:{type:"verify",pincode_entered:!!Y.pincode,txn_id:F}});return}else if(A===ee.AADHAR_NUMBER){h(o),R({name:"eka_profile_info_set",data:{firstname:o==null?void 0:o.firstname,lastname:o==null?void 0:o.lastname,gender:o==null?void 0:o.gender,pincode:o==null?void 0:o.pincode,date_of_birth:o==null?void 0:o.date_of_birth}}),v(ve.CREATE_ABHA_ADDRESS);return}}if(y===ve.CREATE_PHR_EKA_PROFILE){if(!t){R({name:"abha_create_eka_profile_abha_address_missing",data:{platform:C}});return}const[Y,Z,re]=o.date_of_birth?(U=o==null?void 0:o.date_of_birth)==null?void 0:U.split("-"):["","",""],q={abha_address:t,day_of_birth:parseInt(re),first_name:o.firstname,gender:o.gender,last_name:o.lastname||"",month_of_birth:parseInt(Z),pincode:o.pincode,year_of_birth:parseInt(Y)};R({name:"profile_eka_process_started",data:{platform:C,date_of_birth:(o==null?void 0:o.date_of_birth)||null,dob_day:re||null,dob_month:Z||null,dob_year:Y||null}});const{error:X,eka:K,action:oe}=await Ly({...q});if(oe){R({name:"profile_eka_process_failed",data:{platform:C,error_message:((z=oe==null?void 0:oe.cta)==null?void 0:z.title)||"unknown_error",error_message_exists:!!((I=oe==null?void 0:oe.cta)!=null&&I.title)}}),n(oe);return}if(X||!K||!K.oid){R({name:"profile_process_failed",data:{platform:C,error_message:X||"Unknown error",eka_oid:(K==null?void 0:K.oid)||"missing",eka_exists:!!K,date_of_birth:(o==null?void 0:o.date_of_birth)||"missing",dob_day:re||"missing",dob_month:Z||"missing",dob_year:Y||"missing",parsed_date_valid:!!(parseInt(re)&&parseInt(Z)&&parseInt(Y)),firstname:(o==null?void 0:o.firstname)||"missing",gender:(o==null?void 0:o.gender)||"missing",pincode:(o==null?void 0:o.pincode)||"missing"}}),s(Q.REJECTED),f(X||"Something went wrong. Please try again.");return}R({name:"profile_eka_process_success",data:{platform:C,eka:K}}),R({name:"profile_switch_process_started",data:{platform:C,error_message:X,eka:K}});const ie=await w({oid:K.oid});if(ie.error){R({name:"profile_switch_process_failed",data:{platform:C,error_message:ie.error||"Something went wrong, please try again",error_message_exists:!!ie.error}}),s(Q.REJECTED),f(((V=ie.error)==null?void 0:V.message)||"Something went wrong, please try again");return}R({name:"profile_switch_process_success",data:{platform:C,eka:K}}),s(Q.RESOLVED);return}}},D=()=>{a();const k=O.getState().isEkaAppLogin;r(),O.setState({isEkaAppLogin:k})};return m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-bg-bg-01",style:{height:"80vh"},children:[m.jsx(Ta,{title:"",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>g(!0),children:m.jsx(Gr,{className:""})}),className:"pds2-bg-bg-01"}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-flex-1 pds2-p-8",children:[m.jsx("div",{className:"pds2-flex pds2-items-center pds2-justify-between",children:m.jsx("div",{className:"pds2-space-y-2 pds2-text-text-01",children:N?m.jsx("div",{className:"Heading4Semibold",children:"Create ABHA Profile"}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"Heading4Semibold",children:"Create your"}),m.jsx("div",{className:"Heading2Semibold",children:"Eka Profile"})]})})}),m.jsx(U3,{profileData:o,setProfileData:l,error:u,setError:c,pincodeApiError:B})]}),d&&m.jsx("div",{className:"pds2-p-16 pds2-text-text-error pds2-text-center",children:d}),m.jsxs("div",{className:"pds2-sticky pds2-bottom-0 pds2-bg-bg-white pds2-w-full",children:[t&&b===Mt.ABHA_END?m.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:[m.jsxs("div",{className:"",children:[m.jsx("span",{className:"pds2-text-text-03 Body2Regular",children:"Creating for: "}),m.jsx("span",{className:"pds2-text-text-01 Body2Semibold",children:t})]}),m.jsx("button",{onClick:a,className:"Body2Semibold pds2-text-text-brand pds2-rounded-full ripple pds2-px-8 pds2-py-2",children:"Change"})]}):null,m.jsx("div",{className:"pds2-p-16 pds2-w-full",children:m.jsx(dn,{className:"pds2-w-full",title:"Create Profile",state:i===Q.LOADING?"disabled":"enabled",onClick:S,isLoading:i===Q.LOADING})})]}),m.jsx(Xr,{onSubmitClick:D}),m.jsx(ml,{open:x,setOpen:g})]})},B3=[{id:"M",name:"Male"},{id:"F",name:"Female"},{id:"O",name:"Other"}],U3=({profileData:e,setProfileData:t,error:n,setError:r,pincodeApiError:a})=>{const i=({event:c,name:d})=>{const f=c.target.value;let w="";switch(d){case"firstname":f.trim()?w="":w="This field is required";break;case"lastname":!f||f.length<0?w="This field is required":w="";break;case"pincode":!f||isNaN(Number(f))||f.length!=6?w="Pincode must consist of exactly 6 digits":w="";break;case"date_of_birth":!f||f>new Date().toISOString().split("T")[0]?w="Date of Birth is invalid":w="";break}r({...n,[d]:w}),t({...e,[d]:f})},s=c=>{t({...e,gender:c}),r({...n,gender:""})},o=(c,d)=>d!=null&&d.pincode||!((c.firstname??"").trim()!==""&&(c.gender??"").trim()!==""&&(c.date_of_birth??"").trim()!=="")?!1:!c.pincode||(c.pincode+"").length!==6,l=O(c=>c.ekaProfileInfo),u=O(c=>c.abhaAuthFlowMethod);return m.jsxs("form",{className:"pds2-flex pds2-flex-col pds2-space-y-32",children:[m.jsxs("label",{className:"pds2-space-y-8",children:[m.jsxs("div",{className:"Body3Medium pds2-text-text-04",children:["Your name",m.jsx("sup",{className:"pds2-text-text-error Body3Semibold",children:"*"})]}),m.jsxs("div",{className:"pds2-flex pds2-gap-8",children:[m.jsxs("div",{className:"pds2-flex pds2-flex-col",children:[m.jsx(Hr,{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:e.firstname,onChange:c=>i({event:c,name:"firstname"}),autoCapitalize:"on",disabled:!!(l!=null&&l.firstname)&&u===ee.AADHAR_NUMBER,error:n.firstname}),n.firstname&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-4",children:n.firstname})]}),m.jsx("div",{children:m.jsx(Hr,{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:e.lastname,onChange:c=>i({event:c,name:"lastname"}),autoCapitalize:"on",disabled:!!(l!=null&&l.lastname)&&u===ee.AADHAR_NUMBER})})]})]}),m.jsxs("div",{className:"pds2-space-y-8",children:[m.jsxs("div",{className:"pds2-space-y-4",children:[m.jsxs("div",{className:"Body3Medium pds2-text-text-04",children:["Gender",m.jsx("sup",{className:"pds2-text-text-error Body3Semibold",children:"*"})]}),m.jsx("div",{className:"pds2-flex pds2-gap-16",children:B3.map((c,d)=>m.jsx("div",{className:`${n.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:m.jsx(V3,{isSelected:c.id===e.gender,title:c.name,onSelect:()=>s(c.id)})},d))}),n.gender&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-2",children:n.gender})]}),m.jsxs("div",{className:"pds2-flex pds2-flex-col",children:[m.jsx(Hr,{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:e.date_of_birth,disabled:!!(l!=null&&l.date_of_birth)&&u===ee.AADHAR_NUMBER,onChange:c=>i({event:c,name:"date_of_birth"}),type:"date",maxDate:new Date().toISOString().split("T")[0],error:n.date_of_birth}),n.date_of_birth&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-2",children:n.date_of_birth})]})]}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-space-y-4",children:[m.jsx(Hr,{label:"Pincode",isMandatory:!0,textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:o(e,l)||a?"pds2-border-1 pds2-border-text-error":"",value:e.pincode,placeholder:"Enter Pincode",disabled:!!(l!=null&&l.pincode)&&u===ee.AADHAR_NUMBER,onChange:c=>{c.target.value.length>6||i({event:c,name:"pincode"})},type:"number",error:o(e,l)?n.pincode:"",textStyle:o(e,l)||a?"placeholder:pds2-text-text-error":"placeholder:pds2-text-text-04"}),a||n.pincode&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-4",children:n.pincode})]})]})},z3=()=>PC({queryKey:["profilesPhrUserResponse"],queryFn:async()=>{const e=await Lb();var t;return Array.isArray(e)?t=e==null?void 0:e.filter(r=>!r["health-ids"]||r["health-ids"].length===0):t=[],{profiles:t}}}),W3=()=>{const e=O(g=>g.setScreen);O(g=>g.screen),O(g=>g.goBackLoginScreen),O(g=>g.clearAbhaAuthStore);const[t,n]=p.useState(!1);p.useState("");const r=O(g=>g.clientId),a=O(g=>g.aadhaarVerificationSkipStateStatus),i=O(g=>g.isEkaAppLogin),s=O(g=>g.isNewLoginOrCreateFlow),o=O(g=>g.txnId),l=Cn(),u=O(g=>g.abhaAuthFlowMethod),c=({name:g,data:_={}})=>{var y,b;const v={...{login_platform:r,is_eka_app_login:i?"true":"false",is_new_login_or_create_flow:s?"true":"false",txn_id:o||"missing txnId",oid:l!=null&&l["X-User-ID"]?"true":"false",access_token:l!=null&&l.auth?"true":"false",flow:u??""},..._};qe({eventName:g,eventData:v}),(b=(y=window.curio)==null?void 0:y.pushToMixpanel)==null||b.call(y,g,v)};p.useEffect(()=>{if(r==="doctor"){c({name:"page_view",data:{platform:r,page_view:"get-all-profiles-screen"}}),c({name:"redirect_to_create_eka_profile_screen",data:{type:"next"}}),e(ve.CREATE_EKA_PROFILE);return}},[r]);let d=!1;i?d=!1:i||(r==="doctor"?d=!1:d=!0);const{data:f,error:w,isLoading:x}=d?z3():{data:null,error:null,isLoading:!1};return p.useEffect(()=>{if(r==="doctor")return;(async()=>{!x&&f&&(n(!0),await new Promise(_=>setTimeout(_,2e3)),n(!1),!f.profiles||f.profiles.length<1?a===Mt.ABHA_END?(c({name:"redirect_to_create_phr_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.CREATE_PHR_EKA_PROFILE)):(c({name:"redirect_to_create_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.CREATE_EKA_PROFILE)):(c({name:"redirect_to_select_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.SELECT_EKA_PROFILE)))})()},[x,f]),t?m.jsx(Zh,{loading:!0,loadingText:"In progress...",successText:""}):null},Y3=()=>{const e=O(i=>i.setAbhaAuthFlowMethod),t=O(i=>i.clientId),n=O(i=>i.clearAbhaAuthStore);p.useEffect(()=>{var i;if(qe({eventName:"page_view",eventData:{page_view:"abha_login_screen",platform:t}}),e(ee.MOBILE),(i=window.EkaAbha)!=null&&i.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var s,o;(s=window.EkaAbha)!=null&&s.changeStatusBarColor&&((o=window==null?void 0:window.EkaAbha)==null||o.changeStatusBarColor("#FFFFFF"))}},[]);const r=()=>{var s;(s=window.EkaAbha)==null||s.onAbhaClose();const i=O.getState().isNewLoginOrCreateFlow;n(),O.setState({isNewLoginOrCreateFlow:i}),jt()},a=["eka-web","phr"];return m.jsxs("div",{className:"pds2-bg-bg-white",children:[!a.includes(t)&&m.jsx(Ta,{prefixIcon:m.jsx("button",{onClick:r,children:m.jsx(Gr,{})}),title:"",className:"pds2-bg-bg-01"}),m.jsx(K3,{}),m.jsx(G3,{})]})},G3=()=>{const e=O(r=>r.setAbhaAuthFlowMethod),t=O(r=>r.abhaAuthFlowMethod),n=[{method:ee.ABHA_NUMBER,title:"ABHA Number",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Number Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:ee.PHR_ADDRESS,title:"ABHA Address",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Address Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:ee.AADHAR_NUMBER,title:"Aadhaar Number",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm5mcdm3h00070tfs9fjkepff.webp",alt:"Aadhaar Number Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:ee.MOBILE,title:"Mobile Number",icon:m.jsx(Cc,{className:"pds2-w-20 pds2-h-20 pds2-text-icon-success-02"})}];return m.jsxs("div",{className:"pds2-p-16 pds2-space-y-16",children:[m.jsx(Vc,{title:"Other login options for ABHA"}),m.jsx("div",{className:"pds2-space-y-16",children:n.filter(r=>r.method!==t).map(r=>m.jsx(yi,{prefixIcon:r.icon,title:r.title,suffixIcon:m.jsx(Pr,{className:"pds2-ml-auto pds2-h-16 pds2-w-16 pds2-text-text-04 -pds2-rotate-90","aria-hidden":"true"}),onClick:()=>e(r.method)},r.method))})]})},K3=()=>{const e=O(B=>B.setScreen),t=O(B=>B.abhaAuthFlowMethod||ee.MOBILE),n=O(B=>B.setRegistrationType),r=O(B=>B.setAadhaarInitResponse),[a,i]=p.useState(""),[s,o]=p.useState(""),[l,u]=p.useState(Q.IDLE),c=O(B=>B.setLoginIdentifierValue),d=O(B=>B.setSelectedAbhaAddress),[f,w]=p.useState(!1),x=O(B=>B.initAbhaAppMobileNumber),g=O(B=>B.setBottomsheetErrorInfo),[_,h]=Fe.useState(null),[v,y]=p.useState(""),b=O(B=>B.clientId),E=O(B=>B.isEkaAppLogin);p.useEffect(()=>{if(x&&t===ee.MOBILE){i(x),w(x.length===10),o(null);return}i(""),o(null),w(!1)},[t]);const A=B=>{s&&o(null);const T=B.target.value;switch(t){case ee.PHR_ADDRESS:if(T.length>20)return;break;case ee.MOBILE:if(T&&!/^[0-9]+$/.test(T)||T.length>10)return;break;case ee.ABHA_NUMBER:if(!/^[\d-]*$/.test(T)||T.length>17)return;break;case ee.AADHAR_NUMBER:if(T&&!/^[0-9]+$/.test(T)||T.length>12)return;break}if(t===ee.ABHA_NUMBER){const P=B.target.value.replace(/-/g,"");let R="";P.length>0&&(R+=P.slice(0,2)),P.length>2&&(R+=`-${P.slice(2,6)}`),P.length>6&&(R+=`-${P.slice(6,10)}`),P.length>10&&(R+=`-${P.slice(10,14)}`),i(R)}else i(T.trim())},N=({inputVal:B})=>{s&&o(null),B.length===12&&i(B)},C=p.useCallback(()=>{const B=t===ee.MOBILE&&!!x;if(t===ee.AADHAR_NUMBER)return m.jsx($c,{numberOfInputs:3,length:4,placeholder:"XXXX",onSubmit:N});const T={value:a,onChange:A,...t===ee.MOBILE&&{type:"tel",placeholder:"Mobile Number",disabled:B,PrefixComponent:m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-x-8 pds2-border-r pds2-border-border-brand-02 pds2-pr-24",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4mlct2900000tg98p8u967s.webp",alt:"India Flag",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:"pds2-text-text-black",children:"+91"})]})},...t===ee.ABHA_NUMBER&&{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"},...t===ee.PHR_ADDRESS&&{placeholder:"Enter ABHA Address"}};return m.jsx(Hr,{...T})},[t,a,s]),$=(B=_)=>{B&&(O.setState({isLoggedInFromRedirect:!0}),y(a),O.setState({initAbhaAppMobileNumber:a}),O.setState({abhaAuthFlowMethod:ee.MOBILE}),e(ve.CREATE_ABHA_WITH_AADHAAR),g(null))},H=async()=>{u(Q.LOADING);let B="";if(!E){const{txn_id:D,error:k}=await nh({method:tl.ABHA});if(!D||k){o((k==null?void 0:k.message)||"Something went wrong. Please try again."),u(Q.REJECTED);return}B=D,console.log("triggering logout api in login with abha screen"),await lc()}n(ar.LOGIN);const T=t===ee.PHR_ADDRESS?`${a}${ui()==="DEV"?"@sbx":"@abdm"}`:a;console.log("loginIdentifier",T);const{txn_id:P,error:R,action:M,hint:S}=await uc({method:t,identifier:T});if(console.log("after postAbdmLoginInit",M),console.log("after postAbdmLoginInit",M),M){h(M),g(M);return}if(R){o(R||"Something went wrong. Please try again."),u(Q.REJECTED);return}if(!P){o("Something went wrong. Please try again."),u(Q.REJECTED);return}t===ee.PHR_ADDRESS&&d(T),r({authTxnId:B,txnId:P,aadhaarOtpSentToHint:S||null}),c(T),u(Q.RESOLVED),qe({eventName:"abha_login_submitted",eventData:{type:"next",platform:b}}),e(ve.VERIFY_OTP_LOGIN_WITH_ABHA)},F=Fe.useMemo(()=>{switch(t){case ee.PHR_ADDRESS:return a.length>=4&&a.length<=20;case ee.MOBILE:return a.length===10;case ee.ABHA_NUMBER:return a.length===17;case ee.AADHAR_NUMBER:return a.length===12}},[t,a]),L=Fe.useMemo(()=>{switch(t){case ee.ABHA_NUMBER:return"Enter your ABHA Number";case ee.PHR_ADDRESS:return"Enter your ABHA Address";case ee.MOBILE:return"Enter your Mobile Number";case ee.AADHAR_NUMBER:return"Enter your Aadhaar Number";default:return"Enter your ABHA Number"}},[t]);return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"pds2-p-16 pds2-bg-bg-01 pds2-space-y-16 pds2-text-center",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-items-center pds2-gap-16",children:m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abha",className:"pds2-w-64 pds2-h-64"})})}),m.jsx("div",{className:"Heading3Semibold pds2-text-text-black",children:"Log in With ABHA"}),m.jsx("div",{className:"pds2-text-text-black pds2-mt-2",children:L}),m.jsx("div",{className:"pds2-space-y-12",children:m.jsxs("div",{className:"pds2-relative",children:[C(),t===ee.PHR_ADDRESS&&m.jsx("div",{className:"pds2-absolute pds2-right-16 pds2-top-16 Body1Regular pds2-text-text-03",children:ui()==="DEV"?"@sbx":"@abdm"})]})}),s&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:s}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!F||!f||l===Q.LOADING?"disabled":"enabled",isLoading:l===Q.LOADING,onClick:H,className:"pds2-w-full"}),m.jsxs("div",{className:"pds2-flex pds2-flex-row pds2-justify-center pds2-items-center pds2-bg-bg-white pds2-w-fit pds2-px-12 pds2-bg-opacity-60 pds2-rounded-12 pds2-mx-auto",children:[m.jsx("div",{className:"pds2-text-text-04 Body3Regular",children:"Don’t have ABHA?"}),m.jsx(yi,{className:"pds2-text-text-brand Body3Semibold pds2-pl-4 pds2-pr-0 pds2-py-4 ripple pds2-border-none pds2-bg-transparent",width:"pds2-w-fit",title:"Register Now",onClick:()=>{e(ve.CREATE_ABHA_WITH_AADHAAR)}})]})]}),m.jsx(Xr,{onSubmitClick:$})]})},q3=()=>{const e=O(t=>t.setSelectedAbhaAddress);return ol({mutationFn:({txn_id:t,phr_address:n})=>Wb({txn_id:t,phr_address:n}),onSuccess(t){t.profile&&(ki.setQueryData(["abdmProfilePhrResponse"],t.profile),e(t.profile.abha_address))}})},Q3=()=>{var re;const[e,t]=p.useState(null),n=O(q=>q.setScreen),r=O(q=>q.goBackLoginScreen),a=O(q=>q.txnId),i=O(q=>q.authTxnId),s=O(q=>q.abhaAddressList),o=O(q=>q.setBottomsheetErrorInfo),l=O(q=>q.clearAbhaAuthStore),u=O(q=>q.setSelectedAbhaAddress),c=O(q=>q.abhaAuthFlowMethod),d=O(q=>q.loginIdentifierValue),[f,w]=p.useState(""),[x,g]=p.useState(!1),_=O(q=>q.setEkaProfileInfo),h=O(q=>q.setAbhaAuthFlowMethod),v=O(q=>q.setAadhaarVerificationSkipStateStatus),[y,b]=p.useState(Q.IDLE),E=["M","F","O","U"],{mutateAsync:A}=em(),{mutateAsync:N}=q3();O(q=>q.ekaProfileInfo),O(q=>q.registrationType);const C=O(q=>q.clientId),$=O(q=>q.isEkaAppLogin),H=O(q=>q.setRegistrationType),F=O(q=>q.abhaAuthFlowMethod),L=O(q=>q.identityValue),B=O(q=>q.setMobileInitResponse),[T,P]=p.useState({aadhaar:Q.IDLE,mobile:Q.IDLE}),R=O(q=>q.setAadhaarInitResponse),M=O(q=>q.setSelectedAbhaFlow),S=O(q=>q.isNewLoginOrCreateFlow),D=Cn(),k=O(q=>q.setLoginIdentifierValue),[U,z]=p.useState(!1),I=({name:q,data:X={}})=>{var ie,ce;const oe={...{login_platform:C,is_eka_app_login:$?"true":"false",is_new_login_or_create_flow:S?"true":"false",txn_id:a||"missing txnId",oid:D!=null&&D["X-User-ID"]?"true":"false",access_token:D!=null&&D.auth?"true":"false",flow:F??""},...X};qe({eventName:q,eventData:oe}),(ce=(ie=window.curio)==null?void 0:ie.pushToMixpanel)==null||ce.call(ie,q,oe)},V=async()=>{I({name:"abha_login_select_abha_init_started",data:{method:F,platform:C}});const q=(X,K)=>{P(oe=>({...oe,[X]:K}))};if(H(ar.CREATE),F===ee.MOBILE){const{txn_id:X,hint:K,error:oe,action:ie}=await ah({mobile_number:L});if(X&&K){I({name:"abha_login_select_abha_mobile_init_success",data:{method:F,platform:C,txn_id:X}}),B({authTxnId:i,txnId:X,mobileOtpSentToHint:K}),M("mobile"),q("mobile",Q.RESOLVED),H(ar.CREATE),n(ve.ABHA_PHONE_NUMBER_VERIFICATION);return}I({name:"abha_login_select_abha_init_failed",data:{method:F,platform:C,reason:oe||"unknown",reason_exists:!!oe}}),q("mobile",Q.REJECTED),ie?o(ie):w(oe||"Something went wrong")}else if(F===ee.AADHAR_NUMBER){I({name:"abha_fetching_profiles",data:{method:F,platform:C}}),n(ve.GET_ALL_PROFILES);return}},Y=async()=>{var me,se,ye,De,xe,ne;if(c===ee.AADHAR_NUMBER&&e){ii({extraHeaders:{auth:""}}),$||await lc()||I({name:"logout_api_failed_before_init_on_continue_click",data:{method:F,platform:C,reason:"logout_api_response_false"}});const{txn_id:W,error:J,action:we,hint:be}=await uc({method:ee.PHR_ADDRESS,identifier:e.abha_address});if(I({name:"abha_abdm_login_init_triggered",data:{flow_step_type:"init",authTxnId:i,ndhmTxnId:W,method:F}}),console.log("after postAbdmLoginInit",we),console.log("after postAbdmLoginInit",we),we){I({name:"abha_abdm_login_init_abha_error_action",data:{method:F,platform:C,action:((me=we==null?void 0:we.cta)==null?void 0:me.title)||"unknown",action_exists:!!((se=we==null?void 0:we.cta)!=null&&se.title)}}),o(we);return}if(J){I({name:"abha_abdm_login_init_failed",data:{method:F,platform:C,reason:J||"unknown",reason_exists:!!J}}),w(J||"Something went wrong. Please try again.");return}if(!W){w("Something went wrong. Please try again.");return}I({name:"abha_login_init_success",data:{flow_step_type:"init",authTxnId:i,ndhmTxnId:W,hint:be}}),R({authTxnId:i,txnId:W,aadhaarOtpSentToHint:be||null}),k(e.abha_address),h(ee.PHR_ADDRESS),n(ve.VERIFY_OTP_LOGIN_WITH_ABHA);return}if(!e)return;if(u(e.abha_address),console.log(y,"from abha"),!a){I({name:"abha_login_select_abha_txnId_not_found",data:{platform:C,reason:"txnId missing",reason_exists:!0}});return}b(Q.LOADING),I({name:"abha_login_select_abha_verify_start",data:{platform:C,txn_id:a}});const{error:q,eka:X,profile:K,action:oe,skip_state:ie}=await N({txn_id:a,phr_address:e.abha_address});if(oe){I({name:"abha_login_select_abha_error_action",data:{platform:C,txn_id:a,action:((ye=oe==null?void 0:oe.cta)==null?void 0:ye.title)||"unknown",action_exists:!!((De=oe==null?void 0:oe.cta)!=null&&De.title)}}),o(oe);return}if(q||!X){I({name:"abha_login_select_abha_abdm_error",data:{platform:C,txn_id:a,error_message:q||"eka object missing",error_exists:!!q}}),b(Q.REJECTED),w(q);return}if(!ie){w("skip State is missing");return}if(I({name:"abha_login_select_abha_verify_success",data:{platform:C,txn_id:a,skip_state:ie}}),v(ie),K&&(I({name:"abha_login_select_abha_profile_received",data:{platform:C}}),_({date_of_birth:`${K.year_of_birth}-${String(K.month_of_birth).padStart(2,"0")}-${String(K.day_of_birth).padStart(2,"0")}`,firstname:K.first_name,lastname:K.last_name,pincode:K.pincode,gender:K.gender,name:K.first_name+" "+K.last_name,mobile:K.mobile,oid:X==null?void 0:X.oid,middlename:K.middle_name,abha_address:K.abha_address,abha_number:K.abha_number}),u(K.abha_address)),$){if(!X.oid){I({name:"abha_login_select_abha_oid_null",data:{platform:C,oid:(X==null?void 0:X.oid)??"null_or_undefined"}}),b(Q.REJECTED);return}const W=E.includes(K==null?void 0:K.gender)?K==null?void 0:K.gender:void 0,J={oid:(X==null?void 0:X.oid)||"",fln:(K==null?void 0:K.first_name)+" "+(K==null?void 0:K.last_name),dob:`${K==null?void 0:K.year_of_birth}-${String(K==null?void 0:K.month_of_birth).padStart(2,"0")}-${String(K==null?void 0:K.day_of_birth).padStart(2,"0")}`,gen:W,mobile:K==null?void 0:K.mobile,at:"",fn:(K==null?void 0:K.first_name)||"",mn:(K==null?void 0:K.middle_name)||"",ln:(K==null?void 0:K.last_name)||"","health-ids":K!=null&&K.abha_address?[K.abha_address]:void 0,abha_number:(K==null?void 0:K.abha_number)||""},we=vi(J);if(b(Q.RESOLVED),I({name:"abha_login_select_abha_inside_app_success",data:{platform:C,oid:X.oid}}),window.EkaAbha&&window.EkaAbha.onAbhaSuccess){(xe=window.EkaAbha)==null||xe.onAbhaSuccess(JSON.stringify({response:we}));return}bn({response:we}),jt();return}if(!X.min_token||!i){I({name:"abha_login_select_abha_min_token_missing",data:{platform:C,oid:(X==null?void 0:X.oid)??"missing_oid",min_token:(X==null?void 0:X.min_token)??"missing_min_token",auth_txnId:i??"missing_authTxnId"}}),b(Q.REJECTED),w(q||"Something went wrong. Please try again.");return}const ce=await A({txn_id:i,token:X.min_token,...X.oid?{oid:X.oid}:null});if(!ce.data){I({name:"abha_login_select_abha_auth_verify_failed",data:{platform:C,oid:(X==null?void 0:X.oid)??"missing_oid",min_token:(X==null?void 0:X.min_token)??"missing_min_token",auth_txnId:i??"missing_authTxnId"}}),b(Q.REJECTED),w(((ne=ce.error)==null?void 0:ne.message)||"Something went wrong, please try again");return}b(Q.RESOLVED),I({name:"abha_login_select_abha_auth_verify_success",data:{platform:C,oid:X.oid,min_token:X==null?void 0:X.min_token,auth_txnId:i}})},Z=()=>{const q=O.getState().initAbhaAppMobileNumber,X=O.getState().isEkaAppLogin;r(),l(),O.setState({initAbhaAppMobileNumber:q}),O.setState({isEkaAppLogin:X})};return m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-h-full pds2-bg-bg-01",children:[m.jsx(Ta,{title:"Select ABHA to continue",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>g(!0),children:m.jsx(Gr,{})}),suffixIcon:((re=s==null?void 0:s[0])==null?void 0:re.kyc_verified)&&m.jsx(nA,{onClick:()=>z(q=>!q),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"}),U&&m.jsx("div",{onMouseLeave:()=>z(!1),className:"pds2-absolute pds2-right-10 pds2-top-45 pds2-mt-2 pds2-z-50 pds2-animate-fade-in",children:m.jsx(J3,{})}),m.jsxs("div",{className:"pds2-flex-1 pds2-overflow-y-auto pds2-flex pds2-flex-col pds2-p-16 pds2-space-y-16",children:[m.jsxs("div",{className:"pds2-text-text-03 Body1Regular pds2-text-center",children:["We found ",s==null?void 0:s.length," ABHA addresses ",m.jsx("br",{})," select one you want to log in with"]}),m.jsx(X3,{list:s,selectedAbha:e,setSelectedAbha:t}),((s==null?void 0:s.length)??0)<6&&(c===ee.MOBILE||c===ee.AADHAR_NUMBER)&&m.jsxs(m.Fragment,{children:[m.jsx(Vc,{title:"or"}),m.jsx(yi,{title:"Create new ABHA Address",prefixIcon:m.jsx(ow,{}),className:"pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold",onClick:V})]})]}),m.jsxs("div",{className:"pds2-bg-bg-white pds2-shadow-lg pds2-w-full pds2-sticky pds2-bottom-0 pds2-border-t pds2-border-border-brand-02 pds2-p-16 z-10",children:[f&&m.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-4",children:f}),c===ee.ABHA_NUMBER&&m.jsxs("div",{className:"pds2-text-center pds2-bg-bg-warning-03 pds2-py-2 pds2-mb-4",children:[m.jsx("span",{className:"pds2-text-text-03 Body2Regular",children:"Your ABHA No:"}),m.jsx("span",{className:"pds2-text-text-01 Body2Semibold",children:d})]}),m.jsx(dn,{title:"Continue",state:e===null||y===Q.LOADING?"disabled":"enabled",isLoading:y===Q.LOADING,className:"pds2-w-full",onClick:Y})]}),m.jsx(Xr,{onSubmitClick:Z}),m.jsx(ml,{open:x,setOpen:g})]})},X3=({list:e,selectedAbha:t,setSelectedAbha:n})=>m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-brand-02 pds2-w-full pds2-relative",children:e==null?void 0:e.map((r,a)=>m.jsxs(Fe.Fragment,{children:[m.jsxs("label",{className:"pds2-p-16 pds2-flex pds2-space-x-8",children:[m.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:r.abha_address,checked:(t==null?void 0:t.abha_address)===r.abha_address,onChange:()=>{n(r)}}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-space-y-4 pds2-flex-1",children:[m.jsxs("div",{className:"TitlesSubheadline pds2-text-text-primary pds2-flex pds2-flex-row pds2-items-center pds2-justify-between",children:[m.jsx("div",{children:r==null?void 0:r.abha_address}),m.jsx("div",{className:"pds2-flex pds2-flex-row pds2-items-center",children:(r==null?void 0:r.kyc_verified)&&(r.kyc_verified==="VERIFIED"?m.jsx("div",{className:"Label1Bold pds2-rounded-full pds2-h-full",children:m.jsx(rw,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-success-02 pds2-text-[2rem]"})}):m.jsx("div",{className:"Label1Bold pds2-rounded-full pds2-h-full",children:m.jsx(aw,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-orange-300 pds2-text-[2rem]"})}))})]}),m.jsx("div",{className:"pds2-text-text-03 Body3Regular pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-4",children:(r==null?void 0:r.name)&&m.jsx("div",{className:"Body3Regular pds2-text-text-03",children:r.name})})]})]}),a!==e.length-1&&m.jsx("div",{className:"pds2-px-16",children:m.jsx("div",{className:"pds2-bg-border-03 pds2-h-1 pds2-w-full"})})]},r.abha_address))}),J3=()=>m.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:[m.jsxs("div",{className:" pds2-px-16 pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-py-6",children:[m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-full",children:m.jsx(aw,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-orange-400"})}),m.jsx("div",{className:"pds2-text-text-invert",children:"Non KYC"})]}),m.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:[m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-full",children:m.jsx(rw,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-success-02"})}),m.jsx("div",{className:"pds2-text-text-invert",children:"KYC"})]})]}),Z3=()=>{var B;const e=O(T=>T.setScreen),t=O(T=>T.setEkaProfileInfo),n=O(T=>T.registrationType),r=O(T=>T.goBackLoginScreen),[a,i]=p.useState(null),s=O(T=>T.setBottomsheetErrorInfo),o=O(T=>T.clearAbhaAuthStore),[l,u]=p.useState(Q.IDLE),[c,d]=p.useState(!1),[f,w]=p.useState(null),x=O(T=>T.selectedAbhaAddress),g=O(T=>T.aadhaarVerificationSkipStateStatus),{mutateAsync:_}=Rm(),h=ki.getQueryData(["profilesPhrUserResponse"]),v=O(T=>T.clientId),y=O(T=>T.isEkaAppLogin),b=O(T=>T.isNewLoginOrCreateFlow),E=O(T=>T.txnId),A=Cn(),N=O(T=>T.abhaAuthFlowMethod),C=({name:T,data:P={}})=>{var S,D;const M={...{login_platform:v,is_eka_app_login:y?"true":"false",is_new_login_or_create_flow:b?"true":"false",txn_id:E||"missing txnId",oid:A!=null&&A["X-User-ID"]?"true":"false",access_token:A!=null&&A.auth?"true":"false",flow:N??""},...P};qe({eventName:T,eventData:M}),(D=(S=window.curio)==null?void 0:S.pushToMixpanel)==null||D.call(S,T,M)};p.useEffect(()=>{C({name:"choose_eka_profile_screen",data:{platform:v,type:"select"}})},[v]);const $=()=>{if(C({name:"create_family_profile_clicks",data:{platform:v,type:"create",skip_state:g}}),g===Mt.ABHA_END){C({name:"navigate_to_create_phr_profile_screen",data:{platform:v}}),e(ve.CREATE_PHR_EKA_PROFILE);return}C({name:"navigate_to_create_eka_profile_screen",data:{platform:v}}),e(ve.CREATE_EKA_PROFILE)},H=async({profile:T})=>{C({name:"select_profile_clicks",data:{platform:v,oid:T.oid}}),i(T.oid)},F=async()=>{var S,D,k,U;if(C({name:"continue_click_on_choose_eka_profile",data:{platform:v,selectedProfileOid:a,registrationType:n,skip_state:g}}),a&&g===Mt.ABHA_CREATE){const z=h==null?void 0:h.profiles.find(I=>I.oid===a);if(!z){C({name:"continue_click_profile_not_found",data:{platform:v,oid:a||"unknown_oid",oid_exists:!!a}});return}C({name:"navigate_to_create_eka_profile_screen_from_abha_create",data:{platform:v,oid:z.oid}}),t({oid:z.oid,date_of_birth:z.dob,firstname:z.fn,lastname:z.ln,pincode:"",gender:z.gen,mobile:z.mobile,name:z.fln,middlename:z.mn,abha_address:(S=z==null?void 0:z["health-ids"])==null?void 0:S[0],abha_number:z.abha_number}),e(ve.CREATE_EKA_PROFILE);return}if(!x||!a){C({name:"continue_click_missing_profile_or_abha",data:{platform:v,oid:a||"missing_oid",oid_exists:!!a}});return}C({name:"linking_abha_to_profile_start",data:{platform:v,oid:a||"missing_oid",oid_exists:!!a}}),u(Q.LOADING);const{error:T,action:P,eka:R}=await Iy({abha_address:x,oid:a});if(P){C({name:"linking_abha_to_profile_error_action",data:{platform:v,oid:a||"missing_oid",oid_exists:!!a}}),s(P);return}if(T||!R||!R.oid){C({name:"linking_abha_to_profile_failed",data:{platform:v,oid:a||"missing_oid",oid_exists:!!a,error:T||"No EKA/OID",error_exists:!!T}}),u(Q.REJECTED),w(T||"Something went wrong. Please try again.");return}const M=await _({oid:R.oid});if(M.error){C({name:"profile_switch_failed_after_link",data:{platform:v,oid:(R==null?void 0:R.oid)||"missing_oid",oid_exists:!!(R!=null&&R.oid),error:((D=M.error)==null?void 0:D.message)||"unknown_error",error_exists:!!((k=M.error)!=null&&k.message)}}),u(Q.REJECTED),w(((U=M.error)==null?void 0:U.message)||"Something went wrong, please try again");return}C({name:"linking_abha_to_profile_success",data:{platform:v,oid:R.oid}}),u(Q.RESOLVED)},L=()=>{r();const T=O.getState().isEkaAppLogin;o(),O.setState({isEkaAppLogin:T})};return m.jsxs("div",{className:"pds2-w-full pds2-h-screen pds2-flex pds2-flex-col pds2-bg-bg-01",children:[m.jsx(Ta,{title:"Select Eka Profile",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>d(!0),children:m.jsx(Gr,{})}),className:"pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white"}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-relative",children:[m.jsxs("div",{className:"pds2-flex-1 pds2-overflow-y-auto pds2-px-16 pds2-pt-24 pds2-pb-32",children:[m.jsxs("div",{className:"pds2-space-y-16 pds2-flex pds2-flex-col pds2-items-center pds2-text-center",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp",alt:"Link ABHA",className:"pds2-w-163"}),m.jsxs("div",{className:"pds2-space-y-4",children:[m.jsx("div",{className:"pds2-text-text-01 Heading3Semibold",children:"Choose an Eka Profile"}),m.jsx("span",{className:"Body1Regular pds2-text-text-03",children:"Select the person for whom you want to create an ABHA address."})]})]}),m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-justify-center pds2-space-y-12 pds2-mt-24",children:[m.jsx("div",{className:"pds2-text-text-03 Body2Medium pds2-text-center",children:"Select Eka Profile"}),m.jsx("div",{className:"pds2-space-y-8",children:(B=h==null?void 0:h.profiles)==null?void 0:B.map(T=>{const P=a===T.oid;return m.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
|
|
134
|
+
`,tabIndex:-1,ref:a,children:m.jsx("p",{className:`${n?"pds2-text-text-brand Body2Semibold":"pds2-text-text-01 Body2Medium"}`,children:e})})}const dy=()=>{const e=O(k=>k.screen),t=O(k=>k.selectedAbhaAddress),n=O(k=>k.setBottomsheetErrorInfo),r=O(k=>k.clearAbhaAuthStore),a=O(k=>k.goBackLoginScreen),[i,s]=p.useState(Q.IDLE),[o,l]=p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),[u,c]=p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),[d,f]=p.useState(null),{mutateAsync:w}=Rm(),[x,g]=p.useState(!1),_=O(k=>k.ekaProfileInfo),h=O(k=>k.setEkaProfileInfo),v=O(k=>k.setScreen),y=e[e.length-1],b=O(k=>k.aadhaarVerificationSkipStateStatus),E=ki.getQueryData(["abdmProfilePhrResponse"]),A=O(k=>k.abhaAuthFlowMethod);p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""});const N=O(k=>k.isDocAppRequest),C=O(k=>k.clientId),$=O(k=>k.isEkaAppLogin),H=O(k=>k.isNewLoginOrCreateFlow),F=O(k=>k.txnId),L=Cn(),[B,T]=p.useState(null),P=O(k=>k.abhaAuthFlowMethod),R=({name:k,data:U={}})=>{var V,Y;const I={...{login_platform:C,is_eka_app_login:$?"true":"false",is_new_login_or_create_flow:H?"true":"false",txn_id:F||"missing txnId",oid:L!=null&&L["X-User-ID"]?"true":"false",access_token:L!=null&&L.auth?"true":"false",flow:P??""},...U};qe({eventName:k,eventData:I}),(Y=(V=window.curio)==null?void 0:V.pushToMixpanel)==null||Y.call(V,k,I)};p.useEffect(()=>{R({name:"page_view",data:{page_view:"create_profile_screen"}})},[C]),p.useEffect(()=>{var k;if((k=window.EkaAbha)!=null&&k.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var U,z;(U=window.EkaAbha)!=null&&U.changeStatusBarColor&&((z=window==null?void 0:window.EkaAbha)==null||z.changeStatusBarColor("#FFFFFF"))}},[]),p.useEffect(()=>{if(E){const{first_name:k,last_name:U,gender:z,pincode:I,day_of_birth:V,month_of_birth:Y,year_of_birth:Z}=E,re=V===0?1:V,X=`${Z}-${String(Y===0?1:Y).padStart(2,"0")}-${String(re).padStart(2,"0")}`;R({name:"profile_data_set_from_phr_cache",data:{source:"phr_cache",date_of_birth:X,firstname:k??"missing",lastname:U??"missing",gender:z??"missing",pincode:I??"missing",dob_day:V??"missing",dob_month:Y??"missing",dob_year:Z??"missing",flow:P??""}}),l({firstname:k,lastname:U,gender:z,pincode:I,date_of_birth:X});return}if(_){let k="1983",U="01",z="01";if(_.date_of_birth){const V=_.date_of_birth.split("-");k=V[0],U=V[1]==="00"||!V[1]?"01":V[1],z=V[2]==="00"||!V[2]?"01":V[2]}const I=`${k}-${String(U).padStart(2,"0")}-${String(z).padStart(2,"0")}`;l({firstname:_.firstname,lastname:_.lastname,gender:_.gender,pincode:_.pincode,date_of_birth:I,oid:_.oid}),R({name:"profile_data_set_from_eka_profile",data:{source:"eka_profile",date_of_birth:(_==null?void 0:_.date_of_birth)??"missing",firstname:(_==null?void 0:_.firstname)??"missing",lastname:(_==null?void 0:_.lastname)??"missing",gender:(_==null?void 0:_.gender)??"missing",pincode:(_==null?void 0:_.pincode)??"missing",oid:(_==null?void 0:_.oid)??"missing"}})}},[E,_]);const M=p.useMemo(()=>!!(o.firstname&&!u.firstname&&o.date_of_birth&&!u.date_of_birth&&o.pincode&&!u.pincode&&o.gender&&!u.gender),[o,u]),S=async()=>{var U,z,I,V;const k={firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""};if(c(k),o.firstname.trim()||(k.firstname="Enter Name"),o.lastname.trim()||(k.lastname="This field is required"),o.date_of_birth||(k.date_of_birth="Enter DOB"),o.gender||(k.gender="Select Gender"),o.pincode||(k.pincode="Enter Valid Pincode"),!!M){if(R({name:"create_profile_screen_clicks",data:{type:"create_profile"}}),s(Q.LOADING),y===ve.CREATE_EKA_PROFILE){if(R({name:"navigate_to_create_abha_address_screen",data:{type:"next",pincode_entered:(o==null?void 0:o.pincode)??"unknown",eka_profile_info_pincode:(_==null?void 0:_.pincode)??"unknown",flow_type:A||"unknown_method"}}),A===ee.MOBILE){const Y=await Xb({pincode:Number(o.pincode)});if(Y!=null&&Y.error){T(Y!=null&&Y.error?"Invalid Pincode":null),s(Q.REJECTED),R({name:"pincode_api_failed",data:{type:"error",error:Y==null?void 0:Y.error}});return}if(R({name:"pincode_api_success",data:{type:"verify",pincode_received:!!Y.pincode,txn_id:F}}),Y!=null&&Y.pincode){f(null),h(o),R({name:"eka_profile_info_set",data:{firstname:o==null?void 0:o.firstname,lastname:o==null?void 0:o.lastname,gender:o==null?void 0:o.gender,pincode:o==null?void 0:o.pincode,date_of_birth:o==null?void 0:o.date_of_birth}}),v(ve.CREATE_ABHA_ADDRESS);return}R({name:"no_action_on_pincode",data:{type:"verify",pincode_entered:!!Y.pincode,txn_id:F}});return}else if(A===ee.AADHAR_NUMBER){h(o),R({name:"eka_profile_info_set",data:{firstname:o==null?void 0:o.firstname,lastname:o==null?void 0:o.lastname,gender:o==null?void 0:o.gender,pincode:o==null?void 0:o.pincode,date_of_birth:o==null?void 0:o.date_of_birth}}),v(ve.CREATE_ABHA_ADDRESS);return}}if(y===ve.CREATE_PHR_EKA_PROFILE){if(!t){R({name:"abha_create_eka_profile_abha_address_missing",data:{platform:C}});return}const[Y,Z,re]=o.date_of_birth?(U=o==null?void 0:o.date_of_birth)==null?void 0:U.split("-"):["","",""],q={abha_address:t,day_of_birth:parseInt(re),first_name:o.firstname,gender:o.gender,last_name:o.lastname||"",month_of_birth:parseInt(Z),pincode:o.pincode,year_of_birth:parseInt(Y)};R({name:"profile_eka_process_started",data:{platform:C,date_of_birth:(o==null?void 0:o.date_of_birth)||null,dob_day:re||null,dob_month:Z||null,dob_year:Y||null}});const{error:X,eka:K,action:oe}=await Ly({...q});if(oe){R({name:"profile_eka_process_failed",data:{platform:C,error_message:((z=oe==null?void 0:oe.cta)==null?void 0:z.title)||"unknown_error",error_message_exists:!!((I=oe==null?void 0:oe.cta)!=null&&I.title)}}),n(oe);return}if(X||!K||!K.oid){R({name:"profile_process_failed",data:{platform:C,error_message:X||"Unknown error",eka_oid:(K==null?void 0:K.oid)||"missing",eka_exists:!!K,date_of_birth:(o==null?void 0:o.date_of_birth)||"missing",dob_day:re||"missing",dob_month:Z||"missing",dob_year:Y||"missing",parsed_date_valid:!!(parseInt(re)&&parseInt(Z)&&parseInt(Y)),firstname:(o==null?void 0:o.firstname)||"missing",gender:(o==null?void 0:o.gender)||"missing",pincode:(o==null?void 0:o.pincode)||"missing"}}),s(Q.REJECTED),f(X||"Something went wrong. Please try again.");return}R({name:"profile_eka_process_success",data:{platform:C,eka:K}}),R({name:"profile_switch_process_started",data:{platform:C,error_message:X,eka:K}});const ie=await w({oid:K.oid});if(ie.error){R({name:"profile_switch_process_failed",data:{platform:C,error_message:ie.error||"Something went wrong, please try again",error_message_exists:!!ie.error}}),s(Q.REJECTED),f(((V=ie.error)==null?void 0:V.message)||"Something went wrong, please try again");return}R({name:"profile_switch_process_success",data:{platform:C,eka:K}}),s(Q.RESOLVED);return}}},D=()=>{a();const k=O.getState().isEkaAppLogin;r(),O.setState({isEkaAppLogin:k})};return m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-bg-bg-01 pds2-h-full",children:[m.jsx(Ta,{title:"",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>g(!0),children:m.jsx(Gr,{className:""})}),className:"pds2-bg-bg-01"}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-flex-1 pds2-p-8",children:[m.jsx("div",{className:"pds2-flex pds2-items-center pds2-justify-between",children:m.jsx("div",{className:"pds2-space-y-2 pds2-text-text-01",children:N?m.jsx("div",{className:"Heading4Semibold",children:"Create ABHA Profile"}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"Heading4Semibold",children:"Create your"}),m.jsx("div",{className:"Heading2Semibold",children:"Eka Profile"})]})})}),m.jsx(U3,{profileData:o,setProfileData:l,error:u,setError:c,pincodeApiError:B})]}),d&&m.jsx("div",{className:"pds2-p-16 pds2-text-text-error pds2-text-center",children:d}),m.jsxs("div",{className:"pds2-sticky pds2-bottom-0 pds2-bg-bg-white pds2-w-full",children:[t&&b===Mt.ABHA_END?m.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:[m.jsxs("div",{className:"",children:[m.jsx("span",{className:"pds2-text-text-03 Body2Regular",children:"Creating for: "}),m.jsx("span",{className:"pds2-text-text-01 Body2Semibold",children:t})]}),m.jsx("button",{onClick:a,className:"Body2Semibold pds2-text-text-brand pds2-rounded-full ripple pds2-px-8 pds2-py-2",children:"Change"})]}):null,m.jsx("div",{className:"pds2-p-16 pds2-w-full",children:m.jsx(dn,{className:"pds2-w-full",title:"Create Profile",state:i===Q.LOADING?"disabled":"enabled",onClick:S,isLoading:i===Q.LOADING})})]}),m.jsx(Xr,{onSubmitClick:D}),m.jsx(ml,{open:x,setOpen:g})]})},B3=[{id:"M",name:"Male"},{id:"F",name:"Female"},{id:"O",name:"Other"}],U3=({profileData:e,setProfileData:t,error:n,setError:r,pincodeApiError:a})=>{const i=({event:c,name:d})=>{const f=c.target.value;let w="";switch(d){case"firstname":f.trim()?w="":w="This field is required";break;case"lastname":!f||f.length<0?w="This field is required":w="";break;case"pincode":!f||isNaN(Number(f))||f.length!=6?w="Pincode must consist of exactly 6 digits":w="";break;case"date_of_birth":!f||f>new Date().toISOString().split("T")[0]?w="Date of Birth is invalid":w="";break}r({...n,[d]:w}),t({...e,[d]:f})},s=c=>{t({...e,gender:c}),r({...n,gender:""})},o=(c,d)=>d!=null&&d.pincode||!((c.firstname??"").trim()!==""&&(c.gender??"").trim()!==""&&(c.date_of_birth??"").trim()!=="")?!1:!c.pincode||(c.pincode+"").length!==6,l=O(c=>c.ekaProfileInfo),u=O(c=>c.abhaAuthFlowMethod);return m.jsxs("form",{className:"pds2-flex pds2-flex-col pds2-space-y-32",children:[m.jsxs("label",{className:"pds2-space-y-8",children:[m.jsxs("div",{className:"Body3Medium pds2-text-text-04",children:["Your name",m.jsx("sup",{className:"pds2-text-text-error Body3Semibold",children:"*"})]}),m.jsxs("div",{className:"pds2-flex pds2-gap-8",children:[m.jsxs("div",{className:"pds2-flex pds2-flex-col",children:[m.jsx(Hr,{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:e.firstname,onChange:c=>i({event:c,name:"firstname"}),autoCapitalize:"on",disabled:!!(l!=null&&l.firstname)&&u===ee.AADHAR_NUMBER,error:n.firstname}),n.firstname&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-4",children:n.firstname})]}),m.jsx("div",{children:m.jsx(Hr,{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:e.lastname,onChange:c=>i({event:c,name:"lastname"}),autoCapitalize:"on",disabled:!!(l!=null&&l.lastname)&&u===ee.AADHAR_NUMBER})})]})]}),m.jsxs("div",{className:"pds2-space-y-8",children:[m.jsxs("div",{className:"pds2-space-y-4",children:[m.jsxs("div",{className:"Body3Medium pds2-text-text-04",children:["Gender",m.jsx("sup",{className:"pds2-text-text-error Body3Semibold",children:"*"})]}),m.jsx("div",{className:"pds2-flex pds2-gap-16",children:B3.map((c,d)=>m.jsx("div",{className:`${n.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:m.jsx(V3,{isSelected:c.id===e.gender,title:c.name,onSelect:()=>s(c.id)})},d))}),n.gender&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-2",children:n.gender})]}),m.jsxs("div",{className:"pds2-flex pds2-flex-col",children:[m.jsx(Hr,{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:e.date_of_birth,disabled:!!(l!=null&&l.date_of_birth)&&u===ee.AADHAR_NUMBER,onChange:c=>i({event:c,name:"date_of_birth"}),type:"date",maxDate:new Date().toISOString().split("T")[0],error:n.date_of_birth}),n.date_of_birth&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-2",children:n.date_of_birth})]})]}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-space-y-4",children:[m.jsx(Hr,{label:"Pincode",isMandatory:!0,textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:o(e,l)||a?"pds2-border-1 pds2-border-text-error":"",value:e.pincode,placeholder:"Enter Pincode",disabled:!!(l!=null&&l.pincode)&&u===ee.AADHAR_NUMBER,onChange:c=>{c.target.value.length>6||i({event:c,name:"pincode"})},type:"number",error:o(e,l)?n.pincode:"",textStyle:o(e,l)||a?"placeholder:pds2-text-text-error":"placeholder:pds2-text-text-04"}),a||n.pincode&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-4",children:n.pincode})]})]})},z3=()=>PC({queryKey:["profilesPhrUserResponse"],queryFn:async()=>{const e=await Lb();var t;return Array.isArray(e)?t=e==null?void 0:e.filter(r=>!r["health-ids"]||r["health-ids"].length===0):t=[],{profiles:t}}}),W3=()=>{const e=O(g=>g.setScreen);O(g=>g.screen),O(g=>g.goBackLoginScreen),O(g=>g.clearAbhaAuthStore);const[t,n]=p.useState(!1);p.useState("");const r=O(g=>g.clientId),a=O(g=>g.aadhaarVerificationSkipStateStatus),i=O(g=>g.isEkaAppLogin),s=O(g=>g.isNewLoginOrCreateFlow),o=O(g=>g.txnId),l=Cn(),u=O(g=>g.abhaAuthFlowMethod),c=({name:g,data:_={}})=>{var y,b;const v={...{login_platform:r,is_eka_app_login:i?"true":"false",is_new_login_or_create_flow:s?"true":"false",txn_id:o||"missing txnId",oid:l!=null&&l["X-User-ID"]?"true":"false",access_token:l!=null&&l.auth?"true":"false",flow:u??""},..._};qe({eventName:g,eventData:v}),(b=(y=window.curio)==null?void 0:y.pushToMixpanel)==null||b.call(y,g,v)};p.useEffect(()=>{if(r==="doctor"){c({name:"page_view",data:{platform:r,page_view:"get-all-profiles-screen"}}),c({name:"redirect_to_create_eka_profile_screen",data:{type:"next"}}),e(ve.CREATE_EKA_PROFILE);return}},[r]);let d=!1;i?d=!1:i||(r==="doctor"?d=!1:d=!0);const{data:f,error:w,isLoading:x}=d?z3():{data:null,error:null,isLoading:!1};return p.useEffect(()=>{if(r==="doctor")return;(async()=>{!x&&f&&(n(!0),await new Promise(_=>setTimeout(_,2e3)),n(!1),!f.profiles||f.profiles.length<1?a===Mt.ABHA_END?(c({name:"redirect_to_create_phr_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.CREATE_PHR_EKA_PROFILE)):(c({name:"redirect_to_create_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.CREATE_EKA_PROFILE)):(c({name:"redirect_to_select_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.SELECT_EKA_PROFILE)))})()},[x,f]),t?m.jsx(Zh,{loading:!0,loadingText:"In progress...",successText:""}):null},Y3=()=>{const e=O(i=>i.setAbhaAuthFlowMethod),t=O(i=>i.clientId),n=O(i=>i.clearAbhaAuthStore);p.useEffect(()=>{var i;if(qe({eventName:"page_view",eventData:{page_view:"abha_login_screen",platform:t}}),e(ee.MOBILE),(i=window.EkaAbha)!=null&&i.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var s,o;(s=window.EkaAbha)!=null&&s.changeStatusBarColor&&((o=window==null?void 0:window.EkaAbha)==null||o.changeStatusBarColor("#FFFFFF"))}},[]);const r=()=>{var s;(s=window.EkaAbha)==null||s.onAbhaClose();const i=O.getState().isNewLoginOrCreateFlow;n(),O.setState({isNewLoginOrCreateFlow:i}),jt()},a=["eka-web","phr"];return m.jsxs("div",{className:"pds2-bg-bg-white",children:[!a.includes(t)&&m.jsx(Ta,{prefixIcon:m.jsx("button",{onClick:r,children:m.jsx(Gr,{})}),title:"",className:"pds2-bg-bg-01"}),m.jsx(K3,{}),m.jsx(G3,{})]})},G3=()=>{const e=O(r=>r.setAbhaAuthFlowMethod),t=O(r=>r.abhaAuthFlowMethod),n=[{method:ee.ABHA_NUMBER,title:"ABHA Number",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Number Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:ee.PHR_ADDRESS,title:"ABHA Address",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Address Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:ee.AADHAR_NUMBER,title:"Aadhaar Number",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm5mcdm3h00070tfs9fjkepff.webp",alt:"Aadhaar Number Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:ee.MOBILE,title:"Mobile Number",icon:m.jsx(Cc,{className:"pds2-w-20 pds2-h-20 pds2-text-icon-success-02"})}];return m.jsxs("div",{className:"pds2-p-16 pds2-space-y-16",children:[m.jsx(Vc,{title:"Other login options for ABHA"}),m.jsx("div",{className:"pds2-space-y-16",children:n.filter(r=>r.method!==t).map(r=>m.jsx(yi,{prefixIcon:r.icon,title:r.title,suffixIcon:m.jsx(Pr,{className:"pds2-ml-auto pds2-h-16 pds2-w-16 pds2-text-text-04 -pds2-rotate-90","aria-hidden":"true"}),onClick:()=>e(r.method)},r.method))})]})},K3=()=>{const e=O(B=>B.setScreen),t=O(B=>B.abhaAuthFlowMethod||ee.MOBILE),n=O(B=>B.setRegistrationType),r=O(B=>B.setAadhaarInitResponse),[a,i]=p.useState(""),[s,o]=p.useState(""),[l,u]=p.useState(Q.IDLE),c=O(B=>B.setLoginIdentifierValue),d=O(B=>B.setSelectedAbhaAddress),[f,w]=p.useState(!1),x=O(B=>B.initAbhaAppMobileNumber),g=O(B=>B.setBottomsheetErrorInfo),[_,h]=Fe.useState(null),[v,y]=p.useState(""),b=O(B=>B.clientId),E=O(B=>B.isEkaAppLogin);p.useEffect(()=>{if(x&&t===ee.MOBILE){i(x),w(x.length===10),o(null);return}i(""),o(null),w(!1)},[t]);const A=B=>{s&&o(null);const T=B.target.value;switch(t){case ee.PHR_ADDRESS:if(T.length>20)return;break;case ee.MOBILE:if(T&&!/^[0-9]+$/.test(T)||T.length>10)return;break;case ee.ABHA_NUMBER:if(!/^[\d-]*$/.test(T)||T.length>17)return;break;case ee.AADHAR_NUMBER:if(T&&!/^[0-9]+$/.test(T)||T.length>12)return;break}if(t===ee.ABHA_NUMBER){const P=B.target.value.replace(/-/g,"");let R="";P.length>0&&(R+=P.slice(0,2)),P.length>2&&(R+=`-${P.slice(2,6)}`),P.length>6&&(R+=`-${P.slice(6,10)}`),P.length>10&&(R+=`-${P.slice(10,14)}`),i(R)}else i(T.trim())},N=({inputVal:B})=>{s&&o(null),B.length===12&&i(B)},C=p.useCallback(()=>{const B=t===ee.MOBILE&&!!x;if(t===ee.AADHAR_NUMBER)return m.jsx($c,{numberOfInputs:3,length:4,placeholder:"XXXX",onSubmit:N});const T={value:a,onChange:A,...t===ee.MOBILE&&{type:"tel",placeholder:"Mobile Number",disabled:B,PrefixComponent:m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-x-8 pds2-border-r pds2-border-border-brand-02 pds2-pr-24",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4mlct2900000tg98p8u967s.webp",alt:"India Flag",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:"pds2-text-text-black",children:"+91"})]})},...t===ee.ABHA_NUMBER&&{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"},...t===ee.PHR_ADDRESS&&{placeholder:"Enter ABHA Address"}};return m.jsx(Hr,{...T})},[t,a,s]),$=(B=_)=>{B&&(O.setState({isLoggedInFromRedirect:!0}),y(a),O.setState({initAbhaAppMobileNumber:a}),O.setState({abhaAuthFlowMethod:ee.MOBILE}),e(ve.CREATE_ABHA_WITH_AADHAAR),g(null))},H=async()=>{u(Q.LOADING);let B="";if(!E){const{txn_id:D,error:k}=await nh({method:tl.ABHA});if(!D||k){o((k==null?void 0:k.message)||"Something went wrong. Please try again."),u(Q.REJECTED);return}B=D,console.log("triggering logout api in login with abha screen"),await lc()}n(ar.LOGIN);const T=t===ee.PHR_ADDRESS?`${a}${ui()==="DEV"?"@sbx":"@abdm"}`:a;console.log("loginIdentifier",T);const{txn_id:P,error:R,action:M,hint:S}=await uc({method:t,identifier:T});if(console.log("after postAbdmLoginInit",M),console.log("after postAbdmLoginInit",M),M){h(M),g(M);return}if(R){o(R||"Something went wrong. Please try again."),u(Q.REJECTED);return}if(!P){o("Something went wrong. Please try again."),u(Q.REJECTED);return}t===ee.PHR_ADDRESS&&d(T),r({authTxnId:B,txnId:P,aadhaarOtpSentToHint:S||null}),c(T),u(Q.RESOLVED),qe({eventName:"abha_login_submitted",eventData:{type:"next",platform:b}}),e(ve.VERIFY_OTP_LOGIN_WITH_ABHA)},F=Fe.useMemo(()=>{switch(t){case ee.PHR_ADDRESS:return a.length>=4&&a.length<=20;case ee.MOBILE:return a.length===10;case ee.ABHA_NUMBER:return a.length===17;case ee.AADHAR_NUMBER:return a.length===12}},[t,a]),L=Fe.useMemo(()=>{switch(t){case ee.ABHA_NUMBER:return"Enter your ABHA Number";case ee.PHR_ADDRESS:return"Enter your ABHA Address";case ee.MOBILE:return"Enter your Mobile Number";case ee.AADHAR_NUMBER:return"Enter your Aadhaar Number";default:return"Enter your ABHA Number"}},[t]);return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"pds2-p-16 pds2-bg-bg-01 pds2-space-y-16 pds2-text-center",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-items-center pds2-gap-16",children:m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abha",className:"pds2-w-64 pds2-h-64"})})}),m.jsx("div",{className:"Heading3Semibold pds2-text-text-black",children:"Log in With ABHA"}),m.jsx("div",{className:"pds2-text-text-black pds2-mt-2",children:L}),m.jsx("div",{className:"pds2-space-y-12",children:m.jsxs("div",{className:"pds2-relative",children:[C(),t===ee.PHR_ADDRESS&&m.jsx("div",{className:"pds2-absolute pds2-right-16 pds2-top-16 Body1Regular pds2-text-text-03",children:ui()==="DEV"?"@sbx":"@abdm"})]})}),s&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:s}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!F||!f||l===Q.LOADING?"disabled":"enabled",isLoading:l===Q.LOADING,onClick:H,className:"pds2-w-full"}),m.jsxs("div",{className:"pds2-flex pds2-flex-row pds2-justify-center pds2-items-center pds2-bg-bg-white pds2-w-fit pds2-px-12 pds2-bg-opacity-60 pds2-rounded-12 pds2-mx-auto",children:[m.jsx("div",{className:"pds2-text-text-04 Body3Regular",children:"Don’t have ABHA?"}),m.jsx(yi,{className:"pds2-text-text-brand Body3Semibold pds2-pl-4 pds2-pr-0 pds2-py-4 ripple pds2-border-none pds2-bg-transparent",width:"pds2-w-fit",title:"Register Now",onClick:()=>{e(ve.CREATE_ABHA_WITH_AADHAAR)}})]})]}),m.jsx(Xr,{onSubmitClick:$})]})},q3=()=>{const e=O(t=>t.setSelectedAbhaAddress);return ol({mutationFn:({txn_id:t,phr_address:n})=>Wb({txn_id:t,phr_address:n}),onSuccess(t){t.profile&&(ki.setQueryData(["abdmProfilePhrResponse"],t.profile),e(t.profile.abha_address))}})},Q3=()=>{var re;const[e,t]=p.useState(null),n=O(q=>q.setScreen),r=O(q=>q.goBackLoginScreen),a=O(q=>q.txnId),i=O(q=>q.authTxnId),s=O(q=>q.abhaAddressList),o=O(q=>q.setBottomsheetErrorInfo),l=O(q=>q.clearAbhaAuthStore),u=O(q=>q.setSelectedAbhaAddress),c=O(q=>q.abhaAuthFlowMethod),d=O(q=>q.loginIdentifierValue),[f,w]=p.useState(""),[x,g]=p.useState(!1),_=O(q=>q.setEkaProfileInfo),h=O(q=>q.setAbhaAuthFlowMethod),v=O(q=>q.setAadhaarVerificationSkipStateStatus),[y,b]=p.useState(Q.IDLE),E=["M","F","O","U"],{mutateAsync:A}=em(),{mutateAsync:N}=q3();O(q=>q.ekaProfileInfo),O(q=>q.registrationType);const C=O(q=>q.clientId),$=O(q=>q.isEkaAppLogin),H=O(q=>q.setRegistrationType),F=O(q=>q.abhaAuthFlowMethod),L=O(q=>q.identityValue),B=O(q=>q.setMobileInitResponse),[T,P]=p.useState({aadhaar:Q.IDLE,mobile:Q.IDLE}),R=O(q=>q.setAadhaarInitResponse),M=O(q=>q.setSelectedAbhaFlow),S=O(q=>q.isNewLoginOrCreateFlow),D=Cn(),k=O(q=>q.setLoginIdentifierValue),[U,z]=p.useState(!1),I=({name:q,data:X={}})=>{var ie,ce;const oe={...{login_platform:C,is_eka_app_login:$?"true":"false",is_new_login_or_create_flow:S?"true":"false",txn_id:a||"missing txnId",oid:D!=null&&D["X-User-ID"]?"true":"false",access_token:D!=null&&D.auth?"true":"false",flow:F??""},...X};qe({eventName:q,eventData:oe}),(ce=(ie=window.curio)==null?void 0:ie.pushToMixpanel)==null||ce.call(ie,q,oe)},V=async()=>{I({name:"abha_login_select_abha_init_started",data:{method:F,platform:C}});const q=(X,K)=>{P(oe=>({...oe,[X]:K}))};if(H(ar.CREATE),F===ee.MOBILE){const{txn_id:X,hint:K,error:oe,action:ie}=await ah({mobile_number:L});if(X&&K){I({name:"abha_login_select_abha_mobile_init_success",data:{method:F,platform:C,txn_id:X}}),B({authTxnId:i,txnId:X,mobileOtpSentToHint:K}),M("mobile"),q("mobile",Q.RESOLVED),H(ar.CREATE),n(ve.ABHA_PHONE_NUMBER_VERIFICATION);return}I({name:"abha_login_select_abha_init_failed",data:{method:F,platform:C,reason:oe||"unknown",reason_exists:!!oe}}),q("mobile",Q.REJECTED),ie?o(ie):w(oe||"Something went wrong")}else if(F===ee.AADHAR_NUMBER){I({name:"abha_fetching_profiles",data:{method:F,platform:C}}),n(ve.GET_ALL_PROFILES);return}},Y=async()=>{var me,se,ye,De,xe,ne;if(c===ee.AADHAR_NUMBER&&e){ii({extraHeaders:{auth:""}}),$||await lc()||I({name:"logout_api_failed_before_init_on_continue_click",data:{method:F,platform:C,reason:"logout_api_response_false"}});const{txn_id:W,error:J,action:we,hint:be}=await uc({method:ee.PHR_ADDRESS,identifier:e.abha_address});if(I({name:"abha_abdm_login_init_triggered",data:{flow_step_type:"init",authTxnId:i,ndhmTxnId:W,method:F}}),console.log("after postAbdmLoginInit",we),console.log("after postAbdmLoginInit",we),we){I({name:"abha_abdm_login_init_abha_error_action",data:{method:F,platform:C,action:((me=we==null?void 0:we.cta)==null?void 0:me.title)||"unknown",action_exists:!!((se=we==null?void 0:we.cta)!=null&&se.title)}}),o(we);return}if(J){I({name:"abha_abdm_login_init_failed",data:{method:F,platform:C,reason:J||"unknown",reason_exists:!!J}}),w(J||"Something went wrong. Please try again.");return}if(!W){w("Something went wrong. Please try again.");return}I({name:"abha_login_init_success",data:{flow_step_type:"init",authTxnId:i,ndhmTxnId:W,hint:be}}),R({authTxnId:i,txnId:W,aadhaarOtpSentToHint:be||null}),k(e.abha_address),h(ee.PHR_ADDRESS),n(ve.VERIFY_OTP_LOGIN_WITH_ABHA);return}if(!e)return;if(u(e.abha_address),console.log(y,"from abha"),!a){I({name:"abha_login_select_abha_txnId_not_found",data:{platform:C,reason:"txnId missing",reason_exists:!0}});return}b(Q.LOADING),I({name:"abha_login_select_abha_verify_start",data:{platform:C,txn_id:a}});const{error:q,eka:X,profile:K,action:oe,skip_state:ie}=await N({txn_id:a,phr_address:e.abha_address});if(oe){I({name:"abha_login_select_abha_error_action",data:{platform:C,txn_id:a,action:((ye=oe==null?void 0:oe.cta)==null?void 0:ye.title)||"unknown",action_exists:!!((De=oe==null?void 0:oe.cta)!=null&&De.title)}}),o(oe);return}if(q||!X){I({name:"abha_login_select_abha_abdm_error",data:{platform:C,txn_id:a,error_message:q||"eka object missing",error_exists:!!q}}),b(Q.REJECTED),w(q);return}if(!ie){w("skip State is missing");return}if(I({name:"abha_login_select_abha_verify_success",data:{platform:C,txn_id:a,skip_state:ie}}),v(ie),K&&(I({name:"abha_login_select_abha_profile_received",data:{platform:C}}),_({date_of_birth:`${K.year_of_birth}-${String(K.month_of_birth).padStart(2,"0")}-${String(K.day_of_birth).padStart(2,"0")}`,firstname:K.first_name,lastname:K.last_name,pincode:K.pincode,gender:K.gender,name:K.first_name+" "+K.last_name,mobile:K.mobile,oid:X==null?void 0:X.oid,middlename:K.middle_name,abha_address:K.abha_address,abha_number:K.abha_number}),u(K.abha_address)),$){if(!X.oid){I({name:"abha_login_select_abha_oid_null",data:{platform:C,oid:(X==null?void 0:X.oid)??"null_or_undefined"}}),b(Q.REJECTED);return}const W=E.includes(K==null?void 0:K.gender)?K==null?void 0:K.gender:void 0,J={oid:(X==null?void 0:X.oid)||"",fln:(K==null?void 0:K.first_name)+" "+(K==null?void 0:K.last_name),dob:`${K==null?void 0:K.year_of_birth}-${String(K==null?void 0:K.month_of_birth).padStart(2,"0")}-${String(K==null?void 0:K.day_of_birth).padStart(2,"0")}`,gen:W,mobile:K==null?void 0:K.mobile,at:"",fn:(K==null?void 0:K.first_name)||"",mn:(K==null?void 0:K.middle_name)||"",ln:(K==null?void 0:K.last_name)||"","health-ids":K!=null&&K.abha_address?[K.abha_address]:void 0,abha_number:(K==null?void 0:K.abha_number)||""},we=vi(J);if(b(Q.RESOLVED),I({name:"abha_login_select_abha_inside_app_success",data:{platform:C,oid:X.oid}}),window.EkaAbha&&window.EkaAbha.onAbhaSuccess){(xe=window.EkaAbha)==null||xe.onAbhaSuccess(JSON.stringify({response:we}));return}bn({response:we}),jt();return}if(!X.min_token||!i){I({name:"abha_login_select_abha_min_token_missing",data:{platform:C,oid:(X==null?void 0:X.oid)??"missing_oid",min_token:(X==null?void 0:X.min_token)??"missing_min_token",auth_txnId:i??"missing_authTxnId"}}),b(Q.REJECTED),w(q||"Something went wrong. Please try again.");return}const ce=await A({txn_id:i,token:X.min_token,...X.oid?{oid:X.oid}:null});if(!ce.data){I({name:"abha_login_select_abha_auth_verify_failed",data:{platform:C,oid:(X==null?void 0:X.oid)??"missing_oid",min_token:(X==null?void 0:X.min_token)??"missing_min_token",auth_txnId:i??"missing_authTxnId"}}),b(Q.REJECTED),w(((ne=ce.error)==null?void 0:ne.message)||"Something went wrong, please try again");return}b(Q.RESOLVED),I({name:"abha_login_select_abha_auth_verify_success",data:{platform:C,oid:X.oid,min_token:X==null?void 0:X.min_token,auth_txnId:i}})},Z=()=>{const q=O.getState().initAbhaAppMobileNumber,X=O.getState().isEkaAppLogin;r(),l(),O.setState({initAbhaAppMobileNumber:q}),O.setState({isEkaAppLogin:X})};return m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-h-full pds2-bg-bg-01",children:[m.jsx(Ta,{title:"Select ABHA to continue",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>g(!0),children:m.jsx(Gr,{})}),suffixIcon:((re=s==null?void 0:s[0])==null?void 0:re.kyc_verified)&&m.jsx(nA,{onClick:()=>z(q=>!q),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"}),U&&m.jsx("div",{onMouseLeave:()=>z(!1),className:"pds2-absolute pds2-right-10 pds2-top-45 pds2-mt-2 pds2-z-50 pds2-animate-fade-in",children:m.jsx(J3,{})}),m.jsxs("div",{className:"pds2-flex-1 pds2-overflow-y-auto pds2-flex pds2-flex-col pds2-p-16 pds2-space-y-16",children:[m.jsxs("div",{className:"pds2-text-text-03 Body1Regular pds2-text-center",children:["We found ",s==null?void 0:s.length," ABHA addresses ",m.jsx("br",{})," select one you want to log in with"]}),m.jsx(X3,{list:s,selectedAbha:e,setSelectedAbha:t}),((s==null?void 0:s.length)??0)<6&&(c===ee.MOBILE||c===ee.AADHAR_NUMBER)&&m.jsxs(m.Fragment,{children:[m.jsx(Vc,{title:"or"}),m.jsx(yi,{title:"Create new ABHA Address",prefixIcon:m.jsx(ow,{}),className:"pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold",onClick:V})]})]}),m.jsxs("div",{className:"pds2-bg-bg-white pds2-shadow-lg pds2-w-full pds2-sticky pds2-bottom-0 pds2-border-t pds2-border-border-brand-02 pds2-p-16 z-10",children:[f&&m.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-4",children:f}),c===ee.ABHA_NUMBER&&m.jsxs("div",{className:"pds2-text-center pds2-bg-bg-warning-03 pds2-py-2 pds2-mb-4",children:[m.jsx("span",{className:"pds2-text-text-03 Body2Regular",children:"Your ABHA No:"}),m.jsx("span",{className:"pds2-text-text-01 Body2Semibold",children:d})]}),m.jsx(dn,{title:"Continue",state:e===null||y===Q.LOADING?"disabled":"enabled",isLoading:y===Q.LOADING,className:"pds2-w-full",onClick:Y})]}),m.jsx(Xr,{onSubmitClick:Z}),m.jsx(ml,{open:x,setOpen:g})]})},X3=({list:e,selectedAbha:t,setSelectedAbha:n})=>m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-brand-02 pds2-w-full pds2-relative",children:e==null?void 0:e.map((r,a)=>m.jsxs(Fe.Fragment,{children:[m.jsxs("label",{className:"pds2-p-16 pds2-flex pds2-space-x-8",children:[m.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:r.abha_address,checked:(t==null?void 0:t.abha_address)===r.abha_address,onChange:()=>{n(r)}}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-space-y-4 pds2-flex-1",children:[m.jsxs("div",{className:"TitlesSubheadline pds2-text-text-primary pds2-flex pds2-flex-row pds2-items-center pds2-justify-between",children:[m.jsx("div",{children:r==null?void 0:r.abha_address}),m.jsx("div",{className:"pds2-flex pds2-flex-row pds2-items-center",children:(r==null?void 0:r.kyc_verified)&&(r.kyc_verified==="VERIFIED"?m.jsx("div",{className:"Label1Bold pds2-rounded-full pds2-h-full",children:m.jsx(rw,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-success-02 pds2-text-[2rem]"})}):m.jsx("div",{className:"Label1Bold pds2-rounded-full pds2-h-full",children:m.jsx(aw,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-orange-300 pds2-text-[2rem]"})}))})]}),m.jsx("div",{className:"pds2-text-text-03 Body3Regular pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-4",children:(r==null?void 0:r.name)&&m.jsx("div",{className:"Body3Regular pds2-text-text-03",children:r.name})})]})]}),a!==e.length-1&&m.jsx("div",{className:"pds2-px-16",children:m.jsx("div",{className:"pds2-bg-border-03 pds2-h-1 pds2-w-full"})})]},r.abha_address))}),J3=()=>m.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:[m.jsxs("div",{className:" pds2-px-16 pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-py-6",children:[m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-full",children:m.jsx(aw,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-orange-400"})}),m.jsx("div",{className:"pds2-text-text-invert",children:"Non KYC"})]}),m.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:[m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-full",children:m.jsx(rw,{className:"pds2-w-16 pds2-h-16 pds2-text-icon-success-02"})}),m.jsx("div",{className:"pds2-text-text-invert",children:"KYC"})]})]}),Z3=()=>{var B;const e=O(T=>T.setScreen),t=O(T=>T.setEkaProfileInfo),n=O(T=>T.registrationType),r=O(T=>T.goBackLoginScreen),[a,i]=p.useState(null),s=O(T=>T.setBottomsheetErrorInfo),o=O(T=>T.clearAbhaAuthStore),[l,u]=p.useState(Q.IDLE),[c,d]=p.useState(!1),[f,w]=p.useState(null),x=O(T=>T.selectedAbhaAddress),g=O(T=>T.aadhaarVerificationSkipStateStatus),{mutateAsync:_}=Rm(),h=ki.getQueryData(["profilesPhrUserResponse"]),v=O(T=>T.clientId),y=O(T=>T.isEkaAppLogin),b=O(T=>T.isNewLoginOrCreateFlow),E=O(T=>T.txnId),A=Cn(),N=O(T=>T.abhaAuthFlowMethod),C=({name:T,data:P={}})=>{var S,D;const M={...{login_platform:v,is_eka_app_login:y?"true":"false",is_new_login_or_create_flow:b?"true":"false",txn_id:E||"missing txnId",oid:A!=null&&A["X-User-ID"]?"true":"false",access_token:A!=null&&A.auth?"true":"false",flow:N??""},...P};qe({eventName:T,eventData:M}),(D=(S=window.curio)==null?void 0:S.pushToMixpanel)==null||D.call(S,T,M)};p.useEffect(()=>{C({name:"choose_eka_profile_screen",data:{platform:v,type:"select"}})},[v]);const $=()=>{if(C({name:"create_family_profile_clicks",data:{platform:v,type:"create",skip_state:g}}),g===Mt.ABHA_END){C({name:"navigate_to_create_phr_profile_screen",data:{platform:v}}),e(ve.CREATE_PHR_EKA_PROFILE);return}C({name:"navigate_to_create_eka_profile_screen",data:{platform:v}}),e(ve.CREATE_EKA_PROFILE)},H=async({profile:T})=>{C({name:"select_profile_clicks",data:{platform:v,oid:T.oid}}),i(T.oid)},F=async()=>{var S,D,k,U;if(C({name:"continue_click_on_choose_eka_profile",data:{platform:v,selectedProfileOid:a,registrationType:n,skip_state:g}}),a&&g===Mt.ABHA_CREATE){const z=h==null?void 0:h.profiles.find(I=>I.oid===a);if(!z){C({name:"continue_click_profile_not_found",data:{platform:v,oid:a||"unknown_oid",oid_exists:!!a}});return}C({name:"navigate_to_create_eka_profile_screen_from_abha_create",data:{platform:v,oid:z.oid}}),t({oid:z.oid,date_of_birth:z.dob,firstname:z.fn,lastname:z.ln,pincode:"",gender:z.gen,mobile:z.mobile,name:z.fln,middlename:z.mn,abha_address:(S=z==null?void 0:z["health-ids"])==null?void 0:S[0],abha_number:z.abha_number}),e(ve.CREATE_EKA_PROFILE);return}if(!x||!a){C({name:"continue_click_missing_profile_or_abha",data:{platform:v,oid:a||"missing_oid",oid_exists:!!a}});return}C({name:"linking_abha_to_profile_start",data:{platform:v,oid:a||"missing_oid",oid_exists:!!a}}),u(Q.LOADING);const{error:T,action:P,eka:R}=await Iy({abha_address:x,oid:a});if(P){C({name:"linking_abha_to_profile_error_action",data:{platform:v,oid:a||"missing_oid",oid_exists:!!a}}),s(P);return}if(T||!R||!R.oid){C({name:"linking_abha_to_profile_failed",data:{platform:v,oid:a||"missing_oid",oid_exists:!!a,error:T||"No EKA/OID",error_exists:!!T}}),u(Q.REJECTED),w(T||"Something went wrong. Please try again.");return}const M=await _({oid:R.oid});if(M.error){C({name:"profile_switch_failed_after_link",data:{platform:v,oid:(R==null?void 0:R.oid)||"missing_oid",oid_exists:!!(R!=null&&R.oid),error:((D=M.error)==null?void 0:D.message)||"unknown_error",error_exists:!!((k=M.error)!=null&&k.message)}}),u(Q.REJECTED),w(((U=M.error)==null?void 0:U.message)||"Something went wrong, please try again");return}C({name:"linking_abha_to_profile_success",data:{platform:v,oid:R.oid}}),u(Q.RESOLVED)},L=()=>{r();const T=O.getState().isEkaAppLogin;o(),O.setState({isEkaAppLogin:T})};return m.jsxs("div",{className:"pds2-w-full pds2-h-screen pds2-flex pds2-flex-col pds2-bg-bg-01",children:[m.jsx(Ta,{title:"Select Eka Profile",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>d(!0),children:m.jsx(Gr,{})}),className:"pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white"}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-relative",children:[m.jsxs("div",{className:"pds2-flex-1 pds2-overflow-y-auto pds2-px-16 pds2-pt-24 pds2-pb-32",children:[m.jsxs("div",{className:"pds2-space-y-16 pds2-flex pds2-flex-col pds2-items-center pds2-text-center",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp",alt:"Link ABHA",className:"pds2-w-163"}),m.jsxs("div",{className:"pds2-space-y-4",children:[m.jsx("div",{className:"pds2-text-text-01 Heading3Semibold",children:"Choose an Eka Profile"}),m.jsx("span",{className:"Body1Regular pds2-text-text-03",children:"Select the person for whom you want to create an ABHA address."})]})]}),m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-justify-center pds2-space-y-12 pds2-mt-24",children:[m.jsx("div",{className:"pds2-text-text-03 Body2Medium pds2-text-center",children:"Select Eka Profile"}),m.jsx("div",{className:"pds2-space-y-8",children:(B=h==null?void 0:h.profiles)==null?void 0:B.map(T=>{const P=a===T.oid;return m.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
|
|
135
135
|
pds2-border-border-03 hover:pds2-bg-bg-hover-01
|
|
136
136
|
pds2-transition-colors`,children:[m.jsx("input",{type:"radio",name:"ekaProfile",value:T.oid,checked:P,onChange:()=>H({profile:T}),className:"pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14"}),m.jsxs("div",{className:"pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-flex-1",children:[m.jsx("div",{className:"TitlesSubheadline pds2-text-text-primary",children:T.fln}),m.jsx("span",{className:"pds2-ml-auto pds2-text-text-brand pds2-text-14 pds2-font-600",children:"Link"})]})]},T.oid)})}),m.jsx(Vc,{title:"or"}),m.jsx(yi,{title:"Create new Family Member",prefixIcon:m.jsx(ow,{}),className:"pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold",onClick:$})]})]}),m.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:[f&&m.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-8",children:f}),m.jsx(dn,{title:"Continue",state:a===null||l===Q.LOADING?"disabled":"enabled",isLoading:l===Q.LOADING,className:"pds2-w-full",onClick:F})]})]}),m.jsx(Xr,{onSubmitClick:L}),m.jsx(ml,{open:c,setOpen:d})]})},eD=()=>{const e=O(r=>r.clientId);p.useEffect(()=>{var r;if((r=window.EkaAbha)!=null&&r.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var a,i;(a=window.EkaAbha)!=null&&a.changeStatusBarColor&&((i=window==null?void 0:window.EkaAbha)==null||i.changeStatusBarColor("#FFFFFF"))}},[]);const t=()=>{var r;(r=window.EkaAbha)==null||r.onAbhaClose(),jt()},n=["eka-web","phr"];return m.jsxs("div",{className:"pds2-bg-bg-01 pds2-pt-36 pds2-h-full",children:[!n.includes(e)&&m.jsx(Ta,{prefixIcon:m.jsx("button",{onClick:t,children:m.jsx(Gr,{})}),title:"",className:"pds2-bg-bg-01"}),m.jsx(tD,{})]})},tD=()=>{const e=O(ne=>ne.abhaAuthFlowMethod||ee.MOBILE),t=O(ne=>ne.setAbhaAuthFlowMethod),[n,r]=p.useState(""),[a,i]=p.useState(Q.IDLE),s=O(ne=>ne.isEkaAppLogin),[o,l]=p.useState(""),u=O(ne=>ne.setSelectedAbhaAddress),c=O(ne=>ne.setLoginIdentifierValue),d=O(ne=>ne.setScreen),[f,w]=p.useState({aadhaar:Q.IDLE,mobile:Q.IDLE}),x=O(ne=>ne.setRegistrationType),g=O(ne=>ne.setAadhaarInitResponse),_=O(ne=>ne.setMobileInitResponse),h=O(ne=>ne.initAbhaAppMobileNumber),[v,y]=p.useState(""),[b,E]=p.useState(!1),[A,N]=p.useState(!1),[C,$]=p.useState(""),[H,F]=p.useState(""),[L,B]=p.useState(""),T=O(ne=>ne.isNewLoginOrCreateFlow),P=O(ne=>ne.setIsNewLoginOrCreateFlow),R=O(ne=>ne.clientId),M=p.useRef(!1),S=O(ne=>ne.isInitApiTriggered),D=O(ne=>ne.setIsInitApiTriggered),k=O(ne=>ne.setIdentityValue);O(ne=>ne.identityValue);const U=Cn(),z=O(ne=>ne.setSelectedAbhaFlow),I=O(ne=>ne.isDocAppRequest),V=O(ne=>ne.txnId);p.useEffect(()=>{Y({name:"abha_login_or_create_screen",data:{flow:e.toString()}})}),p.useEffect(()=>{if(h&&e===ee.MOBILE){r(h),E(h.length===10),l(null);return}r(""),l(null),E(!1)},[e]),p.useEffect(()=>{S||M.current||v&&v.length===10&&(D(!0),M.current=!0,ie("auto_submit_mobile"))},[v]),p.useEffect(()=>{S||M.current||C&&C.length===12&&(D(!0),M.current=!0,ie("auto_submit_aadhaar"))},[C]);const Y=({name:ne,data:W={}})=>{var be,Ke;const we={...{login_platform:R,is_eka_app_login:s?"true":"false",is_new_login_or_create_flow:T?"true":"false",oid:U!=null&&U["X-User-ID"]?"true":"false",access_token:U!=null&&U.auth?"true":"false",txn_id:V||"missing txnId",flow:e??""},...W};qe({eventName:ne,eventData:we}),(Ke=(be=window.curio)==null?void 0:be.pushToMixpanel)==null||Ke.call(be,ne,we)},Z=Fe.useMemo(()=>{switch(e){case ee.MOBILE:return"Enter your Mobile Number";case ee.AADHAR_NUMBER:return"Enter your Aadhaar Number";default:return""}},[e]),re=ne=>{const W=ne.target.value;switch(e){case ee.PHR_ADDRESS:if(W.length>20)return;B(W),r(W);break;case ee.MOBILE:if(W&&!/^[0-9]+$/.test(W)||W.length>10)return;y(W),E(!0),r(W);break;case ee.ABHA_NUMBER:if(!/^[\d-]*$/.test(W)||W.length>17)return;const J=ne.target.value.replace(/-/g,"");let we="";return J.length>0&&(we+=J.slice(0,2)),J.length>2&&(we+=`-${J.slice(2,6)}`),J.length>6&&(we+=`-${J.slice(6,10)}`),J.length>10&&(we+=`-${J.slice(10,14)}`),F(we),r(we.trim());case ee.AADHAR_NUMBER:if(W&&!/^[0-9]+$/.test(W)||W.length>12)return;$(W),N(!0),r(W);break}r(W.trim())},q=e===ee.MOBILE&&!!h,X=Fe.useMemo(()=>{switch(e){case ee.PHR_ADDRESS:return n.length>=4&&n.length<=20;case ee.MOBILE:return n.length===10;case ee.ABHA_NUMBER:return n.length===17;case ee.AADHAR_NUMBER:return n.length===12}},[e,n]),K=(ne,W)=>{w(J=>({...J,[ne]:W}))},oe=({inputVal:ne})=>{ne.length===12&&(r(ne),$(ne),N(!0))};p.useEffect(()=>{console.log("selectedMethod changed:==================>",e)},[e]);const ie=async ne=>{var we,be,Ke;P(!0),Y({name:"abha_login_next_click",data:{flow_step_type:ne}}),i(Q.LOADING),x(ar.LOGIN);let W="";if(!s){const ke=await lc();Y({name:ke?"abha_logout_success":"abha_logout_failure",data:{platform:R}});const{txn_id:Pe,error:$e}=await nh({method:tl.ABHA});if(!Pe||$e){Y({name:"abha_auth_init_failure",data:{flow_step_type:"init",authTxnId:W,error_message:$e||"missing_txnId_or_unknown_error",error_message_exists:!!$e,txn_id_exists:!!Pe}}),l(($e==null?void 0:$e.message)||"Something went wrong. Please try again."),i(Q.REJECTED);return}W=Pe,Y({name:"abha_auth_init_success.",data:{flow_step_type:"init",auth_txnId:W}})}const J=e===ee.PHR_ADDRESS?`${n}${ui()==="DEV"?"@sbx":"@abdm"}`:n;if(e===ee.MOBILE||e===ee.ABHA_NUMBER||e===ee.PHR_ADDRESS){const{txn_id:ke,error:Pe,action:$e,hint:Ge}=await uc({method:e,identifier:J});if(k(J),Y({name:"abha_login_init_triggered",data:{flow_step_type:"init",authTxnId:W,ndhmTxnId:ke,method:e}}),e===ee.PHR_ADDRESS&&u(J),Pe||!ke){if(((we=$e==null?void 0:$e.cta)==null?void 0:we.pid)==="abha_mobile_enroll"){K("mobile",Q.LOADING),x(ar.CREATE);const{txn_id:_t,hint:mt,error:Tt,action:Et}=await ah({mobile_number:n});if(k(n),z("mobile"),_t&&mt){_({authTxnId:W,txnId:_t,mobileOtpSentToHint:mt}),Y({name:"abha_mobile_registration_init_success",data:{flow_step_type:"init",authTxnId:W,ndhmTxnId:ke,error_message:Tt,error_action:$e}}),K("mobile",Q.RESOLVED),i(Q.RESOLVED),x(ar.CREATE),d(ve.ABHA_PHONE_NUMBER_VERIFICATION);return}if(K("mobile",Q.REJECTED),Y({name:"abha_mobile_registration_init_failure",data:{flow_step_type:"init",authTxnId:W,error_message:Tt||"unknown_error",error_message_exists:!!Tt,error_action_exists:!!Et}}),Et){if((be=Et==null?void 0:Et.cta)!=null&&be.pid)return d(ve.LOGIN_OR_CREATE_ABHA)}else l(Tt||"Something went wrong");l(Tt||"Something went wrong. Please try again."),i(Q.REJECTED);return}Y({name:"abha_login_init_failure",data:{flow_step_type:"init",authTxnId:W,error_message:Pe||"unknown_error",error_message_exists:!!Pe,error_action_exists:!!$e}}),l(Pe||"Something went wrong. Please try again."),i(Q.REJECTED);return}Y({name:"abha_login_init_success",data:{flow_step_type:"init",authTxnId:W,ndhmTxnId:ke,hint:Ge}}),g({authTxnId:W,txnId:ke,aadhaarOtpSentToHint:Ge||null}),c(J),i(Q.RESOLVED),d(ve.VERIFY_OTP_LOGIN_WITH_ABHA);return}if(e===ee.AADHAR_NUMBER){K("aadhaar",Q.LOADING),Y({name:"aadhaar_registration_init_start",data:{flow_step_type:"init",authTxnId:W,aadhaarNumber:n}});const{txn_id:ke,hint:Pe,error:$e,action:Ge}=await Dy({aadhaar_number:n});if(k(n),z("aadhaar"),ke&&Pe){g({authTxnId:W,txnId:ke,aadhaarOtpSentToHint:Pe}),Y({name:"aadhaar_registration_init_success",data:{flow_step_type:"verify",ndhmTxnId:ke,authTxnId:W}}),K("aadhaar",Q.RESOLVED),x(ar.CREATE),i(Q.RESOLVED),d(ve.ABHA_OTP_AND_MOBILE);return}if(Y({name:"abha_registration_init_failure",data:{error_message:$e||"unknown_error",error_message_exists:!!$e,auth_txn_id:W,error_action:Ge,error_action_exists:!!Ge}}),K("aadhaar",Q.REJECTED),i(Q.REJECTED),Ge||$e){(Ke=Ge==null?void 0:Ge.cta)!=null&&Ke.pid?d(ve.LOGIN_OR_CREATE_ABHA):l($e||"Something went wrong");return}}},[ce,me]=p.useState(!1),[se,ye]=p.useState(!1),[De,xe]=p.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"pds2-p-16 pds2-bg-bg-01 pds2-space-y-16 pds2-text-center",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-items-center pds2-gap-16",children:m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abha",className:"pds2-w-64 pds2-h-64"})})}),m.jsx("div",{className:"Heading3Semibold pds2-text-text-black",children:R==="phr"?"Login or Create your ABHA":I?"Add Patient via ABHA":"Create your ABHA"}),m.jsx("div",{className:"pds2-text-text-03",style:{marginTop:"4px"},children:e===ee.MOBILE?"Enter your Mobile Number":e===ee.AADHAR_NUMBER?"Enter your Aadhaar Number":e===ee.ABHA_NUMBER?"Enter your ABHA Number":e===ee.PHR_ADDRESS?"Enter your ABHA Address":Z}),(e===ee.MOBILE||e===ee.AADHAR_NUMBER)&&m.jsxs("div",{className:"pds2-flex pds2-mt-4 pds2-bg-bg-02 pds2-rounded-lg pds2-overflow-hidden pds2-p-1",children:[m.jsxs("button",{onClick:()=>t(ee.MOBILE),className:`pds2-flex-1 pds2-py-3 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative ${e===ee.MOBILE?"pds2-bg-bg-white":"pds2-bg-bg-seperator-dark"}`,style:{clipPath:"polygon(8px 0%, calc(100% - 8px) 0%, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0% calc(100% - 8px), 0% 8px)"},children:[m.jsx(Cc,{className:"pds2-w-14 pds2-h-14 pds2-text-icon-success-02"}),m.jsx("span",{className:`pds2-text-base ${e===ee.MOBILE?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:e===ee.MOBILE?{fontWeight:700}:{fontWeight:400},children:"Mobile"})]}),m.jsxs("button",{onClick:()=>t(ee.AADHAR_NUMBER),className:`pds2-flex-1 pds2-py-3 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative pds2-ml-1 ${e===ee.AADHAR_NUMBER?"pds2-bg-bg-white":"pds2-bg-bg-seperator-dark"}`,style:{clipPath:"polygon(8px 0%, calc(100% - 8px) 0%, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0% calc(100% - 8px), 0% 8px)"},children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm5mcdm3h00070tfs9fjkepff.webp",alt:"Aadhaar",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:`pds2-text-base ${e===ee.AADHAR_NUMBER?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:e===ee.AADHAR_NUMBER?{fontWeight:700}:{fontWeight:400},children:"Aadhaar"})]})]}),(e===ee.MOBILE||e===ee.AADHAR_NUMBER)&&m.jsx("div",{className:"pds2-mt-16 pds2-w-full pds2-max-w-md pds2-mx-auto pds2-px-4 pds2-relative",children:e===ee.AADHAR_NUMBER?m.jsx($c,{numberOfInputs:3,length:4,placeholder:"XXXX",onSubmit:oe,setIsValid:N}):m.jsx(Hr,{value:n,onChange:re,type:"tel",placeholder:"Mobile Number",disabled:q,inputMode:"numeric",autoFocus:!0,maxLength:10,PrefixComponent:m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-x-8 pds2-border-r pds2-border-border-brand-02 pds2-pr-24",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4mlct2900000tg98p8u967s.webp",alt:"India Flag",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:"pds2-text-text-black pds2-text-sm",children:"+91"})]})})}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),(e===ee.MOBILE||e===ee.AADHAR_NUMBER)&&m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!X||a===Q.LOADING?"disabled":"enabled",isLoading:a===Q.LOADING,onClick:()=>ie("aadhaar_or_mobile_on_click"),className:"pds2-w-full"})]}),m.jsx("div",{className:"pds2-mt-24 pds2-mx-16 pds2-pb-16",children:m.jsxs("div",{className:"pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-03 pds2-overflow-hidden",children:[m.jsxs("button",{onClick:()=>me(!ce),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:[m.jsx("span",{className:"pds2-text-text-03",children:"Other login options for ABHA"}),m.jsx(Pr,{className:`pds2-w-16 pds2-h-16 pds2-text-text-03 pds2-transition-transform ${ce?"pds2-rotate-180":""}`})]}),ce&&m.jsxs("div",{children:[m.jsxs("button",{onClick:()=>{me(!1),t(ee.ABHA_NUMBER),ye(!0)},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[m.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:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA",className:"pds2-w-24 pds2-h-24"})}),m.jsx("span",{className:"Body1Regular pds2-text-text-black",children:"Login with ABHA Number"})]}),m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]}),m.jsxs("button",{onClick:()=>{me(!1),t(ee.PHR_ADDRESS),xe(!0)},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[m.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:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA",className:"pds2-w-24 pds2-h-24"})}),m.jsx("span",{className:"Body1Regular pds2-text-text-black",children:"Login with ABHA Address"})]}),m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]})]})]})}),m.jsx(fy,{isOpen:se,setIsOpen:ye,setFlowMethod:t,children:m.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[m.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:m.jsx("button",{onClick:()=>{ye(!1),t(ee.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:"✕"})}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:m.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:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Logo",className:"pds2-w-48 pds2-h-48"})})}),m.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:"Login with ABHA Number"}),m.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:"Enter your 14 digit ABHA Number"}),m.jsx("div",{className:"pds2-mb-24",children:m.jsx(Hr,{value:n,onChange:re,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",inputMode:"numeric",autoFocus:!0})}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!n||a===Q.LOADING?"disabled":"enabled",onClick:()=>ie("after_enter_abha_number_on_click_by_user"),className:"pds2-w-full",isLoading:a===Q.LOADING})]})]})}),m.jsx(fy,{isOpen:De,setIsOpen:xe,setFlowMethod:t,children:m.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[m.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:m.jsx("button",{onClick:()=>{xe(!1),t(ee.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:"✕"})}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:m.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:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Logo",className:"pds2-w-48 pds2-h-48"})})}),m.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:"Login with ABHA Address"}),m.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:"Enter your ABHA Address below"}),m.jsxs("div",{className:"pds2-mb-24 pds2-relative",children:[m.jsx(Hr,{value:n,onChange:re,placeholder:"Enter ABHA Address",inputMode:"text",autoFocus:!0}),m.jsx("div",{className:"pds2-absolute pds2-right-16 pds2-top-16 Body1Regular pds2-text-text-03",children:ui()==="DEV"?"@sbx":"@abdm"})]}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!n||a===Q.LOADING?"disabled":"enabled",onClick:()=>ie("after_enter_abha_address_on_click_by_user"),className:"pds2-w-full",isLoading:a===Q.LOADING})]})]})})]})},fy=({isOpen:e,setIsOpen:t,children:n,setFlowMethod:r,overlayClassName:a="pds2-bg-text-black pds2-bg-opacity-50"})=>e?m.jsxs("div",{className:"pds2-absolute pds2-inset-0 pds2-z-50 pds2-flex pds2-items-end",children:[m.jsx("div",{className:`pds2-absolute pds2-inset-0 ${a}`,style:{backgroundColor:"rgba(0, 0, 0, 0.5)"},onClick:()=>{t(!1),r(ee.MOBILE)}}),m.jsx("div",{className:"pds2-relative pds2-bg-bg-white pds2-rounded-t-24 pds2-w-full",style:{height:"75%",maxHeight:"600px",overflowY:"auto"},children:n})]}):null,nD=()=>{const e=O(n=>n.screen);switch(e[e.length-1]){case ve.LOGIN_WITH_ABHA:return m.jsx(Y3,{});case ve.VERIFY_OTP_LOGIN_WITH_ABHA:return m.jsx(A3,{});case ve.CREATE_ABHA_WITH_AADHAAR:return m.jsx(O3,{});case ve.ABHA_OTP_AND_MOBILE:return m.jsx(L3,{});case ve.ABHA_PHONE_NUMBER_VERIFICATION:return m.jsx(F3,{});case ve.AADHAAR_VERIFICATION_STATUS:return m.jsx(HC,{});case ve.ABHA_MOBILE_LINKING_STATUS:return m.jsx(k3,{});case ve.SELECT_ABHA_FROM_LIST:return m.jsx(Q3,{});case ve.SELECT_EKA_PROFILE:return m.jsx(Z3,{});case ve.CREATE_ABHA_ADDRESS:return m.jsx($3,{});case ve.CREATE_EKA_PROFILE:return m.jsx(dy,{});case ve.CREATE_PHR_EKA_PROFILE:return m.jsx(dy,{});case ve.GET_ALL_PROFILES:return m.jsx(W3,{});case ve.LOGIN_OR_CREATE_ABHA:return m.jsx(eD,{});default:return m.jsx(m.Fragment,{})}},ki=new mC;function rD(){return p.useEffect(()=>()=>{jt()},[]),m.jsx(_C,{client:ki,children:m.jsx("div",{className:"pds2-h-full pds2-w-full pds2-bg-darwin-neutral-0",style:{position:"relative",height:th()==="www-eka"?"75vh":"100vh",overflowY:"auto"},children:m.jsx(nD,{})})})}let no=null,jt,bn;function aD(e){var C;console.log("clear the abha auth store for every sdk invocation",e),O.getState().clearAbhaAuthStore();const{clientId:t,containerId:n,urlParams:r,method:a,data:i,appVersion:s,onSuccess:o,onError:l,onAbhaClose:u}=e,{mobile:c,accessToken:d,oid:f,env:w}=i||{},x={};d&&(x.auth=d),f&&(x["X-User-ID"]=f),console.log("set headers in headers"),console.log("env",w),console.log("invoked initAbhaApp",x);const g=x!==null&&("auth"in x||"X-User-ID"in x);O.getState().setIsEkaAppLogin(g),t==="doc-web"&&O.getState().setIsEkaAppLogin(!0),console.log("clientId ",t),console.log("isEkaAppLogin",O.getState().isEkaAppLogin),t==="androiddoc"||t==="doctor-app-ios"||t==="doctor-ipad-ios"||t==="doc-web"?O.getState().setClientId("doctor"):t==="androidp"||t==="patient-app-ios"?O.getState().setClientId("phr"):t==="www-eka"?O.getState().setClientId("eka-web"):(console.log("here"),O.getState().setClientId("phr"));let _=!1;qe({eventName:"init_abha_app",eventData:{platform:t,method:a||"",mobile:c||"",accessToken:d||"",oid:f||"",appVersion:s||"",isEkaAppLogin:g.toString(),container_id:n}}),iD("init_abha_app",{platform:t,method:a||"",mobile:c||"",accessToken:x.auth||"",oid:x["X-User-ID"]||"",appVersion:s||"",isEkaAppLogin:g.toString(),container_id:n}),(t==="androiddoc"||t==="doctor-app-ios"||t==="doctor-ipad-ios"||t==="doc-web")&&(_=!0,O.getState().setIsDocAppRequest(_)),O.getState().setInitAbhaAppMethod(a==="create_abha_with_mobile"?"create_abha_with_mobile":"login_with_abha"),Tb({clientId:t,env:w==="DEV"?"DEV":"PROD",...x&&{extraHeaders:x}});const h=ve.LOGIN_OR_CREATE_ABHA;O.getState().setInitState({screen:[h],urlParams:r}),O.getState().setAbhaAuthFlowMethod(ee.MOBILE);const v=/[^0-9]/g,y=c||((C=window.EkaAbha)==null?void 0:C.mobileNumber),b=y==null?void 0:y.replace(v,""),E=b==null?void 0:b.slice(-10);E&&E.length===10&&O.getState().setInitAbhaAppMobileNumber(E);const A=()=>{O.getState().clearAbhaAuthStore(),ki.removeQueries(),no==null||no.unmount(),u()},N=document.getElementById(n);if(!N){const $=`Element with id ${n} not found`;console.error($),l({error:$}),A();return}return bn=o,no=V2(N),no.render(m.jsx(rD,{})),jt=A,window.closeAbhaApp=A,A}window.initAbhaApp=aD;function iD(e,t={}){var a;const n=O.getState().clientId||"unknown-platform",r={...t,platform:n};console.log("Tracking Event:",e,r),(a=window.curio)!=null&&a.pushToMixpanel?(console.log("Pushing to Mixpanel:",e,r),window.curio.pushToMixpanel(e,r)):(console.log("Curio not available. Queuing event:",e,r),console.error("Curio not available. Could not push event to Mixpanel."))}
|