import{a as w}from"./chunk-CVN2SFTO.js";import{h as k,x as U}from"./chunk-6IEN3EM2.js";import{s as i,t as L,w as p,x}from"./chunk-MY54U2QA.js";import{c as d,d as g}from"./chunk-E7BKRPHP.js";import{k as f}from"./chunk-QVLAHW2O.js";import{e as m,h as T}from"./chunk-2IY7RDIH.js";import{T as h,ka as n,la as S,nd as b,qa as u,v as r,va as l}from"./chunk-PGS4AHIT.js";var o=function(e){return e[e.AllTasks=1]="AllTasks",e[e.AllUnfinishedTasks=2]="AllUnfinishedTasks",e[e.UserTasks=3]="UserTasks",e[e.UnfinishedUserTasks=4]="UnfinishedUserTasks",e}(o||{});var A=function(e){return e.DocType="epDocType",e.FormClassName="epFormClassName",e.WorkFlowControlId="epWorkFlowControlId",e}(A||{}),$=function(e){return e.Documents="TMNDocuments",e.CreateDocument="THECreateDocument",e.dlWF_60="dlWF_60",e.NewVacation="TSifForm_NoviDopust",e}($||{}),C=function(e){return e.Classification="ltMNClassification",e}(C||{}),D=[{value:o.UnfinishedUserTasks,label:"MyUnfinishedTasks"},{value:o.UserTasks,label:"AllMyTasks"},{value:o.AllUnfinishedTasks,label:"AllUnfinishedTasks"},{value:o.AllTasks,label:"AllTasks"}];U();S();g();L();var a=function(e){return e.TravelOrder="S",e}(a||{});b();T();x();var H=(()=>{class e extends w{get model$(){return this._model$}get attachments$(){return this._attachments$}get connections$(){return this._connections$}get chatLog$(){return this._chatLog$}get isEditMode(){return d.isSet(this.model?.id)}constructor(t,s,c){super(),this.http=t,this.apiService=s,this.router=c,this.model=null,this.modelS=new r(1),this._model$=this.modelS.asObservable(),this.attachmentsS=new r(1),this._attachments$=this.attachmentsS.asObservable(),this.connectionsS=new r(1),this._connections$=this.connectionsS.asObservable(),this.chatLogS=new r(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(t){return this.apiService.get(i.tasks.fetch(t)).pipe(n(s=>{this.shouldRedirectToTravelOrder(s)||this.shouldRedirectToLocation(s)||(this.unsetModel(),this.formGroup=new k([]),this.model=s,this.modelS.next(s))}),h(s=>{throw console.error("Error fetching task",s),s}))}fetchChatLogList(t,s,c){return this.apiService.post(i.tasks.fetchChatLogList,{DocumentQid:t,TaskQid:this.model?.id,TakeAll:!0,sortColumn:s,sortOrder:c}).pipe(n(v=>{this.chatLogS.next(v)}))}fetchAttachmentsList(t){this.apiService.get(i.attachments.fetchAttachmentsList(t)).subscribe(s=>{this.attachmentsS.next(s)})}fetchConnectionsList(t){return this.apiService.get(i.documents.fetchConnectionsList(t)).pipe(n(s=>{this.connectionsS.next(s)}))}shouldRedirectToTravelOrder(t){return t&&t.workflowVariables!=null&&t.workflowVariables.documentKey&&t.workflowVariables.documentKey.trim()!==""&&t.docTypeSetOf===a.TravelOrder?(this.router.navigate(["/human-resources/travel-order/positions"],{queryParams:{id:t.workflowVariables.documentKey,taskId:t.id}}),!0):!1}shouldRedirectToLocation(t){return t&&t.workflowVariables&&t.workflowVariables.acType==="L"&&(!t.workflowVariables.location||t.workflowVariables.location.trim()==="")&&t.workflowVariables.address&&t.workflowVariables.address.trim()!==""&&t.actions&&t.actions.length===1?(this.router.navigate(["/code-lists/locations"],{queryParams:{mode:"create",address:t.workflowVariables.address,taskId:t.id}}),!0):!1}static{this.\u0275fac=function(s){return new(s||e)(l(m),l(p),l(f))}}static{this.\u0275prov=u({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})();export{o as a,A as b,$ as c,C as d,D as e,H as f};
