import{A as xt,m as pt,n as ut,o as mt,p as Ie,q as ht,u as _t,v as ft,w as gt,x as Ct}from"./chunk-ECXJG4VG.js";import{a as Fe}from"./chunk-L3AKYAI7.js";import{o as Mt}from"./chunk-GPXC5TFJ.js";import{a as Lt}from"./chunk-LXG7GT7J.js";import{b as Nt}from"./chunk-F3N5PU5V.js";import{b as kt}from"./chunk-GIYE4OKL.js";import{c as at,d as dt,e as lt}from"./chunk-ZWOB5ADW.js";import{e as vt,g as yt,i as St,p as At}from"./chunk-5LCR2OJC.js";import{$b as Qe,Ac as it,Cb as le,P as z,Pb as Le,Qb as Oe,Ub as Ze,_b as Je,aa as Ke,hc as be,jc as P,ka as Ae,na as Ye,uc as et,wc as tt}from"./chunk-XS4DMB2U.js";import{E as Dt,F as Vt,c as bt,e as x,h as It,i as Ft,j as Tt,l as G,n as wt,r as Pt,t as Et}from"./chunk-IWEPXOJK.js";import{a as ot}from"./chunk-Y77T26QU.js";import{c as ct,d as Z}from"./chunk-XA6AU52H.js";import{V as st}from"./chunk-YFWLORNM.js";import{g as ve,i as ye,k as je,m as Se,o as ce}from"./chunk-DAYGRJHR.js";import{h as Y,k as pe,n as rt,q as nt}from"./chunk-767ZUJWF.js";import{D as O,d as c,e as p,s as He,v as m,w as Xe}from"./chunk-VYUKN3XQ.js";import{c as ze}from"./chunk-AYHVL37M.js";import{h as de}from"./chunk-KXVCY5JT.js";import{v as qe}from"./chunk-VTET4O2Q.js";import{a as Ot}from"./chunk-UF7XRCGB.js";import{Cc as w,Da as te,Ea as ie,Ec as re,Fc as ne,Gc as se,Hc as g,Ic as h,Jc as Ue,K as Q,Na as oe,Nc as ae,P as S,Q as H,Sa as D,Tb as Be,Tc as U,Vb as A,Vc as T,Wb as R,Y as Ne,Z as ge,_ as B,_a as ke,a as u,b as f,fd as _,ga as X,gc as $e,hc as Re,hd as Ce,ia as j,id as xe,jb as W,kb as q,ma as $,od as Ge,pc as L,sd as We,t as fe,tb as Me,u as F,v as Ve,vc as K,wd as V,xd as N,za as ee}from"./chunk-XNQ3RS5P.js";var Ii=c("[Locations] Search Fixed Locations",p()),Fi=c("[Locations] Search Fixed Locations [Success]",p()),Ti=c("[Locations] Search Fixed Locations [Error]",p()),wi=c("[Locations] Get Fixed Location",p()),Pi=c("[Locations] Get Fixed Location [Success]",p()),Ei=c("[Locations] Get Fixed Location [Error]",p()),Di=c("[Location] Remove Search Fixed Locations"),Vi=c("[Location] Update Filter Input",p()),Ni=c("[Location] Clear Filter Input"),Bt=c("[Locations] Get Counties",p()),ki=c("[Locations] Get Counties Success",p()),Mi=c("[Locations] Get Counties Error",p()),Bi=c("[Locations] Get Localities",p()),$i=c("[Locations] Get Localities Success",p()),Ri=c("[Locations] Get Localities Error",p()),Ui=c("[Locations] Remove localities"),Gi=c("[Locations] Set Location Marker",p()),Wi=c("[Locations] Set Location from map",p()),qi=c("[Locations] Set Location from cart",p()),zi=c("[Location] Set Location skeletons",p()),Hi=c("[Location] Set favorite Location",p()),Xi=c("[Location] Set favorite Location Success",p()),ji=c("[Location] Set favorite Location Error",p()),Te=c("[Location] Get favorite or last used Location"),Ki=c("[Location] Get favorite or last used Location Success",p()),Yi=c("[Location] Get favorite or last used Location Error",p()),Zi=c("[Location] Set County input",p()),Ji=c("[Location] Set Locality input",p()),Qi=c("[Location] Clear Address inputs");function $t(e){let i=u({},e);return delete i.__typename,delete i.allowsDropOff,delete i.supportedPaymentType,delete i.schedule,delete i.restrictions,delete i.isFavorite,rt(i)?null:i}var v=Xe("locations"),co=m(v,e=>{var i;return(i=e.searchedFixedLocations)==null?void 0:i.data}),po=m(v,e=>e.searchedFixedLocations.status),uo=m(v,e=>{var i;return(i=e.searchedFixedLocations)==null?void 0:i.request}),mo=m(v,e=>{var i;return(i=e.fixedLocation)==null?void 0:i.data}),ho=m(v,e=>e.filterInput),_o=e=>({selector:v,action:()=>Bt({countryCode:e}),map:i=>{var n;return(n=i.counties)==null?void 0:n.data},shouldDispatch:i=>i.counties.status===O.initial}),fo=m(v,e=>{var i;return(i=e.localities)==null?void 0:i.data}),go=m(v,e=>e.locationMarker),Co=m(v,e=>e==null?void 0:e.selectedLocation),xo=m(v,e=>e.showSkeletons),vo=()=>({selector:m(v,ve,(e,i)=>[e,i]),action:()=>Te(),map:([e])=>e.favoriteOrLastUsedLocation,shouldDispatch:([e,i])=>i&&e.favoriteOrLastUsedLocation.status===O.initial}),yo=()=>({selector:m(v,ve,(e,i)=>[e,i]),action:()=>Te(),map:([e])=>{var i;return(i=e.favoriteOrLastUsedLocation)==null?void 0:i.data},shouldDispatch:([e,i])=>i&&e.favoriteOrLastUsedLocation.status===O.initial}),So=m(v,e=>e.favoriteOrLastUsedLocation.status),Ao=m(v,e=>{var i;return(i=e.favoriteOrLastUsedLocation)==null?void 0:i.data}),Lo=m(v,e=>{var i;return!!((i=e.favoriteOrLastUsedLocation)!=null&&i.data||e.selectedLocation)}),Oo=m(v,e=>{var i;return e.selectedLocation?e.selectedLocation:$t((i=e.favoriteOrLastUsedLocation)==null?void 0:i.data)}),bo=m(v,e=>e.selectedLocation||void 0),Io=m(v,e=>e.countyInput),Fo=m(v,e=>e.localityInput);var ue=function(e){return e[e.CUSTOMER=0]="CUSTOMER",e[e.FIXED_LOCATION=1]="FIXED_LOCATION",e[e.PICKUP_IN_STORE=2]="PICKUP_IN_STORE",e}(ue||{}),me=function(e){return e.CUSTOMER="customer",e.FIXED_LOCATION="fixed-location",e.PICKUP_IN_STORE="pickup-in-store",e}(me||{}),wo={[me.CUSTOMER]:ue.CUSTOMER,[me.FIXED_LOCATION]:ue.FIXED_LOCATION,[me.PICKUP_IN_STORE]:ue.PICKUP_IN_STORE},we=function(e){return e.validationErrors="validationErrors",e.maxOtpCodesVerificationAttempts="maxOtpCodesVerificationAttempts",e}(we||{}),Pe=function(e){return e.validationErrors="validationErrors",e.maxOtpCodesGenerationAttempts="maxOtpCodesGenerationAttempts",e.invalidOtpCode="invalidOtpCode",e}(Pe||{});var Mo=f(u({},P),{map(e){var i,n,t;return((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((t=(n=e==null?void 0:e.cart)==null?void 0:n.actions)==null?void 0:t.includes(z.SetBilling))}}),Ee=f(u({},P),{map(e){var i,n,t;return((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((t=(n=e==null?void 0:e.cart)==null?void 0:n.actions)==null?void 0:t.includes(z.SetBilling))}}),Rt=f(u({},P),{map(e){var i,n,t,o,s;return((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"&&(((t=(n=e==null?void 0:e.cart)==null?void 0:n.actions)==null?void 0:t.includes(z.SetBilling))||((s=(o=e==null?void 0:e.cart)==null?void 0:o.actions)==null?void 0:s.includes(z.SetBillingParty)))}}),Bo=f(u({},P),{map(e){var i,n,t;return((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((t=(n=e==null?void 0:e.cart)==null?void 0:n.actions)==null?void 0:t.includes(z.SetShipping))}}),he=f(u({},P),{map:e=>{var i,n;return((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"?Fe.fromCartBillingAddressToAddressRelation((n=e.cart)==null?void 0:n.billing):void 0}}),_e=f(u({},P),{map:e=>{var i,n;return((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=e.cart)!=null&&n.shipping)?Fe.fromCartShippingAddressToAddressRelation(e.cart.shipping):void 0},filter:e=>e.status===O.success||e.status===O.error}),$o=f(u({},P),{map:e=>{var i,n;return((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=e.cart.shipping)!=null&&n.shippingType)?e.cart.shipping.shippingType:void 0}}),Ut=f(u({},P),{map:e=>e.newClientAcquisition.generateNewAddressOTP}),J=f(u({},P),{map:e=>e.newClientAcquisition.verifyNewAddressOTP}),Ro=f(u({},P),{map:e=>{var i;return!!(((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"&&e.cart.isEligibleForLockers)}}),Uo=m(be,e=>{var i,n;return!(((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=e.cart.shipping)!=null&&n.shippingType.fixedLocation))}),Go=m(be,e=>{var i;if(((i=e.cart)==null?void 0:i.__typename)==="PendingCartResource")return e.usedAddressForShipping});var Wt=(()=>{let i=class i{constructor(t){this.httpClient=t,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(ee(1))),this.cache$}checkIfIsDev(){return Q(this.isDev)}};i.\u0275fac=function(o){return new(o||i)(D(de))},i.\u0275prov=oe({token:i,factory:i.\u0275fac,providedIn:"root"});let e=i;return e})();var Zt=(e,i,n)=>({cartStatus:e,generateNewAddressOTP:i,verifyNewAddressOTP:n});function Jt(e,i){e&1&&(g(0,"strong"),_(1),h()),e&2&&(A(),Ce(" ",i,". "))}function Qt(e,i){e&1&&Ue(0,"oro-skeleton-loader-line",16)}function ei(e,i){if(e&1){let n=ae();g(0,"input",17),U("keyup",function(o){let s=W(n).$implicit,a=T(2);return q(a.switchInput(o,s))}),h()}if(e&2){let n=i.$implicit;K("formControlName",n)("id",n)}}function ti(e,i){e&1&&_(0," Codul este necesar. ")}function ii(e,i){e&1&&_(0," Num\u0103r de caractere invalid. ")}function oi(e,i){if(e&1&&(g(0,"p",9),L(1,ti,1,0)(2,ii,1,0),h()),e&2){let n=T(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 ri(e,i){e&1&&_(0),e&2&&Ce(" \xEEn [",i,"] secunde ")}function ni(e,i){e&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 si(e,i){e&1&&(g(0,"oro-alert",18),_(1," Ai atins num\u0103rul maxim de coduri generate. "),h())}function ai(e,i){e&1&&(g(0,"oro-alert",18),_(1," Codul introdus este invalid. "),h())}function di(e,i){if(e&1&&_(0),e&2){let n=T(2).$implicit;xe(" ",n.message,". Error code: ",n.extensions.errorCode," ")}}function li(e,i){e&1&&_(0," A intervenit o eroare. ")}function ci(e,i){if(e&1&&(g(0,"oro-alert",18),L(1,di,1,2),V(2,"async"),L(3,li,1,0),h()),e&2){let n=T(4);A(),w(1,N(2,1,n.isDev$)?1:3)}}function pi(e,i){if(e&1&&L(0,ni,2,0)(1,si,2,0)(2,ai,2,0)(3,ci,4,3),e&2){let n,t=i.$implicit,o=T(3);w(0,(n=t.extensions.errorCode)===o.generateNewClientAcquisitionOTPTypeErrors.validationErrors?0:n===o.generateNewClientAcquisitionOTPTypeErrors.maxOtpCodesGenerationAttempts?1:n===o.generateNewClientAcquisitionOTPTypeErrors.invalidOtpCode?2:3)}}function ui(e,i){e&1&&ne(0,pi,4,1,null,null,re),e&2&&se(i.errors)}function mi(e,i){e&1&&(g(0,"oro-alert",18),_(1," Codul introdus nu coincide cu cel primit prin sms. Te rog s\u0103 reintroduci codul. "),h())}function hi(e,i){e&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 _i(e,i){if(e&1&&_(0),e&2){let n=T(2).$implicit;xe(" ",n.message,". Error code: ",n.extensions.errorCode," ")}}function fi(e,i){e&1&&_(0," A intervenit o eroare. ")}function gi(e,i){if(e&1&&(g(0,"oro-alert",18),L(1,_i,1,2),V(2,"async"),L(3,fi,1,0),h()),e&2){let n=T(4);A(),w(1,N(2,1,n.isDev$)?1:3)}}function Ci(e,i){if(e&1&&L(0,mi,2,0)(1,hi,2,0)(2,gi,4,3),e&2){let n,t=i.$implicit,o=T(3);w(0,(n=t.extensions.errorCode)===o.validationNumberTypeErrors.validationErrors?0:n===o.validationNumberTypeErrors.maxOtpCodesVerificationAttempts?1:2)}}function xi(e,i){e&1&&ne(0,Ci,3,1,null,null,re),e&2&&se(i.errors)}function vi(e,i){if(e&1){let n=ae();g(0,"button",19),U("click",function(){W(n);let o=T(2);return q(o.forceCheckSMSCode(!0))}),_(1," For\u021Beaz\u0103 validarea "),h()}}function yi(e,i){if(e&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(){W(n);let o=T();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,Jt,2,1,"strong"),V(11,"async"),L(12,Qt,1,0),h(),g(13,"form",7),ne(14,ei,1,2,"input",8,re),h(),L(16,oi,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(){W(n);let o=T();return q(o.sendCodeAgain())}),_(21," Retrimite cod "),L(22,ri,1,1),V(23,"async"),h()(),L(24,ui,2,0)(25,xi,2,0),h(),g(26,"div",13)(27,"button",14),U("click",function(){W(n);let o=T();return q(o.checkSMSCode())}),_(28," Valideaz\u0103 "),h(),L(29,vi,2,0,"button",15),V(30,"async"),h()()}if(e&2){let n,t,o,s,a=i,r=T();A(10),w(10,(n=N(11,9,r.notificationMsisdn$))?10:12,n),A(3),K("formGroup",r.form),A(),se(r.otpFields),A(2),w(16,r.inputOne!=null&&r.inputOne.touched?16:-1),A(4),K("disabled",a.cartStatus===r.XhrStatus.loading||r.disableResendButton||!r.countdownCompleted||r.disableValidationButton),A(2),w(22,(t=!r.countdownCompleted&&N(23,11,r.countdown$))?22:-1,t),A(2),w(24,(o=a.generateNewAddressOTP)?24:-1,o),A(),w(25,(s=a.verifyNewAddressOTP)?25:-1,s),A(2),K("disabled",r.form.invalid||a.cartStatus===r.XhrStatus.loading||r.disableValidationButton),A(2),w(29,N(30,13,r.isImpersonating$)?29:-1)}}var qt=window;qt.dataLayer=qt.dataLayer||[];var zt=(()=>{let i=class i extends ot{constructor(t,o,s,a,r,d){super(),this.dialogRef=t,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=we,this.generateNewClientAcquisitionOTPTypeErrors=Pe,this.countdownCompleted=!0,this.form=new Tt({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(je)}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(t){this.elementRef.nativeElement.contains(t.target)||this.closeAddressForm()}ngOnInit(){this.generateNewAddressOTP$=this.storeSelector.getWithSelector(Ut),this.verifyNewAddressOTP$=this.storeSelector.getWithSelector(J),this.cartStatus$=this.storeSelector.getWithSelector(it),this.isDev$=this.trafficService.checkIfIsDev(),this.notificationMsisdn$=this.generateNewAddressOTP$.pipe(S(t=>t.msisdn)),this.checkIfNeedToDisableButtons(),this.verifyNewAddressOTP$.pipe(ie(this.destroyed$)).subscribe(t=>{t&&t.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 t,o,s,a,r,d,l;if(this.form.valid&&((t=this.inputOne)!=null&&t.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(t){t&&(this.cartDeliveryAddressService.handleVerifyNewAddressOTP("",t),this.track("Add Address - Validate PIN"))}sendCodeAgain(){this.startCountdown(),this.cartDeliveryAddressService.generateNewAddressOTP(),this.track("Add Address - Resend PIN")}switchInput(t,o){var b,y,I,k,M,De;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],(k=this.inputFour)==null||k.setValue(E[3]),d.value=E[3],(M=this.inputFive)==null||M.setValue(E[4]),l.value=E[4],(De=this.inputSix)==null||De.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()),t.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(t=>{t.errors?t.errors.forEach(o=>{this.disableResendButton=o.extensions.errorCode===this.generateNewClientAcquisitionOTPTypeErrors.maxOtpCodesGenerationAttempts}):this.disableResendButton=!1}),this.verifyNewAddressOTP$.pipe(ie(this.destroyed$)).subscribe(t=>{t.errors?t.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(t){let o={event:vt.MIKRO_USER_CLICK,event_action:yt.CHECKOUT_DELIVERY_OPTIONS,event_category:St.CHECKOUT,event_label:t,event_value:At.ZERO};Lt.analyticsPush(o)}startCountdown(){this.countdownCompleted=!1;let t=60;this.countdown$=Ne(1e3).pipe(X(t+1),S(o=>t-o),S(o=>(this.countdownCompleted=o===0,o)))}};i.\u0275fac=function(o){return new(o||i)(R(at),R(ce),R(Wt),R(Ht),R(Me),R(dt))},i.\u0275cmp=ke({type:i,selectors:[["oro-otp-address-validation"]],hostBindings:function(o,s){o&1&&U("click",function(r){return s.onClick(r)},!1,Be)},standalone:!0,features:[Re,Ge],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,yi,31,15,"div",0),V(1,"async"),V(2,"async"),V(3,"async")),o&2){let a;w(0,(a=We(7,Zt,N(1,1,s.cartStatus$),N(2,3,s.generateNewAddressOTP$),N(3,5,s.verifyNewAddressOTP$)))?0:-1,a)}},dependencies:[Dt,wt,bt,It,Ft,Vt,Pt,Et,kt,Nt,qe,Ot],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 e=i;return e})();var Ai={withCredentials:!0};function Li(e){return nt((i,n)=>{var t,o;return((t=i.address)==null?void 0:t.addressId)===((o=n.address)==null?void 0:o.addressId)},e)}var Ht=(()=>{let i=class i{constructor(t,o,s,a,r,d){this.storeSelector=t,this.store=o,this.actions$=s,this.http=a,this.matDialog=r,this.relatedProductsService=d,this._newCustomerDeliveryAddress=new F({}),this.setDeliveryAddressSuccess$=new fe,this.deliveryAddressChanged$=new fe,this._fixedLocationContactPersonSource=new F({}),this.fixedLocationContactPerson$=this._fixedLocationContactPersonSource.asObservable(),this._selectedDeliveryAddressErrorSource=new F(!1),this.selectedDeliveryAddressError$=this._selectedDeliveryAddressErrorSource.asObservable(),this._deliveryAddressDataSource=new F({}),this.deliveryAddressData$=this._deliveryAddressDataSource.asObservable(),this._deliveryAddressFormIsVisibleSource=new F(!1),this.deliveryAddressFormIsVisible$=this._deliveryAddressFormIsVisibleSource.asObservable(),this._billingAddressDataSource=new F({}),this.billingAddressData$=this._billingAddressDataSource.asObservable(),this._billingAddressFormIsVisibleSource=new F(!1),this.billingAddressFormIsVisible$=this._billingAddressFormIsVisibleSource.asObservable(),this._addressFormIsVisibleSource=new F(!1),this.addressFormVisible$=this._addressFormIsVisibleSource.asObservable(),this._addressToggleAriadNextSource=new F(!1),this.addressToggleAriadNext$=this._addressToggleAriadNextSource.asObservable(),this.deliveryFormCompleted$=new Ve,this._preferredNotificationChannelSource=new F(!1),this.preferredNotificationChannel$=this._preferredNotificationChannelSource.asObservable(),this._isBillingAddressEditForm=new F(!1),this.isBillingAddressEditForm$=this._isBillingAddressEditForm.asObservable(),this.deliveryAddressOpenContext=$e(void 0),this.toggleAddressSubject=new F(null),this.toggleAddress$=this.toggleAddressSubject.asObservable(),this.editModeSubject=new F(null),this.editMode$=this.editModeSubject.asObservable()}getSelectedShippingAddress(){return H([this.getShippingAddressList().pipe($()),this.storeSelector.getWithSelector(_e).pipe($()),this.storeSelector.getWithSelector(Se).pipe($()),this.storeSelector.getWithSelector(et()).pipe($()),this.storeSelector.getWithSelector(tt).pipe($()),this.storeSelector.getWithSelector(P).pipe($())]).pipe(B(([t,o,s,a,r,d])=>{var l;return d.status!==O.loading&&((l=d.cart)==null?void 0:l.__typename)==="PendingCartResource"}),S(([t,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=t.find(y=>{var I;return o.address.addressId===((I=y.address)==null?void 0:I.addressId)&&Y(y.party,o.party)});if(b)return this.checkShippingAddressIsComplete(b),b}else if(s){let b=t.find(({isSelected:I})=>I)||t[0],y=(C=d.cart.shipping)==null?void 0:C.shippingType.selection;return this.checkShippingAddressIsComplete(b),b&&(!y||y===Ye.Customer)&&this.store.dispatch(Le({address:b})),b}})).pipe(B(t=>{var o;return!!((o=t==null?void 0:t.party)!=null&&o.type)||!t})).pipe(ee(1))}getSelectedBillingAddress(){return H([this.getBillingAddressList(),this.storeSelector.getWithSelector(he),this.storeSelector.getWithSelector(Se)]).pipe(S(([t,o,s])=>{var a;if((a=o==null?void 0:o.address)!=null&&a.addressId){let r=t.find(d=>{var l,C;return((l=o.address)==null?void 0:l.addressId)===((C=d.address)==null?void 0:C.addressId)&&Y(d.party,o.party)});if(r)return r}else if(s){let r=t.find(({isSelected:d})=>d)||t[0];return r&&this.store.dispatch(Le({address:r})),r}})).pipe(B(t=>{var o;return!!((o=t==null?void 0:t.party)!=null&&o.type)||!t}))}getShippingAddressList(){return this.storeSelector.getWithSelector(ye()).pipe(B(t=>t.status===O.success),S(t=>{var o;return(o=t.me)==null?void 0:o.ssoId}),$(),S(t=>!!t),te(t=>t?this.getLoggedInUserDeliveryAddresses():this.getGuestUserDeliveryAddresses()))}getBillingAddressList(){return this.storeSelector.getWithSelector(ye()).pipe(B(t=>t.status===O.success)).pipe(S(t=>{var o;return!!((o=t.me)!=null&&o.ssoId)})).pipe(te(t=>t?H([this.storeSelector.getWithSelector(st),this.storeSelector.getWithSelector(Rt),this.storeSelector.getWithSelector(Ee),this.storeSelector.getWithSelector(he),this.storeSelector.getWithSelector(Ee).pipe(te(o=>o?this.storeSelector.getWithSelector(Qe()).pipe(B(({status:s})=>s!==O.loading)).pipe(S(({list:s})=>s)):Q([])))]).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 k,M;return((k=I.address)==null?void 0:k.addressId)===((M=r.address)==null?void 0:M.addressId)&&Y(r.party,I.party)});if(!y&&(y=l.find(I=>{var k,M;return((k=I.address)==null?void 0:k.addressId)===((M=r.address)==null?void 0:M.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 Li(C)})):this.storeSelector.getWithSelector(he).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(_t()),this._addressFormIsVisibleSource.next(!1),this._addressToggleAriadNextSource.next(!1),ge(this.actions$.pipe(Z(ft)).pipe(j(!0)),this.actions$.pipe(Z(gt)).pipe(j(!1)))}deleteBillingAddressFromCart(){return this._billingAddressFormIsVisibleSource.next(!1),this._billingAddressDataSource.next({}),this.store.dispatch(pt({billing:null})),ge(this.actions$.pipe(Z(mt)).pipe(j(!0)),this.actions$.pipe(Z(ut)).pipe(j(!1)))}checkIfAddressIsCorrect(t){var o;t.address&&!t.address.county.name||t.address&&!t.address.locality.name||t.address&&!((o=t.address.street)!=null&&o.name)&&!t.address.streetName||t.party&&!t.party.name?this._selectedDeliveryAddressErrorSource.next(!0):this._selectedDeliveryAddressErrorSource.next(!1)}getDeliveryAddressData(){return this.deliveryAddressData$}getIsDeliveryFormCompleted(){return this.deliveryFormCompleted$}setIsDeliveryFormCompleted(t){return this.deliveryFormCompleted$.next(t)}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(t,o){this._deliveryAddressDataSource.next({deliveryAddress:t,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(t,o){this._isBillingAddressEditForm.next(!0),this._billingAddressDataSource.next({billingAddress:t,options:o}),this._billingAddressFormIsVisibleSource.next(!0),this.handleCloseDeliveryAddressForm()}handleEditBillingAddressForCompany(t,o){this._isBillingAddressEditForm.next(!1),this._billingAddressDataSource.next({billingAddress:t,options:o}),this._billingAddressFormIsVisibleSource.next(!0)}handleSelectAddress(t){var o,s,a;t.type===le.BILLING&&this.store.dispatch(Ze({selection:Ae.Customer})),!((o=t.party)!=null&&o.type)||!((s=t.party)!=null&&s.name)?t.type===le.BILLING?this.handleEditBillingAddress(t,{autoDirty:!0}):(this.selectorCartItemIsOfyOrLoy||this.hasAtLeastOneLoyaltyProduct)&&t&&!t.otpValidated&&this.isLoggedIn?this.storeSelector.getWithSelector(J).pipe(X(1)).subscribe(r=>{r.verified?this.handleEditDeliveryAddress(t,{autoDirty:!0,emailValueSet:!1}):this.handleGenerateNewAddressOTP(!1,t)}):this.handleEditDeliveryAddress(t,{autoDirty:!0,emailValueSet:!1}):(t==null?void 0:t.type)===le.BILLING&&((a=t.party)==null?void 0:a.type)!==Ke.Person?this.handleEditBillingAddressForCompany(t,{autoDirty:!0}):(this.selectorCartItemIsOfyOrLoy||this.hasAtLeastOneLoyaltyProduct)&&t&&!t.otpValidated&&this.isLoggedIn?this.storeSelector.getWithSelector(J).pipe(X(1)).subscribe(r=>{r.verified?(this.store.dispatch(Ie({addressType:null})),this.store.dispatch(Oe({address:t}))):this.handleGenerateNewAddressOTP()}):(this.store.dispatch(Ie({addressType:null})),this.store.dispatch(Oe({address:t})))}mapAddressToCommonObject(t,o){var s,a,r,d;return o&&t.address&&(t.address=pe("zipCode",t.address),t.address.locality=pe("zipCode",t.address.locality),t.address.street=pe("zipCode",t.address.street)),t.address=t.address,t.address.apartment=(s=t.address)!=null&&s.apartment?t.address.apartment:"",t.address.building=(a=t.address)!=null&&a.building?t.address.building:"",t.address.streetNo=(r=t.address)!=null&&r.streetNo?t.address.streetNo:"",t.address.staircase=(d=t.address)!=null&&d.staircase?t.address.staircase:"",t}getAddressFormIsVisible(){return this.addressFormVisible$}setAddressToggleAriadNext(t){return this._addressToggleAriadNextSource.next(t)}getAddressToggleAriadNext(){return this.addressToggleAriadNext$}setFixedLocationContactPerson(t,o=!0){this._fixedLocationContactPersonSource.next(t),o&&this.store.dispatch(ht({shippingTypeSelection:Ae.FixedLocation}))}getNotificationChannelByOCN(){return this.http.get("".concat(ze.getCartV2ApiUrl(),"/consent/notification-channel"),f(u({},Ai),{responseType:"text"}))}getPreferredNotificationChannel(){return this.preferredNotificationChannel$}setPreferredNotificationChannel(t){return this._preferredNotificationChannelSource.next(t)}generateNewAddressOTP(){this.store.dispatch(Ct())}handleGenerateNewAddressOTP(t,o){return this.generateNewAddressOTP(),this.dialogRef=this.matDialog.open(zt,{maxWidth:"500px",data:{isCompleteOrder:t}}),this.dialogRef.afterClosed()}handleVerifyNewAddressOTP(t,o){this.store.dispatch(xt({code:t,forced:o}))}toggleAddressUsage(t){this.toggleAddressSubject.next(t)}setEditMode(t){this.editModeSubject.next(t)}getLoggedInUserDeliveryAddresses(){return H([this.storeSelector.getWithSelector(_e),this.storeSelector.getWithSelector(Je()).pipe(B(t=>t.status===O.success),S(t=>t.list||[]))]).pipe(S(([t,o])=>this.mergeDeliveryAddresses(o,t)))}getGuestUserDeliveryAddresses(){return this.storeSelector.getWithSelector(_e).pipe(S(t=>t?[f(u({},t),{isEditable:!0,isKeepBillingDataToggled:t.isKeepBillingDataToggled})]:[]))}mergeDeliveryAddresses(t,o){var r;if(!((r=o==null?void 0:o.address)!=null&&r.addressId))return t;let s=Array.from(t),a=this.findDeliveryAddressInList(o,s);if(a){let d=s.indexOf(a);s[d]=f(u({},a),{party:o.party})}return s}findDeliveryAddressInList(t,o){return o.find(s=>{var a,r;return((a=s.address)==null?void 0:a.addressId)===((r=t.address)==null?void 0:r.addressId)&&Y(t.party,s.party)})||o.find(s=>{var a,r;return((a=s.address)==null?void 0:a.addressId)===((r=t.address)==null?void 0:r.addressId)})}checkShippingAddressIsComplete(t){var o,s,a;t!=null&&t.address&&(!(t!=null&&t.party)||!((o=t==null?void 0:t.party)!=null&&o.name)||!((s=t==null?void 0:t.party)!=null&&s.email)||!((a=t==null?void 0:t.party)!=null&&a.phone))&&this.handleEditDeliveryAddress(t)}};i.\u0275fac=function(o){return new(o||i)(D(ce),D(He),D(ct),D(de),D(lt),D(Mt))},i.\u0275prov=oe({token:i,factory:i.\u0275fac,providedIn:"root"});let e=i;return e})(),Oi=function(e){return e.BILLING="BILLING",e.INSTALLATION="INSTALLATION",e}(Oi||{});export{Ii as a,Fi as b,Ti as c,wi as d,Pi as e,Ei as f,Di as g,Vi as h,Ni as i,Bt as j,ki as k,Mi as l,Bi as m,$i as n,Ri as o,Ui as p,Gi as q,Wi as r,qi as s,zi as t,Hi as u,Xi as v,ji as w,Te as x,Ki as y,Yi as z,Zi as A,Ji as B,Qi as C,$t as D,co as E,po as F,uo as G,ho as H,_o as I,fo as J,go as K,Co as L,xo as M,vo as N,yo as O,So as P,Lo as Q,Oo as R,bo as S,Io as T,Fo as U,ue as V,me as W,wo as X,Wt as Y,Mo as Z,Ee as _,Rt as $,Bo as aa,he as ba,_e as ca,$o as da,J as ea,Ro as fa,Uo as ga,Go as ha,Ht as ia,Oi as ja};