1(()=>{const l=window.loginConfig||{productDomain:"ladesk.com",storageKey:"la_login"};(!l.productId||!l.recaptchaId||!l.apiUrl)&&console.error("Login configuration missing. Check page front-matter.");const u=l.localization||{},r={ERROR:"Error",WAITING:"Waiting",VALID:"Valid"},v={async sendApiRequest(n){const{url:t,method:i="GET",data:s,params:e}=n;let a=t;if(e){const o=new URLSearchParams(e);a+=`?${o.toString()}`}const c={method:i,headers:{"Content-Type":"application/json"}};s&&(c.body=JSON.stringify(s));try{const o=await fetch(a,c);if(!o.ok){let m=`HTTP ${o.status}: ${o.statusText}`;try{const h=await o.json();h&&h.message&&(m=h.message)}catch{}const p=new Error(m);throw p.status=o.status,p}return await o.json()}catch(o){throw o}},parseError(n,t){if(n.status===500)return t;try{return(typeof n=="string"?JSON.parse(n):n).message||t}catch{return t}},debounce(n,t){let i;return function(...e){const a=()=>{clearTimeout(i),n(...e)};clearTimeout(i),i=setTimeout(a,t)}}};class d{constructor(){this.state=r.ERROR,this.message="Invalid field",this.uniqueValues=[]}valid(t=""){return this.state=r.VALID,this.message=t,this}error(t){return this.state=r.ERROR,this.message=t,this}waiting(){return this.state=r.WAITING,this.message="",this}setUnique(...t){return this.uniqueValues=[...t],this}hasUniqueChanged(...t){return this.uniqueValues.length!==t.length?!0:this.uniqueValues.some((i,s)=>i!==t[s])}static textLength(t="Field is required",i=1,s="input"){const e=new d;return e.validate=a=>((a.element.querySelector(s)?.value||"").length>=i?e.valid():e.error(t),e),e}static regex(t,i,s="input"){const e=new d;return e.validate=a=>{const o=a.element.querySelector(s)?.value||"";return t.test(o)?e.valid():e.error(i),e},e}static apiRequest(t,i){const s=new d;return s.precheck=i||(e=>{const a=e.getValue();return!a||a===""?(s.error(u.fieldEmpty||"Field is required"),!0):s.hasUniqueChanged(a)?(s.setUnique(a),!1):!0}),s.validate=async e=>{if(s.precheck(e))return s;try{s.waiting();const a=t(e),c=await v.sendApiRequest(a);s.error(u.domainFailed||"Domain not found")}catch(a){a.message&&a.message.includes("already used")?s.valid(u.domainValid||"Domain found - ready to login"):a.status===404?s.error(u.domainFailed||"Domain not found"):s.error(u.fieldInvalid||"Unable to validate domain")}return s},s}}class f{constructor(t){this.name=t,this.active=!0,this.validators=[],this.validationTimeout=null,this._element=null}get element(){return this._element||(this._element=document.querySelector(`[data-id="${this.name}main"]`)),this._element}get input(){return this.element?.querySelector("input")}getValue(){return this.input?.value||""}setValue(t){return this.input&&(this.input.value=t),this}isActive(){return this.active}setActive(t){return this.active=t,this}setState(t,i=""){return this.element?(Object.values(r).forEach(s=>{this.element.classList.remove(s)}),this.element.classList.add(t),this.setErrorMessage(i),this):this}setErrorMessage(t){const i=this.element?.querySelector(".ErrorMessage");return i&&(i.textContent=t),this}addValidator(t){return this.validators.includes(t)||this.validators.push(t),this}async validate(){if(!(!this.validators.length||!this.isActive())){this.cancelValidation();try{const t=await Promise.all(this.validators.map(a=>a.validate(this))),i=t.find(a=>a.state===r.ERROR);if(i){this.setState(r.ERROR,i.message);return}if(t.find(a=>a.state===r.WAITING)){this.setState(r.WAITING,u.validating||"Validating...");return}const e=t.find(a=>a.message)||t[0];this.setState(r.VALID,e.message)}catch{this.setState(r.ERROR,u.fieldInvalid||"Validation failed")}window.signupForm&&window.signupForm.updateButtonState()}}getState(){if(!this.element)return r.ERROR;for(const t of Object.values(r))if(this.element.classList.contains(t))return t;return r.ERROR}scheduleValidation(t=0){return this.cancelValidation(),t<=0?(this.validate(),this):(this.validationTimeout=setTimeout(()=>{this.validationTimeout=null,this.validate()},t),this)}cancelValidation(){return this.validationTimeout&&(clearTimeout(this.validationTimeout),this.validationTimeout=null),this}validateOn(t,i=0,s=null){const e=v.debounce(()=>{this.scheduleValidation(i)},i),a=s?this.element?.querySelector(s):this.element;return a&&a.addEventListener(t,e),this}}class y{constructor(){this.fields=new Map,this.submitButton=null}
1get element(){return document.querySelector('[data-id="signup"]')}getField(t){return this.fields.has(t)||this.fields.set(t,new f(t)),this.fields.get(t)}getSubmitButton(){return this.submitButton||(this.submitButton=document.querySelector('[data-id="createButtonmain"]')),this.submitButton}async validateAll(){const t=Array.from(this.fields.values()).filter(e=>e.isActive());t.forEach(e=>e.cancelValidation());const i=t.map(e=>e.validate());return await Promise.all(i),t.every(e=>e.getState()===r.VALID)}updateButtonState(){const t=this.getSubmitButton(),s=Array.from(this.fields.values()).filter(e=>e.isActive()).every(e=>e.getState()===r.VALID);t&&(s?(t.classList.remove("cursor-not-allowed"),t.classList.add("cursor-pointer")):(t.classList.add("cursor-not-allowed"),t.classList.remove("cursor-pointer")))}async submit(){if(!await this.validateAll()){this.showErrorPopup();return}try{const i=await this.getReCaptchaToken(),s={subdomain:this.getField("domainField").getValue(),grtoken:i};localStorage.setItem(l.storageKey,s.subdomain);const e=this.getSubmitButton()?.querySelector("span");e&&(e.textContent=u.redirecting||"Redirecting...");const a=`https://${s.subdomain}.${l.productDomain}/agent/`;window.location.href=a}catch(i){console.error("Login failed:",i),this.showErrorPopup()}}async getReCaptchaToken(){return new Promise((t,i)=>{if(typeof grecaptcha>"u"){i(new Error("reCAPTCHA not loaded"));return}grecaptcha.ready(()=>{grecaptcha.execute(l.recaptchaId,{action:"login"}).then(t).catch(i)})})}showErrorPopup(){const t=document.querySelector(".Login__overlay"),i=document.querySelector(".Login__popup");t?.classList.add("active"),i?.classList.add("active")}}class w{constructor(){this.overlay=document.querySelector(".Login__overlay"),this.popup=document.querySelector(".Login__popup"),this.closeButton=document.querySelector(".Login__popup__close")}init(){this.bindEvents()}bindEvents(){document.addEventListener("keydown",t=>{t.key==="Escape"&&this.close()}),this.overlay?.addEventListener("click",()=>this.close()),this.popup?.addEventListener("click",t=>{t.stopPropagation()}),this.closeButton?.addEventListener("click",()=>this.close())}close(){this.overlay?.classList.remove("active"),this.popup?.classList.remove("active")}}function S(n){const t=n.getField("domainField"),i=d.apiRequest(e=>({url:`${l.apiUrl}subscriptions/_check_domain`,method:"POST",params:{productId:l.productId,subdomain:e.getValue()}}));t.addValidator(d.textLength(u.fieldEmpty||"Domain is required",1)).addValidator(i).validateOn("focusout").validateOn("keyup",500).validateOn("change");const s=t.input;return s&&s.addEventListener("input",e=>{const a=e.target.value,c=a.replace(/[^a-zA-Z0-9-]/g,"");a!==c&&(e.target.value=c)}),t}function g(){const n=new y,t=new w;S(n);const i=n.getSubmitButton();return i&&i.addEventListener("click",s=>{s.preventDefault(),n.submit()}),t.init(),window.signupForm=n,n.updateButtonState(),{form:n,popup:t}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):g();})();
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.