1import{t as l}from"./app-events.CMxIl1mF.js";import{w as P}from"./backend-calls.DAfAj5X1.js";import{a as d,b as E,s as I}from"./auth-service.B96Y9STA.js";import{t as f}from"./turnstile-service.CUjs17l9.js";import{f as a,a as y,g}from"./handlers.DZb4R-mE.js";/*!ed53725fb2*/const L={"turnstile-login-widget":"login","turnstile-signup-widget":"signup"},h={"Invalid email or password":"invalid_credentials","This account was created with Google sign-in. Please use the appropriate social login method.":"google_account","Email and password are required":"missing_fields","Invalid request":"invalid_request","Invalid request data":"invalid_request","Request must contain JSON data":"invalid_request","User with this email already exists":"email_exists","Email is required":"email_required","Invalid email format":"email_invalid","Email address is too long":"email_too_long","Temporary email addresses are not allowed":"email_temporary","Password is required":"password_required","Password must be at least 8 characters long":"password_too_short","Password is too long":"password_too_long","Password must contain at least one letter":"password_no_letter","Password must contain at least one number":"password_no_number","Name is too long":"name_too_long","Name contains invalid characters":"name_invalid","Captcha verification required":"captcha_missing","Captcha has expired or already been used. Please refresh and try again.":"captcha_expired","Captcha verification failed. Please try again.":"captcha_failed","Server configuration error. Please contact support.":"captcha_config","Verification service temporarily unavailable. Please try again.":"captcha_unavailable","Verification error. Please try again.":"captcha_error","Failed to create user":"server_error","An error occurred during registration":"server_error"};function b(r,e){if(r===0)return"network";const t=e?.code;if(typeof t=="string"&&/^[a-z0-9_]{1,40}$/.test(t))return t;const s=typeof e?.error=="string"?e.error.trim():"";return s&&h[s]?h[s]:r===429?"rate_limited":`http_${r}`}const m={"/auth/login":"login","/auth/signup":"signup"};function x(){const r=window.location.pathname.replace(/\/+$/,"");return r==="/login"?"login":r==="/signup"?"signup":"other"}let p=!1;function _(){if(!p){p=!0,P({start(r){const e=r.method==="POST"?m[r.path]:void 0;e&&l("Auth Attempted",{method:"password",flow:e})},end(r){const e=r.method==="POST"?m[r.path]:void 0;if(e){if(r.status>=200&&r.status<300){l("Auth Completed",{method:"password",flow:e},{beforeLeaving:!0});return}r.json().then(t=>l("Auth Failed",{method:"password",flow:e,reason:b(r.status,t),http_status:r.status}))}}}),f.onSubmitBlocked(r=>{const e=L[r.widget];!e||r.modal||l("Auth Failed",{method:"password",flow:e,reason:r.reason})});try{const r=d,e=r.initiateGoogleOAuth;typeof e=="function"&&(r.initiateGoogleOAuth=function(...t){return l("Auth Attempted",{method:"google",flow:x()},{beforeLeaving:!0}),e.apply(this,t)})}catch{}}}_();async function T(){if(new URLSearchParams(window.location.search).get("expired")==="1"){d.clearSession();return}if(!d.sessionToken)return;(await d.getCurrentUser()).success&&(window.location.href=E()??"/dashboard")}function w(r){try{return decodeURIComponent(r)}catch{return r}}class v{pageType;isInitialized=!1;constructor(e){this.pageType=e,this.handlePasswordToggle=this.handlePasswordToggle.bind(this),this.handleGoogleAuth=this.handleGoogleAuth.bind(this),this.showSuccessState=this.showSuccessState.bind(this)}init(){this.isInitialized||(this.attachEventListeners(),this.setupFormValidation(),this.handleUrlParams(),this.setupPageSpecificFeatures(),this.forgetAbandonedGoogleSignIn(),this.isInitialized=!0)}forgetAbandonedGoogleSignIn(){this.pageType!=="login"&&this.pageType!=="signup"||(d.abandonOAuthFlow(),window.addEventListener("pageshow",e=>{e.persisted&&d.abandonOAuthFlow()}))}attachEventListeners(){document.querySelectorAll(".password-toggle").forEach(t=>{t.addEventListener("click",this.handlePasswordToggle)}),this.attachPageSpecificListeners()}setupFormValidation(){document.querySelectorAll("form").forEach(t=>{a&&a.setupRealTimeValidation(t,this.pageType)}),this.pageType==="signup"&&this.setupPasswordStrengthIndicator()}handleUrlParams(){const e=new URLSearchParams(window.location.search),t=I(e.get("next"));t&&sessionStorage.setItem("auth_redirect",t);const s=e.get("error");s&&(this.showPageError(w(s)),this.cleanUrl());const n=e.get("success");n&&(this.showPageSuccess(w(n)),this.cleanUrl())}setupPageSpecificFeatures(){switch(this.pageType){case"login":this.setupLoginFeatures();break;case"signup":this.setupSignupFeatures();break;case"forgot-password":this.setupForgotPasswordFeatures();break;case"new-password":this.setupNewPasswordFeatures();break}}setupLoginFeatures(){const e=document.getElementById("login-email");e&&setTimeout(()=>e.focus(),100)}setupSignupFeatures(){const e=document.getElementById("signup-email");e&&setTimeout(()=>e.focus(),100),this.setupEmailConfirmation()}setupForgotPasswordFeatures(){const e=document.getElementById("forgot-email");e&&setTimeout(()=>e.focus(),100);const t=document.getElementById("resend-email");t&&t.addEventListener("click",()=>{this.resendResetEmail()})}setupNewPasswordFeatures(){this.parseResetToken();const e=document.getElementById("new-password");e&&setTimeout(()=>e.focus(),100),this.setupPasswordConfirmation(),this.setupPasswordRequirements()}attachPageSpecificListeners(){if(this.pageType==="forgot-password"){const e=g();if(e){const t=e.showFormSuccess.bind(e);e.showFormSuccess=(s,n)=>{s.id==="forgot-password-form"?this.showSuccessState(n):t(s,n)}}}if(this.pageType==="new-password"){const e=g();if(e){const t=e.showFormSuccess.bind(e);e.showFormSuccess=(s,n)=>{s.id==="new-password-form"?this.showNewPasswordSuccessState(n):t(s,n)}}}}handlePasswordToggle(e){const t=e.currentTarget,s=t.parentElement.querySelector('input[type="password"], input[type="text"]'),n=t.querySelector(".show-password"),o=t.querySelector(".hide-password");s.type==="password"?(s.type="text",n.classList.add("hidden"),o.classList.remove("hidden")):(s.type="password",n.classList.remove("hidden"),o.classList.add("hidden"))}setupPasswordStrengthIndicator(){const e=document.getElementById("signup-password"),t=document.querySelector(".password-strength"),s=document.querySelector(".strength-bar"),n=document.querySelector(".strength-text");!e||!t||e.addEventListener("input",o=>{const c=o.target.value;if(c.length===0){t.classList.add("hidden");return}t.classList.remove("hidden");const i=y;if(i){const S=i.calculatePasswordStrength(c);this.updatePasswordStrengthDisplay(S,s,n)}})}updatePasswordStrengthDisplay(e,t,s){const n={weak:{width:"33%",color:"bg-red-500",text:"Weak"},medium:{width:"66%",color:"bg-yellow-500",text:"Medium"},strong:{width:"100%",color:"bg-green-500",text:"Strong"}},o=n[e]||n.weak;t.style.width=o.width,t.className=`strength-bar h-2 rounded-full transition-all duration-300 ${o.color}`,s.textContent=o.text}setupEmailConfirmation(){const e=document.getElementById("signup-email"),t=document.getElementById("signup-email-confirm");if(!e||!t)return;const s=()=>{t.value&&e.value!==t.value?a&&a.showFieldError(t,"Email addresses do not match"):t.value&&a&&a.clearFieldError(t)};e.addEventListener("blur",s),t.addEventListener("blur",s),t.addEventListener("input",s)}handleGoogleAuth(e){e.preventDefault();const t=g();t&&t.handleGoogleAuthClick?t.handleGoogleAuthClick():window.location.href="/auth/google"}showSuccessState(e){const t=document.getElementById("forgot-password-form"),s=document.getElementById("success-state");if(t&&s){t.style.display="none",s.classList.remove("hidden");const n=s.querySelector("p");n&&e&&(n.textContent=e)}}resendResetEmail(){const e=document.getElementById("forgot-email");if(!e||!e.value)return;const t=document.getElementById("resend-email");t&&(t.disabled=!0,t.textContent="Sending...",window.authService&&window.authService.requestPasswordReset(e.value).then(s=>{s.success?this.showPageSuccess(s.message||"Reset email sent again!"):this.showPageError(s.error||"Failed to resend email")}).catch(s=>{this.showPageError("Network error. Please try again.")}).finally(()=>{t.disabled=!1,t.textContent="Resend email"}))}showPageError(e){this.showPageMessage(e,"error")}showPageSuccess(e){this.showPageMessage(e,"success")}showPageMessage(e,t){const s=document.querySelector(".page-message");s&&s.remove();const n=document.createElement("div");n.className=`page-message fixed top-4 left-1/2 transform -translate-x-1/2 z-50 px-4 py-3 rounded-lg shadow-lg max-w-md w-full mx-4 ${t==="error"?"bg-red-900/90 border border-red-700 text-red-200":"bg-green-900/90 border border-green-700 text-green-200"}`;const o=document.createElement("div");o.className="flex items-center justify-between";const c=document.createElement("span");c.className="text-sm font-medium",c.textContent=e;const i=document.createElement("button");i.type="button",i.className="ml-4 text-current hover:opacity-70 transition-opacity",i.setAttribute("aria-label","Dismiss"),i.innerHTML=` 2 <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> 3 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path> 4 </svg>`,i.addEventListener("click",()=>n.remove()),o.append(c,i),n.appendChild(o),document.body.appendChild(n),setTimeout(()=>{n.parentElement&&n.remove()},5e3)}cleanUrl(){const e=new URL(window.location.href);e.search="",window.history.replaceState({},document.title,e.toString())}getPageType(){return this.pageType}isReady(){return this.isInitialized}parseResetToken(){const t=new URLSearchParams(window.location.search).get("token"),s=document.getElementById("reset-token"),n=document.getElementById("new-password-form"),o=document.getElementById("invalid-token-state");return!t||(s&&(s.value=t),t.length<10)?(n&&(n.style.display="none"),o&&o.classList.remove("hidden"),!1):!0}setupPasswordConfirmation(){const e=document.getElementById("new-password"),t=document.getElementById("confirm-password");if(!e||!t)return;const s=()=>{t.value&&e.value!==t.value?a&&a.showFieldError(t,"Passwords do not match"):t.value&&e.value===t.value&&a&&a.clearFieldError(t)};e.addEventListener("input",s),t.addEventListener("input",s),t.addEventListener("blur",s)}setupPasswordRequirements(){const e=document.getElementById("new-password"),t=document.getElementById("length-req");!e||!t||e.addEventListener("input",s=>{const n=s.target.value,o=t.querySelector("svg");n.length>=8?(o.innerHTML='<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>',o.classList.remove("text-gray-500"),o.classList.add("text-green-400")):(o.innerHTML='<circle cx="12" cy="12" r="10"></circle>',o.classList.remove("text-green-400"),o.classList.add("text-gray-500"))})}showNewPasswordSuccessState(e){const t=document.getElementById("new-password-form"),s=document.getElementById("success-state"),n=document.querySelector(".mt-6.text-center.text-gray-400");if(t&&s){t.style.display="none",n&&(n.style.display="none"),s.classList.remove("hidden");const o=s.querySelector("p");o&&e&&(o.textContent=e)}}}let u=null;
4function F(r){return u||(u=new v(r)),u.init(),u}function k(){return u}T();window.authService=d;window.turnstileService=f;window.formValidator=y;window.formUIManager=a;window.getAuthHandler=g;window.getAuthPageManager=k;window.initAuthPageManager=F;window.AuthPageManager=v;function R(r,e,t){window[r]=e,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}export{R as a,F as i};
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.