import{c as Y,p as S}from"./chunk-ZCZZRJKG.js";import{h as K}from"./chunk-LMJZWCTS.js";import{A as n,B as z,G as y,Sa as W,d as r,e as f,n as G,o as A,p as x,r as L,s as N,t as M,u as U,v as _,w as j,x as w}from"./chunk-E2DT4ALR.js";import{Tc as b,Va as T,ca as d,da as P,ga as c,t as v,u as $}from"./chunk-MUCMJBU7.js";import{a as s,b as l}from"./chunk-B4AJQJMI.js";var m=r("[Notifica\xE7\xF5es/API] Get Notifica\xE7\xF5es"),h=r("[Notifica\xE7\xF5es/API] Get Notifica\xE7\xF5es Success",f()),g=r("[Notifica\xE7\xF5es/API] Get Notifica\xE7\xF5es Failure",f()),F=r("[Notifica\xE7\xF5es/API] Set Notification Read",f()),E=r("[Notifica\xE7\xF5es/API] Set Notification Read Success",f()),k=r("[Notifica\xE7\xF5es/API] Set Notification Read Failure",f());var I="notificacao",u=W(),X=u.getInitialState({data:null,error:null,status:n.PENDING}),Z=M(X,N(m,i=>l(s({},i),{status:n.LOADING,error:null})),N(h,(i,{notificacoes:o})=>u.setAll(o,l(s({},i),{status:n.SUCCESS,error:null}))),N(g,(i,{error:o})=>l(s({},i),{status:n.ERROR,error:o})),N(E,(i,{id:o})=>{let t=i.entities[o];if(t){let e=s({},t.cliente_notificacoes[0]);return e.visualizada=!0,u.updateOne({id:o,changes:{cliente_notificacoes:[e]}},i)}return l(s({},i),{status:n.SUCCESS,error:null})}));function D(i,o){return Z(i,o)}var{selectAll:ti}=u.getSelectors(),O=class extends z{constructor(){super(I),this.getNotificacoesArray=()=>x(this.createFeatureSelector,o=>ti(o)),this.getQuantidadeNaoLidas=()=>x(this.getNotificacoesArray(),o=>o.filter(t=>t.cliente_notificacoes.length&&!t.cliente_notificacoes[0].visualizada).length)}},R=new O;var V=(()=>{class i{constructor(t,e){this.store=t,this.notificationUtilsService=e,this.notificacoes$=this.store.pipe(A(R.getNotificacoesArray())),this.loading$=this.store.pipe(A(R.isLoading())),this.quantidadeNaoLidas$=this.store.pipe(A(R.getQuantidadeNaoLidas()))}getNotificacoes(){this.store.dispatch(m())}abrirPaginaNotificacao(t){this.notificationUtilsService.performAction(t)}registrarNotificacaoVisualizada(t){this.store.dispatch(F({id:t}))}static{this.\u0275fac=function(e){return new(e||i)(c(G),c(S))}}static{this.\u0275prov=d({token:i,factory:i.\u0275fac})}}return i})();var q=(()=>{class i{constructor(t,e,B,H){this.actions$=t,this.filialFacade=e,this.notificacaoWsService=B,this.notificationUtilsService=H,this.getNotificacoesEffect$=U(()=>this.actions$.pipe(j(m),a=>$([a,this.filialFacade.filial$]),y({run:(a,p)=>this.notificacaoWsService.getNotificacoes(p.id).pipe(v(J=>h({notificacoes:J.notificacoes}))),onError:(a,p)=>g({error:p})}))),this.registrarNotificacaoVisualizada$=U(()=>this.actions$.pipe(j(F),y({run:a=>this.notificationUtilsService.setNotificationRead(a.id).pipe(v(()=>E({id:a.id}))),onError:(a,p)=>k({error:p})})))}static{this.\u0275fac=function(e){return new(e||i)(c(_),c(K),c(Y),c(S))}}static{this.\u0275prov=d({token:i,factory:i.\u0275fac})}}return i})();var wi=(()=>{class i{static{this.\u0275fac=function(e){return new(e||i)}}static{this.\u0275mod=T({type:i})}static{this.\u0275inj=P({providers:[V],imports:[b,L.forFeature(I,D),w.forFeature([q])]})}}return i})();export{V as a,wi as b};