import{a as u,b as oe,c as ne}from"./chunk-PBQQHDVG.js";import"./chunk-EASSPTN4.js";import"./chunk-W2FVLM47.js";import{a as te,b as re,c as D}from"./chunk-F773D3JG.js";import{d as Z}from"./chunk-T4WWCZVS.js";import"./chunk-XGY7YIGY.js";import"./chunk-4F4MHU5U.js";import{b as ee}from"./chunk-YX7USEKK.js";import"./chunk-YZWZ7ZNS.js";import"./chunk-2KVEPR7T.js";import"./chunk-JRRXJXAJ.js";import"./chunk-GSUFMNH2.js";import"./chunk-2EGDUSKA.js";import"./chunk-EEG4B6MW.js";import{b as X}from"./chunk-CXVAGXS5.js";import{b as Y}from"./chunk-EWHWQZ72.js";import{a as K,d as g}from"./chunk-IPTPR2KR.js";import{e as J}from"./chunk-7PXFMVM2.js";import{i as W}from"./chunk-XLLQ6366.js";import{f as Q}from"./chunk-Z5PP2CRF.js";import{d as H}from"./chunk-MANB3PJC.js";import{f as z}from"./chunk-A4FSGNM7.js";import{$ as b,Bd as V,F as M,Qc as x,Rc as O,bd as _,ca as R,dc as E,dd as L,md as G,q as l,sc as A,uc as I,vd as q,zd as B}from"./chunk-CBXQYRPM.js";import{Bc as C,Hc as T,La as i,Qc as w,Rb as j,Rc as U,Tc as P,Z as s,Zc as $,ca as m,da as p,fa as d,g as c,ga as v,k,ka as y,la as f,ob as N}from"./chunk-LVXYIJUI.js";var h=(()=>{class e{constructor(t){this.restService=t}scanContainer(t){return this.restService.get(`${M.CONTAINERS}/idCode:${t}`,null)}processContainer(t){return this.restService.post(`${M.CONTAINERS}/processCheckpointScan`,t)}static{this.\u0275fac=function(r){return new(r||e)(d(H))}}static{this.\u0275prov=m({token:e,factory:e.\u0275fac})}}return e})();var a=(()=>{class e{constructor(t){this.containerCheckpointScanService=t}scanContainer(t){return this.containerCheckpointScanService.scanContainer(t)}processScan(t){return this.containerCheckpointScanService.processContainer(t)}static{this.\u0275fac=function(r){return new(r||e)(d(h))}}static{this.\u0275prov=m({token:e,factory:e.\u0275fac})}}return e})();var F=(()=>{class e{static{this.\u0275fac=function(r){return new(r||e)}}static{this.\u0275mod=f({type:e})}static{this.\u0275inj=p({providers:[h,a],imports:[C]})}}return e})();var ie=(()=>{class e{constructor(t,r,o,n){this.containerScanCardService=t,this.containerCheckpointScanFacade=r,this.toastMessageService=o,this.translateService=n,this.destroySubject=new k}ngAfterViewInit(){this.containerScanCardService.IDCodeScannedSubject$.pipe(s(this.destroySubject)).subscribe(t=>{this.scanContainer(t)})}ngOnDestroy(){this.destroySubject.next(),this.destroySubject.complete()}initializeContainerScanCardInfo(){this.containerScanCardInfo={container:null,errorMessage:null}}scanContainer(t){this.initializeContainerScanCardInfo(),this.containerCheckpointScanFacade.scanContainer(t).pipe(s(this.destroySubject)).subscribe({next:r=>{let o=this.getContainerValidationMessage(r);if(!I.isNullOrUndefined(o)){this.containerScanCardInfo.container=r,this.containerScanCardInfo.errorMessage=o,this.containerScanCardService.setProcessedContainerInfo(this.containerScanCardInfo);return}this.processContainer(r).then(n=>{n&&(this.containerScanCardInfo.container=r,this.containerScanCardService.setProcessedContainerInfo(this.containerScanCardInfo))}).catch(()=>{this.handleError()})},error:()=>{this.handleError()}})}getContainerValidationMessage(t){return I.isNullOrUndefined(t)?this.translateService.instant("MSG_ID_CODE_NOT_FOUND"):t.dateInactive<=A.getCurrentDateAsNumber()?this.translateService.instant("MSG_CONTAINER_DEACTIVATED"):null}processContainer(t){return c(this,null,function*(){return new Promise((r,o)=>{this.containerCheckpointScanFacade.processScan(t).pipe(s(this.destroySubject)).subscribe({next:()=>{r(!0)},error:n=>{o(n)}})})})}handleError(){this.toastMessageService.showToastPanel(G.getErrorDefaultConfig().withMessage(this.translateService.instant("MSG_ERROR_WHILE_SCANNING"))),this.containerScanCardInfo.errorMessage="",this.containerScanCardService.setProcessedContainerInfo(this.containerScanCardInfo)}static{this.\u0275fac=function(r){return new(r||e)(i(u),i(a),i(V),i(U))}}static{this.\u0275cmp=y({type:e,selectors:[["abs-container-checkpoint-scan-frame"]],features:[j([u])],decls:1,vars:0,template:function(r,o){r&1&&N(0,"abs-container-scan-card")},dependencies:[oe],encapsulation:2})}}return e})();var me=[{path:"",pathMatch:"full",component:ie,data:{title:R.Dialogs.ContainerCheckpointScan.title},resolve:{translations:()=>v(g).resolve(l.CONTAINER_SCAN_CARD),uniqueIDConfigurations:()=>c(void 0,null,function*(){return v(D).resolve([b.CONTAINER])})}}];function pe(e,ae){return new K(e,[{prefix:l.GENERAL,suffix:".json"},{prefix:l.CONTAINER_SCAN_CARD,suffix:".json"}],ae)}var de=(()=>{class e{static{this.\u0275fac=function(r){return new(r||e)}}static{this.\u0275mod=f({type:e})}static{this.\u0275inj=p({providers:[g,D,re],imports:[C,Q,B,_,q,Y,x,O,W,J,E,L,X,Z,te,ee,F,ne,$.forChild(me),P.forChild({loader:{provide:w,useFactory:pe,deps:[T,z]},isolate:!0})]})}}return e})();export{de as DeliveryContainerCheckpointScanFeatureModule};
