1"use strict"; 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="513a6053-9bea-5627-8e6a-1f22e6af13b1")}catch(e){}}(); 3(self.webpackChunkclient=self.webpackChunkclient||[]).push([["865"],{21490(e,t,s){function i(e){return e.replace(/<!doctype\b[^>]+>/ig,"").replace(/<\/?html[^>]*>/ig,"").replace(/<\/?body[^>]>/ig,"").replace(/<meta[^>]*>/ig,"").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"")}s.d(t,{V:()=>n,s:()=>r});var r=e=>({id:e.id,userId:e.identity,body:i(e.body),type:e.event,timestamp:new Date(e.timestamp),read:e.read?new Date(e.read):void 0,stale:!1}),n=e=>{var{message:t}=e;return{id:t.id,userId:t.identity,body:i(t.body),type:t.event,timestamp:new Date(t.timestamp),read:void 0,stale:!1}}},56777(e,t,s){s.d(t,{J:()=>C});var i=s(39971),r=s(20365),n=s(21490),a=s(15526),d=s(79942),o=s(38107),u=s(17524),h=s(30131),c=s(75841),l=s(26274),p=s(93719),m=s(53940),v=s(36580),b=s(84190),g=s(28138),S=s(2773),w=s(48742),f=s(14316),j=s(56177),I=s(5801),y=s(52372),x=s(32841),k=s(91885),T=s(94375),E=s(49518),O=2*T.b.second;class C extends r.u{constructor(e){super("dialogs.concierge.messages",e,O,10),this.apiHost=new o.m(1),this.userId=e,this.token=E.L.shared(this.userId).data().pipe((0,m.p)(e=>!!e),(0,v.t)(1))}setHosts(e){this.apiHost.next(e)}buildUrl(e,t){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=new URLSearchParams("");return null!==s&&Object.keys(s).forEach(e=>{i.append(e,String(s[e]))}),x.format({protocol:"https",hostname:e,pathname:t,search:i.toString()})}sendFetch(e,t){return(0,u.z)([this.apiHost,this.token]).pipe((0,b.n)(s=>{var[i,r]=s,n=this.buildUrl(i,e,null==t?void 0:t.query),a=new Headers;return a.append("Authorization",'External jwt="'+r+'"'),(0,h.H)(fetch(n,{method:null==t?void 0:t.method,headers:a,body:JSON.stringify(null==t?void 0:t.body)}))}),(0,b.n)(e=>{if(401===e.status)throw Error("Unauthorized");return e.ok?(0,h.H)(e.json()).pipe((0,g.T)(e=>k.Q.success(e)),(0,S.W)(e=>(0,c.of)(k.Q.failure(e)))):(0,c.of)(k.Q.failure(e))}),(0,w.l)(e=>e.pipe((0,f.Z)((e,t)=>"Unauthorized"===e.message&&t<3?(E.L.shared(this.userId).refresh(),i.v.just()):(0,l.$)(e)))),(0,S.W)(e=>(0,c.of)(k.Q.failure(e)))).toSingle()}getActualItems(e,t,s){var i="/contacts/"+this.userId+"/concierge/messages";return this.sendFetch(i,{method:"GET",query:{omit:t,select:e,order:"newest"}}).pipe((0,d.vV)(e=>e.isSuccessful?e.value:{messages:[],omit:0}),(0,d.vV)(e=>(null==e?void 0:e.messages)||[]),(0,d.vV)(e=>({items:e.map(n.s).map(e=>Object.assign({},e,{stale:!0})),ttl:O})))}dataUpdates(e){return p.q.shared(this.userId).messages.pipe((0,m.p)(e=>"concierge"===e.channel),(0,g.T)(e=>(0,n.V)(e)),(0,b.n)(t=>e(void 0).pipe((0,j.s)(1),(0,I.o)(),(0,g.T)(e=>({data:null!=e&&e.data?e.data.concat([t]):[t],ttl:O})))))}getUnreadCount(){var e="/contacts/"+this.userId+"/concierge/messages/count";return this.sendFetch(e,{method:"GET",query:{read:!1}}).pipe((0,d.vV)(e=>e.isSuccessful?e.value:{count:0}),(0,d.vV)(e=>e.count||0))}read(e){return i.v.defer(()=>{var t=this.addOptimisticStateTransformation(t=>t.map(t=>(e.includes(null==t?void 0:t.id)&&(t.read=t.read||new Date,t.stale=!0),t))),s="/contacts/"+this.userId+"/concierge/messages/"+e[e.length-1]+"/read";return this.sendFetch(s,{method:"PUT"}).pipe((0,d.vV)(()=>void 0),(0,y.rQ)(t))})}stale(){return i.v.defer(()=>{var e=this.getState();return e&&this.setState(e.data.map(e=>Object.assign({},e,{stale:!0})),e.expiration),i.v.just(void 0)})}}C.shared=(0,a.G)(e=>new C(e))},49518(e,t,s){s.d(t,{L:()=>h});var i=s(15526),r=s(30495),n=s(79942),a=s(38107),d=s(97983),o=s(50846),u=s(50042);class h extends o.Q{constructor(e){super("winemback.authentication",e,()=>(0,r.Yq)(r.jI.shared().tokens["jwt/retention"].post,this.userId).pipe((0,n.vV)(e=>{var t,{token:s,xhr:i}=e;return{data:s,ttl:(null==(t=(0,u.a)(i))?void 0:t.maxAge)||Number.MAX_SAFE_INTEGER}}),(0,n.ex)(e=>{this.setState(e.data,void 0,e.ttl)}))),this.setState(null,void 0,Number.MAX_SAFE_INTEGER),this.userId=e,this.refreshSubject=ne
3w a.m(1)}refresh(){this.refreshSubject.next(void 0)}shouldRefreshData(){return this.refreshSubject.pipe((0,d.u)(()=>!0))}auth(){return(0,r.p6)(r.jI.shared().tokens["jwt/retention"].post,this.userId).pipe((0,n.vV)(e=>{var t,{data:s,xhr:i}=e;return{data:s.token,ttl:(null==(t=(0,u.a)(i))?void 0:t.maxAge)||Number.MAX_SAFE_INTEGER}}),(0,n.ex)(e=>{var{data:t,ttl:s}=e;this.setState(t,void 0,s)}))}}h.shared=(0,i.G)(e=>new h(e))},93719(e,t,s){s.d(t,{q:()=>w});var i=s(8733),r=s(82788),n=s(30131),a=s(38107),d=s(97156),o=s(17524),u=s(15526),h=s(94375),c=s(74380),l=s(28138),p=s(84190),m=s(53940),v=s(36580),b=s(49518),g=5*h.b.second;class S{constructor(e,t,s,n,a){this.ws=null,this.retry=0,this.timer=null,this.isOpened=!1,this.close=()=>{this.closeWebSocket(),this.messagesSubject.complete(),this.subscription.unsubscribe()},this.update=e=>{e!==this.userId&&(this.userId=e,this.isOpened&&this.closeWebSocket(),this.userId&&this.connect(this.userId))},this.makeUrl=e,this.apiHost=t,this.token=s,this.maxRetry=n,this.fallback=a,this.messagesSubject=new i.B,this.messages=this.messagesSubject.asObservable(),this.subscription=new r.yU,this.subscription.add(c.o.shared().data().pipe((0,l.T)(e=>e.id)).safeSubscribe(e=>this.update(e)))}connect(e){if(this.maxRetry&&++this.retry>this.maxRetry){this.fallback&&this.fallback();return}(0,n.H)(fetch("https://"+this.apiHost+"/contacts/"+e+"/notifications/shards",{headers:{authorization:'External jwt="'+this.token+'"'}})).pipe((0,p.n)(e=>e.json())).safeSubscribe(t=>{var s=new WebSocket(this.makeUrl(t.key,t.shard));this.ws=s,s.onopen=()=>{this.retry=0,this.isOpened=!0,this.onOpen&&this.onOpen()},s.onmessage=e=>{this.messagesSubject.next(e)},s.onerror=()=>{this.isOpened=!1,this.onClose&&this.onClose()},s.onclose=()=>{this.isOpened=!1,this.reconnect(e),this.onClose&&this.onClose()}})}send(e){return!!this.ws&&!!this.isOpened&&(this.ws.send(e),!0)}reconnect(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.connect(e)},g)}closeWebSocket(){this.ws&&(this.timer&&clearTimeout(this.timer),this.timer=null,this.ws.onopen=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onclose=null,this.ws.close(),this.ws=null,this.isOpened=!1,this.retry=0)}}class w{constructor(e){this.connection=null,this.hosts=new a.m(1),this.activeSubject=new d.t(!1),this.userId=e,this.messagesSubject=new i.B,this.messages=this.messagesSubject.asObservable(),this.token=b.L.shared(this.userId).data().pipe((0,m.p)(e=>!!e),(0,v.t)(1))}makeUrl(e,t,s){return"wss://rt"+t+"."+s+"/contacts/notifications/ws?key="+e}setHosts(e,t){this.hosts.next({api:e,websocket:t})}controlConnection(e){this.activeSubject.getValue()!==e&&(e?this.open():this.close())}open(){this.activeSubject.next(!0),(0,o.z)([this.hosts,this.token]).safeSubscribe(e=>{var[t,s]=e;this.connection=new S((e,s)=>this.makeUrl(e,s,t.websocket),t.api,s),this.connection.messages.safeSubscribe(e=>{if(e.data)try{var t=JSON.parse(e.data);this.messagesSubject.next(t)}catch(e){}})})}closeSocket(){this.connection&&(this.connection.close(),this.connection=null)}close(){this.activeSubject.next(!1),this.closeSocket()}}w.shared=(0,u.G)(e=>new w(e))},39204(e,t,s){s.d(t,{C:()=>o});var i=s(98153),r=s(48830),n=s(15526),a=s(15654),d=s(36580);class o{constructor(){this.visible=new r.c(e=>{e.next(!1);var t=()=>e.next(!0),s=()=>e.next(!1);return i.A.states("event.sidebar.concierge.opened",t,"event.sidebar.concierge.closed",s),()=>{i.A.removeStates("event.sidebar.concierge.opened",t,"event.sidebar.concierge.closed",s)}}).pipe((0,a.F)(),(0,d.t)(1))}}o.shared=(0,n.G)(()=>new o)},63184(e,t,s){s.d(t,{C:()=>i.C});var i=s(39204)},57272(e,t,s){s.d(t,{A:()=>D});var i=s(15526),r=s(8733),n=s(38107),a=s(17524),d=s(56607),o=s(75841),u=s(34578),h=s(4126),c=s(48830),l=s(82788),p=s(97156),m=s(56823),v=s(46660),b=s(84190),g=s(65052),S=s(36580),w=s(28138),f=s(15654),j=s(27585),I=s(53940),y=s(21490),x=s(85378),k=s(13462),T=s(5646),E=s(73628),O=s(56777),C=s(39971),R=s(63184),U=s(79942),V=s(93719),F=s(94375),A=s(4938),z=s(22998),M="concierge",H="settings",G={mute:{duration:0}},J=e=>Object.assign({},e,{mute:{duration:e.mute.duration,since:e.mute.since?new Date(e.mute.since):void 0}});
3class D{constructor(e){this.readSubject=new r.B,this.settingsSubject=new n.m(1),this.userId=e,this.settings=this.loadSettings().asObservable().pipe((0,b.n)(()=>this.settingsSubject.pipe((0,g.Z)(G))),(0,S.t)(1)),this.mute=this.settings.pipe((0,b.n)(e=>A.E.shared().currentTime().asObservable().pipe((0,w.T)(t=>{if(!e.mute.duration||!e.mute.since)return!1;var s=e.mute.duration*F.b.day;return e.mute.since.getTime()+s>t})))),this.messages=(0,a.z)([k.T.shared().conciergeEnabled,x.F.shared(this.userId).profile.pipe((0,w.T)(e=>{var t;return e.isSuccessful&&!!(null!=(t=e.value)&&t.gender)}),(0,f.F)())]).pipe((0,b.n)(e=>{var[t,s]=e;return t&&s?O.J.shared(this.userId).paged().items((0,o.of)(1)).pipe((0,j.E)(R.C.shared().visible,this.mute),(0,w.T)(e=>{var[t,s,i]=e;return t.items.map(e=>((s||i)&&(e.stale=!0),e))})):d.w}),(0,S.t)({refCount:!0,bufferSize:1})),this.unreadMessagesCount=(0,a.z)([(0,u.h)(this.messages,this.readSubject),this.mute]).pipe((0,b.n)(e=>{var[t,s]=e;return s?(0,o.of)(0):O.J.shared(this.userId).getUnreadCount()}),(0,S.t)({refCount:!0,bufferSize:1})),this.lastMessage=this.messages.pipe((0,w.T)(e=>e[e.length-1]),(0,I.p)(e=>!!e)),this.chat=(0,a.z)([this.unreadMessagesCount,this.lastMessage]).pipe((0,w.T)(e=>{var[t,s]=e,i=(0,v.Ij)((0,E.oy)((0,T.C)(s)));return i.unreadEventsCount=t,i}),(0,g.Z)(void 0))}pagedMessages(e,t){return(0,h.v)(()=>O.J.shared(this.userId).getUnreadCount().asObservable().pipe((0,b.n)(s=>new c.c(i=>{var r=new l.yU,n=new p.t({items:[],oldEndReached:!1,newEndReached:!1}),a={older:s,newer:s};return r.add(e.pipe((0,w.T)(e=>{var t=Math.max(a.older,e);return e>0&&t%e!=0&&(t=Math.ceil(t/e)*e),a.older=t+e,{omit:t,select:e}}),(0,b.n)(e=>{var{omit:t,select:s}=e;return 0===s?(0,o.of)({items:[],endReached:!1}):O.J.shared(this.userId).items(s,t,void 0).pipe((0,U.vV)(e=>({items:e.reverse(),endReached:e.length<s}))).asObservable()}),(0,j.E)(n)).safeSubscribe(e=>{var[t,s]=e;n.next(Object.assign({},s,{items:t.items.concat(s.items),oldEndReached:t.endReached}))})),r.add(t.pipe((0,w.T)(e=>{var t=Math.max(a.newer-e,0);return t%e!=0&&(t=Math.ceil(t/e)*e),a.newer=t,{omit:t,select:e}}),(0,b.n)(e=>{var{omit:t,select:s}=e;return O.J.shared(this.userId).items(s,t,void 0).pipe((0,U.vV)(e=>({items:e.reverse(),endReached:a.newer<=0}))).asObservable()}),(0,j.E)(n)).safeSubscribe(e=>{var[t,s]=e,i=new Set(s.items.map(e=>{var{id:t}=e;return t})),r=t.items.filter(e=>!i.has(e.id));n.next(Object.assign({},s,{items:s.items.concat(r),newEndReached:t.endReached}))})),r.add(V.q.shared(this.userId).messages.pipe((0,I.p)(e=>"concierge"===e.channel),(0,w.T)(e=>(0,y.V)(e)),(0,j.E)(n),(0,w.T)(e=>{var[t,s]=e;a.older+=1,a.newer+=1,s.newEndReached&&n.next(Object.assign({},s,{items:s.items.concat([t])}))})).safeSubscribe()),r.add(n.subscribe(i)),r}))))}read(e){return O.J.shared(this.userId).read(e).pipe((0,U.ex)(()=>this.readSubject.next()))}loadSettings(){return z.w.shared(M,this.userId).load(H).pipe((0,U.vV)(e=>{e&&this.settingsSubject.next(J(e))}))}updateSettings(e){return z.w.shared(M,this.userId).load(H).pipe((0,U.vV)(e=>e?J(e):G),(0,U.Fg)(t=>A.E.shared().currentTime().pipe((0,U.Fg)(s=>{var i,r=null==t?void 0:t.mute.since;e.mute.duration!==(null==t?void 0:t.mute.duration)&&0!==e.mute.duration&&(r=new Date(s)),0===e.mute.duration&&(r=void 0);var n=Object.assign({},t,{mute:{duration:e.mute.duration,since:r}});return this.settingsSubject.next(n),z.w.shared(M,this.userId).store(H,Object.assign({},n,{mute:{duration:n.mute.duration,since:null==(i=n.mute.since)?void 0:i.toISOString()}}))}))))}start(e){e.add((0,a.z)([k.T.shared().conciergeEnabled,R.C.shared().visible]).pipe((0,I.p)(e=>{var[t,s]=e;return t&&s}),(0,b.n)(()=>O.J.shared(this.userId).stale())).safeSubscribe()),e.add(this.settings.pipe((0,b.n)(e=>A.E.shared().currentTime().pipe((0,U.Fg)(t=>{if(0===e.mute.duration||!e.mute.since)return C.v.just(void 0);var s=e.mute.duration*F.b.day,i=e.mute.since.getTime()+s;if(i<Date.now())return this.updateSettings(G);var r=i-t;return r<F.B?(0,m.O)(r).toSingle().pipe((0,U.Fg)(()=>this.updateSettings(G))):C.v.just(void 0)})))).safeSubscribe())}}D.shared=(0,i.G)(e=>new D(e))},5646(e,t,s){s.d(t,{C:()=>i});var i=e=>({id:e.id,text:e.body,originText:e.body,tag:"concierge-content-tag",timestamp:e.timestamp,sender:"concierge","sender-id":"concierge",recipient:e.userId,"recipient-id":e.userId,meta:{"concierge-message-type":e.type}
3,type:"concierge"})}}]); 4//# sourceMappingURL=sourcemaps/865.ad251d044c5bb00d.js.map 5//# debugId=513a6053-9bea-5627-8e6a-1f22e6af13b1
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.