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