import{c as oe,f as pe,i as ce}from"./chunk-Z53IJKVA.js";import{a as de}from"./chunk-JNU67AVD.js";import{a as ie}from"./chunk-Z4NKQXFV.js";import{b as ae,e as Q}from"./chunk-ZFWLWLFX.js";import{c as bt,f as Rt,i as Dt,k as Ut,l as kt}from"./chunk-UDYE5SGF.js";import{c as zt,g as Ht,i as Jt,n as q,o as Kt,p as B,q as L,r as Wt,s as V}from"./chunk-VIRBXNP6.js";import{b as ne}from"./chunk-SMNAC7CE.js";import{m as Mt}from"./chunk-NP5JJVSS.js";import{p as Nt}from"./chunk-ENQ3ITDB.js";import{i as gt,o as $t,r as Tt,u as Ot,y as wt}from"./chunk-2O6BQYSU.js";import{$ as Gt,P as Ft,S as jt,V as xt,ca as Qt,f as qt,j as Bt,r as Lt,z as Vt}from"./chunk-UWN6FDIC.js";import{B as C,e as F,g as Xt,m as Yt,o as Zt,r as _t,t as te,u as ee,v as re,w as j,x,y as G,z as m}from"./chunk-MIOHNJCY.js";import{f as vt}from"./chunk-C2VXQ6L5.js";import{o as se}from"./chunk-MFSGKODO.js";import{Aa as k,Fa as yt,G as ct,Ga as Ct,Oa as Pt,S as dt,Sa as St,X as ut,Z as mt,a as pt,aa as lt,oa as ft,pa as ht}from"./chunk-73GUXIT2.js";import{B as ot,C as nt,D as h,E as y,a as P,b as Z,c as _,d as S,e as w,f as tt,g as et,h as v,i as rt,j as E,k as N,l as it,n,o as A,p as I,q as g,s as M,t as b,u as st,v as R,x as D,y as at,z as U}from"./chunk-HRYIRC5N.js";import{b as At,s as It}from"./chunk-C2EV7IAO.js";import{b as r,c as Et,d as i}from"./chunk-GXS7C5SQ.js";import{s as Y}from"./chunk-ALDBR463.js";import{k as X}from"./chunk-FRH63NMA.js";import{Ba as l,F as u,Ia as K,K as o,Na as f,Oa as W,R as H,V as J,Z as c,da as O,ya as a}from"./chunk-V6BPA3D7.js";var fe=()=>t=>t.data&&t.data.clearCart&&!t.errors?[tt()]:t.errors?[w({errors:t.errors})]:[w({errors:[new Error("handleClearCartResponse communication error")]}),n({failedAction:S.type})],he=t=>t.data&&!t.errors?E():t.errors?rt({errors:t.errors}):n({failedAction:v.type}),ye=t=>{if(t?.errors?.length)return u(Z({errors:t.errors}));if(t?.data?.cartV2){let s=[_({cart:t.data.cartV2}),Zt({quantity:pt(t?.data?.cartV2)})];return u(...s)}return u(n({failedAction:P.type}))},Ce=t=>t.data&&t.data.setTelewebInfo&&!t.errors?U():t.errors?at({errors:t.errors}):n({failedAction:D.type}),Pe=t=>s=>s.data&&s.data.setOtyConsumption&&!s.errors?g({oty:t}):s.errors?I({errors:s.errors}):n({failedAction:A.type}),Se=t=>t.data&&t.data.setPayment&&!t.errors?R():t.errors?st({errors:t.errors}):n({failedAction:b.type}),d=t=>s=>u(n({failedAction:t.type,error:s})),Ae=()=>t=>t.data&&t.data.generateNewAddressOTP&&!t.errors?B({data:t.data}):t.data&&t.errors?Kt({errors:t.errors}):n({failedAction:q.type}),Ie=()=>t=>t.data&&t.data.verifyNewAddressOTP&&!t.errors?V({data:t.data}):t.data&&t.errors?Wt({errors:t.errors}):n({failedAction:L.type}),ge=t=>s=>s.data&&s.data.updatePpy2PpdMsisdn&&!s.errors?m.updatePpy2PpdMsisdnSuccess({msisdn:t}):s.data&&s.errors?m.updatePpy2PpdMsisdnError({errors:s.errors}):n({failedAction:m.updatePpy2PpdMsisdn.type}),$e=t=>s=>s.data&&s.data.updatePpy2PpdMsisdn&&!s.errors?C.updatePpyPrepayMsisdnSuccess({msisdn:t}):s.data&&s.errors?C.updatePpyPrepayMsisdnError({errors:s.errors}):n({failedAction:C.updatePpyPrepayMsisdn.type}),rr=(()=>{class t{constructor(z,$,ue,me,le){this.actions$=z,this.cartApolloClient=$,this.router=ue,this.store=me,this.snackBar=le,this.otpService=W(de),this.dismissNotification$=r(()=>this.actions$.pipe(i(v)).pipe(a(e=>this.cartApolloClient.mutate({mutation:ut,variables:{notifications:[{notificationId:e.notification.id,cartItemId:e.notification.itemRef&&e.notification.itemRef.itemId}]}}).pipe(o(he))))),this.eShopCartChange$=r(()=>H(window,"message").pipe(J(e=>e.data==="eShopCartChange")).pipe(O(N()))),this.getCart$=r(()=>this.actions$.pipe(i(P),a(e=>this.cartApolloClient.query({query:mt}).pipe(a(ye)).pipe(c(d(e)))))),this.logCommunicationError$=r(()=>this.actions$.pipe(i(n),l(console.error)),{dispatch:!1}),this.reloadCart$=r(()=>this.actions$.pipe(i(F,Nt,bt,pe,ce,Dt,oe,Rt,E,N,zt,Jt,_t,g,R,kt,U,It,Lt,xt,Bt,gt,$t,Tt,Ot,B,V,h.updateInstallmentPeriodSuccess,h.updateInstallmentPeriodError,j.updateSimOptionSuccess,j.updateSimOptionError,x.updatePrepayProductTypeSuccess,x.updatePrepayProductTypeError,G.updateSubscriptionTypeSuccess,m.updatePpy2PpdMsisdnSuccess,Gt,Qt,Vt,wt),a(e=>e.type===F.type&&e.triggerGetCart===!1?[y.getItemIds()]:[P(),Mt()]))),this.updateCartStateFromResponse=r(()=>this.actions$.pipe(i(ee,Xt,Yt),o(e=>e.cart?re({cart:e.cart}):se()))),this.reloadCartFromLocalStore$=r(()=>this.actions$.pipe(i(I,Ut,te),o(()=>it()))),this.reloadCartOnProfileChange$=r(()=>this.actions$.pipe(i(At)).pipe(O(et()))),this.resetCart$=r(()=>this.actions$.pipe(i(S)).pipe(a(()=>this.cartApolloClient.mutate({mutation:dt}))).pipe(a(fe())).pipe(c(()=>u(n({failedAction:S.type}))))),this.setCartImpersonation$=r(()=>this.actions$.pipe(i(D),a(e=>this.cartApolloClient.mutate({mutation:Pt,variables:{teleweb:{callType:e.callType,userType:e.userType}}}).pipe(o(Ce)).pipe(c(d(e)))))),this.updateInstallmentPeriod$=r(()=>this.actions$.pipe(i(h.updateInstallmentPeriod),a(e=>this.cartApolloClient.mutate({mutation:St,variables:{term:e.period}}).pipe(o(p=>p.data?h.updateInstallmentPeriodSuccess():h.updateInstallmentPeriodError()),c(d(e)))))),this.setOtyConsumption$=r(()=>this.actions$.pipe(i(A),a(e=>this.cartApolloClient.mutate({mutation:yt,variables:{value:e.oty,unit:ct.Fix}}).pipe(o(Pe(e.oty))).pipe(c(d(e)))))),this.setOtyConsumptionError$=r(()=>this.actions$.pipe(i(I),o(e=>e.errors.find(p=>p.message.toLowerCase().trim()==="Value provided for oty consumption thresholds:1 exceeds maximum allowed oty points: 0".toLowerCase().trim())?A({oty:0}):ie()))),this.setOtyConsumptionSuccess$=r(()=>this.actions$.pipe(i(g),l(e=>{e?.oty>=1&&this.store.dispatch(M())})),{dispatch:!1}),this.openShowUseOtyMessageNotification$=r(()=>this.actions$.pipe(i(M),l(()=>{this.snackBar.open("Valoarea punctelor a fost sc\u0103zut\u0103 din totalul de plat\u0103.","x",{horizontalPosition:"center",verticalPosition:"top",duration:5e3})})),{dispatch:!1}),this.setPayment$=r(()=>this.actions$.pipe(i(b),a(e=>this.cartApolloClient.mutate({mutation:Ct,variables:{method:e.method,parameters:e.parameters||[]}}).pipe(o(Se)).pipe(c(d(e)))))),this.setTab$=r(()=>this.actions$.pipe(i(ot,nt),a(e=>u(Ht({shippingTypeSelection:e.shippingTypeSelection}))))),this.generateNewAddressOTP$=r(()=>this.actions$.pipe(i(q),a(e=>this.cartApolloClient.mutate({mutation:ft}).pipe(o(Ae())).pipe(c(d(e)))))),this.verifyNewAddressOTP$=r(()=>this.actions$.pipe(i(L),a(e=>{let p={code:e.code};return e.forced&&(p.forced=e.forced),this.cartApolloClient.mutate({mutation:ht,variables:p}).pipe(o(Ie())).pipe(c(d(e)))}))),this.updatePpy2PpdNotLoggedMsisdn$=r(()=>this.actions$.pipe(i(m.updatePpy2PpdMsisdn),a(e=>this.cartApolloClient.mutate({mutation:k,variables:{msisdn:e.msisdn}}).pipe(o(ge(e.msisdn))).pipe(c(d(e)))))),this.updatePpyPrepayMsisdn$=r(()=>this.actions$.pipe(i(C.updatePpyPrepayMsisdn),a(e=>this.cartApolloClient.mutate({mutation:k,variables:{msisdn:e.msisdn}}).pipe(o($e(e.msisdn))).pipe(c(d(e)))))),this.getUnofferedCartItemIds$=r(()=>this.actions$.pipe(i(y.getItemIds,Q),a(e=>e.type===Q.type&&e.recommendationsRequest.type!==ae.BoughtTogether?u():this.cartApolloClient.query({query:lt}).pipe(o(p=>p.data&&p.data.unofferedCart&&p.data.unofferedCart.__typename!=="EmptyCartResource"?y.getItemIdsSuccess({ids:p.data.unofferedCart.items.filter(T=>!!T?.product?.id).map(T=>T?.product?.id)}):y.getItemIdsError()))))),this.startOTPCountDown$=r(()=>this.actions$.pipe(i(jt,Ft,qt),l(()=>{this.otpService.startCountDown(60)})),{dispatch:!1}),this.clearOTPInterval$=r(()=>this.actions$.pipe(i(G.updateSubscriptionTypeSuccess,m.updatePpy2PpdMsisdnSuccess),l(()=>{this.otpService.clearInterval()})),{dispatch:!1})}static{this.\u0275fac=function($){return new($||t)(f(Et),f(ne),f(X),f(Y),f(vt))}}static{this.\u0275prov=K({token:t,factory:t.\u0275fac})}}return t})();export{d as a,rr as b};