import{a as v}from"./chunk-CVN2SFTO.js";import{h as m,y}from"./chunk-PZHJ5CIW.js";import{s,t as b,w as D,x as f}from"./chunk-BRJ3RGGT.js";import{c as u,d as w}from"./chunk-E7BKRPHP.js";import{A as p,a as r,b as h,ka as a,la as I,nd as g,q as d,qa as l,v as i,va as S}from"./chunk-PGS4AHIT.js";y();I();w();b();g();f();var C=(()=>{class c extends v{get model$(){return this._model$}get attachments$(){return this._attachments$}get connections$(){return this._connections$}get isEditMode(){return u.isSet(this.model?.id)}constructor(e){super(),this.apiService=e,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.selectedDocuments=[]}unset(){this.formGroup=void 0}unsetModel(){this.model=null,this.modelS.next(null),this.attachmentsS.next(null),this.connectionsS.next(null)}fetch(e){return this.apiService.get(s.documents.fetch(e)).pipe(a(t=>{this.unsetModel(),this.formGroup=new m([]),this.model=t,this.modelS.next(t)}))}fetchList(e){return this.apiService.post(s.documents.fetchList,{Keywords:e&&e.search?e.search:"",SubjectId:e&&e.subjectId?e.subjectId:"",Doctypes:e.docTypes,Statuses:e.statuses,Classifications:e.classifications,Users:e.users,Departments:e.departments,CostDrvs:e.costDrvs,DateFrom:e.dateFrom?e.dateFrom:null,DateTo:e.dateTo?e.dateTo:null,TakeAll:!1,Start:e.start,Length:e.length,SortColumn:e.sortColumn,SortOrder:e.sortOrder,ShowDeleted:!!(e&&e.showDeleted==!0),Id:e.id?e.id:null,Note:e.note?e.note:null,RefNo:e.refNo?e.refNo:null,MailBoxId:e.mailBoxId?e.mailBoxId:null,StorageId:e.storageId?e.storageId:null,GUID:e.guid?e.guid:null})}deleteDocuments(e){let t=this.selectedDocuments.map(n=>n.anDocumentQId);return this.apiService.post(s.documents.deleteDocuments,{Ids:t,IsDeleted:e})}permanentDeleteDocuments(){let e=this.selectedDocuments.map(t=>t.anDocumentQId);return this.apiService.post(s.documents.permanentDeleteDocuments,{Ids:e})}deleteDocument(e){return this.apiService.post(s.documents.deleteDocuments,{Ids:[e],IsDeleted:!0})}fetchNeighour(e,t,n=!0){return this.apiService.get(s.documents.fetchNeighour+`${u.qparams({acKey:e,docType:t,isPrevious:n})}`).pipe(a(o=>{this.formGroup=new m([]),this.model=o,this.modelS.next(o)}))}fetchConnectionsList(){return this.model?.acKey?this.apiService.get(s.documents.fetchConnectionsList(this.model.acKey)).pipe(a(e=>{this.connectionsS.next(e)})):(this.connectionsS.next(null),p())}fetchAttachmentsList(e){this.apiService.get(s.attachments.fetchAttachmentsList(e)).subscribe(t=>{this.attachmentsS.next(t)})}getFileByteArray(e){return new d(t=>{let n=new FileReader;n.readAsArrayBuffer(e),n.onload=()=>{let o=n.result;t.next(new Uint8Array(o)),t.complete()},n.onerror=()=>{console.log("Error reading file")}})}runDocumentWorkflow(e,t){return console.log(this.selectedDocuments),this.apiService.post(s.documents.runDocumentWorkflow,{DocumentId:t,WorkflowId:e,Items:t?null:this.selectedDocuments})}fetchDocumentWorkflows(e){return this.apiService.post(s.documents.fetchDocumentWorkflows,{FormName:"MNDocuments%",FormName2:"PAW",WizardType:e})}fetchAvailableDocumentLinks(e){return this.apiService.get(s.documents.fetchAvailableDocumentLinks(e))}addNewDocumentConnection(e,t){return this.apiService.post(s.documents.addNewDocumentConnection,{DocumentQid:e,AcKey:t.acKey,FormName:"PAW_Documentation"})}saveForm(e){return this.apiService.put(s.documents.saveForm,r({},e))}create(e,t){let n=t??this.model;var o=h(r({},n),{Files:e});return this.apiService.post(s.documents.create,r({},o))}static{this.\u0275fac=function(t){return new(t||c)(S(D))}}static{this.\u0275prov=l({token:c,factory:c.\u0275fac,providedIn:"root"})}}return c})();export{C as a};
