import{a as I,b as A}from"./chunk-SN34CLEC.js";import{a as v,b as D}from"./chunk-WJY6GDZG.js";import{a as f,b as P}from"./chunk-GKFLU7NZ.js";import{a as p,b as y}from"./chunk-3AUKOF45.js";import{Gb as n,J as o,Sd as g,Tb as u,Vb as m,b as d,ha as r,ia as c,ka as t,na as b,oa as q,r as s,x as l}from"./chunk-XJKQ67XR.js";import{e as S}from"./chunk-SZAW6ZBW.js";var E,C=S(()=>{q();b();y();g();D();A();P();E=(()=>{class a extends p{constructor(e,i,h){super(),this.editService=e,this.crudService=i,this.longOperationIndicatorService=h,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()),o(e=>!!e),c(this.destroyed$)).subscribe(e=>{this.item.id||(this.item.id=e),this.callActionAccept(),this.afterSave()},d,()=>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(l(h=>({request:i,item:h})),t(()=>this.longOperationIndicatorService.hideIndicator()));this.editService.editRequest.pipe(o(i=>i.key===this.key),t(()=>this.longOperationIndicatorService.showIndicator()),r(i=>e(i)),t(i=>this.requestParams=i.request),t(i=>this.item=i.item),t(()=>this.requiredAdministrativePermission=this.editAdministrationPermission),r(()=>this.afterLoad()),r(()=>this.beforeDisplay()),c(this.destroyed$)).subscribe(()=>{this.displayDialog=!!this.item,this.isNew=!1},d,()=>this.longOperationIndicatorService.hideIndicator())}subscribeToCreateRequest(){this.editService.createRequest.pipe(o(e=>e.key===this.key),t(e=>this.requestParams=e),t(e=>this.item=this.crudService.create(e.data)),t(()=>this.requiredAdministrativePermission=this.addAdministrativePermission),r(()=>this.afterCreate()),r(()=>this.beforeDisplay()),c(this.destroyed$)).subscribe(()=>{this.displayDialog=!0,this.isNew=!0})}static{this.\u0275fac=function(i){return new(i||a)(n(v),n(I),n(f))}}static{this.\u0275dir=u({type:a,features:[m]})}}return a})()});export{E as a,C as b};
