<script>!function(){function e(){const e=tma__getProfileObjFromLS();if(!e)return void console.error("User profile not found");const r=tma__profile__getFormEditProfileHtml(e);tma__drawPopup({id:"edit-profile",main:document.getElementById("app")||document.body,content:tma__translate(r,"userbar_dict"),closeBtns:[".tlk-popup__close-cancel"]}),function(e){if("function"==typeof tma__profile__addUploadEvents){if(tma__profile__addUploadEvents(),e.memberlogo_uuid){"undefined"==typeof tildaMembers&&(window.tildaMembers={}),void 0===tildaMembers.upload&&(tildaMembers.upload={}),tildaMembers.upload.id=e.memberlogo_uuid,tildaMembers.upload.oldId=e.memberlogo_uuid;const o=document.querySelector(".tlk-upload__reset");o&&o.addEventListener("click",t)}}else console.warn("tma__profile__addUploadEvents is not defined. Image upload may not work.")}(e),function(e){const t=document.getElementById("form-change-profile");if(!t)return void console.error("Edit profile form not found");const r=t.querySelector(".tlk-popup__change-lang"),l=t.querySelector('button[type="submit"]');t.addEventListener("submit",(o=>{o.preventDefault(),function(e,t,o,r){tma__resetErrorFields(t),tma__resetErrorRequest(t);const l=tma__validationFormFields(t);if(l.length>0)return void tma__showErrorFields(t,l,"userbar_dict");const a=function(e,t,o){const r=tma__serializeArray(t);r.projectid=e.projectid,r.token=e.token,r.tzoffset=(new Date).getTimezoneOffset(),window.tildaMembers&&window.tildaMembers.upload&&window.tildaMembers.upload.id?r.memberlogo=window.tildaMembers.upload.id:r.memberlogo="";o&&o.value!==tildaMembers.userLang&&(r.lang=o.value);return r}(e,t,o),n=JSON.stringify(a);tma__request("/api/editprofile/",n,r,(o=>{!function(e,t,o,r){if("ok"===e.status&&"object"==typeof e.data){const l=e.data;r.lang&&!l.lang&&(l.lang=r.lang);const a=function(e,t,o){if(t.name!==e.name||t.login!==e.login||t.memberlogo!==e.memberlogo||t.memberlogo_uuid!==e.memberlogo_uuid||o.lang&&o.lang!==e.lang)return!0;return!1}(t,l,r);a&&(!function(e,t,o){Object.assign(e,{name:t.name||e.name,login:t.login||e.login,memberlogo:t.memberlogo||"",memberlogo_uuid:t.memberlogo_uuid||"",lang:t.lang||e.lang}),o&&!o.memberlogo&&(e.memberlogo="",e.memberlogo_uuid="");window.tildaMembers&&window.tildaMembers.upload&&(tildaMembers.upload.id=e.memberlogo_uuid||"",tildaMembers.upload.oldId=e.memberlogo_uuid||"")}(t,l),function(e){const t="tilda_members_profile"+e.projectid;localStorage.setItem(t,JSON.stringify(e)),localStorage.setItem(t+"_timestamp",Math.floor(Date.now()/1e3))}(t),l.lang&&l.lang!==tildaMembers.userLang&&(tildaMembers.userLang=l.lang),setTimeout((()=>window.location.reload()),1e3)),tma__showSuccessRequest(o,tma__translate("{{edit_profile_success_text}}","userbar_dict"))}else tma__showErrorRequest(o,e.code,"userbar_dict","edit_profile")}(o,e,t,a)}))}(e,t,r,l)}));const a=t.querySelector(".tlk-popup__change-password");a&&a.addEventListener("click",o)}(e)}function t(e){e.preventDefault();const t=e.target.closest(".tlk-upload");if(!t)return;const o=t.querySelector('input[type="file"]'),r=t.querySelector(".tlk-upload__preview"),l=t.querySelector(".tlk-upload__btn"),a=t.querySelector(".tlk-upload__error");o&&(o.value=""),r&&(r.innerHTML=""),l&&(l.style.display="block"),a&&(a.innerHTML="",a.classList.remove("tlk-upload__error_show")),window.tildaMembers&&window.tildaMembers.upload&&(tildaMembers.upload.id="",tildaMembers.upload.oldId="");const n=tma__getProfileObjFromLS();if(n){n.memberlogo="",n.memberlogo_uuid="";const e="tilda_members_profile"+parseInt(document.querySelector("#allrecords").dataset.tildaProjectId);localStorage.setItem(e,JSON.stringify(n))}}function o(){const e=tma__profile__getFormChangePasswordHtml();tma__drawPopup({id:"change-password",main:document.getElementById("app")||document.body,content:tma__translate(e,"userbar_dict"),closeBtns:[".tlk-popup__close-cancel"]});const t=document.getElementById("form-change-password");t&&(tma__profile__addButtonShowHidePasswordEvents(t),t.addEventListener("submit",r))}function r(e){e.preventDefault();const t=e.target,o=t.querySelector('button[type="submit"]');tma__resetErrorFields(t),tma__resetErrorRequest(t);const r=tma__validationFormFields(t);if(r.length>0)return void tma__showErrorFields(t,r,"userbar_dict");const l=function(e){const t=tma__serializeArray(e),o=tma__getProfileObjFromLS();return t.projectid=o.projectid,t.token=o.token,t.tzoffset=(new Date).getTimezoneOffset(),t}(t),a=JSON.stringify(l);tma__request("/api/editpassword/",a,o,(e=>{!function(e,t){"ok"===e.status?(tma__showSuccessRequest(t,tma__translate("{{change_password_success_text}}","userbar_dict")),setTimeout((()=>{tma__closePopup(document.getElementById("change-password")),tma__closePopup(document.getElementById("edit-profile")),dispatchEvent(new Event("resize"))}),1e3)):tma__showErrorRequest(t,e.code,"userbar_dict","change_password")}(e,t)}))}function l(t){const r=t.target.closest('a[href="#profile:edit"], button[href="#profile:edit"], a[href="#password"], button[href="#password"]');r&&(t.preventDefault(),"#profile:edit"===r.getAttribute("href")?e():"#password"===r.getAttribute("href")&&o())}document.addEventListener("DOMContentLoaded",(()=>{const e=parseInt(document.querySelector("#allrecords").dataset.tildaProjectId),t=window.localStorage.getItem("tilda_members_profile"+e);t&&JSON.parse(t).login?("undefined"==typeof tildaMembers&&(window.tildaMembers={}),void 0===tildaMembers.upload&&(tildaMembers.upload={}),document.addEventListener("click",l),document.querySelectorAll('[href="#login"]').forEach((e=>e.parentNode.remove())),document.querySelectorAll('[href="#signup"]').forEach((e=>e.parentNode.remove()))):(document.querySelectorAll('[href="#signup"]').forEach((e=>e.setAttribute("href","/members/signup/"))),document.querySelectorAll('[href="#login"]').forEach((e=>e.setAttribute("href","/members/login/"))),document.querySelectorAll('[href="#logout"]').forEach((e=>e.parentNode.remove())),document.querySelectorAll('[href="#profile:edit"]').forEach((e=>e.parentNode.remove())),document.querySelectorAll('[href="#password"]').forEach((e=>e.parentNode.remove()))),document.querySelectorAll('[href="#logout"]').forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault();const t=parseInt(document.querySelector("#allrecords").dataset.tildaProjectId);window.localStorage.removeItem("tilda_members_profile"+t),window.localStorage.removeItem("tilda_members_profile"+t+"_timestamp"),window.location.replace("/")}))}))}))}();</script> <style>.tlk-userbar, .tlk__userbar {display: none !important;}</style>