import{a as I,b as O}from"./chunk-KFLE3FIT.js";import{a as f,b as P}from"./chunk-BZFDENKG.js";import{a as v,b}from"./chunk-MOK7XOAA.js";import{a as u,b as y}from"./chunk-QGVT6DPT.js";import{J as s,Jb as c,Sa as g,Sb as p,Ub as m,X as d,be as q,ha as l,ia as r,ka as a,x as h}from"./chunk-WL5U2YIT.js";import{e as S}from"./chunk-ADEKKGI2.js";var M,D=S(()=>{g();y();q();O();P();b();M=(()=>{let t=class t extends u{constructor(i,e,n){super(),this.editService=i,this.crudService=e,this.longOperationIndicatorService=n,this.displayDialog=!1,this.editMode=!1}ngOnInit(){this.subscribeToEditRequest(),this.subscribeToCreateRequest()}save(i){this.saveItem(i)}cancel(){this.callActionCancel()}saveItem(i){this.longOperationIndicatorService.showIndicator(),this.crudService.save(this.item).pipe(d(()=>this.longOperationIndicatorService.hideIndicator()),a(()=>this.longOperationIndicatorService.hideIndicator()),s(e=>!!e),r(this.destroyed$)).subscribe(e=>{this.callActionAccept(),i&&i(e)})}callActionAccept(i=!0){this.requestParams&&this.requestParams.accept&&(this.requestParams.accept(),this.requestParams=null),i&&(this.displayDialog=!1)}callActionCancel(i=!0){this.requestParams&&this.requestParams.cancel&&(this.requestParams.cancel(),this.requestParams=null),i&&(this.displayDialog=!1)}subscribeToEditRequest(){let i=e=>this.crudService.get(e.id).pipe(h(n=>({request:e,item:n})),a(()=>this.longOperationIndicatorService.hideIndicator()));this.editService.editRequest.pipe(s(e=>e.key===this.key),a(()=>this.longOperationIndicatorService.showIndicator()),l(e=>i(e)),r(this.destroyed$)).subscribe({next:e=>{this.editMode=!0,this.requestParams=e.request,this.item=this.initItem?this.initItem(e.item):e.item,this.displayDialog=!!this.item},complete:()=>this.longOperationIndicatorService.hideIndicator()})}subscribeToCreateRequest(){this.editService.createRequest.pipe(s(i=>i.key===this.key),r(this.destroyed$)).subscribe(i=>{this.editMode=!1,this.requestParams=i,this.item=this.createEmptyItem(i.data),this.displayDialog=!0})}};t.\u0275fac=function(e){return new(e||t)(c(I),c(f),c(v))},t.\u0275dir=p({type:t,features:[m]});let o=t;return o})()});export{M as a,D as b};
