import{a as h}from"./chunk-YXEJJOGX.js";import{a}from"./chunk-CEK6WLCM.js";import{b as m}from"./chunk-6SCLTKCI.js";import{r as g}from"./chunk-VSIACUI5.js";import{Ib as c,J as u,M as r,d as o,e as t}from"./chunk-4SVIVQBS.js";var b=(()=>{let n=class n{constructor(e,i,s,p,f){this.http=e,this.systemService=i,this.authRefService=s,this.opportunityService=p,this.uiService=f,this.activeUser=null,this.viewingLedger=new t(void 0),this.stoppedViewingLedger=new o,this.sendingForQuote=new t(void 0),this.stoppedSendingForQuote=new o,this.sendingExecutedDocuments=new t(void 0),this.stoppedSendingExecutedDocuments=new o,this.documentsSentForSigning=new t(void 0),this.sendingDocuments=new t(void 0),this.stoppedSendingDocuments=new o,this.signingDocuments=new t(void 0),this.stoppedSigningDocuments=new o,this.preparingEstimate=new t(void 0),this.viewingDetails=new t(void 0),this.managingPayments=new t(void 0),this.watchUser()}watchUser(){this.userSubscription=this.authRefService.user.subscribe({next:e=>{this.activeUser=e}})}startViewingLedger(e){this.viewingLedger.next(e)}stopViewingLedger(){this.viewingLedger.next(void 0),this.stoppedViewingLedger.next()}startSendingQuote(e){if(this.activeUser!=null)if(e.documents.length<=0){let i=this.opportunityService.canModifyOpportunity(e),s=e.generateDocuments();i?this.opportunityService.updateDocuments(e,s,this.activeUser).then(()=>{this.sendingForQuote.next(e)}):(e.documents=s,this.sendingForQuote.next(e))}else this.sendingForQuote.next(e);else this.uiService.prompt("Unable to Prepare Quote","You do not have permission to prepare a quote. Please contact support or try logging in again.","Okay").subscribe({next:()=>{}})}stopSendingQuote(){this.sendingForQuote.next(void 0),this.stoppedSendingForQuote.next()}startSendingExecutedDocuments(e){this.sendingExecutedDocuments.next(e)}stopSendingExecutedDocuments(){this.sendingExecutedDocuments.next(void 0),this.stoppedSendingExecutedDocuments.next()}startSendingDocuments(e){this.sendingDocuments.next(e)}stopSendingDocuments(e=void 0){this.documentsSentForSigning.next(e),this.sendingDocuments.next(void 0),this.stoppedSendingDocuments.next()}startSigningDocuments(e,i,s=!1){this.signingDocuments.next({opportunity:e,onlyCustomerFacing:s,signer:i})}stopSigningDocuments(){this.signingDocuments.next(void 0),this.stoppedSigningDocuments.next()}startPreparingEstimate(e){this.preparingEstimate.next(e)}stopPreparingEstimate(){this.preparingEstimate.next(void 0)}viewDetails(e){this.viewingDetails.next(e)}stopViewingDetails(){this.viewingDetails.next(void 0)}startMakingPayments(e){this.managingPayments.next(e)}stopMakingPayments(){this.managingPayments.next(void 0)}ngOnDestroy(){this.userSubscription?.unsubscribe()}};n.\u0275fac=function(i){return new(i||n)(r(c),r(h),r(g),r(m),r(a))},n.\u0275prov=u({token:n,factory:n.\u0275fac});let d=n;return d})();export{b as a};
