@qratilabs/qrati-connect 2.2.0 → 2.2.2

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/element/{AuthLayout-CyO9f3yS.js → AuthLayout-yBnXbTdQ.js} +1 -1
  3. package/element/ContentsPage-BpGmiu2Y.js +16 -0
  4. package/element/{CuratePage-Da329OuY.js → CuratePage-Bf96ltsu.js} +1 -1
  5. package/element/{Dialog-DUE33ABe.js → Dialog-BqAbQiPJ.js} +1 -1
  6. package/element/{DotLottiePlayer-8MlLiMyZ.js → DotLottiePlayer-BtxapiSJ.js} +1 -1
  7. package/element/{EventHeaderAdminButtons-ZWRtXY11.js → EventHeaderAdminButtons-BplHheBN.js} +2 -2
  8. package/element/{FolderBreadcrumb-CEs6rjY8.js → FolderBreadcrumb-DhqYRcyB.js} +1 -1
  9. package/element/{ForgotPasswordPage-DcrSZb4Y.js → ForgotPasswordPage-Z0fY0XwU.js} +1 -1
  10. package/element/{InputField-C89vrW2H.js → InputField-B4v4KXcE.js} +1 -1
  11. package/element/{LazyLoadImage-CCgs8tnO.js → LazyLoadImage-DAovisp3.js} +1 -1
  12. package/element/{LeaderboardPage-CTDNDeXw.js → LeaderboardPage-Ygaebr-t.js} +1 -1
  13. package/element/{LoginPage-smlCb8hl.js → LoginPage-DIZ7qlYO.js} +1 -1
  14. package/element/{NCMVHL6D-mctK8Nwg.js → NCMVHL6D-CxiMFMqg.js} +1 -1
  15. package/element/{PublicEvents-D2zm99Nv.js → PublicEvents-D4eUZCHS.js} +1 -1
  16. package/element/{RegisterPage-B6iFPEOf.js → RegisterPage-Bg7pyJeh.js} +1 -1
  17. package/element/{SocialLoginButton-Bmw5w2Wo.js → SocialLoginButton-DsAt02H9.js} +1 -1
  18. package/element/{UploadPage-CeUd2Ngw.js → UploadPage-C0ek4Qqe.js} +1 -1
  19. package/element/{VideoPlayer-D3O9yQy5.js → VideoPlayer-g56XT4-3.js} +1 -1
  20. package/element/element.es.js +1 -1
  21. package/element/{heic2any-ChkiLE0t.js → heic2any-z2RaaSEC.js} +1 -1
  22. package/element/{index-Dc66pO4G.js → index-BhzTVsTo.js} +1 -1
  23. package/element/{index-eZDSy_OJ.js → index-DDOpdb3i.js} +2 -2
  24. package/element/{index.esm-fgGipFtS.js → index.esm-BbqgTw7t.js} +1 -1
  25. package/element/{photoswipe-CqOSmPl3.js → photoswipe-B7SExy7W.js} +1 -1
  26. package/element/styles.css +1 -1
  27. package/element/{tslib.es6-CrRFG_pJ.js → tslib.es6-DIRCPYhi.js} +1 -1
  28. package/element/{useOrgAccess-DwChBdHT.js → useOrgAccess-CQNPoSFq.js} +1 -1
  29. package/element/web.es.js +1 -1
  30. package/package.json +1 -1
  31. package/react/{CQ_GAdf6.js → BBaDMfm_.js} +1 -1
  32. package/react/{DtITAxUS.js → BE9_Ublk.js} +1 -1
  33. package/react/{DOyHX7jh.js → BX9GvyM-.js} +1 -1
  34. package/react/C1kBrsed.js +16 -0
  35. package/react/{01YpbkrK.js → C27Sy5Nr.js} +1 -1
  36. package/react/{Bhx5l06G.js → C5XgHCIU.js} +1 -1
  37. package/react/{DlRtYLod.js → CBpEkjwz.js} +1 -1
  38. package/react/{DDDUG6Th.js → Cb66NH94.js} +1 -1
  39. package/react/{C9K7NHY-.js → Ck9enZ3e.js} +1 -1
  40. package/react/{DGbDKxZM.js → CouLaMtF.js} +1 -1
  41. package/react/{BC4qG4vp.js → Cr9MgBeI.js} +2 -2
  42. package/react/{CwHDgEUw.js → DLUmYnVL.js} +1 -1
  43. package/react/{3-7xITP8.js → DZqtPzMv.js} +1 -1
  44. package/react/{YK1PgWHO.js → Dhcvm9yI.js} +1 -1
  45. package/react/{D9rAIIEm.js → DppB7lia.js} +1 -1
  46. package/react/{DGrws0Ed.js → DqmSOLfe.js} +1 -1
  47. package/react/{DBT304mv.js → Dx52SzWS.js} +1 -1
  48. package/react/{DgG5NhsB.js → FcDLBnwX.js} +1 -1
  49. package/react/{DR9E1aMG.js → Ld9VPzmf.js} +2 -2
  50. package/react/{HRRHpVRs.js → MZeQHhBV.js} +1 -1
  51. package/react/{Cy0hl_vl.js → U0g8gQE-.js} +1 -1
  52. package/react/index.es.js +2 -2
  53. package/react/{Cwug7XlJ.js → qwl23nTI.js} +1 -1
  54. package/react/{B-6zXxDr.js → x0a0HaZy.js} +1 -1
  55. package/umd/web.umd.js +87 -87
  56. package/element/ContentsPage-DTXin7QX.js +0 -16
  57. package/react/BG98DA1v.js +0 -16
