import{a as Ct,b as xt,c as vt,d as Fe,g as yt,k as St,l as At,m as Lt,n as Ot,q as bt}from"./chunk-HNDR6KRA.js";import{a as Te}from"./chunk-ZAGW7ZY2.js";import{a as $t}from"./chunk-5XWSR7MO.js";import{d as lt}from"./chunk-CA5IAOZB.js";import{a as It}from"./chunk-O3P4S4W4.js";import{b as Bt}from"./chunk-F3N5PU5V.js";import{b as Rt}from"./chunk-GIYE4OKL.js";import{c as ct,d as pt,e as ut}from"./chunk-ZWOB5ADW.js";import{c as mt,e as ht,g as _t,n as ft}from"./chunk-XI2EB733.js";import{Cb as Ie,E as Le,Eb as P,I as Je,Pb as it,Rb as ot,Vb as rt,Xa as le,h as H,ib as Oe,jb as be,nb as Qe,tb as et,u as Ze,ub as tt}from"./chunk-GYYYM227.js";import{E as kt,F as Mt,c as Tt,e as x,h as wt,i as Pt,j as Et,l as G,n as Dt,r as Vt,t as Nt}from"./chunk-IWEPXOJK.js";import{a as nt}from"./chunk-Y77T26QU.js";import{V as dt}from"./chunk-YFWLORNM.js";import{c as gt,d as J}from"./chunk-XA6AU52H.js";import{g as ye,i as Se,k as Ye,m as Ae,o as ce}from"./chunk-DAYGRJHR.js";import{h as Z,k as pe,n as st,q as at}from"./chunk-767ZUJWF.js";import{D as O,d as c,e as p,s as Ke,v as m,w as je}from"./chunk-VYUKN3XQ.js";import{c as Xe}from"./chunk-AYHVL37M.js";import{h as de}from"./chunk-KXVCY5JT.js";import{v as He}from"./chunk-VTET4O2Q.js";import{a as Ft}from"./chunk-UF7XRCGB.js";import{Cc as w,Da as te,Ea as ie,Ec as re,Fc as ne,Ga as Be,Gc as se,Hc as g,Ic as h,Jc as We,K as ee,Na as oe,Nc as ae,P as S,Q as X,Sa as R,Tb as Ue,Tc as U,Vb as A,Vc as F,Wb as $,Y as ke,Z as ge,_ as M,_a as Re,a as u,b as f,ca as Me,fd as _,ga as W,gc as Ce,hc as Ge,hd as xe,ia as K,id as ve,jb as z,kb as q,ma as B,od as ze,pc as L,sd as qe,t as fe,tb as $e,u as T,v as Ne,vc as Y,wd as D,xd as V,za as j}from"./chunk-XNQ3RS5P.js";var Ti=c("[Locations] Search Fixed Locations",p()),wi=c("[Locations] Search Fixed Locations [Success]",p()),Pi=c("[Locations] Search Fixed Locations [Error]",p()),Ei=c("[Locations] Get Fixed Location",p()),Di=c("[Locations] Get Fixed Location [Success]",p()),Vi=c("[Locations] Get Fixed Location [Error]",p()),Ni=c("[Location] Remove Search Fixed Locations"),ki=c("[Location] Update Filter Input",p()),Mi=c("[Location] Clear Filter Input"),Ut=c("[Locations] Get Counties",p()),Bi=c("[Locations] Get Counties Success",p()),Ri=c("[Locations] Get Counties Error",p()),$i=c("[Locations] Get Localities",p()),Ui=c("[Locations] Get Localities Success",p()),Gi=c("[Locations] Get Localities Error",p()),Wi=c("[Locations] Remove localities"),zi=c("[Locations] Set Location Marker",p()),qi=c("[Locations] Set Location from map",p()),Hi=c("[Locations] Set Location from cart",p()),Xi=c("[Location] Set Location skeletons",p()),Ki=c("[Location] Set favorite Location",p()),ji=c("[Location] Set favorite Location Success",p()),Yi=c("[Location] Set favorite Location Error",p()),we=c("[Location] Get favorite or last used Location"),Zi=c("[Location] Get favorite or last used Location Success",p()),Ji=c("[Location] Get favorite or last used Location Error",p()),Qi=c("[Location] Set County input",p()),eo=c("[Location] Set Locality input",p()),to=c("[Location] Clear Address inputs");function Gt(t){let i=u({},t);return delete i.__typename,delete i.allowsDropOff,delete i.supportedPaymentType,delete i.schedule,delete i.restrictions,delete i.isFavorite,st(i)?null:i}var v=je("locations"),uo=m(v,t=>{var i;return(i=t.searchedFixedLocations)==null?void 0:i.data}),mo=m(v,t=>t.searchedFixedLocations.status),ho=m(v,t=>{var i;return(i=t.searchedFixedLocations)==null?void 0:i.request}),_o=m(v,t=>{var i;return(i=t.fixedLocation)==null?void 0:i.data}),fo=m(v,t=>t.filterInput),go=t=>({selector:v,action:()=>Ut({countryCode:t}),map:i=>{var n;return(n=i.counties)==null?void 0:n.data},shouldDispatch:i=>i.counties.status===O.initial}),Co=m(v,t=>{var i;return(i=t.localities)==null?void 0:i.data}),xo=m(v,t=>t.locationMarker),vo=m(v,t=>t==null?void 0:t.selectedLocation),yo=m(v,t=>t.showSkeletons),So=()=>({selector:m(v,ye,(t,i)=>[t,i]),action:()=>we(),map:([t])=>t.favoriteOrLastUsedLocation,shouldDispatch:([t,i])=>i&&t.favoriteOrLastUsedLocation.status===O.initial}),Ao=()=>({selector:m(v,ye,(t,i)=>[t,i]),action:()=>we(),map:([t])=>{var i;return(i=t.favoriteOrLastUsedLocation)==null?void 0:i.data},shouldDispatch:([t,i])=>i&&t.favoriteOrLastUsedLocation.status===O.initial}),Lo=m(v,t=>t.favoriteOrLastUsedLocation.status),Oo=m(v,t=>{var i;return(i=t.favoriteOrLastUsedLocation)==null?void 0:i.data}),bo=m(v,t=>{var i;return!!((i=t.favoriteOrLastUsedLocation)!=null&&i.data||t.selectedLocation)}),Io=m(v,t=>{var i;return t.selectedLocation?t.selectedLocation:Gt((i=t.favoriteOrLastUsedLocation)==null?void 0:i.data)}),Fo=m(v,t=>t.selectedLocation||void 0),To=m(v,t=>t.countyInput),wo=m(v,t=>t.localityInput);var Mo=f(u({},P),{map(t){var i,n,e;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((e=(n=t==null?void 0:t.cart)==null?void 0:n.actions)==null?void 0:e.includes(H.SetBilling))}}),Pe=f(u({},P),{map(t){var i,n,e;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((e=(n=t==null?void 0:t.cart)==null?void 0:n.actions)==null?void 0:e.includes(H.SetBilling))}}),Wt=f(u({},P),{map(t){var i,n,e,o,s;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&(((e=(n=t==null?void 0:t.cart)==null?void 0:n.actions)==null?void 0:e.includes(H.SetBilling))||((s=(o=t==null?void 0:t.cart)==null?void 0:o.actions)==null?void 0:s.includes(H.SetBillingParty)))}}),Bo=f(u({},P),{map(t){var i,n,e;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((e=(n=t==null?void 0:t.cart)==null?void 0:n.actions)==null?void 0:e.includes(H.SetShipping))}}),ue=f(u({},P),{map:t=>{var i,n;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"?Te.fromCartBillingAddressToAddressRelation((n=t.cart)==null?void 0:n.billing):void 0}}),me=f(u({},P),{map:t=>{var i,n;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=t.cart)!=null&&n.shipping)?Te.fromCartShippingAddressToAddressRelation(t.cart.shipping):void 0},filter:t=>t.status===O.success||t.status===O.error}),Ro=f(u({},P),{map:t=>{var i,n;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=t.cart.shipping)!=null&&n.shippingType)?t.cart.shipping.shippingType:void 0}}),zt=f(u({},P),{map:t=>t.newClientAcquisition.generateNewAddressOTP}),Q=f(u({},P),{map:t=>t.newClientAcquisition.verifyNewAddressOTP}),$o=f(u({},P),{map:t=>{var i;return!!(((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&t.cart.isEligibleForLockers)}}),Uo=m(Ie,t=>{var i,n;return!(((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=t.cart.shipping)!=null&&n.shippingType.fixedLocation))}),Go=m(Ie,t=>{var i;if(((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource")return t.shippingAddressSource});var he=function(t){return t[t.CUSTOMER=0]="CUSTOMER",t[t.FIXED_LOCATION=1]="FIXED_LOCATION",t[t.PICKUP_IN_STORE=2]="PICKUP_IN_STORE",t}(he||{}),_e=function(t){return t.CUSTOMER="customer",t.FIXED_LOCATION="fixed-location",t.PICKUP_IN_STORE="pickup-in-store",t}(_e||{}),qo={[_e.CUSTOMER]:he.CUSTOMER,[_e.FIXED_LOCATION]:he.FIXED_LOCATION,[_e.PICKUP_IN_STORE]:he.PICKUP_IN_STORE},Ee=function(t){return t.validationErrors="validationErrors",t.maxOtpCodesVerificationAttempts="maxOtpCodesVerificationAttempts",t}(Ee||{}),De=function(t){return t.validationErrors="validationErrors",t.maxOtpCodesGenerationAttempts="maxOtpCodesGenerationAttempts",t.invalidOtpCode="invalidOtpCode",t}(De||{});var Ht=(()=>{let i=class i{constructor(e){this.httpClient=e,this.isDev=document.location.href.indexOf("localhost")>-1||document.location.href.indexOf("dev")>-1||document.location.href.indexOf("dev3")>-1,this.toggleUrl=this.isDev?"https://www-dev.orange.ro/webshopportlets/api/trafic-to-eshop":"https://www.orange.ro/webshopportlets/api/trafic-to-eshop"}isTrafficToNewShop(){return this.cache$||(this.cache$=this.httpClient.get(this.toggleUrl).pipe(j(1))),this.cache$}checkIfIsDev(){return ee(this.isDev)}};i.\u0275fac=function(o){return new(o||i)(R(de))},i.\u0275prov=oe({token:i,factory:i.\u0275fac,providedIn:"root"});let t=i;return t})();var ei=(t,i,n)=>({cartStatus:t,generateNewAddressOTP:i,verifyNewAddressOTP:n});function ti(t,i){t&1&&(g(0,"strong"),_(1),h()),t&2&&(A(),xe(" ",i,". "))}function ii(t,i){t&1&&We(0,"oro-skeleton-loader-line",16)}function oi(t,i){if(t&1){let n=ae();g(0,"input",17),U("keyup",function(o){let s=z(n).$implicit,a=F(2);return q(a.switchInput(o,s))}),h()}if(t&2){let n=i.$implicit;Y("formControlName",n)("id",n)}}function ri(t,i){t&1&&_(0," Codul este necesar. ")}function ni(t,i){t&1&&_(0," Num\u0103r de caractere invalid. ")}function si(t,i){if(t&1&&(g(0,"p",9),L(1,ri,1,0)(2,ni,1,0),h()),t&2){let n=F(2);A(),w(1,!(n.inputOne==null||n.inputOne.errors==null)&&n.inputOne.errors.required?1:!(n.inputOne==null||n.inputOne.errors==null)&&n.inputOne.errors.minlength||!(n.inputOne==null||n.inputOne.errors==null)&&n.inputOne.errors.maxlength?2:-1)}}function ai(t,i){t&1&&_(0),t&2&&xe(" \xEEn [",i,"] secunde ")}function di(t,i){t&1&&(g(0,"oro-alert",18),_(1," A intervenit o problem\u0103 \xEEn generarea codului OTP. Te rug\u0103m \xEEncearc\u0103 mai t\xE2rziu. "),h())}function li(t,i){t&1&&(g(0,"oro-alert",18),_(1," Ai atins num\u0103rul maxim de coduri generate. "),h())}function ci(t,i){t&1&&(g(0,"oro-alert",18),_(1," Codul introdus este invalid. "),h())}function pi(t,i){if(t&1&&_(0),t&2){let n=F(2).$implicit;ve(" ",n.message,". Error code: ",n.extensions.errorCode," ")}}function ui(t,i){t&1&&_(0," A intervenit o eroare. ")}function mi(t,i){if(t&1&&(g(0,"oro-alert",18),L(1,pi,1,2),D(2,"async"),L(3,ui,1,0),h()),t&2){let n=F(4);A(),w(1,V(2,1,n.isDev$)?1:3)}}function hi(t,i){if(t&1&&L(0,di,2,0)(1,li,2,0)(2,ci,2,0)(3,mi,4,3),t&2){let n,e=i.$implicit,o=F(3);w(0,(n=e.extensions.errorCode)===o.generateNewClientAcquisitionOTPTypeErrors.validationErrors?0:n===o.generateNewClientAcquisitionOTPTypeErrors.maxOtpCodesGenerationAttempts?1:n===o.generateNewClientAcquisitionOTPTypeErrors.invalidOtpCode?2:3)}}function _i(t,i){t&1&&ne(0,hi,4,1,null,null,re),t&2&&se(i.errors)}function fi(t,i){t&1&&(g(0,"oro-alert",18),_(1," Codul introdus nu coincide cu cel primit prin sms. Te rog s\u0103 reintroduci codul. "),h())}function gi(t,i){t&1&&(g(0,"oro-alert",18),_(1," Ai atins num\u0103rul maxim de coduri pentru ast\u0103zi. Te rug\u0103m s\u0103 \xEEncerci peste 24h. "),h())}function Ci(t,i){if(t&1&&_(0),t&2){let n=F(2).$implicit;ve(" ",n.message,". Error code: ",n.extensions.errorCode," ")}}function xi(t,i){t&1&&_(0," A intervenit o eroare. ")}function vi(t,i){if(t&1&&(g(0,"oro-alert",18),L(1,Ci,1,2),D(2,"async"),L(3,xi,1,0),h()),t&2){let n=F(4);A(),w(1,V(2,1,n.isDev$)?1:3)}}function yi(t,i){if(t&1&&L(0,fi,2,0)(1,gi,2,0)(2,vi,4,3),t&2){let n,e=i.$implicit,o=F(3);w(0,(n=e.extensions.errorCode)===o.validationNumberTypeErrors.validationErrors?0:n===o.validationNumberTypeErrors.maxOtpCodesVerificationAttempts?1:2)}}function Si(t,i){t&1&&ne(0,yi,3,1,null,null,re),t&2&&se(i.errors)}function Ai(t,i){if(t&1){let n=ae();g(0,"button",19),U("click",function(){z(n);let o=F(2);return q(o.forceCheckSMSCode(!0))}),_(1," For\u021Beaz\u0103 validarea "),h()}}function Li(t,i){if(t&1){let n=ae();g(0,"div",0)(1,"div",1)(2,"h3",2),_(3,"Cod PIN"),h(),g(4,"button",3),U("click",function(){z(n);let o=F();return q(o.cancel())}),g(5,"span",4),_(6,"\xD7"),h()()(),g(7,"div",5)(8,"p",6),_(9," Pentru a continua procesul, introdu codul de validare primit prin SMS la num\u0103rul "),L(10,ti,2,1,"strong"),D(11,"async"),L(12,ii,1,0),h(),g(13,"form",7),ne(14,oi,1,2,"input",8,re),h(),L(16,si,3,1,"p",9),g(17,"div",10)(18,"p",11),_(19,"Nu ai primit codul PIN?"),h(),g(20,"button",12),U("click",function(){z(n);let o=F();return q(o.sendCodeAgain())}),_(21," Retrimite cod "),L(22,ai,1,1),D(23,"async"),h()(),L(24,_i,2,0)(25,Si,2,0),h(),g(26,"div",13)(27,"button",14),U("click",function(){z(n);let o=F();return q(o.checkSMSCode())}),_(28," Valideaz\u0103 "),h(),L(29,Ai,2,0,"button",15),D(30,"async"),h()()}if(t&2){let n,e,o,s,a=i,r=F();A(10),w(10,(n=V(11,9,r.notificationMsisdn$))?10:12,n),A(3),Y("formGroup",r.form),A(),se(r.otpFields),A(2),w(16,r.inputOne!=null&&r.inputOne.touched?16:-1),A(4),Y("disabled",a.cartStatus===r.XhrStatus.loading||r.disableResendButton||!r.countdownCompleted||r.disableValidationButton),A(2),w(22,(e=!r.countdownCompleted&&V(23,11,r.countdown$))?22:-1,e),A(2),w(24,(o=a.generateNewAddressOTP)?24:-1,o),A(),w(25,(s=a.verifyNewAddressOTP)?25:-1,s),A(2),Y("disabled",r.form.invalid||a.cartStatus===r.XhrStatus.loading||r.disableValidationButton),A(2),w(29,V(30,13,r.isImpersonating$)?29:-1)}}var Xt=window;Xt.dataLayer=Xt.dataLayer||[];var Kt=(()=>{let i=class i extends nt{constructor(e,o,s,a,r,d){super(),this.dialogRef=e,this.storeSelector=o,this.trafficService=s,this.cartDeliveryAddressService=a,this.elementRef=r,this.data=d,this.otpFields=["one","two","three","four","five","six"],this.XhrStatus=O,this.validationNumberTypeErrors=Ee,this.generateNewClientAcquisitionOTPTypeErrors=De,this.countdownCompleted=!0,this.form=new Et({one:new G("",[x.required,x.minLength(1),x.maxLength(1)]),two:new G("",[x.required,x.minLength(1),x.maxLength(1)]),three:new G("",[x.required,x.minLength(1),x.maxLength(1)]),four:new G("",[x.required,x.minLength(1),x.maxLength(1)]),five:new G("",[x.required,x.minLength(1),x.maxLength(1)]),six:new G("",[x.required,x.minLength(1),x.maxLength(1)])}),this.isImpersonating$=this.storeSelector.getWithSelector(Ye)}get inputOne(){return this.form.get("one")}get inputTwo(){return this.form.get("two")}get inputThree(){return this.form.get("three")}get inputFour(){return this.form.get("four")}get inputFive(){return this.form.get("five")}get inputSix(){return this.form.get("six")}onClick(e){this.elementRef.nativeElement.contains(e.target)||this.closeAddressForm()}ngOnInit(){this.generateNewAddressOTP$=this.storeSelector.getWithSelector(zt),this.verifyNewAddressOTP$=this.storeSelector.getWithSelector(Q),this.cartStatus$=this.storeSelector.getWithSelector(rt),this.isDev$=this.trafficService.checkIfIsDev(),this.notificationMsisdn$=this.generateNewAddressOTP$.pipe(S(e=>e.msisdn)),this.checkIfNeedToDisableButtons(),this.verifyNewAddressOTP$.pipe(ie(this.destroyed$)).subscribe(e=>{e&&e.verified===!0&&(this.data.isCompleteOrder||(this.data.address?this.cartDeliveryAddressService.handleEditDeliveryAddress(this.data.address):this.cartDeliveryAddressService.handleAddDeliveryAddress()),this.dialogRef.close(this.data.isCompleteOrder))}),this.startCountdown()}checkSMSCode(){var e,o,s,a,r,d,l;if(this.form.valid&&((e=this.inputOne)!=null&&e.value)){let C=((o=this.inputOne)==null?void 0:o.value)+((s=this.inputTwo)==null?void 0:s.value)+((a=this.inputThree)==null?void 0:a.value)+((r=this.inputFour)==null?void 0:r.value)+((d=this.inputFive)==null?void 0:d.value)+((l=this.inputSix)==null?void 0:l.value);this.cartDeliveryAddressService.handleVerifyNewAddressOTP(C),this.track("Add Address - Validate PIN")}}forceCheckSMSCode(e){e&&(this.cartDeliveryAddressService.handleVerifyNewAddressOTP("",e),this.track("Add Address - Validate PIN"))}sendCodeAgain(){this.startCountdown(),this.cartDeliveryAddressService.generateNewAddressOTP(),this.track("Add Address - Resend PIN")}switchInput(e,o){var b,y,I,N,k,Ve;let s=document.getElementById("one"),a=document.getElementById("two"),r=document.getElementById("three"),d=document.getElementById("four"),l=document.getElementById("five"),C=document.getElementById("six");if(s.value.length===6){let E=s.value;s.value="",(b=this.inputOne)==null||b.setValue(E[0]),s.value=E[0],(y=this.inputTwo)==null||y.setValue(E[1]),a.value=E[1],(I=this.inputThree)==null||I.setValue(E[2]),r.value=E[2],(N=this.inputFour)==null||N.setValue(E[3]),d.value=E[3],(k=this.inputFive)==null||k.setValue(E[4]),l.value=E[4],(Ve=this.inputSix)==null||Ve.setValue(E[5]),C.value=E[5],C.focus();return}if(s.value&&s.value.length>1){s.value="";return}if(a.value&&a.value.length>1){a.value="";return}if(r.value&&r.value.length>1){r.value="";return}if(d.value&&d.value.length>1){d.value="";return}if(l.value&&l.value.length>1){l.value="";return}if(C.value&&C.value.length>1){C.value="";return}if(o==="one"&&s.value.length===1){a==null||a.focus();return}if(o==="two"&&a.value.length===1){r==null||r.focus();return}if(o==="three"&&r.value.length===1){d==null||d.focus();return}if(o==="four"&&d.value.length===1){l==null||l.focus();return}o==="five"&&l.value.length===1&&(C==null||C.focus()),e.key==="Backspace"&&(o==="six"&&(C.value="",l.focus()),o==="five"&&(l.value="",d.focus()),o==="four"&&(d.value="",r.focus()),o==="three"&&(r.value="",a.focus()),o==="two"&&(a.value="",s.focus()),o==="one"&&(s.value=""))}checkIfNeedToDisableButtons(){this.generateNewAddressOTP$.pipe(ie(this.destroyed$)).subscribe(e=>{e.errors?e.errors.forEach(o=>{this.disableResendButton=o.extensions.errorCode===this.generateNewClientAcquisitionOTPTypeErrors.maxOtpCodesGenerationAttempts}):this.disableResendButton=!1}),this.verifyNewAddressOTP$.pipe(ie(this.destroyed$)).subscribe(e=>{e.errors?e.errors.forEach(o=>{this.disableValidationButton=o.extensions.errorCode===this.validationNumberTypeErrors.maxOtpCodesVerificationAttempts}):this.disableValidationButton=!1})}cancel(){this.dialogRef.close(),this.closeAddressForm()}closeAddressForm(){this.cartDeliveryAddressService._newCustomerDeliveryAddress.next({}),this.cartDeliveryAddressService.handleCloseDeliveryAddressForm(),this.track("Cancel Add Address")}track(e){let o={event:mt.MIKRO_USER_CLICK,event_action:ht.CHECKOUT_DELIVERY_OPTIONS,event_category:_t.CHECKOUT,event_label:e,event_value:ft.ZERO};It.analyticsPush(o)}startCountdown(){this.countdownCompleted=!1;let e=60;this.countdown$=ke(1e3).pipe(W(e+1),S(o=>e-o),S(o=>(this.countdownCompleted=o===0,o)))}};i.\u0275fac=function(o){return new(o||i)($(ct),$(ce),$(Ht),$(jt),$($e),$(pt))},i.\u0275cmp=Re({type:i,selectors:[["oro-otp-address-validation"]],hostBindings:function(o,s){o&1&&U("click",function(r){return s.onClick(r)},!1,Ue)},standalone:!0,features:[Ge,ze],decls:4,vars:11,consts:[[1,"otp-modal"],[1,"otp-modal__header"],[1,"otp-modal__tile"],["aria-label","Close",1,"otp-modal__close-button",3,"click"],["aria-hidden","true"],[1,"otp-modal__body"],[1,"otp-modal__description"],[1,"otp-modal__form",3,"formGroup"],["matInput","","type","text",1,"otp-modal__input",3,"formControlName","id"],[1,"otp-modal__error"],[1,"otp-modal__retry"],[1,"otp-modal__retry-text"],[1,"otp-modal__retry-button",3,"click","disabled"],[1,"otp-modal__footer"],[1,"btn","btn-primary",3,"click","disabled"],[1,"btn","btn-danger"],["height","15px","width","99px",2,"display","inline-block"],["matInput","","type","text",1,"otp-modal__input",3,"keyup","formControlName","id"],["type","error",1,"otp-modal__alert"],[1,"btn","btn-danger",3,"click"]],template:function(o,s){if(o&1&&(L(0,Li,31,15,"div",0),D(1,"async"),D(2,"async"),D(3,"async")),o&2){let a;w(0,(a=qe(7,ei,V(1,1,s.cartStatus$),V(2,3,s.generateNewAddressOTP$),V(3,5,s.verifyNewAddressOTP$)))?0:-1,a)}},dependencies:[kt,Dt,Tt,wt,Pt,Mt,Vt,Nt,Rt,Bt,He,Ft],styles:[".mat-mdc-dialog-container{border-radius:4px!important;padding:0;margin:1rem} .mat-mdc-dialog-container .mat-mdc-dialog-surface{padding:0} body.modal-open{height:100vh;overflow-y:hidden}.otp-modal__header[_ngcontent-%COMP%]{position:relative;display:flex;align-items:flex-start;justify-content:space-between;padding:16px 40px;border-bottom:1px solid #DDDDDD;border-top-left-radius:0;border-top-right-radius:0}.otp-modal__title[_ngcontent-%COMP%]{font-size:21px;line-height:26px;margin-bottom:0}.otp-modal__close-button[_ngcontent-%COMP%]{position:absolute;right:2.3rem;top:2.3rem;padding:15px;margin:-2rem -2rem -2rem auto;background:none;border:none;font-size:calc(1.275rem + .3vw);cursor:pointer;font-weight:bolder}.otp-modal__body[_ngcontent-%COMP%]{padding:20px 1rem}.otp-modal__description[_ngcontent-%COMP%]{margin-bottom:16px;font-size:1rem;line-height:24px}.otp-modal__form[_ngcontent-%COMP%]{display:flex;flex-direction:row;column-gap:6px}.otp-modal__input[_ngcontent-%COMP%]{width:45px;height:48px;border-radius:6px;outline:none;font-size:40px;line-height:40px;font-weight:700;text-align:center;border:2px solid #979797;caret-color:#ff7900;padding-inline:2px!important}.otp-modal__input[_ngcontent-%COMP%]::-webkit-inner-spin-button, .otp-modal__input[_ngcontent-%COMP%]::-webkit-outer-spin-button{display:none}.otp-modal__error[_ngcontent-%COMP%]{display:block;font-size:14px;line-height:18px;color:#cd3c14;margin:0;margin-top:1rem}.otp-modal__retry[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;justify-content:center;margin-top:16px}.otp-modal__retry-text[_ngcontent-%COMP%]{font-size:12px;line-height:14px;color:#666;margin-bottom:0;margin-right:1rem}.otp-modal__retry-button[_ngcontent-%COMP%]{display:inline-block;border:none;font-size:12px;line-height:14px;box-shadow:none;background:transparent;padding:0;margin:0;color:#ff7900;cursor:pointer}.otp-modal__retry-button[_ngcontent-%COMP%]:disabled{color:#ccc!important;cursor:not-allowed}.otp-modal__alert[_ngcontent-%COMP%]{margin:1rem 0}.otp-modal__footer[_ngcontent-%COMP%]{display:flex;flex-direction:column;justify-content:center;padding:1.75rem;border-top:1px solid #DDDDDD}.otp-modal__footer[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{max-width:277px;width:100%;height:44px;margin:auto;font-size:1rem;font-weight:700;cursor:pointer;border:none}.otp-modal__footer[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:disabled{cursor:not-allowed}.otp-modal__footer[_ngcontent-%COMP%] button.btn-danger[_ngcontent-%COMP%]{margin-top:1rem}@media screen and (min-width: 768px){.otp-modal__header[_ngcontent-%COMP%]{padding:16px 40px}.otp-modal__body[_ngcontent-%COMP%]{padding:20px 40px}.otp-modal__description[_ngcontent-%COMP%]{font-size:17px;margin-bottom:36px}.otp-modal__input[_ngcontent-%COMP%]{width:60px;height:63px;font-size:51px;line-height:31px}.otp-modal__retry-text[_ngcontent-%COMP%], .otp-modal__retry-button[_ngcontent-%COMP%]{font-size:14px;line-height:18px}.otp-modal__footer[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{max-width:277px;width:100%;height:44px;margin:auto}}"]});let t=i;return t})();var bi={withCredentials:!0};function Ii(t){return at((i,n)=>{var e,o;return((e=i.address)==null?void 0:e.addressId)===((o=n.address)==null?void 0:o.addressId)},t)}var jt=(()=>{let i=class i{constructor(e,o,s,a,r){this.storeSelector=e,this.store=o,this.actions$=s,this.http=a,this.matDialog=r,this._newCustomerDeliveryAddress=new T({}),this.setDeliveryAddressSuccess$=new fe,this.deliveryAddressChanged$=new fe,this._fixedLocationContactPersonSource=new T({}),this.fixedLocationContactPerson$=this._fixedLocationContactPersonSource.asObservable(),this._selectedDeliveryAddressErrorSource=new T(!1),this.selectedDeliveryAddressError$=this._selectedDeliveryAddressErrorSource.asObservable(),this._deliveryAddressDataSource=new T({}),this.deliveryAddressData$=this._deliveryAddressDataSource.asObservable(),this._deliveryAddressFormIsVisibleSource=new T(!1),this.deliveryAddressFormIsVisible$=this._deliveryAddressFormIsVisibleSource.asObservable(),this._billingAddressDataSource=new T({}),this.billingAddressData$=this._billingAddressDataSource.asObservable(),this._billingAddressFormIsVisibleSource=new T(!1),this.billingAddressFormIsVisible$=this._billingAddressFormIsVisibleSource.asObservable(),this._addressFormIsVisibleSource=new T(!1),this.addressFormVisible$=this._addressFormIsVisibleSource.asObservable(),this._addressToggleAriadNextSource=new T(!1),this.addressToggleAriadNext$=this._addressToggleAriadNextSource.asObservable(),this.deliveryFormCompleted$=new Ne,this._preferredNotificationChannelSource=new T(!1),this.preferredNotificationChannel$=this._preferredNotificationChannelSource.asObservable(),this._isBillingAddressEditForm=new T(!1),this.isBillingAddressEditForm$=this._isBillingAddressEditForm.asObservable(),this.deliveryAddressOpenContext=Ce(void 0),this.editModeSubject=new T(null),this.editMode$=this.editModeSubject.asObservable(),this.notificationChannelLoading=Ce(!0)}getSelectedShippingAddress(){return X([this.getShippingAddressList().pipe(B()),this.storeSelector.getWithSelector(me).pipe(B()),this.storeSelector.getWithSelector(Ae).pipe(B()),this.storeSelector.getWithSelector(it()).pipe(B()),this.storeSelector.getWithSelector(ot).pipe(B()),this.storeSelector.getWithSelector(P).pipe(B())]).pipe(M(([e,o,s,a,r,d])=>{var l;return d.status!==O.loading&&((l=d.cart)==null?void 0:l.__typename)==="PendingCartResource"}),S(([e,o,s,a,r,d])=>{var l,C;if(this.isLoggedIn=s,this.selectorCartItemIsOfyOrLoy=a,this.hasAtLeastOneLoyaltyProduct=r,(l=o==null?void 0:o.address)!=null&&l.addressId){let b=e.find(y=>{var I;return o.address.addressId===((I=y.address)==null?void 0:I.addressId)&&Z(y.party,o.party)});if(b)return this.checkShippingAddressIsComplete(b),b}else if(s){let b=e.find(({isSelected:I})=>I)||e[0],y=(C=d.cart.shipping)==null?void 0:C.shippingType.selection;return this.checkShippingAddressIsComplete(b),b&&(!y||y===Je.Customer)&&this.store.dispatch(Oe({address:b})),b}})).pipe(M(e=>{var o;return!!((o=e==null?void 0:e.party)!=null&&o.type)||!e})).pipe(j(1))}getSelectedBillingAddress(){return X([this.getBillingAddressList(),this.storeSelector.getWithSelector(ue),this.storeSelector.getWithSelector(Ae)]).pipe(S(([e,o,s])=>{var a;if((a=o==null?void 0:o.address)!=null&&a.addressId){let r=e.find(d=>{var l,C;return((l=o.address)==null?void 0:l.addressId)===((C=d.address)==null?void 0:C.addressId)&&Z(d.party,o.party)});if(r)return r}else if(s){let r=e.find(({isSelected:d})=>d)||e[0];return r&&this.store.dispatch(Oe({address:r})),r}})).pipe(M(e=>{var o;return!!((o=e==null?void 0:e.party)!=null&&o.type)||!e}))}getShippingAddressList(){return this.storeSelector.getWithSelector(Se()).pipe(M(e=>e.status===O.success),S(e=>{var o;return(o=e.me)==null?void 0:o.ssoId}),B(),S(e=>!!e),te(e=>e?this.getLoggedInUserDeliveryAddresses():this.getGuestUserDeliveryAddresses()))}getBillingAddressList(){return this.storeSelector.getWithSelector(Se()).pipe(M(e=>e.status===O.success)).pipe(S(e=>{var o;return!!((o=e.me)!=null&&o.ssoId)})).pipe(te(e=>e?X([this.storeSelector.getWithSelector(dt),this.storeSelector.getWithSelector(Wt),this.storeSelector.getWithSelector(Pe),this.storeSelector.getWithSelector(ue),this.storeSelector.getWithSelector(Pe).pipe(te(o=>o?this.storeSelector.getWithSelector(tt()).pipe(M(({status:s})=>s!==O.loading)).pipe(S(({list:s})=>s)):ee([])))]).pipe(S(([o,s,a,r,d])=>{var b;if(!a&&r)return[f(u({},r),{isEditable:!1,isSelected:!0})];if(a&&r&&(d==null?void 0:d.length)===0)return[f(u({},r),{isEditable:!0,isSelected:!0})];let l=d?Array.from(d):[];if(r&&((b=r.address)!=null&&b.addressId)){let y=l.find(I=>{var N,k;return((N=I.address)==null?void 0:N.addressId)===((k=r.address)==null?void 0:k.addressId)&&Z(r.party,I.party)});if(!y&&(y=l.find(I=>{var N,k;return((N=I.address)==null?void 0:N.addressId)===((k=r.address)==null?void 0:k.addressId)}),y)){let I=l.indexOf(y);l[I]=f(u({},y),{party:r.party})}}if(s||!(r!=null&&r.party))return l;let C=l==null?void 0:l.map(y=>f(u({},y),{party:r.party}));return Ii(C)})):this.storeSelector.getWithSelector(ue).pipe(S(o=>o?[f(u({},o),{isEditable:!0})]:[]))))}getSelectedDeliveryAddressError(){return this.selectedDeliveryAddressError$}deleteShippingAddressFromCart(){return this._deliveryAddressFormIsVisibleSource.next(!1),this._deliveryAddressDataSource.next({}),this.store.dispatch(St()),this._addressFormIsVisibleSource.next(!1),this._addressToggleAriadNextSource.next(!1),ge(this.actions$.pipe(J(At)).pipe(K(!0)),this.actions$.pipe(J(Lt)).pipe(K(!1)))}deleteBillingAddressFromCart(){return this._billingAddressFormIsVisibleSource.next(!1),this._billingAddressDataSource.next({}),this.store.dispatch(Ct({billing:null})),ge(this.actions$.pipe(J(vt)).pipe(K(!0)),this.actions$.pipe(J(xt)).pipe(K(!1)))}checkIfAddressIsCorrect(e){var o;e.address&&!e.address.county.name||e.address&&!e.address.locality.name||e.address&&!((o=e.address.street)!=null&&o.name)&&!e.address.streetName||e.party&&!e.party.name?this._selectedDeliveryAddressErrorSource.next(!0):this._selectedDeliveryAddressErrorSource.next(!1)}getDeliveryAddressData(){return this.deliveryAddressData$}getIsDeliveryFormCompleted(){return this.deliveryFormCompleted$}setIsDeliveryFormCompleted(e){return this.deliveryFormCompleted$.next(e)}getDeliveryAddressFormIsVisible(){return this.deliveryAddressFormIsVisible$}handleCloseDeliveryAddressForm(){this._deliveryAddressFormIsVisibleSource.next(!1),this._deliveryAddressDataSource.next({}),this._addressFormIsVisibleSource.next(!1),this._addressToggleAriadNextSource.next(!1)}handleAddDeliveryAddress(){this._deliveryAddressFormIsVisibleSource.next(!0),this._addressFormIsVisibleSource.next(!0),this.deliveryAddressOpenContext.set("Add"),this.handleCloseBillingAddressForm()}handleEditDeliveryAddress(e,o){this._deliveryAddressDataSource.next({deliveryAddress:e,options:o}),this._deliveryAddressFormIsVisibleSource.next(!0),this._addressFormIsVisibleSource.next(!0),this.deliveryAddressOpenContext.set("Edit"),this.handleCloseBillingAddressForm()}getBillingAddressData(){return this.billingAddressData$}getBillingAddressFormIsVisible(){return this.billingAddressFormIsVisible$}handleCloseBillingAddressForm(){this._billingAddressFormIsVisibleSource.next(!1),this._billingAddressDataSource.next({})}handleAddBillingAddress(){this._isBillingAddressEditForm.next(!1),this._billingAddressFormIsVisibleSource.next(!0),this.handleCloseDeliveryAddressForm()}handleActivateEditForCompany(){this._isBillingAddressEditForm.next(!0)}handleEditBillingAddress(e,o){this._isBillingAddressEditForm.next(!0),this._billingAddressDataSource.next({billingAddress:e,options:o}),this._billingAddressFormIsVisibleSource.next(!0),this.handleCloseDeliveryAddressForm()}handleEditBillingAddressForCompany(e,o){this._isBillingAddressEditForm.next(!1),this._billingAddressDataSource.next({billingAddress:e,options:o}),this._billingAddressFormIsVisibleSource.next(!0)}handleSelectAddress(e){var o,s,a;e.type===le.BILLING&&this.store.dispatch(Qe({selection:Le.Customer})),!((o=e.party)!=null&&o.type)||!((s=e.party)!=null&&s.name)?e.type===le.BILLING?this.handleEditBillingAddress(e,{autoDirty:!0}):(this.selectorCartItemIsOfyOrLoy||this.hasAtLeastOneLoyaltyProduct)&&e&&!e.otpValidated&&this.isLoggedIn?this.storeSelector.getWithSelector(Q).pipe(W(1)).subscribe(r=>{r.verified?this.handleEditDeliveryAddress(e,{autoDirty:!0,emailValueSet:!1}):this.handleGenerateNewAddressOTP(!1,e)}):this.handleEditDeliveryAddress(e,{autoDirty:!0,emailValueSet:!1}):(e==null?void 0:e.type)===le.BILLING&&((a=e.party)==null?void 0:a.type)!==Ze.Person?this.handleEditBillingAddressForCompany(e,{autoDirty:!0}):(this.selectorCartItemIsOfyOrLoy||this.hasAtLeastOneLoyaltyProduct)&&e&&!e.otpValidated&&this.isLoggedIn?this.storeSelector.getWithSelector(Q).pipe(W(1)).subscribe(r=>{r.verified?(this.store.dispatch(Fe({addressType:null})),this.store.dispatch(be({address:e}))):this.handleGenerateNewAddressOTP()}):(this.store.dispatch(Fe({addressType:null})),this.store.dispatch(be({address:e})))}mapAddressToCommonObject(e,o){var s,a,r,d;return o&&e.address&&(e.address=pe("zipCode",e.address),e.address.locality=pe("zipCode",e.address.locality),e.address.street=pe("zipCode",e.address.street)),e.address=e.address,e.address.apartment=(s=e.address)!=null&&s.apartment?e.address.apartment:"",e.address.building=(a=e.address)!=null&&a.building?e.address.building:"",e.address.streetNo=(r=e.address)!=null&&r.streetNo?e.address.streetNo:"",e.address.staircase=(d=e.address)!=null&&d.staircase?e.address.staircase:"",e}getAddressFormIsVisible(){return this.addressFormVisible$}setAddressToggleAriadNext(e){return this._addressToggleAriadNextSource.next(e)}getAddressToggleAriadNext(){return this.addressToggleAriadNext$}setFixedLocationContactPerson(e,o=!0){this._fixedLocationContactPersonSource.next(e),o&&this.store.dispatch(yt({shippingTypeSelection:Le.FixedLocation}))}getNotificationChannelByOCN(){return this.notificationChannelLoading.set(!0),this.http.get("".concat(Xe.getCartV2ApiUrl(),"/consent/notification-channel"),f(u({},bi),{responseType:"text"})).pipe(Be(()=>this.notificationChannelLoading.set(!1)),Me(e=>{throw this.notificationChannelLoading.set(!1),e}),j({bufferSize:1,refCount:!0}))}getPreferredNotificationChannel(){return this.preferredNotificationChannel$}setPreferredNotificationChannel(e){return this._preferredNotificationChannelSource.next(e)}selectPreferredNotificationChannel(e){this.storeSelector.getWithSelector($t()).pipe(W(1)).subscribe(o=>{let{insuranceTermsAgreed:s,isAbove16:a,hasPaymentCommitment:r,keepIdCard:d,gdprConsents:l}=o;this.store.dispatch(lt({insuranceTermsAgreed:s,isAbove16:a,hasPaymentCommitment:r,keepIdCard:d,gdprConsents:l,notificationChannel:e}))})}generateNewAddressOTP(){this.store.dispatch(Ot())}handleGenerateNewAddressOTP(e,o){return this.generateNewAddressOTP(),this.dialogRef=this.matDialog.open(Kt,{maxWidth:"500px",data:{isCompleteOrder:e}}),this.dialogRef.afterClosed()}handleVerifyNewAddressOTP(e,o){this.store.dispatch(bt({code:e,forced:o}))}setEditMode(e){this.editModeSubject.next(e)}getLoggedInUserDeliveryAddresses(){return X([this.storeSelector.getWithSelector(me),this.storeSelector.getWithSelector(et()).pipe(M(e=>e.status===O.success),S(e=>e.list||[]))]).pipe(S(([e,o])=>this.mergeDeliveryAddresses(o,e)))}getGuestUserDeliveryAddresses(){return this.storeSelector.getWithSelector(me).pipe(S(e=>e?[f(u({},e),{isEditable:!0,shippingAddressSourceSubResource:e.shippingAddressSourceSubResource})]:[]))}mergeDeliveryAddresses(e,o){var r;if(!((r=o==null?void 0:o.address)!=null&&r.addressId))return e;let s=Array.from(e),a=this.findDeliveryAddressInList(o,s);if(a){let d=s.indexOf(a);s[d]=f(u({},a),{party:o.party})}return s}findDeliveryAddressInList(e,o){return o.find(s=>{var a,r;return((a=s.address)==null?void 0:a.addressId)===((r=e.address)==null?void 0:r.addressId)&&Z(e.party,s.party)})||o.find(s=>{var a,r;return((a=s.address)==null?void 0:a.addressId)===((r=e.address)==null?void 0:r.addressId)})}checkShippingAddressIsComplete(e){var o,s,a;e!=null&&e.address&&(!(e!=null&&e.party)||!((o=e==null?void 0:e.party)!=null&&o.name)||!((s=e==null?void 0:e.party)!=null&&s.email)||!((a=e==null?void 0:e.party)!=null&&a.phone))&&this.handleEditDeliveryAddress(e)}};i.\u0275fac=function(o){return new(o||i)(R(ce),R(Ke),R(gt),R(de),R(ut))},i.\u0275prov=oe({token:i,factory:i.\u0275fac,providedIn:"root"});let t=i;return t})();export{Ti as a,wi as b,Pi as c,Ei as d,Di as e,Vi as f,Ni as g,ki as h,Mi as i,Ut as j,Bi as k,Ri as l,$i as m,Ui as n,Gi as o,Wi as p,zi as q,qi as r,Hi as s,Xi as t,Ki as u,ji as v,Yi as w,we as x,Zi as y,Ji as z,Qi as A,eo as B,to as C,Gt as D,uo as E,mo as F,ho as G,fo as H,go as I,Co as J,xo as K,vo as L,yo as M,So as N,Ao as O,Lo as P,bo as Q,Io as R,Fo as S,To as T,wo as U,Mo as V,Pe as W,Wt as X,Bo as Y,ue as Z,me as _,Ro as $,Q as aa,$o as ba,Uo as ca,Go as da,Ht as ea,he as fa,_e as ga,qo as ha,jt as ia};