1import{a as u}from"./chunk-GCUHT3BO.js";import"./chunk-DW3DSYX4.js";import"./chunk-IJQ2CRSL.js";import"./chunk-WJN7FNVB.js";import"./chunk-QNP2V3E3.js";import"./chunk-6NJE4IPO.js";import"./chunk-6TJB6AAQ.js";import"./chunk-JSZP35VH.js";import"./chunk-W4BO5QHV.js";import"./chunk-XTG2QKW3.js";import{a as d}from"./chunk-NZTDWNC2.js";import"./chunk-24QZRBAK.js";import"./chunk-FOEPKLLX.js";import{g as P,i as R,j as M}from"./chunk-TXLECCWT.js";import"./chunk-OK5RV444.js";import"./chunk-37FDMDDG.js";import{L as U,c as V,e as w,g as D,h as I,j as O,l as F,o as W,x as X,y as q}from"./chunk-7JRSK7QJ.js";import{a as N,b as m}from"./chunk-W7A2LXGN.js";import{f as G}from"./chunk-FQ3EYPSJ.js";import{d as y,e as b}from"./chunk-N4XGHN5K.js";import"./chunk-LPGEMBOY.js";import{$b as n,Ac as k,Bb as p,Dc as r,P as A,Tb as S,Vb as _,Wc as x,_b as h,ac as o,bc as s,ic as L,kb as l,lc as C,ma as c,md as T,oc as f,ua as g,va as v}from"./chunk-FKAK7BJG.js";import"./chunk-QBUHZOWM.js";var j={registration_disabled:"Registration is currently disabled. Please contact support for access.",account_already_linked:"This account is already linked to a different authentication provider.",external_login_failed:"External login failed. Please try again.",email_not_provided:"Email address not provided by the authentication provider.",correlation_missing:"Authentication session expired. Please try again.",state_expired:"Authentication session expired. Please try again.",no_token:"Authentication failed. No token received."};var J=()=>["/forgot-password"],K=()=>["fab","google"],Z=()=>["fab","microsoft"];function $(t,E){t&1&&(n(0,"h2",1),s(1,"app-spinner"),r(2," Logging in"),o())}function ee(t,E){t&1&&(n(0,"span",12),r(1," - Valid email is required"),o())}function te(t,E){if(t&1){let e=L();n(0,"div",21)(1,"div",22)(2,"span",23),r(3,"\u2014 OR \u2014"),o()(),n(4,"button",24),C("click",function(){g(e);let a=f(2);return v(a.onLoginWithGoogle())}),s(5,"fa-icon",25),r(6," Continue with Google "),o(),n(7,"button",26),C("click",function(){g(e);let a=f(2);return v(a.onLoginWithMicrosoft())}),s(8,"fa-icon",25),r(9," Continue with Microsoft "),o()()}t&2&&(l(5),h("icon",x(2,K)),l(3),h("icon",x(3,Z)))}function ie(t,E){if(t&1){let e=L();n(0,"div",2),s(1,"div",3),n(2,"div",4)(3,"h1"),r(4,"Login"),o(),n(5,"p"),r(6,"Please enter your email and password to continue."),o(),n(7,"div",5)(8,"div",6)(9,"form",7),C("ngSubmit",function(){g(e);let a=f();return v(a.onLogin())}),n(10,"div",8)(11,"div",9)(12,"div",10)(13,"label",11),r(14," Email "),S(15,ee,2,0,"span",12),o(),s(16,"fa-icon",13)(17,"input",14),o()(),n(18,"div",9)(19,"div",10)(20,"label",15),r(21,"Password"),o(),s(22,"fa-icon",16)(23,"input",17),o()()(),n(24,"button",18),r(25,"Login"),o()()()(),n(26,"div",19)(27,"a",20),r(28,"Forgot Password?"),o()(),S(29,te,10,4,"div",21),o(),s(30,"div",3),o()}if(t&2){let e=f();l(9),h("formGroup",e.loginForm),l(6),_(e.hasErrorAndTouched("email")?15:-1),l(2),k("is-invalid",e.hasErrorAndTouched("email")),l(6),k("is-invalid",e.hasErrorAndTouched("password")),l(4),h("routerLink",x(8,J)),l(2),_(e.showSso?29:-1)}}var Q=(()=>{class t{constructor(){this.router=c(R),this.alertify=c(y),this.authService=c(m),this.supplierService=c(b),this.error=T(),this.showSso=!1,this.loginForm=new O({email:new F("",{validators:[w.required,w.email],nonNullable:!0}),password:new F("",{validators:w.required,nonNullable:!0})}),this.loading=!1}ngOnInit(){if(this.authService.loggedIn()){this.router.navigateByUrl(this.authService.getHomePageForUser());return}this.showSso=this.supplierService.currentSupplier?.settings?.usesSso??!1,this.handleErrorQueryParam()}handleErrorQueryParam(){let e=this.error();if(!e)return;let i=j[e]||"An error occurred during login. Please try again.";this.alertify.error(i)}onLogin(){if(this.loginForm.markAllAsTouched(),this.loginForm.invalid)return;let{email:e,password:i}=this.loginForm.value;this.loading=!0,this.authService.login({email:e,password:i,supplierId:this.supplierService.currentSupplier.id}).pipe(A(1)).subscribe({next:()=>{this.alertify.success("logged in successfully");let{xeroLoginLink:a,redirectLink:z}=this.authService;window.location.href=a||m.backToLink||z},error:()=>{this.loading=!1,this.alertify.error("Your Email Address or password is incorrect")}})}onLoginWithGoogle(){this.authService.loginWithGoogle()}onLoginWithMicrosoft(){this.authService.loginWithMicrosoft()}hasErrorAndTouched(e){return this.hasError(e)&&this.touched(e)}hasError(e){return!!this.loginForm.get(e).errors}touched(e){return this.loginForm.get(e).touched}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=p({type:t,selectors:[["app-login"]],inputs:{error:[1,"error"]},decls:4,vars:1,consts:[[1,"container"],[1,"text-center","mt-5","mb-5"],[1,"row","mt-5"],[1,"col-sm-3"],[1,"col-sm-6"],[1,"booking"],[1,"widget","search"],[3,"ngSubmit","formGroup"],[1,"row"],[1,"col-12"],[1,"form-group"],["for","email"],[1,"color-red"],["icon","envelope"],["type","text","placeholder","[email protected]","formControlName","email",1,"form-control"],["for","password"],["icon","key"],["type","password","placeholder","Your Password","formControlName","password",1,"form-control"],["type","submit",1,"btn","btn-primary"],[1,"text-right"],[1,"btn","text-black-50",3,"routerLink"],[1,"mt-3"],[1,"text-center","mb-3"],[1,"text-muted"],["type","button",1,"btn","btn-secondary","btn-block","mb-2",3,"click"],[1,"mr-2",3,"icon"],["type","button",1,"btn","btn-secondary","btn-block",3,"click"]],template:function(i,a){i&1&&(s(0,"app-nav"),n(1,"div",0),S(2,$,3,0,"h2",1)(3,ie,31,9,"div",2),o()),i&2&&(l(2),_(a.loading?2:3))},dependencies:[u,G,U,W,V,D,I,q,X,M,d],encapsulation:2})}}return t})();var Y=(()=>{class t{constructor(){this.authService=c(m)}ngOnInit(){setTimeout(()=>{window.location.href=this.authService.getHomePageForUser()},3e3)}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=p({type:t,selectors:[["app-redirect"]],decls:5,vars:0,consts:[[1,"container"],[1,"h2","text-center","mt-5","mb-5"]],template:function(i,a){i&1&&(s(0,"app-nav"),n(1,"div",0)(2,"div",1),s(3,"app-spinner"),r(4," Redirecting"),o()())},dependencies:[u,d],encapsulation:2})}}return t})();var B=(()=>{class t{constructor(){this.route=c(P),this.xeroService=c(N),this.authService=c(m),this.alertify=c(y),this.supplierService=c(b)}
1ngOnInit(){let e=this.route.snapshot.queryParamMap.get("code"),i=this.route.snapshot.queryParamMap.get("state");this.xeroService.storeLoginToken(e,i,this.supplierService.currentSupplier.id,this.authService.currentUser().id).subscribe(a=>{this.alertify.success("logged into Xero successfully")},a=>{this.alertify.error(a.error),setTimeout(()=>{console.log(a.error)},5e3),window.location.href="/supplier/bookings/"},()=>{this.alertify.message("Redirecting to Dashboard"),window.location.href="/supplier/bookings/"})}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=p({type:t,selectors:[["app-xero"]],decls:5,vars:0,consts:[[1,"container"],[1,"text-center","mt-5","mb-5"]],template:function(i,a){i&1&&(s(0,"app-nav"),n(1,"div",0)(2,"h2",1),s(3,"app-spinner"),r(4," Finishing Xero Authentication"),o()())},dependencies:[u,d],encapsulation:2})}}return t})();var De=[{path:"",component:Q},{path:"xero",component:B},{path:"redirect",component:Y}];export{De as routes};
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.