import{r as e,h as i}from"./p-083180bf.js";import"./p-f8a09b0f.js";import{k as a,m as t,f as s,n}from"./p-a7fc1e02.js";import{l as r,n as o,J as l,j as c,b as d,i as v}from"./p-d0993bb9.js";import{c as u}from"./p-c1086930.js";import"./p-cef45012.js";import"./p-49b20dae.js";import"./p-c813ec64.js";import{P as m}from"./p-2668335b.js";const f=class{constructor(i){e(this,i),this.ignored=!0,this.redirectPath="/verifyEmail",this.emailVerificationHeader="Verify your email",this.resendEmailButtonText="Re-send Email",this.verifyMessage="A verification email was sent to {email}. Please verify your email to continue to the portal. Resending an email will invalidate the previous email.",this.verificationStatusMessage="Checking verification status in {countdown}",this.verificationLoadingMessage="Checking verification status",this.verificationResentMessage="Your verification email has been resent successfully",this.networkErrorMessage="An error occurred while verifying your password. Please refresh the page.",n(this)}disconnectedCallback(){}render(){const{states:e,callbacks:n,content:f}=v()?u({states:{error:"",loading:!1,success:!1,countdown:10},callbacks:{submit:async()=>{}},content:{email:"test@example.com",verifyMessage:(h=this).verifyMessage,emailVerificationHeader:h.emailVerificationHeader,resendEmailButtonText:h.resendEmailButtonText,verificationLoadingMessage:h.verificationLoadingMessage,verificationStatusMessage:h.verificationStatusMessage,verificationResentMessage:h.verificationResentMessage,networkErrorMessage:h.networkErrorMessage}},h.demoData||{},{arrayMerge:(e,i)=>i}):function(e){var i,n,v,u,m,f,h,g,p;const[b,{loading:y,errors:w}]=r(),[M,{data:j,loading:k}]=o(),I=l(),P=null===(i=null==I?void 0:I.managedIdentity)||void 0===i?void 0:i.email,E=new URLSearchParams(c.location.search),x=E.get("nextPage"),[R,V]=a(!1),[C,L]=a(""),[S,_]=a(10),A=t(void 0),B=t(void 0);async function H(){var i;const a=await M();if(null===(i=null==a?void 0:a.managedIdentitySession)||void 0===i?void 0:i.emailVerified)return clearInterval(A.current),c.push({pathname:e.redirectPath,search:E.toString()&&"?"+E.toString()});U(10)}const T=(e=1e4)=>setInterval(H,e),q=e=>setInterval((()=>_(e)),1e3);function U(e){if(clearInterval(B.current),clearInterval(A.current),"hidden"===document.visibilityState)return;e&&_(e);let i=S||10;B.current=q(e-1||i-1),A.current=T(1e3*e||1e3*i)}const Y=d((()=>U()),[S]);return s((()=>(A.current||(H(),A.current=T()),()=>{clearInterval(A.current)})),[]),s((()=>(S>0&&(clearInterval(B.current),B.current=q(S-1)),document.addEventListener("visibilitychange",Y),()=>{clearInterval(B.current),document.removeEventListener("visibilitychange",Y)})),[S]),{states:{loading:y,error:(null===(m=null===(u=null===(v=null===(n=null==w?void 0:w.response)||void 0===n?void 0:n.errors)||void 0===v?void 0:v[0])||void 0===u?void 0:u.extensions)||void 0===m?void 0:m.message)||(null===(g=null===(h=null===(f=null==w?void 0:w.response)||void 0===f?void 0:f.errors)||void 0===h?void 0:h[0])||void 0===g?void 0:g.message)||C,success:R,loadingVerification:k,isVerified:!!(null===(p=null==j?void 0:j.managedIdentitySession)||void 0===p?void 0:p.emailVerified),countdown:S},callbacks:{submit:async()=>{var i;if(!P)return;L(""),V(!1);const a={email:P,urlParams:x?{nextPage:x}:null,redirectPath:e.redirectPath},t=await b(a);t instanceof Error?t.message&&L(e.networkErrorMessage):(null===(i=t.requestManagedIdentityVerificationEmail)||void 0===i?void 0:i.success)&&V(!0)}},content:{email:P,verifyMessage:e.verifyMessage,emailVerificationHeader:e.emailVerificationHeader,resendEmailButtonText:e.resendEmailButtonText,verificationLoadingMessage:e.verificationLoadingMessage,verificationStatusMessage:e.verificationStatusMessage,verificationResentMessage:e.verificationResentMessage,networkErrorMessage:e.networkErrorMessage}}}(this);var h;return i(m,{states:e,callbacks:n,content:f})}};export{f as sqm_portal_email_verification}