1"use strict";(self.webpackChunkResponsiveApps=self.webpackChunkResponsiveApps||[]).push([[1625],{8495:(K,W,s)=>{s.d(W,{Y:()=>g});var y=s(84412),D=s(2615);let g=(()=>{class f{constructor(){this._selectedDelivery=new y.t(null),this.o_selectedDelivery=this._selectedDelivery.asObservable()}get selectedDelivery(){return this._selectedDelivery.getValue()}set selectedDelivery(p){this._selectedDelivery.next(p)}get prevDelDate(){return this._prevDelDate}set prevDelDate(p){this._prevDelDate=p}static{this.\u0275fac=function(O){return new(O||f)}}static{this.\u0275prov=D.jDH({token:f,factory:f.\u0275fac,providedIn:"root"})}}return f})()},11625:(K,W,s)=>{s.d(W,{g:()=>Y});var y=s(84572),D=s(7673),g=s(18810),f=s(983),c=s(23294),p=s(61594),O=s(96354),_=s(31397),a=s(65245),l=s(25558),m=s(48531),d=s(56174),T=s(89079),v=s(9046),S=s(2615),P=s(71827),M=s(79772),B=s(99230),N=s(19209),F=s(12222),L=s(51253),H=s(8495),z=s(27491),Z=s(68018),j=s(15049),w=s(632),J=s(55944);let Y=(()=>{class V{constructor(n,i,e,t,o,r,u,h,C,x,A,U){this.webshopDataService=n,this.timeService=i,this.s_tourStore=e,this.s_userStore=t,this.s_localStorage=o,this.s_data=r,this.s_selectedDeliveryStore=u,this.s_uiConfig=h,this.s_translate=C,this.s_template=x,this.s_webshop=A,this.s_mobileAp
1p=U,this.subs=[],this.tourCache=new m.W,this.o_defaultZipCode=(0,y.z)([this.s_uiConfig.globalConfig.logicalConfIndex.app_webshop_defaultZipCode.execute.valueAsObservable,this.s_uiConfig.globalConfig.logicalConfIndex.app_webshop_defaultZipCode.defaultValue.valueAsObservable]).pipe((0,O.T)(([I,E])=>1==I&&null!=E?E:null)),this.s_tourStore.zipCode=this.s_localStorage.getLocalStorageStringValue(d.u.WEBSHOP_PLZ),this.subs.push(this.s_template.debounceUntilComponentsVisible((0,y.z)([t.o_webshopUser,e.o_zipCode.pipe((0,a.i)(1)),this.o_defaultZipCode])).subscribe(I=>{let b=I[1];!I[0]&&b!=I[2]&&this.setSavedZipCode(b)})),this.subs.push(this.s_template.debounceUntilComponentsVisible((0,y.z)([this.o_defaultZipCode,this.s_userStore.o_isLoggedIn])).pipe((0,p.$)(([I,E])=>!E)).subscribe(([I,E])=>{null!=I&&(this.s_tourStore.zipCode=I)})),this.subs.push(this.s_template.debounceUntilComponentsVisible((0,y.z)([this.s_tourStore.o_zipCode.pipe((0,c.F)()),this.s_userStore.o_isLoggedIn])).pipe((0,l.n)(([I,E])=>E||null==I?f.w:this.loadToursForZipCode(I))).subscribe()),U.isMobileApp&&this.currentZipCode.pipe((0,T.pQ)()).subscribe(I=>
1{this.s_mobileApp.sendMessage({type:v.B.CHANGED_ZIP_CODE,message:I})})}ngOnDestroy(){this.subs.forEach(n=>n.unsubscribe())}setSavedZipCode(n){null!=n?this.s_localStorage.putLocalStorageStringValue(d.u.WEBSHOP_PLZ,n):this.s_localStorage.removeItem(d.u.WEBSHOP_PLZ)}loadToursForZipCode(n){return this.getDefaultTours(n).pipe((0,O.T)(i=>{i||(i=[]),this.s_tourStore.tours=i}))}getDefaultTours(n){return this.s_tourStore.getDefaultTours(n)}getNonDefaultTours(n){return this.s_tourStore.getNonDefaultTours(n)}getFirstTourInstanceWhereOrderLimitNotReached(n,i,e,t=!1){return this.s_tourStore.getFirstTourInstanceWhereOrderLimitNotReached(n,i,e,t)}getNextDeliveryDate(n,i,e){return this.s_tourStore.getNextDeliveryDate(n,i,e)}getFirstPossibleDeliveryBreakDate(n,i){return this.getFirstTourInstanceWhereOrderLimitNotReached(n,i,void 0,!0).pipe((0,O.T)(e=>{if(!e)return;let t=n.find(r=>r.sid===e.tourSid);if(!t)return;let o=e.execDate.clone();for(let r=1;r<=6;r++){let u=r<t.dayOfWeek?t.dayOfWeek-r:t.dayOfWeek-r+7;if(n.find(h=>h.dayOfWeek===u))break;o.date-=1}return o}))}getTour(n,i,e){return this.s_tourStore.getTour(n,i,e)}getTourForShopCartPosGroup(n){return n?.tourSid?this.getTourBySid(n.tourSid):(0,D.of)(null)}getTourBySid(n){return this.tourCache.getObservable({tourSid:n},this._getTourBySid(n))}_getTourBySid(n){return null==n?(0,D.of)(null):this.s_tourStore.o_allTours.pipe((0,p.$)(),(0,l.n)(i=>{const e=this.getTourFromArray(n,i);return e?(0,D.of)(e):this.s_data.getTours(null,null,[n]).pipe((0,O.T)(t=>t?.length?t[0]:null))}))}getTourFromArray(n,i){if(i)for(let e of i)if(e.sid==n)return e;return null}getTourInstance(n,i,e){return this.s_tourStore.getTourInstanceByDateAndAddressOrZipCode(n,i,e)}getTourInstanceWithZipCodeFallback(n,i,e){return this.getTourInstance(n,i||this.s_tourStore.zipCode,e)}getTourInstanceByAddressSidWithZipCodeFallback(n,i,e){let t=this.s_userStore.getDeliveryAddressBySid(i);return this.getTourInstance(n,t||this.s_tourStore.zipCode,e)}initArticlePosWithTourInstSids(n){return n?.length?(0,y.z)(n.map(i=>i.getDeliveryCondTourInstSid()?(0,D.of)(i):this.getTourInstanceByAddressSidWithZipCodeFallback(i.getDeliveryCondDate(),i.getDeliveryCondAddressSid(),i.getProductDetail()).pipe((0,O.T)(e=>(i.setDeliveryContTourInstSid(e?.sid),i))))):(0,D.of)(n)}getTourInstancesBySid(n,i,e){return this.s_tourStore.getTourInstances(n,i,e)}getTourTypes(n){return this.s_tourStore.getTourTypes(n)}getTourTypeOfTour(n){return n&&n.tourTypeSid?this.getTourTypes([n.tourTypeSid]).pipe((0,O.T)(i=>{if(i&&i.length)return i[0]})):(0,D.of)(void 0)}get currentZipCode(){return this.s_tourStore.o_zipCode.pipe((0,_.Z)(n=>n?(0,D.of)(n):this.s_selectedDeliveryStore.o_selectedDelivery.pipe((0,O.T)(i=>i&&i.address?i.address.zipCode:null))))}getMinOrderLimit(n,i,e){if(n){let t;return i&&(t=this.s_userStore.getDeliveryAddressBySid(i)),this.currentZipCode.pipe((0,_.Z)(o=>this.getTour(n,t||o,e).pipe((0,l.n)(r=>r?this.s_tourStore.getTourInstance(r.sid,n).pipe((0,O.T)(u=>u?u.closingTime:null)):(0,D.of)(null)))),(0,p.$)())}return(0,D.of)(null)}minOrderLimitReached(n,i,e){return(0,y.z)([this.getMinOrderLimit(n,i,e),this.timeService.o_serverDate]).pipe((0,O.T)(t=>{let o=t[0];return!o||o.isBefore(t[1])}))}minOrderLimitReachedForDateAndTourSid(n,i){return n&&i?(0,y.z)([this.s_tourStore.getTourInstance(i,n),this.timeService.o_serverDate]).pipe((0,O.T)(([e,t])=>!e?.closingTime||e.closingTime.isBefore(t))):(0,D.of)(!0)}getOrderAllowedAndErrorMessage(n,i){return this.getTourInstance(n,i).pipe((0,l.n)(e=>0==e?.orderAllowed?e.orderNotAllowedMessage?(0,D.of)({orderAllowed:!1,orderNotAllowedMessage:e.orderNotAllowedMessage}):this.s_translate.get("text.tourInstOrderNotAllowed").pipe((0,p.$)(),(0,O.T)(t=>({orderAllowed:!1,orderNotAllowedMessage:t}))):(0,D.of)({orderAllowed:!0})))}isInTransit(n,i){return n?this.s_tourStore.getTourInstance(n,i,!0).pipe((0,p.$)(),(0,O.T)(e=>e?.enqState==d.u.ENQ_STATE_INTRANSIT)):(0,D.of)(!1)}isDefaultZipCodeSet(){return!(!this.s_uiConfig.globalConfig.logicalConfIndex.app_webshop_defaultZipCode.execute.value||!this.s_uiConfig.globalConfig.logicalConfIndex.app_webshop_defaultZipCode.defaultValue.value)}getDefaultZipCodeFromConfig(){return this.s_uiConfig.globalConfig.logicalConfIndex.app_webshop_defaultZipCode.defaultValue.value}hideDefaultZipCode(){return this.s_uiConfig.globalConfig.logicalConfIndex.app_webshop_hideDefaultZipCode.execute.value}hideZipCode(){return this.isDefaultZipCodeSet()&&this.hideDefaultZipCode()&&this.getDefaultZipCodeFromConfig()==this.s_tourStore.zipCode}getTourByShopCartPosGroup(n){return n?.tourSid?this.getTourBySid(n.tourSid):(0,D.of)(null)}checkForTour(n){return this.checkForTourObservable(n).toPromise()}checkForTourObservable(n){return this.s_tourStore.o_allStandardTours.pipe((0,p.$)(),(0,l.n)(i=>i&&i.length?(0,D.of)(void 0):this.s_webshop.tryLogin(n).pipe((0,l.n)(e=>e?(0,D.of)(void 0):(0,g.$)(void 0)))))}static{this.\u0275fac=function(i){return new(i||V)(S.KVO(P.x),S.KVO(M.v),S.KVO(B.b),S.KVO(N.w),S.KVO(F.s),S.KVO(L.Q),S.KVO(H.Y),S.KVO(z.s),S.KVO(Z.c$),S.KVO(j.I),S.KVO(w.WebshopUserService),S.KVO(J.z))}}static{this.\u0275prov=S.jDH({token:V,factory:V.\u0275fac,providedIn:"root"})}}return V})()},23127:(K,W,s)=>{s.d(W,{Dn:()=>O,Zh:()=>p,dq:()=>c});var y=s(67374),D=s.n(y),g=s(56174),f=s(62121);D().prototype.toJSON=function(){return this.format()};let c=(()=>{class _{get start(){return this.startDate?.getIsoStringWithoutTimeZone()}get end(){return this.endDate?.getIsoStringWithoutTimeZone()}set orderAllowed(l){0==l?this.className.push("order-not-allowed"):this.className=this.className.filter(m=>"order-not-allowed"!=m)}static{this.counter=0}constructor(l,m,d){this.allDay=!0,this.className=[],this.id=_.counter++,this.title=l||"text.event",this.startDate=m,this.addressSid=d,m.isBefore(f.s.create())?this.className.push("fc-past"):this.className.push("fc-future")}select(){this.className.push("selected")}unselect(){this.className=this.className.filter(l=>"selected"!=l)}isSelected(){return this.className.find(l=>"selected"==l)}dateWithin(l){return!!l&&(this.startDate&&this.endDate?l.isBetween(this.startDate,this.endDate,"day","[)"):this.startDate.isSame(l,"day"))}copy(){let l=new _(this.title,this.startDate.clone(),this.addressSid);return l.id=this.id,l.endDate=this.endDate?this.endDate.clone():null,l.allDay=this.allDay,l.className=JSON.parse(JSON.stringify(this.className)),l}isSpecial(){return this instanceof p&&(this.deliveryCondSid==g.u.WEBSHOP_SHOPCARTPOS_SPECIALDELIVERY||this.deliveryCondSid==g.u.WEBSHOP_SHOPCARTPOS_SPECIALWISHDELIVERYDATE)}}return _})();class p extends c{constructor(a,l,m,d,T){super(a,l,m),this._isOpen=!1,this._isFinished=!1,this.className.push("deliveryDay"),this.deliveryCondSid=d,this.tourSid=T}static createDeliveryEvent(a,l,m=void 0,d=void 0){return new p("text.deliveryDay",a,l,m,d)}static createEmptyDeliveryEvent(a,l,m=void 0,d=void 0){let T=this.createDeliveryEvent(a,l,m,d);return T&&(T.isEmpty=!0),T}set isOpen(a){a!=this._isOpen&&(a?this.className.push("open"):this.className=this.className.filter(l=>"open"!=l),this._isOpen=a)}get isOpen(){return this._isOpen}set isEmpty(a){a!=this._isEmpty&&(a?this.className.push("empty"):this.className=this.className.filter(l=>"empty"!=l),this._isEmpty=a)}get isEmpty(){return this._isEmpty}set deliveryCondSid(a){a!=g.u.WEBSHOP_SHOPCARTPOS_WISHDELIVERYDATE&&a!=g.u.WEBSHOP_SHOPCARTPOS_SPECIALWISHDELIVERYDATE?this.className.push("default"):this.className=this.className.filter(l=>"default"!=l),a==g.u.WEBSHOP_SHOPCARTPOS_SPECIALDELIVERY||a==g.u.WEBSHOP_SHOPCARTPOS_SPECIALWISHDELIVERYDATE?this.className.push("special"):this.className=this.className.filter(l=>"special"!=l),this._deliveryCondSid=a}get deliveryCondSid(){return this._deliveryCondSid}changeToSpecialDelivery(){this.deliveryCondSid=this.deliveryCondSid==g.u.WEBSHOP_SHOPCARTPOS_WISHDELIVERYDATE?g.u.WEBSHOP_SHOPCARTPOS_SPECIALWISHDELIVERYDATE:g.u.WEBSHOP_SHOPCARTPOS_SPECIALDELIVERY}set isFinished(a){a!=this._isFinished&&(a?this.className.push("finished"):this.className=this.className.filter(l=>"finished"!=l),this._isFinished=a)}get isFinished(){return this._isFinished}copy(){let a=new p(this.title,this.startDate.clone(),this.addressSid,this.deliveryCondSid,this.tourSid);return a.id=this.id,a.endDate=this.endDate?this.endDate.clone():null,a.allDay=this.allDay,a.className=JSON.parse(JSON.stringify(this.className)),a._isEmpty=this._isEmpty,a._isOpen=this._isOpen,a._isFinished=this._isFinished,a.hasDelivery=this.hasDelivery,a}}class O extends c{constructor(a,l,m,d,T,v,S,P){super(a,l,d),this.endDate=m,this.timeUsageId=T,this.costInd=v,null!=P&&(this.id=P),this.replacementAddressSid=S,this.className.push("deliveryBreak")}static newId(){return O.counter++}static createHolidayEvent(a,l,m,d,T,v){let S=a.clone(),P=l.clone();return P.add({day:1}),new O("text.holiday",S,P,m,d,T,v)}copyParams(a){this.startDate=a.startDate,this.endDate=a.endDate,this.costInd=a.costInd,this.replacementAddressSid=a.replacementAddressSid}copy(a=!1){return new O(this.title,this.startDate.clone(),this.endDate.clone(),this.addressSid,this.timeUsageId,this.costInd,this.replacementAddressSid,a?O.newId():this.timeUsageId)}get isDonated(){return this.costInd===g.u.COST_IND_DONATE}}},36189:(K,W,s)=>{s.d(W,{e:()=>D});var y=s(56174);class D{constructor(f,c,p=[y.u.COST_IND_HOLIDAY,y.u.COST_IND_DONATE,y.u.COST_IND_GENERAL_HOLIDAY]){this.from=f,this.to=c,this.costIndSids=p,f.setDate(f.getDate()-1)}getJson(){let f={};f.from=this.from,f.to=this.to;let c=[];return this.costIndSids.forEach(p=>c.push(p)),f.costIndSids=c,f}}},50534:(K,W,s)=>{s.d(W,{H:()=>c});var y=s(48531),D=s(57786),g=s(2615),f=s(19209);let c=(()=>{class p{constructor(_){this.s_store=_,this.currentTimeUsagesCache=new y.W,(0,D.h)(this.s_store.onLogin,this.s_store.onLogout).subscribe(()=>{this.currentTimeUsagesCache.clearItems()})}static{this.\u0275fac=function(a){return new(a||p)(g.KVO(f.w))}}static{this.\u0275prov=g.jDH({token:p,factory:p.\u0275fac,providedIn:"root"})}}return p})()},51034:(K,W,s)=>{s.d(W,{d:()=>g});var y=s(23127),D=s(62121);class g{constructor(c,p,O,_,a,l,m,d,T,v){this.sid=c,this.aName=p,this.costIndSID=O,this.startTime=_,this.endTime=a,this.partner
1SID=l,this.recordStateSID=m,this.costInd2SID=d,this.addressSid=T,this.deliveryAddressSid=v}static convert(c){let p=D.s.create(c.startTime),O=D.s.create(c.endTime);return new g(c.sid,c.aName,c.costIndSID,p,O,c.partnerSID,c.recordStateSID,c.costInd2SID,c.addressSid,c.deliveryAddressSid)}getJson(){let c={};return c.sid=this.sid,c.aName=this.aName,c.costIndSID=this.costIndSID,c.startTime=this.startTime.getTime(),c.endTime=this.endTime.getTime(),c.partnerSID=this.partnerSID,c.recordStateSID=this.recordStateSID,c.costInd2SID=this.costInd2SID,c.addressSid=this.addressSid,c.deliveryAddressSid=this.deliveryAddressSid,c}toHolidayEvent(){return y.Dn.createHolidayEvent(this.startTime,this.endTime,this.addressSid,this.sid,this.costIndSID,this.deliveryAddressSid)}}},51253:(K,W,s)=>{s.d(W,{Q:()=>l});var y=s(53058),D=s(96354),g=s(99437),f=s(39066),c=s(62121);class p{constructor(d,T,v,S,P,M,B,N){this.sid=d,this.name=T,this.execDate=v,this.closingTime=S,this.tourSid=P,this.orderAllowed=M,this.orderNotAllowedMessage=B,this.enqState=N}static convert(d){let T=d.execDate?c.s.create(d.execDate):null,v=d.closingTime?c.s.create(d.closingTime):null,S=!0;return null!=d.orderAllowed&&(S=d.orderAllowed),new p(d.sid,d.name,T,v,d.tourSid,S,d.orderNotAllowedMessage,d.enqState)}}var O=s(56174),_=s(2615),a=s(35890);let l=(()=>{class m{constructor(T){this.s_data=T,this.homeUrl="/"}getTours(T,v=[O.u.WEBSHOP_TOUR_NORMAL,O.u.WEBSHOP_TOUR_SHIP],S){let P={};return P.zipCode=T,P.tourTypeSids=v,S&&(P.tourSids=S),this.s_data.post("webshop/gettours",JSON.stringify(P),void 0,this.homeUrl,!1,!0).pipe((0,D.T)(function M(B){if(0==(B=B.json()).length)return null;let N=[];return B.forEach(F=>{N.push(y.p.convert(F))}),N}),(0,g.W)(this.s_data.notifyUsererror.bind(this.s_data)))}getTourTypes(T){return this.s_data.post("common/gettourtypes",JSON.stringify({identifiers:T.map(v=>({tourTypeSid:v}))}),void 0,this.homeUrl,!1,!0).pipe((0,D.T)(v=>(v=v.json()).tourTypes.map(S=>f.Z.convert(S))),(0,g.W)(this.s_data.notifyUsererror.bind(this.s_data)))}getTourInstances(T){return this.s_data.post("webshop/gettourinstances",JSON.stringify(T.getJson()),void 0,this.homeUrl,!1,!0).pipe((0,D.T)(function v(S){S=S.json();let P=[];return S.forEach(M=>P.push(p.convert(M))),P}),(0,g.W)(this.s_data.notifyUsererror.bind(this.s_data)))}static{this.\u0275fac=function(v){return new(v||m)(_.KVO(a.u))}}static{this.\u0275prov=_.jDH({token:m,factory:m.\u0275fac,providedIn:"root"})}}return m})()},98513:(K,W,s)=>{s.d(W,{c:()=>_});var y=s(51034),D=s(99437),g=s(96354),f=s(88141),c=s(2615),p=s(35890),O=s(50534);let _=(()=>{class a{constructor(m,d){this.dataService=m,this.cachingService=d,this.homeUrl="/"}getCurrentTimeUsages(){let m=this.cachingService.currentTimeUsagesCache,d=this.dataService.get("webshop/getcurrenttimeusages",void 0,this.homeUrl,!1,!0).pipe((0,g.T)(function T(v){let S=v.json(),P=[];for(let M=0;M<S.length;M++)P.push(y.d.convert(S[M]));return P}),(0,D.W)(this.dataService.notifyUsererror.bind(this.dataService)));return m.getObservable(null,d)}saveTimeUsage(m){return this.dataService.post("webshop/savetimeusage",JSON.stringify(m.getJson()),void 0,this.homeUrl,!1,!0).pipe((0,f.M)(()=>this.cachingService.currentTimeUsagesCache.clearItems()),(0,g.T)(d=>200==d.status?y.d.convert(d.json()):null),(0,D.W)(this.dataService.notifyUsererror.bind(this.dataService)))}saveTimeUsages(m){return this.dataService.post("webshop/savetimeusages",JSON.stringify({timeUsages:m.map(d=>d.getJson())}),void 0,this.homeUrl,!1,!0).pipe((0,f.M)(()=>this.cachingService.currentTimeUsagesCache.clearItems()),(0,g.T)(d=>200==d.status?d.json().timeUsages.map(v=>y.d.convert(v)):null),(0,D.W)(this.dataService.notifyUsererror.bind(this.dataService)))}getTimeUsages(m){return this.dataService.post("webshop/gettimeusages",JSON.stringify(m.getJson()),void 0,this.homeUrl,!1,!0).pipe((0,g.T)(function d(T){T=T.json();let v=[];return T.timeUsages&&T.timeUsages.length&&T.timeUsages.forEach(S=>v.push(y.d.convert(S))),v}),(0,D.W)(this.dataService.notifyUsererror.bind(this.dataService)))}static{this.\u0275fac=function(d){return new(d||a)(c.KVO(p.u),c.KVO(O.H))}}static{this.\u0275prov=c.jDH({token:a,factory:a.\u0275fac,providedIn:"root"})}}return a})()},99230:(K,W,s)=>{s.d(W,{b:()=>Q});var y=s(84412),D=s(71985),g=s(84572),f=s(7673),c=s(92688),p=s(22806),O=s(5964),_=s(96354),a=s(25558),l=s(61594),m=s(39901),d=s(53058);class T extends d.p{constructor(i,e){super(i.sid,i.name,i.shortName,i.dayOfWeek,i.cachedNextDeliveryDate,i.picRowguid,i.dayOfWeekClosing,i.closingTime,i.remark,i.crmPartnerRespSid,i.crmPartnerResp,i.crmPartnerRespVulgo,i.partnerCarr,i.tourTypeSid,i.defaultTour),this.zipCode=e}}var v=s(48531);class S{get items(){return this._items}constructor(i){this._items=i}equals(i){return!this.items&&!i||!(!this.items||!i||this.items.length!==i.items.length)&&JSON.stringify(this.items)===JSON.stringify(i.items)}}var P=s(19634);class M{constructor(i,e,t,o,r){this.tourSids=i,this.dateFrom=e,this.dateTo=t,this.allowFinishedDateNotNull=o,this.orderAllowedQuerySid=r}getJson(){let i={};return i.tourSids=this.tourSids,i.dateFrom=this.dateFrom.valueOf(),i.dateTo=this.dateTo.valueOf(),i.allowFinishedDateNotNull=this.allowFinishedDateNotNull,i.orderAllowedQuerySid=this.orderAllowedQuerySid,i}}var B=s(36189),N=s(56174),F=s(62121),L=s(2615),H=s(19209),z=s(51253),Z=s(79772),j=s(98513),w=s(27491),J=s(28370),Y=s(23018),V=s(15049);let Q=(()=>{class n{get tours(){return this._tours.getValue()}set tours(e){this._tours.next(e)}get zipCode(){return this._zipCode.getValue()}set zipCode(e){this._zipCode.next(e)}get allTours(){return this._allTours}constructor(e,t,o,r,u,h,C,x){this.s_userStore=e,this.s_tourData=t,this.s_time=o,this.s_webshopData=r,this.s_uiConfig=u,this.s_exchange=h,this.s_uiObjectHelper=C,this.s_template=x,this._tours=new y.t(null),this.o_tours=this._tours.asObservable(),this._zipCode=new y.t(null),this.o_zipCode=this._zipCode.asObservable(),this.tourCache=new v.W,this.tourTypeCache=new v.W,this.subs=[],this.tourInstanceCache=new v.W,this.timeUsageCache=new v.W,this.subs.push(e.o_user.pipe((0,O.p)(A=>!!A)).subscribe(()=>{this.tours=null})),this.o_allStandardTours=D.c.create(A=>{let I,U=[];return U.push(x.debounceUntilComponentsVisible(this.s_userStore.o_webshopUser.pipe((0,O.p)(E=>!!E))).subscribe(E=>{I&&I.unsubscribe();let b=[E.mainAddress];E.additionalAddresses&&E.additionalAddresses.length&&(b=b.concat(E.additionalAddresses)),b=b.filter(R=>!!R.tours),b.length&&(I=(0,g.z)(...b.map(R=>this.getDefaultTours(R).pipe((0,_.T)($=>$.map(G=>new T(G,R.zipCode)))))).subscribe(R=>{A.next([].concat(...R))}))})),U.push(x.debounceUntilComponentsVisible((0,g.z)(this.o_tours,this._zipCode)).subscribe(E=>{let b=E[0],R=E[1];!this.s_userStore.user&&b&&R&&A.next(b.map($=>new T($,R)))})),U.push(x.debounceUntilComponentsVisible(this.s_userStore.o_user.pipe((0,O.p)(E=>!E))).subscribe(()=>{A.next(this.tours?this.tours.map(E=>new T(E,this.zipCode)):[])}
1)),()=>{I&&I.unsubscribe(),U.forEach(E=>E.unsubscribe())}}),this.o_allWishDeliveryTours=this.o_allStandardTours.pipe((0,a.n)(A=>{if(A){let U=A.map(I=>this.getToursByZipCodeAndTourTypes(I.zipCode,[N.u.WEBSHOP_TOUR_WISH]).pipe((0,_.T)(E=>E?E.map(b=>new T(b,I.zipCode)):[])));return U.length?(0,g.z)(...U).pipe((0,_.T)(I=>[].concat(...I))):(0,f.of)([])}return(0,f.of)([])})),this.o_allTours=D.c.create(A=>{let U=[],I=[];return U.push(this.s_template.debounceUntilComponentsVisible(this.o_allStandardTours).subscribe(E=>{I=E})),U.push(this.s_template.debounceUntilComponentsVisible(this.o_allWishDeliveryTours).subscribe(E=>{let b=I.concat(E);A.next(b)})),()=>U.forEach(E=>E.unsubscribe())}),this.subs.push(this.o_allTours.subscribe(A=>this._allTours=A))}getFirstTourInstanceWhereOrderLimitNotReached(e,t,o,r=!1){if(!e||!e.length)return(0,f.of)(void 0);let u=(0,f.of)(!0);return 1===e.length&&e[0].cachedNextDeliveryDate&&(!o||e[0].cachedNextDeliveryDate.isAfter(o))&&(u=this.isDateInAnyTimeUsage(e[0].cachedNextDeliveryDate,t,r)),u.pipe((0,a.n)(h=>{let C=(0,f.of)(null);return h||(C=this.getTourInstance(e[0].sid,e[0].cachedNextDeliveryDate)),(0,g.z)([C,this.s_time.o_serverDate])}),(0,a.n)(([h,C])=>{if(h?.closingTime&&!h.closingTime.isSameOrBefore(C)&&h.orderAllowed)return(0,f.of)(h);let A=C.clone();return o&&o>A&&(A=o.clone()),A.week+=4,this.getTourInstances(e.map(U=>U.sid),C,A).pipe((0,a.n)(U=>U?this.findNextValidTourInst(U,t,C,o,r):(0,f.of)(void 0)),(0,_.T)(U=>{if(U)return 1===e.length&&!o&&(e[0].cachedNextDeliveryDate=U.execDate),U}))}))}findNextValidTourInst(e,t,o,r,u){return e?.length?(e=e.sort((h,C)=>h.execDate.isBefore(C.execDate)?-1:1),(0,c.x)(...e.map(h=>h.closingTime&&!h.closingTime.isAfter(o)||r&&!h.execDate.isSameOrAfter(r)||!h.orderAllowed?(0,f.of)(null):this.isDateInAnyTimeUsage(h.execDate,t,u).pipe((0,_.T)(C=>C?null:h)))).pipe((0,l.$)(h=>!!h),(0,m.U)(null))):(0,f.of)(null)}getAllRelevantTimeUsages(e,t,o){return e=e.clone(),t=t.clone(),e.startOf("day"),t.endOf("day"),(0,g.z)([this.timeUsageCache.getObservable({from:e,to:t},this.s_webshopData.getTimeUsages(new B.e(new Date(e.valueOf()),new Date(t.valueOf())))),this.s_webshopData.getCurrentTimeUsages()]).pipe((0,_.T)(([r,u])=>{let h=[];return r&&h.push(...r),u&&h.push(...u),h.filter(C=>C.costIndSID==N.u.COST_IND_GENERAL_HOLIDAY||o.indexOf(C.addressSid)>-1)}))}isDateInAnyTimeUsage(e,t,o=!1){return o?(0,f.of)(!1):this.getFirstMatchingTimeUsage([{date:e,addressSid:t}]).pipe((0,_.T)(r=>!!r))}getFirstMatchingTimeUsage(e,t=!1){return(0,g.z)([this.s_time.o_serverDate,this.s_exchange.o_lastDispoDay]).pipe((0,a.n)(([o,r])=>{let u=new Set(e.map(h=>h.addressSid));return this.getAllRelevantTimeUsages(o,r,Array.from(u))}),(0,_.T)(o=>
1{if(null!=o){let r;for(let u of o)if(r=e.find(h=>h.date&&this.isTimeUsageValidForAddressSid(u,h.addressSid)&&h.date.isBetween(u.startTime,u.endTime,void 0,"[]")&&(!t||u.costIndSID==N.u.COST_IND_GENERAL_HOLIDAY)),r)return{timeUsage:u,matchingDateAndAddressSid:r}}return null}),(0,l.$)())}isTimeUsageValidForAddressSid(e,t){return e.costIndSID==N.u.COST_IND_GENERAL_HOLIDAY||t==e.addressSid}getWishDeliveryTour(e,t,o){return new Promise((r,u)=>{this.getNonDefaultTours(t).subscribe(h=>{h&&h.length?this.getTourInstances(h.map(C=>C.sid),e).subscribe(C=>{r(this.getSortedToursForTourInsts(C,h,o)[0])}):r(null)})})}getTour(e,t,o){return this.getSortedTours(e,t,o).pipe((0,_.T)(r=>r?.[0]))}getSortedTours(e,t,o){return(0,p.H)(this.getDefaultTours(t)).pipe((0,a.n)(u=>u?this.getTourInstances(u.map(h=>h.sid),e).pipe((0,a.n)(h=>{let C=this.getSortedToursForTourInsts(h,u,o);return C?.length?(0,f.of)(C):(0,p.H)(this.getWishDeliveryTour(e,t,o)).pipe((0,_.T)(A=>!A||!A.defaultTour&&C?.length?C:[A]))})):(0,f.of)([])))}getSortedToursForTourInsts(e,t,o){let r=[];if(e){e=e.sort(this.compareTourInsts);for(let u of e){let h=t.find(C=>C.sid===u.tourSid);h&&(!o||this.productAllowedForTour(o,h,u.execDate))&&r.push(h)}}return r}compareTourInsts(e,t){return e||t?!e&&t?1:e&&!t||e.closingTime?.isAfter(t.closingTime)?-1:1:0}productAllowedForTour(e,t,o){return!e?.articleTourUsages||!t?.sid||!e.articleTourUsages.find(r=>r.tourSid==t.sid&&(o?(!r.from||r.from.isSameOrBefore(o))&&(!r.to||r.to.isAfter(o)):!r.to||r.to.isSameOrAfter(F.s.create())))}getToursByZipCodeAndTourTypes(e,t=[N.u.WEBSHOP_TOUR_NORMAL,N.u.WEBSHOP_TOUR_SHIP]){return this.tourCache.getObservable({zipCode:e,tourTypes:new S(t)},this.s_tourData.getTours(e,t))}getTourTypes(e){return this.tourTypeCache.getObservable(e,this.s_tourData.getTourTypes(e))}getDefaultTours(e){return this.getDefaultOrNonDefaultTours(e,!0)}getNonDefaultTours(e){return this.getDefaultOrNonDefaultTours(e,!1)}getDefaultOrNonDefaultTours(e,t){return this.getTourTypes([]).pipe((0,a.n)(o=>{if(o){let r=[];if(o.forEach(u=>{u.dispOnShopAsDef==t&&r.push(u.sid)}),e instanceof P.p){if(t)return(0,f.of)(e.tours?e.tours.filter(u=>-1!==r.indexOf(u.tourTypeSid)):[]);e=e.zipCode}return this.getToursByZipCodeAndTourTypes(e,r)}return(0,f.of)([])}))}getNextDeliveryDate(e,t,o){return e&&!Array.isArray(e)&&(e=[e]),this.getFirstTourInstanceWhereOrderLimitNotReached(e,t,o).pipe((0,_.T)(r=>{if(r)return r.execDate}))}getDefaultOrNextStandardTour(e){let t=e&&e.tours&&e.tours.find(o=>o.defaultTour);return t?(0,f.of)(t):this.getDefaultTours(e||this.zipCode).pipe((0,a.n)(o=>o?this.getFirstTourInstanceWhereOrderLimitNotReached(o,e?.sid).pipe((0,_.T)(r=>{if(r)return o.find(u=>u.sid===r.tourSid)})):(0,f.of)(void 0)))}getNextDefaultDeliveryDate(e){if(e){let t=this.getDefaultTours(e).pipe((0,a.n)(r=>this.getNextDeliveryDate(r,e?.sid))),o=e&&e.tours&&e.tours.find(r=>r.defaultTour);return o?this.s_uiConfig.globalConfig.logicalConfIndex.app_webshop_preferDefaultTourForDeliveryDateAfterLogin.execute.valueAsObservable.pipe((0,l.$)(),(0,a.n)(r=>r?this.getNextDeliveryDate(o,e?.sid):t)):t}return(0,f.of)(void 0)}getOrderLimitReachedByDateAndAddressOrZipCode(e,t,o){return(0,g.z)([this.getTourInstanceByDateAndAddressOrZipCode(e,t,o),this.s_time.o_serverDate]).pipe((0,_.T)(([r,u])=>!r||r.closingTime?.isBefore(u)))}getTourInstanceByDateAndAddressOrZipCode(e,t,o){return this.getSortedTourInstances(e,t,o).pipe((0,_.T)(r=>r?.[0]))}getSortedTourInstances(e,t,o){return this.getSortedTours(e,t,o).pipe((0,a.n)(r=>r?.length?this.getTourInstances(r.map(u=>u.sid),e).pipe((0,_.T)(u=>u?u.sort(this.compareTourInsts):[])):(0,f.of)([])))}getTourInstance(e,t,o){return this.getTourInstances([e],t,void 0,o).pipe((0,_.T)(r=>r.length?r[0]:null),(0,l.$)())}getDefaultStandardTour(e){return e?this.getDefaultTours(e).pipe((0,_.T)(t=>{if(t&&t.length)return t.find(o=>o.defaultTour)||t[0]})):(0,f.of)(void 0)}getDefaultStandardTourForOrder(e){return e?e.tour?(0,f.of)(e.tour):this.getDefaultStandardTour(e.deliveryAddress):(0,f.of)(void 0)}getTourInstances(e,t,o,r){let u=null;return u=e instanceof Array?e:e?[e]:null,(t=t.clone()).startOf("day"),o||(o=t.clone()),(0,g.z)([this.s_exchange.o_lastDispoDay,this.s_uiObjectHelper.uiObjValueAsNumberIfExecute(this.s_uiConfig.globalConfig.logicalConfIndex.app_webshop_tourInstancesOrderAllowedQuerySid)]).pipe((0,l.$)(),(0,a.n)(([h,C])=>{o.isAfter(h)&&(o=h),o.endOf("day");let x=new M(u,t,o,r,C);return this.tourInstanceCache.getObservable({tourSids:u,dateFrom:t,dateTo:o,allowFinishedDateNotNull:r},this.s_tourData.getTourInstances(x))}))}getLastDeliveryDate(e){return e&&e.length?(0,g.z)([this.s_time.o_serverDate,this.s_exchange.o_lastDispoDay]).pipe((0,a.n)(([t,o])=>this.getTourInstances(e.map(r=>r.sid),t,o).pipe((0,_.T)(r=>r&&r.length?r[r.length-1].execDate:null)))):(0,f.of)(null)}
1ngOnDestroy(){this.subs.forEach(e=>e.unsubscribe())}getToursForDayOfWeek(e,t){return this.getDefaultTours(t).pipe((0,_.T)(o=>o?.filter(r=>r.dayOfWeek==e)))}getNextDeliveryDateForDayOfWeek(e,t){return this.getToursForDayOfWeek(e,t).pipe((0,a.n)(o=>this.getNextDeliveryDate(o,t instanceof P.p&&t.sid)))}static{this.\u0275fac=function(t){return new(t||n)(L.KVO(H.w),L.KVO(z.Q),L.KVO(Z.v),L.KVO(j.c),L.KVO(w.s),L.KVO(J.b),L.KVO(Y.Z),L.KVO(V.I))}}static{this.\u0275prov=L.jDH({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.