1import{r as w,j as e}from"./react-CIxK7Ytf.js";import{G as ne,R as ie}from"./GenericDialogClose-BhgD4Hbv.js";import{f as A,c as de,W as le,s as ce,L as me,I as k,B as b,X as ue,Y as se,D as xe,Z as he,H as be,_ as pe,$ as ge,a0 as fe,a1 as we,G as Ne}from"./index-Bn-TEejP.js";import{P as ye}from"./PhoneInputNew-b6FnXgNL.js";import{c as Z,a as P,f as U,b as je}from"./yup-CaBDzsyo.js";import{a as $}from"./axios-upsvKRUO.js";import{c as ae,u as G,b as S}from"./@tanstack-Cwtxfz9U.js";import{F as V,a as W,b as _,E as ve}from"./formik-nsBbo8Pf.js";import{a as re,u as z}from"./react-redux-Ba2zKi24.js";import{u as m}from"./sonner-DP2LCZdN.js";import{M as K}from"./Modal-Cd9X-Yuw.js";import{I as M}from"./InputField-C4t4hNYn.js";import{R as ke,r as Fe}from"./resetPassword-Cn-8X5m3.js";import{f as oe}from"./forgotPasswordEmail-1ST2D5k2.js";import{S as Pe}from"./verifyForgotPasswordOtp-D_RIQ-Dg.js";import{O as Ce}from"./react-otp-input-CaJvthin.js";import{R as Se}from"./react-dom-hYMYhjpN.js";import{g as Ee}from"./getSubscription-CGf9vZQb.js";import{a as L}from"./js-cookie-Cz0CWeBA.js";import{L as Ae}from"./react-router-dom-DNuzzO-f.js";import{H as Te}from"./Header-DZbOleOH.js";import"./classnames-BvecX-wu.js";import"./react-router-h1mnqiX1.js";import"./@remix-run-Dpdp2-eB.js";import"./@reduxjs-CoJy1jWf.js";import"./redux-DITMfSWq.js";import"./immer-DqxjFn0G.js";import"./redux-thunk-ClJT1hhx.js";import"./date-fns-DlrUdYzn.js";import"./redux-persist-BwI-ocgj.js";import"./redux-persist-transform-encrypt-BxgxdjQf.js";import"./crypto-js-C4s5gQtU.js";import"./json-stringify-safe-Ceg3X2jo.js";import"./jwt-decode-VWaDGczM.js";import"./clsx-B-dksMZM.js";import"./framer-motion-tyukSy1E.js";import"./motion-utils-C_SlKRoS.js";import"./motion-dom-DWDx2Ux7.js";import"./scheduler-CzFDRTuY.js";import"./use-sync-external-store-CfBJO5CP.js";import"./@radix-ui-v9NUSzRv.js";import"./react-remove-scroll-BM-vmX49.js";import"./tslib-CDuPK5Eb.js";import"./react-remove-scroll-bar-BdrzH1OL.js";import"./react-style-singleton-CZ64I1TX.js";import"./get-nonce-C-Z93AgS.js";import"./use-sidecar-4r3Coh42.js";import"./use-callback-ref-CqZoCnLq.js";import"./aria-hidden-DQ5UC2Eg.js";import"./@floating-ui-DIMQRn-Y.js";import"./class-variance-authority-Dp3B9jqt.js";import"./tailwind-merge-D696Ktp4.js";import"./cmdk-vrXxQQJw.js";import"./@babel-D91nw8a6.js";import"./lucide-react-DRHOuL6p.js";import"./react-phone-number-input-BuKpS87u.js";import"./libphonenumber-js-UqH4YWCW.js";import"./prop-types-MGImeh4_.js";import"./input-format-Cw9uCqbS.js";import"./country-flag-icons-D4lwPBzr.js";import"./property-expr-DEi1ZLzV.js";import"./tiny-case-BJ7jYKNY.js";import"./toposort-BfAdQVTN.js";import"./deepmerge-DhIoniG1.js";import"./lodash-es-dVqQl90_.js";import"./react-fast-compare-CZbOeUrI.js";import"./hoist-non-react-statics-B8GYo8kq.js";import"./react-is-8JwjhRSi.js";const Be=Z({firstName:P().required("First name is required").trim().min(1,"First name must be at least 1 characters long").max(255,"First name must not exceed 255 characters").matches(/^[a-zA-Z]+$/,"First name can only contain letters").matches(/^(?!.*([.'-])\1).*$/,"First name cannot contain consecutive special characters").matches(/^\S+$/,"First name must be a single name"),lastName:P().required("Last name is required").trim().min(1,"Last name must be at least 1 characters long").max(255,"Last name must not exceed 255 characters").matches(/^[a-zA-Z]+$/,"Last name can only contain letters").matches(/^(?!.*([.'-])\1).*$/,"Last name cannot contain consecutive special characters").matches(/^\S+$/,"Last name must be a single name"),jobTitle:P().trim().required("Designation is required").min(2,"Designation must be at least 2 characters").max(255,"Designation must not exceed 255 characters").matches(/^[a-zA-Z\s]+$/,"Designation can only contain letters").matches(/^(?!.*\s{2,}).*$/,"Designation cannot contain consecutive spaces"),email:P().email("Invalid Email Id").trim().matches(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,"Invalid Email format"),phoneNumber:U().required("Phone number is required"),countryCode:U().notRequired()}
1),Me=Z({firstName:P().required("First name is required").trim().min(1,"First name must be at least 1 characters long").max(255,"First name must not exceed 255 characters").matches(/^[a-zA-Z]+$/,"First name can only contain letters").matches(/^(?!.*([.'-])\1).*$/,"First name cannot contain consecutive special characters").matches(/^\S+$/,"First name must be a single name"),lastName:P().required("Last name is required").trim().min(1,"Last name must be at least 1 characters long").max(255,"Last name must not exceed 255 characters").matches(/^[a-zA-Z]+$/,"Last name can only contain letters").matches(/^(?!.*([.'-])\1).*$/,"Last name cannot contain consecutive special characters").matches(/^\S+$/,"Last name must be a single name"),jobTitle:P().trim().min(2,"Designation must be at least 2 characters").max(255,"Designation must not exceed 255 characters").matches(/^[a-zA-Z\s]+$/,"Designation can only contain letters").matches(/^(?!.*\s{2,}).*$/,"Designation cannot contain consecutive spaces"),email:P().email("Invalid Email Id").trim().matches(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,"Invalid Email format"),phoneNumber:U().notRequired(),countryCode:U().notRequired()}),ze="https://api.we-link.ai";async function Ie(n){const{token:a}=A();try{return(await $.put(`${ze}/dashboard/user/update_personal_details`,Object.fromEntries(Object.entries(n).filter(([h,l])=>l!=="")),{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}const Le=()=>{var f;const[n,a]=w.useState(!1),[s,h]=w.useState(!1),l=re(),p=ae(),{decodedToken:g}=A(),{data:t,isLoading:i}=G({queryKey:["myProfile"],queryFn:de,retry:1});w.useEffect(()=>{t!=null&&t.email&&(l(le(t.email)),l(ce(t)))},[t,l]);const{mutate:N,isPending:v}=S({mutationFn:r=>Ie(r),onSuccess:()=>{a(!0),p.invalidateQueries({queryKey:["myProfile"]}),m.success("Profile updated successfully !")},onError:()=>{m.error("Failed to update profile")}});if(i)return e.jsx("div",{className:"relative flex h-screen w-full",children:e.jsx(me,{})});const E=r=>Object.fromEntries(Object.entries(r).map(([d,o])=>[d,typeof o=="string"?o.trim():o]));return e.jsx("section",{className:"mt-4 w-full rounded-xl border border-gray-300 bg-white dark:bg-accent-dark",children:e.jsxs("div",{className:"p-5",children:[e.jsx("h2",{className:"text-lg font-bold dark:text-white",children:"Basic Details"}),e.jsx("p",{className:"pt-1 font-switzer text-sm text-[#616E78]",children:"Edit your profile details to keep it up to date."}),e.jsx(V,{initialValues:{firstName:((f=t==null?void 0:t.firstName)==null?void 0:f.trim())||"",lastName:(t==null?void 0:t.lastName)||"",jobTitle:(t==null?void 0:t.job_title)||"",email:(t==null?void 0:t.email)||"",phoneNumber:t!=null&&t.phone_number?Number(t.phone_number):void 0,countryCode:t!=null&&t.country_code?Number(t.country_code):void 0},validationSchema:()=>{if(t){const r="phone_number"in t&&"country_code"in t,d="job_title"in t;return!r||!d?Me:Be}},onSubmit:(r,{setFieldValue:d})=>{if(g&&g.userId){const o=E(r);Object.entries(o).forEach(([x,y])=>{typeof y=="string"&&d(x,y,!1)});const F=o.phoneNumber!==void 0&&o.phoneNumber!==null&&Number(o.phoneNumber)!==Number(t==null?void 0:t.phone_number),u=o.countryCode!==void 0&&o.countryCode!==null&&Number(o.countryCode)!==Number(t==null?void 0:t.country_code),C={userId:g.userId,...o.firstName!==(t==null?void 0:t.firstName)&&o.firstName!==""&&{firstName:o.firstName},...o.lastName!==(t==null?void 0:t.lastName)&&o.lastName!==""&&{lastName:o.lastName},...o.jobTitle!==(t==null?void 0:t.job_title)&&o.jobTitle!==""&&{jobTitle:o.jobTitle},...o.email!==(t==null?void 0:t.email)&&o.email!==""&&{email:o.email},...F||u?{phoneNumber:Number(o.phoneNumber),countryCode:Number(o.countryCode)}:{},...F||u?{phoneNumber:Number(o.phoneNumber),countryCode:Number(o.countryCode)}:{}};N(C)}else m.error("Failed to update profile")},children:({errors:r,touched:d,handleSubmit:o,setFieldValue:F,values:u,isValid:C,dirty:x})=>(w.useEffect(()=>{x&&a(!1)},[u,x]),e.jsxs(W,{className:"mt-5 space-y-6",children:[e.jsxs("div",{className:"w-full",children:[e.jsx("label",{htmlFor:"firstName",className:"block font-switzer-medium text-xs text-[#0A0D0E] dark:text-white",children:"First Name"}),e.jsx(_,{id:"firstName",name:"firstName",type:"text",maxLength:256,className:"mt-1 block w-full rounded-md border-2 px-3 py-[0.8rem] text-primary-dark focus-within:border-[#9199A0] md:w-3/5 lg:w-2/5"}),r.firstName&&e.jsxs("div",{className:"flex items-center gap-1 pt-1",children:[e.jsx(k,{src:"error",className:"h-4 w-4 text-red-500"}),e.jsx("div",{className:"text-sm text-red-500",children:r.firstName})]})]}),e.jsxs("div",{className:"w-full",children:[e.jsx("label",{htmlFor:"lastName",className:"block font-switzer-medium text-xs text-[#0A0D0E] dark:text-white",children:"Last Name"}),e.jsx(_,{id:"lastName",name:"lastName",type:"text",maxLength:256,className:"mt-1 block w-full rounded-md border-2 px-3 py-[0.8rem] text-primary-dark focus-within:border-[#9199A0] md:w-3/5 lg:w-2/5"}),r.lastName&&e.jsxs("div",{className:"flex items-center gap-1 pt-1",children:[e.jsx(k,{src:"error",className:"h-4 w-4 text-red-500"}),e.jsx("div",{className:"text-sm text-red-500",children:r.lastName})]})]}),e.jsxs("div",{className:"w-full",children:[e.jsx("label",{htmlFor:"jobTitle",className:"block font-switzer-medium text-xs text-[#0A0D0E] dark:text-white",children:"Designation"}),e.jsx(_,{id:"jobTitle",name:"jobTitle",type:"text",maxLength:256,className:"mt-1 block w-full rounded-md border-2 px-3 py-[0.8rem] text-primary-dark focus-within:border-[#9199A0] md:w-3/5 lg:w-2/5"}),r.jobTitle&&e.jsxs("div",{className:"flex items-center gap-1 pt-1",children:[e.jsx(k,{src:"error",className:"h-4 w-4 text-red-500"}),e.jsx("div",{className:"text-sm text-red-500",children:r.jobTitle})]})]}),e.jsxs("div",{className:"w-full",children:[e.jsx("label",{htmlFor:"email",className:"block font-switzer-medium text-xs text-[#0A0D0E] dark:text-white",children:"Email"}),e.jsx(_,{id:"email",name:"email",type:"email",readOnly:!0,className:"mt-1 block w-full cursor-default rounded-md border-2 px-3 py-[0.8rem] text-[#626e79] dark:text-[#414b54] md:w-3/5 lg:w-2/5"}),r.email&&d.email&&e.jsxs("div",{className:"flex items-center gap-1 pt-1",children:[e.jsx(k,{src:"error",className:"h-4 w-4 text-red-500"}),e.jsx("div",{className:"text-sm text-red-500",children:r.email})]})]}),e.jsxs("section",{children:[e.jsx("div",{className:"mb-1 block font-switzer-medium text-xs dar
1k:text-secondary-dark",children:"Phone Number"}),e.jsx("div",{className:"w-full md:w-3/5 lg:w-2/5",children:e.jsx(ye,{setFieldValue:F,phone_number:u.phoneNumber,country_code:u.countryCode,onValidityChange:y=>h(y),containerClassName:"w-full rounded-md border-2 focus-within:border-[#9199a0] dark:border-[#e5e7eb] dark:bg-secondary-bgSecondaryDark dark:focus-within:border-[#9199a0]"})}),e.jsx(ve,{name:"phoneNumber",component:"div",className:"text-sm text-red-500"})]}),e.jsx("div",{className:"flex",children:e.jsx(b,{buttonText:"Save",className:"h-[3rem] w-[5rem] bg-[#146EF5] font-switzer-medium text-sm text-white hover:bg-blue-700",onClick:()=>o(),disabled:v||!x||!C||u.phoneNumber!==void 0&&u.phoneNumber!==null&&!s||n,loading:v})})]}))})]})})},De="https://api.we-link.ai";async function $e(n){const{token:a}=A();try{return(await $.delete(`${De}/dashboard/user/remove_profile_image`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},data:{userId:n}})).data.message}catch(s){throw s}}const Oe="https://api.we-link.ai";async function qe(n){const{token:a}=A();try{return(await $.post(`${Oe}/dashboard/user/upload_profile_image`,n,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}function Re(n,a,s={maxWidth:600,maxHeight:600,quality:.4,maxFileSizeMB:2}){const h=(s.maxFileSizeMB??2)*1024*1024;if(n.size>h)return;const l=new FileReader;l.readAsDataURL(n),l.onload=()=>{const p=new Image;p.src=l.result,p.onload=()=>{const g=document.createElement("canvas");let t=p.width,i=p.height;t>i?t>s.maxWidth&&(i=Math.round(i*s.maxWidth/t),t=s.maxWidth):i>s.maxHeight&&(t=Math.round(t*s.maxHeight/i),i=s.maxHeight),g.width=t,g.height=i;const N=g.getContext("2d");if(!N)return;N.drawImage(p,0,0,t,i);const v=g.toDataURL("image/jpeg",s.quality);a(v,n.type,n.size)},p.onerror=()=>{m.error("Error uploading image")}}}const _e=()=>{var r;const n=ae(),{decodedToken:a}=A(),{darkMode:s}=z(d=>d==null?void 0:d.darkMode),{data:h}=G({queryKey:["myProfileImage"],queryFn:()=>ue(),retry:1}),l=z(d=>d.user.profile),[p,g]=w.useState(null),{mutate:t}=S({mutationFn:d=>qe(d),onSuccess:()=>{n.invalidateQueries({queryKey:["myProfileImage"]}),m.success("Profile image uploaded successfully!")},onError:()=>{m.error("Failed to upload profile image. Please try again.")}}),{mutate:i,isPending:N}=S({mutationFn:d=>$e(d),onMutate:()=>{},onSuccess:d=>{n.invalidateQueries({queryKey:["myProfileImage"]}),g(null),m.success(d)},onError:()=>{m.error("Failed to remove profile image. Please try again.")}}),v=async d=>{var x;const o=(x=d.target.files)==null?void 0:x[0];if(!o)return;const F=2,u=F*1024*1024;if(o.size>u){m.error(`Image size must be less than ${F}MB`);return}if(!["image/jpeg","image/png","image/webp"].includes(o.type)){m.error("Only JPG, PNG, or WebP images are allowed.");return}if(!o.type.startsWith("image/")){m.error("Selected file is not a valid image.");return}Re(o,(y,O,Y)=>{g(y),t({base64:y,type:O,size:Y,userId:(a==null?void 0:a.userId)||""})},{maxWidth:600,maxHeight:600,quality:.4})},E=()=>{N||(a!=null&&a.userId?i(a.userId):m.error("User ID is missing."))},f=p||(h==null?void 0:h.base64)||null;return e.jsxs("main",{className:"mt-2 md:mt-0",children:[e.jsxs("section",{className:"flex items-center space-x-1 py-2 md:space-x-4",children:[e.jsx("div",{children:f?e.jsx(k,{src:f,className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-blue-100 text-black md:h-14 md:w-14",children:e.jsx("span",{className:"text-lg font-bold",children:se((r=l==null?void 0:l.firstName)==null?void 0:r.trim())?se(l==null?void 0:l.firstName.trim()):""})})}),e.jsxs("div",{className:"flex items-center gap-2 md:flex-col md:items-start",children:[e.jsxs("label",{className:"flex cursor-pointer items-center rounded-md border border-gray-300 px-2 py-2 duration-500 ease-in-out hover:border-gray-700 md:px-4 md:py-[0.625rem]",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:d=>{v(d),d.target.value=""}}),e.jsx(k,{src:"uploadProfileImage",className:"dark:invert"}
1),e.jsx("div",{className:"px-2 font-switzer-medium text-xs dark:text-white md:text-sm",children:"Upload new picture"})]}),e.jsx("div",{children:f&&e.jsx(xe,{activateModal:d=>e.jsx(b,{buttonText:"Remove picture",buttonTextClassName:"text-[#b7280c] md:text-sm text-xs",onClick:()=>{d()},disabled:N,buttonLogoName:"delete",className:"items-center gap-1 px-0 py-2 text-[#BF2B17] hover:underline hover:underline-offset-2 md:px-4"}),renderChildren:d=>e.jsxs("div",{className:"rounded-lg",children:[e.jsxs("div",{className:"border-Neutral-300 flex items-center justify-between border-b dark:border-[#252b36]",children:[e.jsxs("h3",{className:"flex gap-3 px-2 py-4 text-lg font-semibold dark:text-secondary-dark md:px-4 md:py-5",children:[s?e.jsx(k,{src:"delete"}):e.jsx(k,{src:"deleteBlack"}),"Delete Your Profile Picture ?"]}),e.jsx(b,{className:"mr-2 h-fit w-fit hover:bg-gray-100 dark:hover:bg-[#1B202A]",onClick:()=>{d()},logoClassName:"dark:invert",buttonText:"",buttonLogoName:"closeButton"})]}),e.jsxs("p",{className:"px-3 py-5 text-sm font-semibold dark:text-secondary-dark md:px-6",children:["Are you sure you want to delete ?"," "]}),e.jsxs("div",{className:"flex justify-end space-x-2 rounded-b-lg bg-[#F7F9FB] px-5 py-3 dark:bg-[#1B202A]",children:[e.jsx(b,{buttonText:"Cancel",onClick:()=>{d()},className:"border-Neutral-600 h-[3rem] w-[5rem] rounded-md border hover:bg-[#E5EDF8] dark:border-[#252b36] dark:hover:bg-[#232d3f]"}),e.jsx(b,{buttonText:"Delete",onClick:E,disabled:N,loading:N,className:"h-[3rem] w-[5rem] bg-[#146EF5] text-white hover:bg-[#0c58d1]"})]})]})})})]})]}),e.jsx("div",{className:"w-full",children:e.jsx(Le,{})})]})},Ue=({onClose:n,onOtpSubmit:a})=>{const s=z(x=>x.email.email||""),[h,l]=w.useState(""),[p,g]=w.useState(!0),[t,i]=w.useState(!1),[N,v]=w.useState(30),[E,f]=w.useState(!1),{mutate:r,isPending:d}=S({mutationFn:x=>Pe(x),onSuccess:()=>{m.success("OTP verified successfully!"),g(!1),i(!0)},onError:()=>{m.error("Incorrect OTP! Please check and try again."),l(""),f(!1)}}),{mutate:o}=S({mutationFn:x=>ke(x),onSuccess:()=>{m.success("Password Reset Successfully!"),n()},onError:()=>{m.error("Failed to Reset Password")}}),F=()=>{if(h.length!==6){m.error("Please fill in all 6 digits of the OTP.");return}if(!s){m.error("Email is required to verify OTP");return}a(h),r({email:s,otp:h})},u=S({mutationFn:x=>oe(x),onSuccess:()=>{m.success("Email resent successfully !"),setTimeout(()=>{f(!1)},4e4)},onError:()=>{m.error("Failed to resend email")}}),C=()=>{if(!s){m.error("Email is not available in the state!");return}l(""),v(30),f(!0),u.mutate({email:s})};return w.useEffect(()=>{if(N>0){const x=setInterval(()=>{v(y=>y-1)},1e3);return()=>clearInterval(x)}else f(!1)},[N]),e.jsxs("main",{children:[p&&e.jsx(K,{onClose:n,title:"Verify it's you",iconName:"userSettings",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("section",{className:"p-5",children:[e.jsxs("p",{className:"mb-4 font-switzer-semibold text-sm dark:text-white",children:["We sent a six-digit code to ",s,". Enter the code below"]}),e.jsx(Ce,{value:h,onChange:x=>l(x.toUpperCase()),numInputs:6,inputStyle:"inputStyle focus:border-gray-500 dark:focus:border-gray-300 focus:outline-none focus:ring-1 focus:ring-gray-300 dark:focus:ring-white transition",shouldAutoFocus:!0,renderInput:x=>e.jsx("input",{...x}),containerStyle:"flex gap-1 md:gap-4 my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("p",{className:"font-switzer text-sm text-[#828D96]",children:["Haven",e.jsx("sup",{children:"'"}),"t received the OTP?"]}),E?e.jsx("p",{className:"text-sm text-[#828D96]",children:`Resend in ${N}s`}):e.jsx(b,{className:"text-blue-600",buttonLogoName:"",buttonText:"Resend",buttonTextClassName:"text-sm",onClick:C})]})]}),e.jsx("div",{className:"flex justify-end rounded-b-xl bg-[#F7F9FB] p-3 dark:bg-[#1B202A]",children:e.jsx(b,{buttonText:"Submit",onClick:F,disabled:d||h.length!==6,loading:d,className:"h-[3rem] w-[5rem] cursor-pointer rounded-md bg-blue-600 font-semibold text-white duration-200 ease-in-out hover:bg-blue-600"})})]})}),t&&e.jsx(K,{onClose:()=>{i(!1),n()},title:"New password",iconName:"userSettings",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("section",{className:"px-4 py-3",children:e.jsx("p",{className:"mb-2 font-switzer-semibold text-sm dark:text-white",children:"Please enter your new password"})}),e.jsx(V,{initialValues:{newPassword:"",confirmPassword:""},validationSchema:Fe,onSubmit:x=>{if(x.newPassword!==x.confirmPassword){alert("Passwords do not match");return}o({...x,email:s,otp:h}),i(!1)},children:({isValid:x,dirty:y})=>e.jsxs(W,{children:[e.jsxs("div",{className:"mx-4",children:[e.jsx(M,{label:"New Password",name:"newPassword",type:"password",minLength:8,maxLength:32,togglePasswordIcon:!0}),e.jsx(M,{label:"Confirm Password",name:"confirmPassword",type:"password",minLength:8,maxLength:32,togglePasswordIcon:!0})]}),e.jsx("div",{className:"flex justify-end rounded-b-xl bg-[#F7F9FB] p-3 dark:bg-[#1B202A]",children:e.jsx(b,{disabled:!y||!x,buttonText:"Submit",className:"bg-[#146EF5] px-4 py-[0.625rem] font-switzer-medium text-sm text-white",type:"submit"})})]})})]})})]})}
1,D=({name:n,activeModalName:a,setActiveModalName:s,activateModal:h,renderChildren:l})=>{const{darkMode:p}=z(i=>i.darkMode),g=a===n,t=i=>{i!=null&&i.name&&i.name!==n?s(i.name):s(g?null:n),i!=null&&i.callback&&i.callback()};return w.useEffect(()=>{const i=document.documentElement;return p?i.classList.add("dark"):i.classList.remove("dark"),()=>i.classList.remove("dark")},[p]),e.jsxs(e.Fragment,{children:[h(t),g&&Se.createPortal(e.jsx("section",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 text-black dark:bg-black/50 dark:text-white",children:e.jsx("div",{className:"m-4 rounded-lg bg-white p-1 shadow-lg dark:bg-[#12161D] dark:p-0 md:m-8",children:l(t)})}),document.body)]})},Ze="https://api.we-link.ai";async function Ve(n){const{token:a}=A();try{return(await $.post(`${Ze}/auth/change_password`,Object.fromEntries(Object.entries(n).filter(([h,l])=>l!=="")),{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}const We=Z({currentPassword:P().required("Current password is required"),newPassword:P().min(8,"Password must be at least 8 characters").max(32,"Password must not exceed 32 characters").matches(/^\S*$/,"Password cannot contain spaces").required("New password is required"),confirmPassword:P().oneOf([je("newPassword"),""],"Passwords must match").matches(/^\S*$/,"Password cannot contain spaces").required("Confirm password is required")}),Ye=({onClose:n})=>{const{decodedToken:a}=A(),[s,h]=w.useState(!1),[l,p]=w.useState(!1),[g,t]=w.useState(null),i=z(u=>u.email.email),N=()=>{h(!0)},v=()=>{h(!1),p(!0)},{mutate:E,isPending:f}=S({mutationFn:u=>Ve(u),onSuccess:()=>{p(!0),t("SuccessModal"),m.success("Password changed successfully!")},onError:u=>{u.response.data.message.includes("Current password is incorrect")?m.error("Current password is incorrect"):u.response.data.message.includes("You cannot reuse any of your last 5 passwords.")?m.error("You cannot reuse any of your last 5 passwords."):m.error("Failed to change Password")}}),r=S({mutationFn:oe,onSuccess:()=>{p(!0),N(),m.success("Otp sent successfully!")},onError:u=>{u.message.includes("Too many OTP attempts. Please try again later.")?m.error("Too many OTP attempts. Please try again later "):m.error("Failed to send OTP")}}),d={currentPassword:"",newPassword:"",confirmPassword:""},o=()=>{if(!i){m.error("Email is not available in the state !");return}r.mutate({email:i})},F=()=>{};return e.jsxs(e.Fragment,{children:[!s&&e.jsxs(K,{onClose:()=>{n(),p(!1)},title:s?"Verify It's You":"Change Password",iconName:"userSettings",...l&&{classname:"hidden"},children:[e.jsx("p",{className:"mt-5 px-5 font-switzer-semibold text-sm text-[#0A0D0E] dark:text-white",children:"Please enter your current password to change it"}),e.jsx(V,{initialValues:d,validationSchema:We,onSubmit:u=>{if(a&&a.userId){const{confirmPassword:C,...x}=u;E({...x,userId:a.userId})}},children:({isValid:u,dirty:C})=>e.jsxs(W,{className:"mt-3 space-y-1",children:[e.jsxs("div",{className:"px-5",children:[e.jsx(M,{label:"Current Password",name:"currentPassword",type:"password",togglePasswordIcon:!0,placeholder:"",minLength:8,maxLength:32,className:"mb-0 px-4 font-switzer-medium text-xs"}),e.jsx(M,{label:"New Password",name:"newPassword",type:"password",minLength:8,maxLength:32,togglePasswordIcon:!0,placeholder:"",className:"mb-0 px-4 font-switzer-medium text-xs"}),e.jsx(M,{label:"Re-enter new password",name:"confirmPassword",type:"password",minLength:8,maxLength:32,togglePasswordIcon:!0,placeholder:"",className:"mb-0 px-4 font-switzer-medium text-xs"}),e.jsx(b,{buttonText:"Forgot Password?",className:"my-3 cursor-pointer bg-transparent font-switzer text-sm text-[#146EF5]",buttonTextClassName:"hover:underline",onClick:o,type:"button"})]}),e.jsx("div",{className:"mt-6 flex justify-end rounded-b-xl bg-[#F7F9FB] p-4 dark:bg-[#1B202A]",children:e.jsx(b,{buttonText:"Submit",className:"h-[3rem] w-[5rem] bg-[#146EF5] font-switzer-medium text-sm text-white",type:"submit",loading:f,disabled:!u||!C||f})})]})})]}),s&&e.jsx(Ue,{onClose:()=>{v()},onOtpSubmit:F}),e.jsx(D,{name:"SuccessModal",activeModalName:g,setActiveModalName:t,activateModal:()=>e.jsx(e.Fragment,{}),renderChildren:u=>
1e.jsxs("div",{className:"w-fit rounded-lg border border-[#EDF1F4] dark:border-[#272E3B] md:w-[37.875rem]",children:[e.jsxs("div",{className:"border-Neutral-300 flex items-center justify-between border-b dark:border-[#252b36]",children:[e.jsxs("h4",{className:"flex gap-2 px-4 py-5 font-semibold",children:[e.jsx(k,{src:"tickCircle",className:"dark:invert"}),"Password change successful!"]}),e.jsx(b,{overRideStyle:!0,className:"mr-2 h-fit w-fit rounded-full hover:bg-gray-100 dark:hover:bg-[#1B202A]",buttonText:"",logoClassName:"size-7 dark:invert",buttonLogoName:"closeButton",onClick:()=>{t(null),u()}})]}),e.jsxs("div",{className:"flex flex-col gap-1 p-6",children:[e.jsx("p",{className:"text-md font-semibold dark:text-white",children:"Your password has been changed successfully!"}),e.jsx("p",{className:"text-sm text-[#444F58] dark:text-[#616e75]",children:"Use your new password to log in"})]}),e.jsx("div",{className:"flex justify-end space-x-2 rounded-b-lg bg-[#F7F9FB] px-5 py-3 dark:bg-[#1B202A]",children:e.jsx(b,{buttonText:"Ok",className:"rounded-lg bg-blue-600 px-6 py-2 text-white hover:bg-blue-700",onClick:()=>{n(),u()}})})]})})]})},He=Z({email:P().required("Email is required").email("Invalid Email Id").trim().matches(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,"Invalid Email format"),password:P().min(8,"Password must be at least 8 characters").max(32,"Password must be not more than 32 characters").required("Password is required")}),Ke="https://api.we-link.ai";async function Ge({id:n,email:a,password:s}){const{token:h}=A();try{return(await $.delete(`${Ke}/management/delete_customer`,{data:{id:n,email:a,password:s},headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`}})).data}catch(l){throw l.response.data.errors.join(",")}}const Qe="https://api.we-link.ai";async function Je({id:n,email:a,password:s}){const{token:h}=A();try{return(await $.post(`${Qe}/management/validate_delete`,{id:n,email:a,password:s},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`}})).data}catch(l){throw l}}const Xe=()=>{var J,X,ee,te;const n=re(),a=z(c=>c.user.profile),{permissions:s}=z(c=>c.permissions),h=a==null?void 0:a._id,l=((X=(J=s==null?void 0:s.billing)==null?void 0:J.plans)==null?void 0:X.read)||((te=(ee=s==null?void 0:s.billing)==null?void 0:ee.plans)==null?void 0:te.write),p="masteradmin",g=window.location.hostname.split(".")[0],[t,i]=w.useState({email:"",password:""}),[N,v]=w.useState(!1),E=()=>{v(!0)},[f,r]=w.useState(null),d=()=>{v(!1)},[o,F]=w.useState(5),{data:u}=G({queryKey:["subscription"],enabled:l&&g&&g!==p&&(a==null?void 0:a.role)!=="Observer",queryFn:Ee,retry:1}),{mutate:C}=S({mutationFn:Je,onSuccess:c=>{var q,I;const j=(q=c.errors)==null?void 0:q.some(T=>T.heading==="Admin role alert"),B=(I=c.errors)==null?void 0:I.some(T=>T.heading==="Active subscription found");(u==null?void 0:u.subscription)!==null&&B?r("subscription"):r(j?"deletionWarning":"confirmationModal")},onError:c=>{m.error(c.response.data.message??"Validation Error")}}),{mutate:x}=S({mutationFn:Ge,onSuccess:()=>{m.success("User Deleted"),r("finalStep");const c=setInterval(()=>{F(j=>(j===1&&(clearInterval(c),Q()),j-1))},1e3)},onError:c=>{m.error(c)}}),y=a,O=y==null?void 0:y.pwdUpdatedAt,Y=c=>{if(!c)return"";const j=new Date(c),q=new Date().getTime()-j.getTime(),I=Math.floor(q/1e3),T=Math.floor(I/60),R=Math.floor(T/60),H=Math.floor(R/24);return H>0?`${H} day${H>1?"s":""} ago`:R>0?`${R} hour${R>
11?"s":""} ago`:T>0?`${T} minute${T>1?"s":""} ago`:`${I} second${I!==1?"s":""} ago`},Q=async()=>{n(he()),n(be()),n({type:"RESET_APP_STATE"}),n({type:pe}),ge(),fe(),await we.purge(),localStorage.clear(),sessionStorage.clear();const c="we-link.ai",j="masteradmin",B=window.location.hostname.split(".")[0];L.remove(Ne(),{path:"/",domain:c}),L.remove("accessToken"),L.remove("weLinkAccessToken"),L.remove("weLinkSignupAccessToken"),B&&B===j?L.remove("weLinkAdminToken",{path:"/",domain:c}):L.remove("weLinkCustomerToken",{path:"/",domain:c}),window.location.href="/login"};return e.jsxs("main",{className:"pl-4 pr-4 md:pl-7 md:pr-[7rem] lg:pr-[23rem]",children:[e.jsx(_e,{}),e.jsx("section",{className:"mt-5 h-auto w-full rounded-xl border border-gray-300 bg-white p-5 dark:bg-accent-dark",children:e.jsxs("div",{className:"flex flex-col justify-between gap-3 md:flex-row md:items-center",children:[e.jsxs("div",{className:"flex flex-col md:w-1/2",children:[e.jsx("h2",{className:"text-base font-semibold text-[#0A0D0E] dark:text-white",children:"Password"}),e.jsx("div",{className:"text-[#616E78]",children:O?e.jsxs(e.Fragment,{children:["Your password was last changed"," ",Y(O),"."]}):e.jsx(e.Fragment,{})})]}),e.jsx("div",{children:e.jsx(b,{buttonText:"Change password",className:"rounded-md border border-[#9199A0] bg-transparent px-2 py-1 font-switzer-medium text-sm text-black duration-500 ease-in-out hover:bg-gray-200 dark:border-[#5e6a82] dark:text-[#dcdfe7] hover:dark:bg-gray-700 md:mt-0 md:px-4 md:py-[0.625rem]",onClick:E,buttonTextClassName:"text-sm "})})]})}),N&&e.jsx(Ye,{onClose:d}),e.jsxs("section",{className:"mt-5",children:[e.jsx(D,{name:"deleteAccount",activeModalName:f,setActiveModalName:r,activateModal:c=>e.jsx(b,{buttonText:"Delete Account",buttonTextClassName:"text-[#b7280c] text-md",onClick:()=>{r("deleteAccount"),c()},buttonLogoName:"delete",className:"gap-1 py-2 text-[#BF2B17] hover:underline hover:underline-offset-2"}),renderChildren:c=>e.jsxs("div",{className:"w-fit rounded-lg border border-[#EDF1F4] dark:border-[#272E3B] md:w-[37.875rem]",children:[e.jsxs("div",{className:"border-Neutral-300 flex items-center justify-between border-b dark:border-[#252b36]",children:[e.jsxs("h4",{className:"flex gap-2 px-2 py-3 text-sm font-semibold md:px-4 md:py-5 md:text-lg",children:[e.jsx(k,{src:"deleteBlack",className:"dark:invert"}),"Delete Your We-Link account ?"]}),e.jsx(b,{overRideStyle:!0,className:"mr-2 h-fit w-fit rounded-md hover:bg-gray-100 dark:hover:bg-[#1B202A]",buttonText:"",logoClassName:"size-7 dark:invert",buttonLogoName:"closeButton",onClick:()=>{r(null),c()}})]}),e.jsxs("div",{className:"px-3 py-2 md:px-6 md:py-5",children:[e.jsx("p",{className:"md:text-md pb-2 font-switzer-semibold text-sm",children:"Are you sure you want to delete your account ?"}),e.jsx("p",{className:"text-sm text-[#444F58] dark:text-secondary-dark",children:"Deleting your We-Link account will also delete all the data in your account. This process can't be undone."})]}),e.jsx(V,{initialValues:{email:"",password:""},validationSchema:He,onSubmit:j=>{if((a==null?void 0:a.email)!==j.email){m.error("Email is not Matching");return}C({...j,id:h}),i({email:j.email,password:j.password})},children:({isValid:j,dirty:B})=>e.jsxs(W,{noValidate:!0,children:[e.jsxs("div",{className:"px-3 py-2 md:px-6 md:py-5",children:[e.jsxs("div",{className:"mb-1 space-x-1 font-switzer-semibold text-sm dark:text-secondary-dark",children:[e.jsx("span",{className:"font-switzer-medium text-sm dark:text-secondary-dark",children:"Type your email ID"}),e.jsx("br",{className:"block md:hidden"}),e.jsxs("span",{className:"text-blue-600",children:["'",a==null?void 0:a.email,"'"]}),e.jsx("span",{className:"font-switzer-medium text-sm dark:text-secondary-dark",children:"to confirm the deletion"})]}),e.jsx(M,{name:"email",type:"email",autoComplete:"new-email",required:!0}),e.jsx(M,{label:"Enter your password",name:"password",type:"password",autoComplete:"new-password",togglePasswordIcon:!0,minLength:8,maxLength:32,required:!0})]}),e.jsx("div",{className:"flex justify-end rounded-b-lg bg-[#F7F9FB] px-5 py-3 dark:border-t dark:border-[#272E3B] dark:bg-[#1B202A]",children:e.jsx(b,{buttonText:"Delete",type:"submit",disabled:!j||!B,className:"h-[3rem] w-[5rem] bg-[#146EF5] text-white hover:bg-[#1164e0]"})})]})})]})}),e.jsx(D,{name:"subscription",activeModalName:f,setActiveModalName:r,activateModal:()=>e.jsx(e.Fragment,{}),renderChildren:c=>
1e.jsxs("div",{className:"w-fit rounded-lg border border-[#EDF1F4] dark:border-[#272E3B] md:w-[37.875rem]",children:[e.jsxs("div",{className:"border-Neutral-300 flex items-center justify-between border-b dark:border-[#252b36]",children:[e.jsxs("h4",{className:"flex gap-2 px-4 py-5 font-semibold",children:[e.jsx(k,{src:"warning",className:"dark:invert"}),"Subscription is active"]}),e.jsx(b,{overRideStyle:!0,className:"mr-2 h-fit w-fit rounded-full hover:bg-gray-100 dark:hover:bg-[#1B202A]",buttonText:"",logoClassName:"size-7 dark:invert",buttonLogoName:"closeButton",onClick:()=>{r(null),c()}})]}),e.jsxs("div",{className:"px-6 py-6",children:[e.jsx("p",{className:"pb-1.5 text-sm font-semibold",children:"Active subscription found"}),e.jsx("p",{className:"pb-2 text-sm text-[#444F58] dark:text-secondary-dark",children:"Your account has an active subscription. Deleting your account will cancel your subscription, and no refunds will be issued."})]}),e.jsx("div",{className:"flex justify-end space-x-3 bg-[#F7F9FB] px-5 py-3 dark:border-t dark:border-[#272E3B] dark:bg-[#1B202A]",children:e.jsx(Ae,{to:"/billing",className:"border-Neutral-600 rounded-md border px-3 py-2 hover:bg-gray-200 dark:border-[#252b36] dark:hover:bg-[#232d3f]",children:"Manage Subscription"})})]})}),e.jsx(D,{name:"deletionWarning",activeModalName:f,setActiveModalName:r,activateModal:()=>e.jsx(e.Fragment,{}),renderChildren:c=>e.jsxs("div",{className:"w-fit rounded-lg border border-[#EDF1F4] dark:border-[#272E3B] md:w-[37.875rem]",children:[e.jsxs("div",{className:"border-Neutral-300 flex items-center justify-between border-b dark:border-[#252b36]",children:[e.jsxs("h4",{className:"flex gap-2 px-4 py-5 font-semibold",children:[e.jsx(k,{src:"warning",className:"dark:invert"}),"Admin role alert"]}),e.jsx(b,{overRideStyle:!0,className:"mr-2 h-fit w-fit rounded-full hover:bg-gray-100 dark:hover:bg-[#1B202A]",buttonText:"",logoClassName:"size-7 dark:invert",buttonLogoName:"closeButton",onClick:()=>{r(null),c()}})]}),e.jsx("div",{className:"px-6 py-6",children:e.jsx("p",{className:"text-sm text-[#444F58] dark:text-secondary-dark",children:"You are the admin. Deleting your account will remove all data. Assign a new admin before deleting your account."})}),e.jsx("div",{className:"flex justify-end rounded-b-lg bg-[#F7F9FB] px-5 py-3 dark:border-t dark:border-[#272E3B] dark:bg-[#1B202A]",children:e.jsx(b,{buttonText:"Delete Account",onClick:()=>{c({name:"confirmationModal"})},className:"bg-[#146EF5] px-3 py-2 text-white hover:bg-[#1164e0]"})})]})}),e.jsx(D,{name:"confirmationModal",activeModalName:f,setActiveModalName:r,activateModal:()=>e.jsx(e.Fragment,{}),renderChildren:c=>e.jsxs("div",{className:"w-fit rounded-lg border border-[#EDF1F4] dark:border-[#272E3B] md:w-[37.875rem]",children:[e.jsxs("div",{className:"border-Neutral-300 flex items-center justify-between border-b dark:border-[#252b36]",children:[e.jsxs("h4",{className:"flex gap-2 px-4 py-5 font-semibold",children:[e.jsx(k,{src:"deleteBlack",className:"dark:invert"}),"Delete your account"]}),e.jsx(b,{overRideStyle:!0,className:"mr-2 h-fit w-fit rounded-full hover:bg-gray-100 dark:hover:bg-[#1B202A]",buttonText:"",logoClassName:"size-7 dark:invert",buttonLogoName:"closeButton",onClick:()=>{r(null),c()}})]}),e.jsx("div",{className:"px-6 py-6",children:e.jsx("p",{className:"text-sm text-[#444F58] dark:text-secondary-dark",children:"Are you sure you want to delete your account ?"})}),e.jsxs("div",{className:"flex justify-end space-x-2 rounded-b-lg bg-[#F7F9FB] px-5 py-3 dark:border-t dark:border-[#272E3B] dark:bg-[#1B202A]",children:[e.jsx(b,{buttonText:"Cancel",onClick:()=>{r(null),c()},className:"border-Neutral-600 rounded-md border px-3 py-2 hover:bg-[#E5EDF8] dark:border-[#252b36] dark:hover:bg-[#232d3f]"}),e.jsx(b,{buttonText:"Delete",onClick:()=>{x({id:h,email:t.email,password:t.password})},className:"h-[3rem] w-[5rem] bg-[#146EF5] text-white hover:bg-[#1164e0]"})]})]})}),e.jsx(D,{name:"finalStep",activeModalName:f,setActiveModalName:r,activateModal:()=>e.jsx(e.Fragment,{}),renderChildren:c=>
1e.jsxs("div",{className:"w-fit rounded-lg border border-[#EDF1F4] dark:border-[#272E3B] md:w-[37.875rem]",children:[e.jsxs("div",{className:"border-Neutral-300 flex items-center justify-between border-b dark:border-[#252b36]",children:[e.jsxs("h4",{className:"flex gap-2 px-4 py-5 text-lg font-semibold",children:[e.jsx(k,{src:"tickCircle",className:"size-7 dark:invert"})," ","Account deleted successfully"]}),e.jsx(b,{overRideStyle:!0,className:"mr-2 h-fit w-fit rounded-full hover:bg-gray-100 dark:hover:bg-[#1B202A]",buttonText:"",buttonLogoName:"closeButton",logoClassName:"size-7 dark:invert",onClick:()=>{r(null),c()}})]}),e.jsxs("p",{className:"px-6 py-6 text-sm text-[#444F58] dark:text-secondary-dark",children:["Your We-Link account has been deleted permanently. You will be redirected to the homepage in"," ",e.jsx("span",{className:"font-bold text-[#458FFF]",children:o})," ","seconds."]}),e.jsx("div",{className:"flex justify-end rounded-b-lg bg-[#F7F9FB] px-5 py-3 dark:border-t dark:border-[#272E3B] dark:bg-[#1B202A]",children:e.jsx(b,{buttonText:"Ok",onClick:()=>{r(null),c(),Q()},className:"bg-[#146EF5] px-3 py-2 text-white hover:bg-[#1164e0]"})})]})})]})]})},hs=()=>{const[n,a]=w.useState(null);return e.jsxs("main",{className:"w-screen bg-primary-settingsBg dark:bg-primary-dark",children:[e.jsxs("div",{className:"flex px-5 md:px-6 md:py-0",children:[e.jsx(Te,{title:"My account",icon:"settings",headerClassName:"py-4"}),e.jsx(ne,{name:"openSidebar",activeModalName:n,setActiveModalName:a,activateModal:s=>e.jsx(b,{buttonText:"",onClick:()=>{s()},buttonLogoName:"downArrow",logoClassName:"w-fit dark:invert",className:"block rounded px-2 font-switzer-medium text-xs md:hidden"}),renderChildren:()=>e.jsx("div",{className:"w-screen",children:e.jsx(ie,{})})})]}),e.jsx("hr",{className:"w-full text-[#DCE1E5] dark:border-[#232A38]"}),e.jsx("section",{className:"md:p-2",children:e.jsx(Xe,{})})]})};export{hs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.