import{a as p}from"./chunk-CVN2SFTO.js";import{h as d,y as V}from"./chunk-PZHJ5CIW.js";import{s,t as k,w as f,x as L}from"./chunk-MW4YCIED.js";import{c as u,d as g}from"./chunk-2AH3OLVO.js";import{k as m}from"./chunk-QVLAHW2O.js";import{f as a,i as v}from"./chunk-B46M6TSS.js";import{T as l,ka as n,la as S,nd as b,qa as h,v as i,va as o}from"./chunk-PGS4AHIT.js";V();S();g();k();var c=function(r){return r.TravelOrder="S",r}(c||{});b();v();L();var E=(()=>{class r extends p{get model$(){return this._model$}get attachments$(){return this._attachments$}get connections$(){return this._connections$}get chatLog$(){return this._chatLog$}get isEditMode(){return u.isSet(this.model?.id)}constructor(e,t,w){super(),this.http=e,this.apiService=t,this.router=w,this.model=null,this.modelS=new i(1),this._model$=this.modelS.asObservable(),this.attachmentsS=new i(1),this._attachments$=this.attachmentsS.asObservable(),this.connectionsS=new i(1),this._connections$=this.connectionsS.asObservable(),this.chatLogS=new i(1),this._chatLog$=this.chatLogS.asObservable(),this.selectedDocuments=[]}unset(){this.formGroup=void 0}unsetModel(){this.model=null,this.modelS.next(null),this.attachmentsS.next(null),this.connectionsS.next(null),this.chatLogS.next(null)}fetch(e){return this.apiService.get(s.tasks.fetch(e)).pipe(n(t=>{this.shouldRedirectToTravelOrder(t)||this.shouldRedirectToLocation(t)||(this.unsetModel(),this.formGroup=new d([]),this.model=t,this.modelS.next(t))}),l(t=>{throw console.error("Error fetching task",t),t}))}fetchAttachmentsList(e){this.apiService.get(s.attachments.fetchAttachmentsList(e)).subscribe(t=>{this.attachmentsS.next(t)})}fetchConnectionsList(e){return this.apiService.get(s.documents.fetchConnectionsList(e)).pipe(n(t=>{this.connectionsS.next(t)}))}shouldRedirectToTravelOrder(e){return e&&e.workflowVariables!=null&&e.workflowVariables.documentKey&&e.workflowVariables.documentKey.trim()!==""&&e.docTypeSetOf===c.TravelOrder?(this.router.navigate(["/human-resources/travel-order/positions"],{queryParams:{id:e.workflowVariables.documentKey,taskId:e.id}}),!0):!1}shouldRedirectToLocation(e){return e&&e.workflowVariables&&e.workflowVariables.acType==="L"&&(!e.workflowVariables.location||e.workflowVariables.location.trim()==="")&&e.workflowVariables.address&&e.workflowVariables.address.trim()!==""&&e.actions&&e.actions.length===1?(this.router.navigate(["/code-lists/locations"],{queryParams:{mode:"create",address:e.workflowVariables.address,taskId:e.id}}),!0):!1}static{this.\u0275fac=function(t){return new(t||r)(o(a),o(f),o(m))}}static{this.\u0275prov=h({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})();export{E as a};
