import{t as me,r as o,aM as pe,bA as ge,eY as he,z as _e,y as I,bD as fe,ce as be,af as d,d5 as ye,fD as xe,j as t,b5 as Ce,n as Ne,L as Te,dn as ve,T as G,f7 as Ae,f8 as Ee,B as we,S as Se,dp as Le,fE as Pe,fF as Ie,fG as je,fH as Fe,fI as ke,fJ as Me,en as j,bh as F,e5 as Ue,cc as qe,fK as Be,fL as Oe}from"./index-CNnTZTc7.js";import{r as ze}from"./react-router-dom.min-CueLcAwJ.js";import{P as Re}from"./index-D-NY1ncL.js";import{Z as He}from"./index-DGhinOqI.js";const Ge="_textInputRowContainer_o6dug_88",Ze="_textContainer_o6dug_104",Ke="_disclaimer_o6dug_110",Ye="_HealthDisclaimer_o6dug_124",Je="_disclaimerLink_o6dug_128",Xe="_divider_o6dug_134",We="_submitButtonContainer_o6dug_139",$e="_duplicateLeadLabel_o6dug_145",Qe="_submitButton_o6dug_139",r={textInputRowContainer:Ge,textContainer:Ze,disclaimer:Ke,HealthDisclaimer:Ye,disclaimerLink:Je,divider:Xe,submitButtonContainer:We,duplicateLeadLabel:$e,submitButton:Qe},nt=Z=>{const{autoFocus:K=!0,contactAnAgentClassName:Y,disablePattern:p=!0,from:J=""}=Z,{clearErrors:A,formState:{errors:n},handleSubmit:X,register:g,setError:h,getValues:W,setValue:c,watch:N}=me(),$=o.useContext(pe),[_,Q]=o.useState(""),[V,k]=o.useState(!1),M=N("firstName"),U=N("lastName"),a=N("phone"),i=N("zipCode"),D=ze.useHistory(),{purlAgentData:T}=o.useContext(ge),{clientService:q}=he(),{zipCode:u,setZipCode:B,error:f,onZipCodeChange:ee}=o.useContext(_e),[te,O]=o.useState(!1),[ne,m]=o.useState(!1),E=I(e=>e.planTypeDetail.selectedAgentType),w=I(e=>e.planTypeDetail.medicareAgent),S=I(e=>e.planTypeDetail.finalExpenseAgent),ae=o.useMemo(()=>w&&E===fe?w:S&&E===be?S:d(ye),[E,w,S]);o.useEffect(()=>{i!=null&&i.length&&!xe.test(i)&&c("zipCode",i.replace(/\D/g,"")),typeof i=="string"&&B(i.replace(/\D/g,""))},[i,c]),o.useEffect(()=>{ee()},[]),o.useEffect(()=>{(i==null?void 0:i.length)<5?m(!0):m(f?!0:!M||!U||!a||!i)},[f,M,U,a,i]),o.useEffect(()=>{typeof i=="string"&&i!==u&&c("zipCode",u)},[u,c]);const L=JSON.parse(localStorage.getItem("reqAgentData")),ie=localStorage.getItem("fromReqCallBack"),{agentFirstName:se,agentLastName:oe,agentNpn:z,agentPurlCode:R,caLicense:re,email:ce,virtualNumber:P}=ie==="homePage"?ae||{}:L||T||{};o.useEffect(()=>{let e=a;(e==null?void 0:e.length)>(_==null?void 0:_.length)&&((a==null?void 0:a.length)===3||(a==null?void 0:a.length)===7?(e=a+"-",c("phone",e)):(a==null?void 0:a.length)>12&&(e=_,c("phone",_))),Q(e)},[a]);const le=async()=>{const e=await q.getUser(),{consumerid:b}=e,y={agentNpnSwitchedFrom:"",agentNpnSwitchedTo:z,agentPurlSwitchedTo:R,consumerId:b,isActive:!0,leadId:null};await q.agentAssociation(y)},de=(e,b)=>{var s,x,C;O(!0),k(!1),m(!0);const y=window.location.pathname===j||window.location.pathname===F?"https://app.leadconduit.com/flows/65a91a320ee395fdf06f7746/sources/5cc35e1e0522c3d926db505b/submit":"https://app.leadconduit.com/flows/62ea9c21aaeaea03a00cafdb/sources/5cc35e1e0522c3d926db505b/submit";e.campaignName=" ",e.leadTypeThom="EWL",e.trustedFormCertUrl=(s=document.querySelector("[name=xxTrustedFormToken]"))==null?void 0:s.value,e.trustedFormPingUrl=(x=document.querySelector("[name=xxTrustedFormCertUrl]"))==null?void 0:x.value,e.trustedFormToken=(C=document.querySelector("[name=xxTrustedFormPingUrl]"))==null?void 0:C.value;const v={agent_email_address_thom:ce,agent_first_name_thom:se,agent_last_name_thom:oe,agent_npn_thom:z,agent_phone_thom:P==null?void 0:P.replace("+1",""),agent_purl_thom:R,ca_license_number_thom:re||(T==null?void 0:T.caLicense),campaign_account:e==null?void 0:e.campaignName,campaign_thom:J,campaign_medium:d(Pe)||"",campaign_source:d(Ie)||"",campaign_name:d(je)||"",campaign_content:d(Fe)||"",search_terms:d(ke)||"","google.clid":d(Me)||"",email:e==null?void 0:e.emailAddress,first_name:e==null?void 0:e.firstName,last_name:e==null?void 0:e.lastName,lead_type_thom:"Test Lead",phone_1:e==null?void 0:e.phone.replaceAll("-",""),postal_code:e==null?void 0:e.zipCode,product:window.location.pathname===j||window.location.pathname===F?"PlanEnroll Final Expense (Realtime Lead)":"PlanEnroll (Realtime Lead)",trustedform_cert_url:e==null?void 0:e.trustedFormCertUrl};B(e==null?void 0:e.zipCode),L&&(v.ilc_campaign_id_thom=L.agentLeadCampaignId),Ue({url:y,body:v}).then(async l=>{O(!1),(l==null?void 0:l.outcome)==="success"?(qe("contact_an_agent_request_submit"),localStorage.removeItem("clearFilterSearch"),localStorage.removeItem("fromReqCallBack"),$.isAuthenticated()&&(await le(),localStorage.removeItem("reqAgentData")),D.push(window.location.pathname===j||window.location.pathname===F?Be:Oe)):(l==null?void 0:l.reason)==="Duplicate lead"&&k(!0),m(!1),b.target.reset()})},ue=async(e,b)=>{var x,C,l,H;const{emailAddress:y,phone:v}=e,s=await Le(y,v);((x=s==null?void 0:s.email)==null?void 0:x.status)==="invalid"&&h("emailAddress",{type:"pattern"}),((C=s==null?void 0:s.phone)==null?void 0:C.status)==="invalid"&&h("phone",{type:"pattern"}),((l=s==null?void 0:s.email)==null?void 0:l.status)!=="invalid"&&((H=s==null?void 0:s.phone)==null?void 0:H.status)!=="invalid"&&!f&&de(e,b)};return o.useEffect(()=>{f&&u.length===5?h("zipCode",{type:"pattern"}):A("zipCode")},[f,u,c,h,A]),o.useEffect(()=>{c("zipCode",u)},[c]),t.jsxs("div",{className:r.formContainer,children:[t.jsx(Ce,{}),t.jsx("form",{onSubmit:X(ue),children:t.jsxs("div",{className:`${r.textInputRowContainer} ${Y} `,children:[t.jsx("div",{className:r.textContainer,children:t.jsx(Ne,{autoFocus:K,disablePattern:p,id:"firstName",labelText:"First Name",register:g,error:n==null?void 0:n.firstName,required:!0})}),t.jsx("div",{className:r.textContainer,children:t.jsx(Te,{disablePattern:p,id:"lastName",labelText:"Last Name",register:g,required:!0,error:n==null?void 0:n.lastName})}),t.jsx("div",{className:r.textContainer,children:t.jsx(He,{disablePattern:p,id:"zipCode",labelText:"Zip Code",register:g,required:!0,error:n==null?void 0:n.zipCode})}),t.jsx("div",{className:r.textContainer,children:t.jsx(Re,{disablePattern:p,id:"phone",labelText:"Phone Number",register:g,required:!0,error:n==null?void 0:n.phone,setError:h,clearErrors:A,value:W("phone")})}),t.jsx("div",{className:r.textContainer,children:t.jsx(ve,{disablePattern:p,id:"emailAddress",labelText:"Email (Optional)",register:g,required:!1,error:n==null?void 0:n.emailAddress})}),V&&t.jsx(G,{className:r.duplicateLeadLabel,children:"Thank you. Your request has already been submitted. A PlanEnroll Network Agent will be contacting you."}),t.jsx("div",{className:r.divider}),t.jsx(G,{className:r.disclaimer,children:window.location.href.indexOf("final-expense")>-1?"This is a solicitation for insurance and I understand by providing my phone number and information and clicking Submit, I am giving permission to contact me for the purpose of marketing insurance products and services. I also understand I may be contacted by a properly licensed insurance agent who can answer my questions and provide information about life insurance products and services. The licensed insurance agents who might contact me are not connected with or endorsed by any government agency or program. The communications consented to above include marketing of insurance products.":t.jsxs(t.Fragment,{children:[t.jsx("p",{className:r.HealthDisclaimer,children:"By providing and submitting my personal contact information to PlanEnroll, I agree to be contacted by a PlanEnroll licensed insurance agent who can answer my questions and provide information about available Medicare coverage options, such as Medicare Advantage, Prescription Drug (Part D) and Medicare Supplement insurance plans. This is a solicitation for insurance. The communications consented to above include marketing of insurance products. Licensed insurance agents are not connected with or endorsed by the U.S. government or the federal Medicare program. I understand that submitting this form does NOT affect my current enrollment, nor will it enroll me in a Medicare Advantage Plan, Prescription Drug Plan, or other Medicare plan. A Medicare Advantage Plan is a health insurance plan provided through a private insurer and delivers Medicare Part A and Part B benefits. A Part D Drug Plan is a prescription drug insurance plan provided through a private insurer and delivers Medicare Part D benefits."}),t.jsxs("p",{children:["By clicking the Submit button, I expressly consent by electronic signature to the sharing of my personal beneficiary information with PlanEnroll and its licensed agents and to receive informational and marketing communications via automatic telephone dialing system or by artificial/pre-recorded message, email, or by text message from this website (operated by Integrity Marketing Group) and PlanEnroll licensed agents at the telephone number above (even if my number is currently listed on any state, federal, local or corporate Do Not Call list) including my wireless number if provided. Carrier message and data rates may apply. I understand that my consent is not required as a condition of purchasing any goods or services and that I may revoke my consent at any time. I understand that I will be able to separately consent to the use of my personal beneficiary information with any other licensed agent affiliated with PlanEnroll from whom I may request further assistance. I also acknowledge that I have read and agree to the"," ",t.jsx(Ae,{className:r.disclaimerLink})," ","and"," ",t.jsx(Ee,{className:r.disclaimerLink}),". If you do not want to share your information, please click on Do Not Sell My Information located in the footer for more details."]})]})}),t.jsx("div",{className:r.submitButtonContainer,children:t.jsx(we,{disabled:ne||(n==null?void 0:n.phone),className:r.submitButton,label:"Submit",type:"submit"})}),te?t.jsx(Se,{}):null]})})]})};export{nt as C};
//# sourceMappingURL=index-Dl431XGQ.js.map