import{a as n,c as C,f as L,g as U,h as b}from"./chunk-LJRETJNY.js";import{a as f}from"./chunk-SQTC4ZEW.js";import{Ea as D,ya as h}from"./chunk-TV2MZFBF.js";import{b as S,d as E}from"./chunk-R5GBW5HQ.js";import{S as u,a as m,pd as l,va as d,za as s}from"./chunk-3NIPUOIR.js";var T=(()=>{class t{constructor(){this.commonHttpErrorService=s(S),this.httpClient=s(l)}getDocumentStatuss(){return this.httpClient.get("document-status").pipe(u(this.commonHttpErrorService.handleError))}getDocumentStatusById(e){let r=`document-status/${e}`;return this.httpClient.get(r).pipe(u(this.commonHttpErrorService.handleError))}addDocumentStatus(e){return this.httpClient.post("documentStatus",e).pipe(u(this.commonHttpErrorService.handleError))}updateDocumentStatus(e){let r=`document-status/${e.id}`;return this.httpClient.put(r,e).pipe(u(this.commonHttpErrorService.handleError))}deleteDocumentStatus(e){let r=`document-status/${e}`;return this.httpClient.delete(r).pipe(u(this.commonHttpErrorService.handleError))}static{this.\u0275fac=function(r){return new(r||t)}}static{this.\u0275prov=d({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();var g={statusList:[],loadList:!0,isAddorUpdate:!1,curruntStatus:{id:"",name:"",description:"",colorCode:""}},Y=C({providedIn:"root"},b(g),U((t,i=s(T),e=s(h),r=s(D))=>({loadDocumentStatus(){i.getDocumentStatuss().subscribe({next:o=>{n(t,{statusList:[...o],loadList:!1})}})},addDocumentStatus(o){i.addDocumentStatus(o).subscribe({next:c=>{let a=c;a&&(n(t,{curruntStatus:m({},a),isAddorUpdate:!0,loadList:!0}),e.success(r.getValue("DOCUMENT_STATUS_CREATED_SUCCESSFULLY")))}})},updateDocumentStatus(o){i.updateDocumentStatus(o).subscribe({next:c=>{n(t,{curruntStatus:m({},c),isAddorUpdate:!0,statusList:t.statusList().map(p=>o.id===p.id?o:p)}),e.success(r.getValue("DOCUMENT_STATUS_UPDATED_SUCCESSFULLY"))}})},deleteDocumentStatus(o){i.deleteDocumentStatus(o).subscribe({next:()=>{n(t,{loadList:!0}),e.success(r.getValue("DOCUMENT_STATUS_DELETED_SUCCESSFULLY"))}})},resetFlag(){n(t,{isAddorUpdate:!1})}})),L({onInit(t,i=s(E)){f(t.loadList).subscribe(e=>{e&&t.loadDocumentStatus()}),i.isLogin()&&t.loadDocumentStatus()}}));export{T as a,Y as b};