@@ -1 +1 @@
1
- import{j as e,u as r,T as o,J as n,k as a,i as t,a4 as s,P as l}from"./DR9E1aMG.js";import i,{useState as c}from"react";import{I as d}from"./YK1PgWHO.js";import{u,o as m,c as f,C as p,a as h,b as g}from"./HhCRmfOk.js";const v=({count:r=1,currentStep:o=0,disabled:n,onStepClick:a})=>{const t=n||!a;return e.jsx("ol",{role:"list",className:"qc:flex qc:items-center qc:space-x-4 qc:pl-1.5",children:Array.from({length:r}).map((r,n)=>e.jsx("li",{children:n<o?e.jsx("button",{className:"qc:bg-primary qc:block qc:size-3 qc:rounded-full",disabled:t,onClick:()=>a&&a(n)}):n===o?e.jsxs("button",{className:"qc:relative qc:flex qc:items-center qc:justify-center","aria-current":"step",disabled:t,onClick:()=>a&&a(n),children:[e.jsx("span",{className:"qc:absolute qc:flex qc:size-6 qc:p-px","aria-hidden":"true",children:e.jsx("span",{className:"qc:bg-primary qc:size-full qc:rounded-full qc:bg-opacity-40"})}),e.jsx("span",{className:"qc:bg-primary qc:relative qc:block qc:size-3 qc:rounded-full","aria-hidden":"true"})]}):e.jsx("button",{className:"qc:block qc:size-3 qc:rounded-full qc:bg-text-secondary-light",disabled:t,onClick:()=>a&&a(n)})},`progress-dot-${n}`))})},q={email:""},w=f().shape({email:h().required("Please enter your email").email("Enter a valid email")}),x=({onCodeSent:s})=>{const[l,i]=c(!1),[f,h]=c(null),{props:{organizationId:g}}=r(),{control:v,handleSubmit:x,formState:{errors:y}}=u({mode:"onSubmit",defaultValues:q,resolver:m(w)});return e.jsxs("div",{className:"w-full space-y-6",children:[e.jsx(o,{variant:"h5",align:"center",children:"Reset password"}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:w-full qc:space-y-4 qc:lg:space-y-8",onSubmit:x(async e=>{h(null),i(!0);try{await a.post(t.SEND_PASSWORD_RESET_CODE,{json:{email:e.email?.toLowerCase()},headers:{"x-org-id":g}}),s(e.email.toLowerCase())}catch(e){console.error("Error sending verification code:",e),h(e.message||e||"An error occurred while sending the code. Please try again.")}i(!1)}),children:[e.jsx(p,{name:"email",control:v,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"Email",disabled:l,type:"email",value:r,onChange:o,onBlur:n,error:y.email?.message})}),e.jsx(n,{fullWidth:!0,type:"submit",loading:l,children:"Send verification code"})]}),f&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:f})]})};var y=function(e){return"object"==typeof e&&null!==e},b=function(e){var r=e.value,o=void 0===r?"":r,n=e.numInputs,a=void 0===n?4:n,t=e.onChange,s=e.onPaste,l=e.renderInput,c=e.shouldAutoFocus,d=void 0!==c&&c,u=e.inputType,m=void 0===u?"text":u,f=e.renderSeparator,p=e.placeholder,h=e.containerStyle,g=e.inputStyle,v=e.skipDefaultStyles,q=void 0!==v&&v,w=i.useState(0),x=w[0],b=w[1],j=i.useRef([]),S=function(){return o?o.toString().split(""):[]},C="number"===m||"tel"===m;i.useEffect(function(){j.current=j.current.slice(0,a)},[a]),i.useEffect(function(){var e;d&&(null===(e=j.current[0])||void 0===e||e.focus())},[d]);var P=function(){if("string"==typeof p){if(p.length===a)return p;p.length>0&&console.error("Length of the placeholder should be equal to the number of inputs.")}},N=function(e){return(C?!isNaN(Number(e)):"string"==typeof e)&&1===e.trim().length},D=function(e){var r=e.target.value;N(r)&&(R(r),I(x+1))},E=function(e){var r=e.nativeEvent,o=e.target.value;if(!N(o)){if(o.length===a)o.split("").some(function(e){return!N(e)})||(O(o.split("")),I(a-1));null===r.data&&"deleteContentBackward"===r.inputType&&(e.preventDefault(),R(""),I(x-1)),e.target.value=""}},k=function(){b(x-1)},A=function(e){var r=S();[e.code,e.key].includes("Backspace")?(e.preventDefault(),R(""),I(x-1)):"Delete"===e.code?(e.preventDefault(),R("")):"ArrowLeft"===e.code?(e.preventDefault(),I(x-1)):"ArrowRight"===e.code||e.key===r[x]?(e.preventDefault(),I(x+1)):("Spacebar"===e.code||"Space"===e.code||"ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault()},I=function(e){var r,o,n=Math.max(Math.min(a-1,e),0);j.current[n]&&(null===(r=j.current[n])||void 0===r||r.focus(),null===(o=j.current[n])||void 0===o||o.select(),b(n))},R=function(e){var r=S();r[x]=e[0],O(r)},O=function(e){var r=e.join("");t(r)},B=function(e){var r;e.preventDefault();var o=S(),n=x,t=e.clipboardData.getData("text/plain").slice(0,a-x).split("");if(!C||!t.some(function(e){return isNaN(Number(e))})){for(var s=0;s<a;++s)s>=x&&t.length>0&&(o[s]=null!==(r=t.shift())&&void 0!==r?r:"",n++);I(n),O(o)}};return i.createElement("div",{style:Object.assign({display:"flex",alignItems:"center"},y(h)&&h),className:"string"==typeof h?h:void 0,onPaste:s},Array.from({length:a},function(e,r){return r}).map(function(e){var r,o,n;return i.createElement(i.Fragment,{key:e},l({value:null!==(r=S()[e])&&void 0!==r?r:"",placeholder:null!==(n=null===(o=P())||void 0===o?void 0:o[e])&&void 0!==n?n:void 0,ref:function(r){return j.current[e]=r},onChange:D,onFocus:function(r){return function(e){return function(r){b(r),e.target.select()}}(r)(e)},onBlur:k,onKeyDown:A,onPaste:B,autoComplete:"off","aria-label":"Please enter OTP character ".concat(e+1),style:Object.assign(q?{}:{width:"1em",textAlign:"center"},y(g)?g:{}),className:"string"==typeof g?g:void 0,type:m,inputMode:C?"numeric":"text",onInput:E},e),e<a-1&&("function"==typeof f?f(e):f))}))};const j={code:""},S=f().shape({code:h().required("Please enter the code")}),C=({email:s,onCodeVerified:l})=>{const{props:{organizationId:i}}=r(),[d,f]=c(!1),[h,g]=c(null),{control:v,handleSubmit:q,watch:w}=u({mode:"onSubmit",defaultValues:j,resolver:m(S)});return e.jsxs("div",{className:"qc:space-y-4 qc:lg:space-y-8",children:[e.jsxs(o,{variant:"h5",align:"center",children:["Enter the code sent to ",e.jsx("span",{className:"qc:text-primary qc:font-medium",children:s})]}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:flex qc:w-full qc:flex-col qc:items-center qc:gap-4 qc:lg:gap-8",onSubmit:q(async e=>{g(null),f(!0);try{await a.post(t.VERIFY_PASSWORD_RESET_CODE,{json:{email:s,code:e.code},headers:{"x-org-id":i}}),l&&l()}catch(e){console.error(e.message),g("An error occurred while verifying the code. Please try again.")}f(!1)}),children:[e.jsx(p,{name:"code",control:v,render:({field:{value:r,onChange:o}})=>e.jsx(b,{value:r,onChange:o,numInputs:6,shouldAutoFocus:!0,inputType:"number",isInputNum:!0,containerStyle:"qc:flex qc:gap-4",inputStyle:"qc:rounded qc:border focus:qc:border-primary qc:text-foreground qc:bg-white disabled:qc:border-border disabled:qc:text-gray-400 otp-input qc:text-xl focus:qc:outline-none focus:qc:ring-0 focus:qc:boder-none",renderInput:r=>e.jsx("input",{...r})})}),e.jsx(n,{fullWidth:!0,type:"submit",disabled:w("code").length<6,loading:d,children:"Submit"})]}),h&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:h})]})},P={password:"",confirmPassword:""},N=f().shape({password:h().required("Please enter your password").min(8,"Min password length is 8"),confirmPassword:h().required("Please confirm your password").min(8,"Min password length is 8").oneOf([g("password"),null],"Passwords do not match")}),D=({email:s,onPasswordReset:l})=>{const{props:{organizationId:i}}=r(),[f,h]=c({showPassword:!1,showConfirmPassword:!1}),[g,v]=c(!1),[q,w]=c(null),{control:x,handleSubmit:y,formState:{errors:b}}=u({defaultValues:P,mode:"onSubmit",resolver:m(N)});return e.jsxs("div",{className:"qc:w-full qc:space-y-4",children:[e.jsx(o,{variant:"h5",align:"center",children:"Set new password"}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:w-full qc:space-y-8",onSubmit:y(async e=>{w(null),v(!0);try{const r=await a.post(t.RESET_PASSWORD,{json:{email:s.toLowerCase(),password:e.password},headers:{"x-org-id":i}});r.error?w(r.error):l()}catch{w("An error occurred while resetting the password. Please try again.")}v(!1)}),children:[e.jsxs("div",{className:"qc:relative",children:[e.jsx(p,{name:"password",control:x,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"New password",disabled:g,type:f.showPassword?"text":"password",value:r,onChange:o,onBlur:n,error:b.password?.message})}),e.jsx(n,{variant:"ghost",color:"primary",className:"qc:absolute -qc:right-4 qc:top-7",icon:f.showPassword?"mdi:eye-outline":"mdi:eye-off-outline",onClick:()=>h({...f,showPassword:!f.showPassword})})]}),e.jsxs("div",{className:"qc:relative",children:[e.jsx(p,{name:"confirmPassword",control:x,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"Confirm new password",disabled:g,type:f.showConfirmPassword?"text":"password",value:r,onChange:o,onBlur:n,error:b.confirmPassword?.message})}),e.jsx(n,{variant:"ghost",color:"primary",className:"qc:absolute -qc:right-4 qc:top-7",icon:f.showConfirmPassword?"mdi:eye-outline":"mdi:eye-off-outline",onClick:()=>h({...f,showConfirmPassword:!f.showConfirmPassword})})]}),e.jsx(n,{fullWidth:!0,type:"submit",color:"primary",loading:g,children:"Reset password"})]}),q&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:q})]})},E=()=>{const r=s(),[o,n]=c(null),[a,t]=c(0);return e.jsxs("div",{className:"space-y-9",children:[(({index:a})=>{switch(a){case 0:return e.jsx(x,{onCodeSent:e=>{n(e),t(1)}});case 1:return e.jsx(C,{email:o,onCodeVerified:()=>t(2)});case 2:return e.jsx(D,{email:o,onPasswordReset:()=>{r(l.LOGIN)}})}})({index:a}),e.jsx("div",{className:"qc:mt-8 qc:flex qc:justify-center",children:e.jsx(v,{count:3,currentStep:a})})]})};export{E as default};
1
+ import{j as e,u as r,T as o,J as n,k as a,i as t,a4 as s,P as l}from"./Ld9VPzmf.js";import i,{useState as c}from"react";import{I as d}from"./Dhcvm9yI.js";import{u,o as m,c as f,C as p,a as h,b as g}from"./HhCRmfOk.js";const v=({count:r=1,currentStep:o=0,disabled:n,onStepClick:a})=>{const t=n||!a;return e.jsx("ol",{role:"list",className:"qc:flex qc:items-center qc:space-x-4 qc:pl-1.5",children:Array.from({length:r}).map((r,n)=>e.jsx("li",{children:n<o?e.jsx("button",{className:"qc:bg-primary qc:block qc:size-3 qc:rounded-full",disabled:t,onClick:()=>a&&a(n)}):n===o?e.jsxs("button",{className:"qc:relative qc:flex qc:items-center qc:justify-center","aria-current":"step",disabled:t,onClick:()=>a&&a(n),children:[e.jsx("span",{className:"qc:absolute qc:flex qc:size-6 qc:p-px","aria-hidden":"true",children:e.jsx("span",{className:"qc:bg-primary qc:size-full qc:rounded-full qc:bg-opacity-40"})}),e.jsx("span",{className:"qc:bg-primary qc:relative qc:block qc:size-3 qc:rounded-full","aria-hidden":"true"})]}):e.jsx("button",{className:"qc:block qc:size-3 qc:rounded-full qc:bg-text-secondary-light",disabled:t,onClick:()=>a&&a(n)})},`progress-dot-${n}`))})},q={email:""},w=f().shape({email:h().required("Please enter your email").email("Enter a valid email")}),x=({onCodeSent:s})=>{const[l,i]=c(!1),[f,h]=c(null),{props:{organizationId:g}}=r(),{control:v,handleSubmit:x,formState:{errors:y}}=u({mode:"onSubmit",defaultValues:q,resolver:m(w)});return e.jsxs("div",{className:"w-full space-y-6",children:[e.jsx(o,{variant:"h5",align:"center",children:"Reset password"}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:w-full qc:space-y-4 qc:lg:space-y-8",onSubmit:x(async e=>{h(null),i(!0);try{await a.post(t.SEND_PASSWORD_RESET_CODE,{json:{email:e.email?.toLowerCase()},headers:{"x-org-id":g}}),s(e.email.toLowerCase())}catch(e){console.error("Error sending verification code:",e),h(e.message||e||"An error occurred while sending the code. Please try again.")}i(!1)}),children:[e.jsx(p,{name:"email",control:v,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"Email",disabled:l,type:"email",value:r,onChange:o,onBlur:n,error:y.email?.message})}),e.jsx(n,{fullWidth:!0,type:"submit",loading:l,children:"Send verification code"})]}),f&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:f})]})};var y=function(e){return"object"==typeof e&&null!==e},b=function(e){var r=e.value,o=void 0===r?"":r,n=e.numInputs,a=void 0===n?4:n,t=e.onChange,s=e.onPaste,l=e.renderInput,c=e.shouldAutoFocus,d=void 0!==c&&c,u=e.inputType,m=void 0===u?"text":u,f=e.renderSeparator,p=e.placeholder,h=e.containerStyle,g=e.inputStyle,v=e.skipDefaultStyles,q=void 0!==v&&v,w=i.useState(0),x=w[0],b=w[1],j=i.useRef([]),S=function(){return o?o.toString().split(""):[]},C="number"===m||"tel"===m;i.useEffect(function(){j.current=j.current.slice(0,a)},[a]),i.useEffect(function(){var e;d&&(null===(e=j.current[0])||void 0===e||e.focus())},[d]);var P=function(){if("string"==typeof p){if(p.length===a)return p;p.length>0&&console.error("Length of the placeholder should be equal to the number of inputs.")}},N=function(e){return(C?!isNaN(Number(e)):"string"==typeof e)&&1===e.trim().length},D=function(e){var r=e.target.value;N(r)&&(R(r),I(x+1))},E=function(e){var r=e.nativeEvent,o=e.target.value;if(!N(o)){if(o.length===a)o.split("").some(function(e){return!N(e)})||(O(o.split("")),I(a-1));null===r.data&&"deleteContentBackward"===r.inputType&&(e.preventDefault(),R(""),I(x-1)),e.target.value=""}},k=function(){b(x-1)},A=function(e){var r=S();[e.code,e.key].includes("Backspace")?(e.preventDefault(),R(""),I(x-1)):"Delete"===e.code?(e.preventDefault(),R("")):"ArrowLeft"===e.code?(e.preventDefault(),I(x-1)):"ArrowRight"===e.code||e.key===r[x]?(e.preventDefault(),I(x+1)):("Spacebar"===e.code||"Space"===e.code||"ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault()},I=function(e){var r,o,n=Math.max(Math.min(a-1,e),0);j.current[n]&&(null===(r=j.current[n])||void 0===r||r.focus(),null===(o=j.current[n])||void 0===o||o.select(),b(n))},R=function(e){var r=S();r[x]=e[0],O(r)},O=function(e){var r=e.join("");t(r)},B=function(e){var r;e.preventDefault();var o=S(),n=x,t=e.clipboardData.getData("text/plain").slice(0,a-x).split("");if(!C||!t.some(function(e){return isNaN(Number(e))})){for(var s=0;s<a;++s)s>=x&&t.length>0&&(o[s]=null!==(r=t.shift())&&void 0!==r?r:"",n++);I(n),O(o)}};return i.createElement("div",{style:Object.assign({display:"flex",alignItems:"center"},y(h)&&h),className:"string"==typeof h?h:void 0,onPaste:s},Array.from({length:a},function(e,r){return r}).map(function(e){var r,o,n;return i.createElement(i.Fragment,{key:e},l({value:null!==(r=S()[e])&&void 0!==r?r:"",placeholder:null!==(n=null===(o=P())||void 0===o?void 0:o[e])&&void 0!==n?n:void 0,ref:function(r){return j.current[e]=r},onChange:D,onFocus:function(r){return function(e){return function(r){b(r),e.target.select()}}(r)(e)},onBlur:k,onKeyDown:A,onPaste:B,autoComplete:"off","aria-label":"Please enter OTP character ".concat(e+1),style:Object.assign(q?{}:{width:"1em",textAlign:"center"},y(g)?g:{}),className:"string"==typeof g?g:void 0,type:m,inputMode:C?"numeric":"text",onInput:E},e),e<a-1&&("function"==typeof f?f(e):f))}))};const j={code:""},S=f().shape({code:h().required("Please enter the code")}),C=({email:s,onCodeVerified:l})=>{const{props:{organizationId:i}}=r(),[d,f]=c(!1),[h,g]=c(null),{control:v,handleSubmit:q,watch:w}=u({mode:"onSubmit",defaultValues:j,resolver:m(S)});return e.jsxs("div",{className:"qc:space-y-4 qc:lg:space-y-8",children:[e.jsxs(o,{variant:"h5",align:"center",children:["Enter the code sent to ",e.jsx("span",{className:"qc:text-primary qc:font-medium",children:s})]}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:flex qc:w-full qc:flex-col qc:items-center qc:gap-4 qc:lg:gap-8",onSubmit:q(async e=>{g(null),f(!0);try{await a.post(t.VERIFY_PASSWORD_RESET_CODE,{json:{email:s,code:e.code},headers:{"x-org-id":i}}),l&&l()}catch(e){console.error(e.message),g("An error occurred while verifying the code. Please try again.")}f(!1)}),children:[e.jsx(p,{name:"code",control:v,render:({field:{value:r,onChange:o}})=>e.jsx(b,{value:r,onChange:o,numInputs:6,shouldAutoFocus:!0,inputType:"number",isInputNum:!0,containerStyle:"qc:flex qc:gap-4",inputStyle:"qc:rounded qc:border focus:qc:border-primary qc:text-foreground qc:bg-white disabled:qc:border-border disabled:qc:text-gray-400 otp-input qc:text-xl focus:qc:outline-none focus:qc:ring-0 focus:qc:boder-none",renderInput:r=>e.jsx("input",{...r})})}),e.jsx(n,{fullWidth:!0,type:"submit",disabled:w("code").length<6,loading:d,children:"Submit"})]}),h&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:h})]})},P={password:"",confirmPassword:""},N=f().shape({password:h().required("Please enter your password").min(8,"Min password length is 8"),confirmPassword:h().required("Please confirm your password").min(8,"Min password length is 8").oneOf([g("password"),null],"Passwords do not match")}),D=({email:s,onPasswordReset:l})=>{const{props:{organizationId:i}}=r(),[f,h]=c({showPassword:!1,showConfirmPassword:!1}),[g,v]=c(!1),[q,w]=c(null),{control:x,handleSubmit:y,formState:{errors:b}}=u({defaultValues:P,mode:"onSubmit",resolver:m(N)});return e.jsxs("div",{className:"qc:w-full qc:space-y-4",children:[e.jsx(o,{variant:"h5",align:"center",children:"Set new password"}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:w-full qc:space-y-8",onSubmit:y(async e=>{w(null),v(!0);try{const r=await a.post(t.RESET_PASSWORD,{json:{email:s.toLowerCase(),password:e.password},headers:{"x-org-id":i}});r.error?w(r.error):l()}catch{w("An error occurred while resetting the password. Please try again.")}v(!1)}),children:[e.jsxs("div",{className:"qc:relative",children:[e.jsx(p,{name:"password",control:x,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"New password",disabled:g,type:f.showPassword?"text":"password",value:r,onChange:o,onBlur:n,error:b.password?.message})}),e.jsx(n,{variant:"ghost",color:"primary",className:"qc:absolute qc:-right-4 qc:top-7",icon:f.showPassword?"mdi:eye-outline":"mdi:eye-off-outline",onClick:()=>h({...f,showPassword:!f.showPassword})})]}),e.jsxs("div",{className:"qc:relative",children:[e.jsx(p,{name:"confirmPassword",control:x,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"Confirm new password",disabled:g,type:f.showConfirmPassword?"text":"password",value:r,onChange:o,onBlur:n,error:b.confirmPassword?.message})}),e.jsx(n,{variant:"ghost",color:"primary",className:"qc:absolute qc:-right-4 qc:top-7",icon:f.showConfirmPassword?"mdi:eye-outline":"mdi:eye-off-outline",onClick:()=>h({...f,showConfirmPassword:!f.showConfirmPassword})})]}),e.jsx(n,{fullWidth:!0,type:"submit",color:"primary",loading:g,children:"Reset password"})]}),q&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:q})]})},E=()=>{const r=s(),[o,n]=c(null),[a,t]=c(0);return e.jsxs("div",{className:"space-y-9",children:[(({index:a})=>{switch(a){case 0:return e.jsx(x,{onCodeSent:e=>{n(e),t(1)}});case 1:return e.jsx(C,{email:o,onCodeVerified:()=>t(2)});case 2:return e.jsx(D,{email:o,onPasswordReset:()=>{r(l.LOGIN)}})}})({index:a}),e.jsx("div",{className:"qc:mt-8 qc:flex qc:justify-center",children:e.jsx(v,{count:3,currentStep:a})})]})};export{E as default};