import {a,d}from'./chunk-DrpPgge3.js';import {c,p as p$1}from'./chunk-B7_1MEbK.js';import {J,a5 as fh,cI as p,c as tS,b2 as v,cN as g,bI,aJ as hf,aq as Sr,bE as ff,ah as ot,ay as df,w as wo,bc as I,bW as JT,bu as dy}from'./main-WUGO6e7n.js';var B,P=J(()=>{fh();p();tS();a();c();v();B=(()=>{class t extends g{constructor(e,i,o){super(),this.editService=e,this.crudService=i,this.longOperationIndicatorService=o,this.displayDialog=!1,this.editMode=!1;}ngOnInit(){this.subscribeToEditRequest(),this.subscribeToCreateRequest();}save(e){this.saveItem(e);}cancel(){this.callActionCancel();}saveItem(e){this.longOperationIndicatorService.showIndicator(),this.crudService.save(this.item).pipe(bI(()=>this.longOperationIndicatorService.hideIndicator()),hf(()=>this.longOperationIndicatorService.hideIndicator()),Sr(i=>!!i),ff(this.destroyed$)).subscribe(i=>{this.callActionAccept(),e&&e(i);});}callActionAccept(e=!0){this.requestParams&&this.requestParams.accept&&(this.requestParams.accept(),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(o=>({request:i,item:o})),hf(()=>this.longOperationIndicatorService.hideIndicator()));this.editService.editRequest.pipe(Sr(i=>i.key===this.key),hf(()=>this.longOperationIndicatorService.showIndicator()),df(i=>e(i)),ff(this.destroyed$)).subscribe({next:i=>{this.editMode=!0,this.requestParams=i.request,this.item=this.initItem?this.initItem(i.item):i.item,this.displayDialog=!!this.item;},complete:()=>this.longOperationIndicatorService.hideIndicator()});}subscribeToCreateRequest(){this.editService.createRequest.pipe(Sr(e=>e.key===this.key),ff(this.destroyed$)).subscribe(e=>{this.editMode=!1,this.requestParams=e,this.item=this.createEmptyItem(e.data),this.displayDialog=!0;});}static{this.\u0275fac=function(i){return new(i||t)(wo(d),wo(p$1),wo(I))};}static{this.\u0275dir=JT({type:t,features:[dy]});}}return t})();});export{B,P};