import {u,d}from'./chunk-BrIGe1dS.js';import {p as p$1,l}from'./chunk-CIbFTbhP.js';import {J,a5 as fh,a6 as pi,cI as p,c as tS,b2 as v,cN as g,al as Kv,aJ as hf,aq as Sr,bE as ff,dD as Be,ah as ot,ay as df,w as wo,bc as I,bW as JT,bu as dy}from'./main-WUGO6e7n.js';var E,C=J(()=>{fh();pi();p();tS();u();p$1();v();E=(()=>{class a extends g{constructor(e,i,h){super(),this.editService=e,this.crudService=i,this.longOperationIndicatorService=h,this.displayDialog=!1;}afterLoad(){return Kv(null)}afterCreate(){return Kv(null)}afterSave(){return Kv(null)}beforeDisplay(){return Kv(null)}beforeSave(){return Kv(null)}ngOnInit(){this.subscribeToEditRequest(),this.subscribeToCreateRequest();}save(){this.saveItem();}cancel(){this.callActionCancel();}saveItem(){this.longOperationIndicatorService.showIndicator(),this.beforeSave(),this.crudService.save(this.item).pipe(hf(()=>this.longOperationIndicatorService.hideIndicator()),Sr(e=>!!e),ff(this.destroyed$)).subscribe(e=>{this.item.id||(this.item.id=e),this.callActionAccept(),this.afterSave();},Be,()=>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(ot(h=>({request:i,item:h})),hf(()=>this.longOperationIndicatorService.hideIndicator()));this.editService.editRequest.pipe(Sr(i=>i.key===this.key),hf(()=>this.longOperationIndicatorService.showIndicator()),df(i=>e(i)),hf(i=>this.requestParams=i.request),hf(i=>this.item=i.item),hf(()=>this.requiredAdministrativePermission=this.editAdministrationPermission),df(()=>this.afterLoad()),df(()=>this.beforeDisplay()),ff(this.destroyed$)).subscribe(()=>{this.displayDialog=!!this.item,this.isNew=!1;},Be,()=>this.longOperationIndicatorService.hideIndicator());}subscribeToCreateRequest(){this.editService.createRequest.pipe(Sr(e=>e.key===this.key),hf(e=>this.requestParams=e),hf(e=>this.item=this.crudService.create(e.data)),hf(()=>this.requiredAdministrativePermission=this.addAdministrativePermission),df(()=>this.afterCreate()),df(()=>this.beforeDisplay()),ff(this.destroyed$)).subscribe(()=>{this.displayDialog=!0,this.isNew=!0;});}static{this.\u0275fac=function(i){return new(i||a)(wo(d),wo(l),wo(I))};}static{this.\u0275dir=JT({type:a,features:[dy]});}}return a})();});export{C,E};