import{loadPageTexts as e,getPageText as t}from"../i18n/main.min.js";import{hide_login_page as n,hide_signup_page as a,show_startpage as s,show_home as o}from"../main/main.min.js";import{validatePasswordSecurity as i,countOccurrences as r,jCloudUIElements as c}from"../tools/main.min.js";import{more_options_menu_hide as d}from"../nav/menus/moreoptions/main.min.js";const u=function(){const e=document.querySelector("#email"),t=document.querySelector("#password-container"),n=document.querySelector("#password");e.value.length>0&&(e.style.borderBottomLeftRadius="0",e.style.borderBottomRightRadius="0",n.style.borderTopLeftRadius="0",n.style.borderTopRightRadius="0",n.classList.add("show"),t.style.display="block",setTimeout(()=>{t.classList.add("show")},10)),e.addEventListener("input",function(){0===e.value.length&&(setTimeout(()=>{t.classList.remove("show")},10),e.style.borderBottomLeftRadius="10px",e.style.borderBottomRightRadius="10px",n.style.borderTopLeftRadius="10px",n.style.borderTopRightRadius="10px",n.classList.remove("show"),t.style.display="none")})},l=async function(){const e=document.querySelector("#email").value,a=document.querySelector("#password").value;document.querySelector("#loading").style.display="flex";const s=document.querySelector("#login-error"),i=new URLSearchParams;i.append("e",e),i.append("p",a),i.append("s",document.querySelector("#login-options-stay").checked?"true":"false"),await fetch("https://jcloud-services.ddns.net:1024/get-token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i.toString(),credentials:"include"}).then(async e=>{if(200===e.status){await e.text();document.cookie=`signed_in=true; path=/; ${document.querySelector("#login-options-stay").checked?"Max-Age=1728000":""}; Secure; SameSite=strict`,document.querySelector("#authorized-mom-part").style.display="block",n(),o()}else 401===e.status?(s.textContent=await t("/login","0a3277611792429cbdbea27f8238b2e9","0"),s.classList.remove("hidden")):404===e.status&&(s.textContent=await t("/login","6f7684f96cfe47e3ad01c1f566de5f53","0"),s.classList.remove("hidden"))}).catch(async e=>{await c.alert(e)}),document.querySelector("#loading").style.display="none"},p=async function(){const e=document.querySelector("#signup-error"),n=document.querySelector("#signup-email").value,a=document.querySelector("#signup-password").value,s=document.querySelector("#signup-password-confirm").value,o=document.querySelector("#signup-first-name").value,d=document.querySelector("#signup-last-name").value,u=document.querySelector("#signup-language").value,l=new Date(document.querySelector("#signup-birth-date").value),p=Math.floor((new Date-l)/864e5),m=document.querySelector("#signup-pre-installed-applications").value,y=document.querySelector("#signup-pre-installed-applications-installing-locations").value;if(n&&a&&s&&o&&d&&u&&l&&m&&y)if(p>=4745)if(n.length>0&&1===r(n,"@"))if(a===s)if(i(a)){let s=new URLSearchParams;s.append("e",n),s.append("p",a),s.append("fn",o),s.append("ln",d),s.append("lang",u),s.append("by",l.getFullYear()),s.append("bm",l.getMonth()+1),s.append("bd",l.getDate()),s.append("pia",m),s.append("il",y),await fetch("https://jcloud-services.ddns.net:1024/register",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()}).then(async o=>{202===o.status?(await c.alert("Das Konto wurde erfolgreich erstellt."),s=new URLSearchParams,s.append("e",n),s.append("p",a),await fetch("https://jcloud-services.ddns.net:1024/get-token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()}).then(async e=>{200===e.status&&(document.cookie=`User=${n}; path=/; Max-Age=1728000; Secure; Samesite=strict`,document.cookie="signed_in=true; path=/; Max-Age=1728000; Secure; Samesite=strict",window.location.href="/")}).catch(async e=>{await c.alert(e)})):409===o.status?e.innerHTML=await t("/signup","e730f1e7a56a49e383ab4dc25d85072f","0"):500===o.status&&(e.innerHTML=e.innerHTML=await t("/signup","9094396415c14bfeb09dc3de40c74936","0"))}).catch(async e=>{await c.alert(e)})}else e.innerHTML=await t("/signup","676e5f3ada1b40488aa841ae380d6fa3","0");else e.innerHTML=await t("/signup","7d6499350697401c8ea2f7ca60d0c474","1");else e.innerHTML=await t("/signup","2c04ed45a2d04b42916f5d23ee63e7c1","0");else e.innerHTML=await t("/signup","2bc37506b1024fe196a6aea65406b83f","0");else e.innerHTML=await t("/signup","a827a1ffb86e4f0786e951abe4a54ab3","0")},m=function(){const e=document.querySelector("#signup-form-page-1"),t=document.querySelector("#signup-form-page-2");e.classList.remove("hidden"),t.classList.add("hidden")},y=function(){const e=document.querySelector("#signup-form-page-1"),t=document.querySelector("#signup-form-page-2"),n=document.querySelector("#signup-form-page-3");e.classList.add("hidden"),t.classList.remove("hidden"),n.classList.add("hidden")},h=function(){const e=document.querySelector("#signup-form-page-2"),t=document.querySelector("#signup-form-page-3");e.classList.add("hidden"),t.classList.remove("hidden")},g=async function(){await fetch("https://jcloud-services.ddns.net:1024/session",{method:"DELETE"}).then(async t=>{204===t.status?(document.cookie="User=; path=/; max-age=-1",document.cookie="signed_in=; path=/; max-age=-1",d(),s(),document.querySelector("#authorized-mom-part").style.display="none",history.pushState(null,"","/"),await e("/"),document.querySelector("#files").setAttribute("class","hidden"),document.querySelector("#home").setAttribute("class","hidden"),document.querySelector("#link-home").style.display="none",document.querySelector("#user-details-on-footer").style.display="none",document.querySelector("#user-details-on-footer").setAttribute("class",""),window.scroll(0,0)):await c.alert("Aufgrund eines unbekannten Fehlers ist eine Abmeldung derzeit nicht möglich. Bitte versuchen Sie es später erneut.")}).catch(async e=>{await c.alert("Aufgrund eines Netzwerkfehlers ist eine Abmeldung derzeit nicht möglich. Bitte versuchen Sie es später erneut.")})};export{u as submit_email,l as check_password,p as createUser,m as signupPage1,y as signupPage2,h as signupPage3,g as signOut};