@veltdev/sdk
Version:
Velt is an SDK to add collaborative features to your product within minutes. Example: Comments like Figma, Frame.io, Google docs or sheets, Recording like Loom, Huddles like Slack and much more.
1 lines • 91.7 kB
JavaScript
import{a as K}from"./chunk-FBBI2VKM.js";import"./chunk-O76AOF76.js";import{A,B as N,y as Jt}from"./chunk-3J52NZMN.js";import{a as Be}from"./chunk-4ACOV475.js";import{b as ve,c as Je,d as re}from"./chunk-WTYACTR5.js";import{a as Vt}from"./chunk-6E3N35RF.js";import{a as Gt}from"./chunk-KEM6PWSD.js";import{a as It}from"./chunk-UJRDSNTY.js";import{D as _t,F as yt,da as f,ea as We,fa as $,ga as ze,s as Ct}from"./chunk-KU45CEXD.js";import{$ as ae,Db as vt,Df as xt,Dh as Nt,E as Y,Eb as pt,Ed as bt,Ee as p,Ef as Ut,Eh as wt,Fa as l,Fb as dt,Fc as ft,Fh as Ft,G as ot,Ga as he,Gc as D,Hi as Wt,I as He,Ib as te,Ii as zt,J as ke,Jb as ut,Kb as Re,L as Ke,Lc as Le,Le as rt,M as Qe,Md as Et,Nb as se,Nd as Pt,Nf as Tt,Ob as Me,Pa as m,Pb as ht,Pc as St,Pf as me,Q as at,Ra as ct,T as W,Ta as lt,Ua as x,Va as mt,W as H,X as Ze,Ya as U,Yf as Ot,_a as g,_b as j,a as C,aa as st,b as w,bc as _,bi as Rt,ca as P,cc as b,ci as ge,db as gt,dc as tt,de as nt,di as v,ei as Mt,fc as k,ff as it,fh as Dt,g as oe,ha as De,ia as Ae,ig as kt,ii as Lt,jh as At,k as Xe,kc as ce,l as ue,lb as c,lc as le,li as je,mb as T,mi as $e,nb as O,ob as R,oe as X,pc as ne,qa as Ne,r as F,sb as d,tb as u,ti as jt,ua as we,ub as Fe,v as L,vb as qe,vh as E,wa as I,xb as et,yi as $t,zb as s,zi as Bt}from"./chunk-GR3NESUB.js";var z=(()=>{let r=class r{constructor(e,t,i,a,h,y,M,Ve,Ye,Ue,Te,Oe,de){this.analyticsService=e,this.docService=t,this.domService=i,this.authService=a,this.afAuth=h,this.iamService=y,this.databaseService=M,this.configService=Ve,this.avatarService=Ye,this.loggingService=Ue,this.flockService=Te,this.commonDbService=Oe,this.realtimeAdapter=de,this.db=null,this.presenceUser$=new ue(new it),this.documentPaths=null,this.inactivityTime=300*1e3,this.offlineInactivityTime=600*1e3,this.presenceUsers$=new ue([]),this.presenceUsersSubscription=null,this.includeSelf$=new ue(!0),this.customPresenceUsers$=new ue([]),this.userIdleStateDetectionSubscription=null,this.userOfflineStateDetectionSubscription=null;try{this.loggingService.log("%c[WB] Creating CLASS: PresenceService","color: blue;"),this.databaseService.getDb().pipe(Y(S=>!!S),ke(1)).subscribe(S=>{S&&(this.db=S,this.getUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnUserDbConnectionStateChange().subscribe(()=>{},B=>{this.loggingService.catch("Error in PresenceService constructor updateOnUserDbConnectionStateChange: ",B)}),this.updateOnDatabaseDisconnect().subscribe(()=>{},B=>{this.loggingService.catch("Error in PresenceService constructor updateOnDatabaseDisconnect: ",B)}),this.updateOnDocumentFocusChange(),this.updateOnAllowedFeatureListChange())},S=>{this.loggingService.catch("Error in PresenceService constructor: ",S)}),this.authService.addPreSignOutFuction("presence-signout",this.signOutUser.bind(this)),this.presenceUsers$.pipe(Qe()).subscribe(([S,B])=>{try{B?.length>=0&&this.analyticsService.updateDefaultProperties({presenceUsersCount:B?.length}),sessionStorage.getItem(p.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE)||B?.length>1&&S.length!==B.length&&(sessionStorage.setItem(p.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE,"true"),this.presenceActionsService?.onMultipleUsersOnline({users:B}))}catch(gn){this.loggingService.catch("Error in presenceUsers$ pairwise subscription: ",gn)}}),this.authService.getUser$().pipe(Y(S=>!!S),ke(1)).subscribe(S=>{S?(this.detectUserIdleState(),this.detectUserOfflineState()):(this.unsubscribeUserIdleStateDetectionSubscription(),this.unsubscribeUserOfflineStateDetectionSubscription())}),this.presenceUser$.subscribe(S=>{try{S?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:JSON.parse(JSON.stringify(S)),state:S?.onlineStatus})}catch(B){this.loggingService.catch("Error in presenceUser$ subscription: ",B)}},S=>{this.loggingService.catch("Error in presenceUser$ subscribe: ",S)}),this.customPresenceUsers$.subscribe(()=>{try{let S=this.presenceUsers$.value.filter(B=>!B.localOnly);this.presenceUsers$.next(this.mergeWithCustomUsers(S))}catch(S){this.loggingService.catch("Error in customPresenceUsers$ subscription: ",S)}}),this.domService.onNetworkStatusChange$().subscribe(S=>{try{!S&&this.presenceUser$?.value?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:w(C({},JSON.parse(JSON.stringify(this.presenceUser$.value))),{onlineStatus:p.PRESENCE_STATUS_OFFLINE}),state:p.PRESENCE_STATUS_OFFLINE})}catch(B){this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscription: ",B)}},S=>{this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscribe: ",S)})}catch(S){this.loggingService.catch("Error in PresenceService constructor: ",S)}}setPresenceActionsService(e){try{this.presenceActionsService=e}catch(t){this.loggingService.catch("Error in setPresenceActionsService: ",t)}}detectUserIdleState(){try{this.unsubscribeUserIdleStateDetectionSubscription();let e=!1;this.userIdleStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(Ze(2e3),H(()=>{this.presenceUser$.value&&e&&(this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_ONLINE),e=!1)}),He(this.inactivityTime),H(()=>{this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_AWAY,{isUserIdle:!0}),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserIdleState: ",e)}}detectUserOfflineState(){try{this.unsubscribeUserOfflineStateDetectionSubscription();let e=!1;this.userOfflineStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(Ze(2e3),He(this.offlineInactivityTime),H(()=>{this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_OFFLINE,{isUserIdle:!0}),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserOfflineState: ",e)}}unsubscribeUserIdleStateDetectionSubscription(){try{this.userIdleStateDetectionSubscription&&(this.userIdleStateDetectionSubscription.unsubscribe(),this.userIdleStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserIdleStateDetectionSubscription: ",e)}}unsubscribeUserOfflineStateDetectionSubscription(){try{this.userOfflineStateDetectionSubscription&&(this.userOfflineStateDetectionSubscription.unsubscribe(),this.userOfflineStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserOfflineStateDetectionSubscription: ",e)}}getUser(){this.loggingService.log("%c[WB] Calling FUNCTION: getUser","color: green;"),this.authService.getUser$().pipe(Y(e=>!!e)).subscribe(e=>{e&&this.setPresenceUser(e)},e=>{this.loggingService.catch("Error in getUser: ",e)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$().pipe(H(e=>{this.documentPaths=e}),Qe(),H(([e,t])=>{e&&this.updateUserStatusOnDocumentChange(p.PRESENCE_STATUS_OFFLINE,e),t&&this.updateUserStatusOnDocumentChange(p.PRESENCE_STATUS_ONLINE,t)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths: ",e)})}getLocation(){this.docService.getLocation$().pipe(H(e=>{this.updateUserOnLocationChange(e)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getLocation: ",e)})}getPresenceUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getPresenceUser","color: green;"),this.presenceUser$.asObservable()}getPresenceUserValue(){return this.presenceUser$.value}getOnlineUsersOnCurrentDocument(e){return this.loggingService.log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;"),this.authService.getAuthState$().pipe(Y(t=>!!t),W(t=>this.isFeatureAllowed({firebaseUser:t,users:[],filteredUsers:[]})),W(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(L(i=>(t.featureAllowed=i,t))):F(t)),W(t=>t.featureAllowed?this.authService.isPlanExpired$().pipe(L(i=>(t.featureAllowed=!i,t))):F(t)),W(t=>t.featureAllowed?F(t).pipe(W(i=>this.docService.getDocumentPaths$().pipe(L(a=>(this.documentPaths=a,i.documentPaths=a,i)))),W(i=>this.getDataFromDocumentId(e).pipe(L(a=>(i.users=a||[],C({},i))))),L(i=>(e?e?.statuses?.length?i.filteredUsers=i?.users?.filter(a=>e?.statuses?.includes(a?.onlineStatus)):i.filteredUsers=i?.users?.slice():i.filteredUsers=this.filterOnlineUsers(i.users,i.firebaseUser),i)),W(i=>this.getIncludeSelf$().pipe(L(a=>(a||(i.filteredUsers=i?.filteredUsers?.filter(h=>h?.userSnippylyId!==i.user?.userSnippylyId)),i)))),W(i=>{let a=i?.filteredUsers||[];return this.customPresenceUsers$.pipe(L(()=>this.mergeWithCustomUsers(a)))})):F([])),Ke(At))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Y(t=>!!t),L(t=>w(C({},e),{config:t})),W(t=>this.authService.getUser$().pipe(L(i=>w(C({},t),{user:i})))),W(t=>Tt(t.config,t.user,X.PRESENCE)?F(w(C({},t),{featureAllowed:!0})):(this.loggingService.warn("Presence feature is not allowed."),F(w(C({},t),{featureAllowed:!1})))),Ke((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Y(t=>!!t),W(t=>{if(this.db=t,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.presence){let i=new Date(Date.now()-864e5).getTime();return this.commonDbService.dbListener({feature:"allPresence",properties:{documentId:e?.documentId??this.documentPaths?.documentId,organizationId:e?.organizationId??this.documentPaths?.organizationId,skipFirestore:!0,useQuery:!0,rtdbQuery:[Et("timestamp"),Pt(i)]}}).pipe(ot(a=>(this.loggingService.catch("Error in PresenceService getDataFromDocumentId: ",a),F(null))),L(a=>a?.data),L(a=>{let h=[];if(a){let y=Object.values(a).filter(M=>typeof M=="object");for(let M of y)h.push(M)}return h}))}else return F([])}))}filterOnlineUsers(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: filterOnlineUsers","color: green;");try{let a=e.slice().filter(h=>{let y=me(h.timestamp);return h.userSnippylyId&&(h.onlineStatus===p.PRESENCE_STATUS_ONLINE||h.onlineStatus===p.PRESENCE_STATUS_AWAY)&&y<this.offlineInactivityTime});return this.presenceUsers$.next(this.mergeWithCustomUsers(a)),a}catch(i){return this.loggingService.catch("Error in filterOnlineUsers:",i),[]}}enableIncludeSelf(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableIncludeSelf","color: green;"),this.includeSelf$.value===!0)return;this.includeSelf$.next(!0)}catch(e){this.loggingService.catch("Error in PresenceService enableIncludeSelf: ",e)}}disableIncludeSelf(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableIncludeSelf","color: green;"),this.includeSelf$.value===!1)return;this.includeSelf$.next(!1)}catch(e){this.loggingService.catch("Error in PresenceService disableIncludeSelf: ",e)}}getIncludeSelf$(){return this.includeSelf$.asObservable()}getIncludeSelf(){return this.includeSelf$.value}getPresenceUserFromExternalId(e){try{if(this.presenceUsers$.value&&this.presenceUsers$.value.length>0){let t=this.presenceUsers$.value.find(i=>i.userId===e);if(t)return t}return null}catch(t){return this.loggingService.catch("Error in getNameFromSnippylyId:",t),null}}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}updateCurrentPresenceUser(e){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateCurrentPresenceUser","color: green;");try{if(this.documentPaths?.presence&&e&&e.userId&&this.authService.isFeatureAllowed(X.PRESENCE)){if(!e.isAnonymous){e.pageInfo=new rt,e?.onlineStatus===p.PRESENCE_STATUS_ONLINE&&(e.isTabAway=!1,e.isUserIdle=!1);let t=JSON.parse(JSON.stringify(e));this.authService.getUser()&&this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(w(C({},t),{timestamp:this.timestamp})))})}this.presenceUser$.next(e)}}catch(t){this.loggingService.catch("Error in updateCurrentPresenceUser:",t)}})}setCurrentPresenceUserStatus(e,t){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setCurrentPresenceUserStatus","color: green;");try{this.loggingService.log(e);let i=this.presenceUser$.value;if(i.onlineStatus!==e){this.presenceUsersSubscription&&this.presenceUsersSubscription?.unsubscribe();let a=i.onlineStatus,h=e;this.presenceUsersSubscription=this.getPresenceUsers$().pipe(Y(y=>!!y?.length),ke(1)).subscribe(y=>{y?.length>1&&this.analyticsService.trackEvent(E.Events.Presence.PRESENCE_USER_STATUS_CHANGED,{oldStatus:a,newStatus:h,totalUsers:y?.length,presenceSnippylyUserIds:y?.map(M=>M.userSnippylyId),presenceClientUserIds:y?.map(M=>M.userId)})})}i.onlineStatus=e,t&&(i.isTabAway=t?.isTabAway,i.isUserIdle=t?.isUserIdle),e===p.PRESENCE_STATUS_ONLINE&&(i.isTabAway=!1,i.isUserIdle=!1),e===p.PRESENCE_STATUS_OFFLINE&&this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.updateCurrentPresenceUser(i)}catch(i){this.loggingService.catch("Error in setCurrentPresenceUserStatus:",i)}})}updateUserStatusOnDocumentChange(e,t){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserStatusOnDocumentChange","color: green;");try{let i=this.presenceUser$.value;if(i.onlineStatus=e,t?.presence&&i&&i.userId&&!i.isAnonymous&&this.authService.isFeatureAllowed(X.PRESENCE)){let a=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"presence",properties:{documentId:t?.documentId,organizationId:t?.organizationId,userId:i.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}catch(i){this.loggingService.catch("Error in updateUserStatusOnDocumentChange:",i)}})}updateUserOnLocationChange(e){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserOnLocationChange","color: green;");try{let t=this.presenceUser$.value;if(t.location=e?e.location:null,t.locationId=e?e?.locationId:null,this.documentPaths?.presence&&t&&t.userId&&!t.isAnonymous&&this.authService.isFeatureAllowed(X.PRESENCE)){let i=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}}catch(t){this.loggingService.catch("Error in updateUserOnLocationChange:",t)}})}updateOnUserDbConnectionStateChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnUserDbConnectionStateChange","color: green;");let e=this.realtimeAdapter.rtdbRef(this.db,".info/connected"),t=this.realtimeAdapter.rtdbObjectVal$("presence",e).pipe(L(i=>i?p.PRESENCE_STATUS_ONLINE:p.PRESENCE_STATUS_OFFLINE));return this.authService.getAuthState$().pipe(at(1),W(i=>i?t:F(p.PRESENCE_STATUS_OFFLINE)),H(i=>this.setCurrentPresenceUserStatus(i)))}updateOnDocumentFocusChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDocumentFocusChange","color: green;");try{document&&document.addEventListener("visibilitychange",e=>{this.authService.getUser()&&(document.visibilityState==="hidden"?(this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!1)):(this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!0)))}),window&&(window.addEventListener("focus",()=>{this.authService.getUser()&&(this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!0))}),window.addEventListener("blur",()=>{this.authService.getUser()&&(document.visibilityState!=="hidden"&&this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!1))}))}catch(e){this.loggingService.catch("Error in updateOnDocumentFocusChange:",e)}}updateOnAllowedFeatureListChange(){try{this.configService.getConfig$().subscribe(e=>{if(e&&e.featureAllowList?.length){let t=this.presenceUser$.value,i=!1;if(e.featureAllowList.includes(X.PRESENCE)?t?.onlineStatus!==p.PRESENCE_STATUS_ONLINE&&(t.onlineStatus=p.PRESENCE_STATUS_ONLINE,i=!0):t?.onlineStatus!==p.PRESENCE_STATUS_OFFLINE&&(t.onlineStatus=p.PRESENCE_STATUS_OFFLINE,i=!0),i&&this.authService.getUser()&&this.documentPaths?.presence&&t&&t.userId&&!t.isAnonymous){let a=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}})}catch(e){this.loggingService.catch("Error in updateOnAllowedFeatureListChange:",e)}}updateOnDatabaseDisconnect(){return this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDatabaseDisconnect","color: green;"),this.authService.getAuthState$().pipe(Y(e=>!!e),W(e=>this.docService.getDocumentPaths$().pipe(L(t=>e))),H(e=>oe(this,null,function*(){try{if(this.documentPaths?.presence&&e){let t=yield this.authService.getIdTokenResultForUser(e,!0).catch(a=>null);if(!t)return;let{user:i}=t.claims;if(!i?.isAnonymous&&this.documentPaths?.presence){this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession();let a=`${this.documentPaths.presence}/${e.uid}`;this.commonDbService.setupOnDisconnect(a,{onlineStatus:p.PRESENCE_STATUS_OFFLINE,timestamp:this.timestamp}).catch(h=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",h)})}}}catch(t){this.loggingService.catch("Error in updateOnDatabaseDisconnect:",t)}})))}setPresenceUser(e){this.loggingService.log("%c[WB] Calling FUNCTION: setPresenceUser","color: green;");try{let t=this.presenceUser$.value;t.userId=e?.userId,t.name=e?.name,t.email=e?.email,t.photoUrl=e?.photoUrl,t.userSnippylyId=e?.userSnippylyId,t.color=e?.color,t.textColor=e?.textColor,t.initial=e?.initial,t.timestamp=this.timestamp,t.type=e?.type,t.isReadOnly=e?.isReadOnly,t.isAnonymous=e?.isAnonymous;let i=e?.name?.split(" ");if(i&&i.length>0){let a=i[0],h=i.length>1?i[i.length-1]:null,y=h?h[0]:null;a&&(t.name=`${a} ${y?y+".":""}`)}this.updateCurrentPresenceUser(t)}catch(t){this.loggingService.catch("Error in setPresenceUser:",t)}}signOutUser(e){return new Promise((t,i)=>{try{this.documentPaths?.presence&&e?this.commonDbService.getData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0}}).then(a=>{a&&(this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.commonDbService.updateData({feature:"presence",errorCallback:h=>{i(h)},callback:()=>{t(null)},properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0},data:JSON.parse(JSON.stringify(w(C({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:p.PRESENCE_STATUS_OFFLINE})))})),t(null)}).catch(a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),i(a)}):t(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),i(a)}})}setInactivityTime(e){try{this.inactivityTime=e,this.analyticsService.trackEvent(E.Events.Presence.PRESENCE_SET_CUSTOM_INACTIVITY_TIMER,{inactivityTime:this.inactivityTime}),this.detectUserIdleState()}catch(t){this.loggingService.catch("Error in setInactivityTime: ",t)}}getInactivityTime(){return this.inactivityTime}setOfflineInactivityTime(e){try{e>=this.inactivityTime?(this.offlineInactivityTime=e,this.analyticsService.trackEvent(E.Events.Presence.PRESENCE_SET_CUSTOM_OFFLINE_INACTIVITY_TIMER,{offlineInactivityTime:this.offlineInactivityTime}),this.detectUserOfflineState()):this.loggingService.catch("Error in setOfflineInactivityTime: ","offline-inactivity-time value is less than inactivity-time.")}catch(t){this.loggingService.catch("Error in setOfflineInactivityTime: ",t)}}getOfflineInactivityTime(){return this.offlineInactivityTime}getPresenceUsers$(){return this.presenceUsers$.asObservable()}getPresenceUsers(){return this.presenceUsers$.value}get timestamp(){return this.commonDbService.getServerTimestamp()}addCustomUser(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: addCustomUser","color: green;");let t=e?.user,i=e?.localOnly??!1;if(!t?.userId){this.loggingService.catch("Error in addCustomUser: ","userId is required");return}let a=this.buildCustomPresenceUser(t,i);if(!a)return;if(i){let h=this.customPresenceUsers$.value,y=h.findIndex(M=>M.userId===t.userId);if(y>=0){let M=[...h];M[y]=a,this.customPresenceUsers$.next(M)}else this.customPresenceUsers$.next([...h,a])}else this.persistCustomUserToDb(a)}catch(t){this.loggingService.catch("Error in addCustomUser: ",t)}}removeCustomUser(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeCustomUser","color: green;");let t=e?.user?.userId,i=e?.localOnly??!1;if(!t){this.loggingService.catch("Error in removeCustomUser: ","userId is required");return}if(i){let a=this.customPresenceUsers$.value,h=a.filter(y=>y.userId!==t);h.length!==a.length&&this.customPresenceUsers$.next(h)}else{let a=this.buildCustomPresenceUser(e.user,!1);a&&this.removeCustomUserFromDb(a)}}catch(t){this.loggingService.catch("Error in removeCustomUser: ",t)}}mergeWithCustomUsers(e){try{let t=this.customPresenceUsers$.value;if(t.length===0)return e;let i=new Set(e.map(h=>h.userId)),a=t.filter(h=>!i.has(h.userId));return[...e,...a]}catch(t){return this.loggingService.catch("Error in mergeWithCustomUsers: ",t),e}}buildCustomPresenceUser(e,t=!1){try{let i=this.configService.getApiKey(),a=new it;return a.userId=e.userId,a.name=e.name||e.userId,a.email=e.email||"",a.photoUrl=e.photoUrl||"",a.onlineStatus=e.onlineStatus||p.PRESENCE_STATUS_ONLINE,a.color=e.color||this.avatarService.generateUserColor(),a.textColor=e.textColor||"",a.type="custom",a.initial=e.initial||(a.name?a.name.charAt(0).toUpperCase():"U"),a.timestamp=Date.now(),a.isReadOnly=e.isReadOnly??!1,a.isAnonymous=e.isAnonymous??!1,a.location=e.location||null,a.locationId=e.locationId??null,a.pageInfo=e.pageInfo||new rt,a.isTabAway=!1,a.isUserIdle=!1,a.userSnippylyId=e.userSnippylyId||(i?kt(i,e.userId):`custom_${e.userId}`),a.localOnly=t,a}catch(i){return this.loggingService.catch("Error in buildCustomPresenceUser: ",i),null}}persistCustomUserToDb(e){try{if(this.documentPaths?.presence&&e?.userId&&this.authService.isFeatureAllowed(X.PRESENCE)){let t=JSON.parse(JSON.stringify(e));delete t.localOnly,this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(w(C({},t),{timestamp:this.timestamp})))})}}catch(t){this.loggingService.catch("Error in persistCustomUserToDb: ",t)}}removeCustomUserFromDb(e){try{this.documentPaths?.presence&&e?.userId&&this.authService.isFeatureAllowed(X.PRESENCE)&&this.commonDbService.deleteData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0}})}catch(t){this.loggingService.catch("Error in removeCustomUserFromDb: ",t)}}};r.\u0275fac=function(t){return new(t||r)(P(ge),P($t),P(je),P($e),P(bt),P(Gt),P(jt),P(Mt),P(Lt),P(v),P(K),P(zt),P(Wt))},r.\u0275prov=ae({token:r,factory:r.\u0275fac,providedIn:"root"});let n=r;return n})();var ie=class{constructor(){this.filteredPresenceUsers=[],this.shadowDom=!0,this.maxUsers=5,this.showTooltip=()=>{},this.closeTooltip=()=>{},this.onPresenceUserClick=()=>{}}};var V=class{constructor(){this.shadowDom=!0,this.calculateUserAwayTime=()=>{}}};var Kt=n=>({componentConfigSignal:n}),un=(n,r)=>({condition:n,data:r}),hn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-avatar-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function fn(n,r){if(n&1&&(d(0),R(1,"snippyly-user-avatar",3),u()),n&2){let o=s(2).ngIf,e=s();l(),Re("away",o.presenceUser.onlineStatus===e.constants.PRESENCE_STATUS_AWAY)("velt-presence-avatar--away",o.presenceUser.onlineStatus===e.constants.PRESENCE_STATUS_AWAY),c("user",o.presenceUser)}}function Sn(n,r){if(n&1&&(d(0),g(1,fn,2,5,"ng-container",2),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,hn,e.template,_(1,Kt,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Cn(n,r){if(n&1&&(d(0),g(1,Sn,2,9,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,un,o.conditionSignal(),_(1,Kt,o.componentConfigSignal)))}}var fe=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-avatar",this.constants=p;try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipAvatarComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-avatar-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-avatar","s-presence-avatar",3,"user"]],template:function(t,i){t&1&&g(0,Cn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,re],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{display:flex}[_nghost-%COMP%]:empty{display:none}.velt-presence-avatar[_ngcontent-%COMP%]{position:relative;border-radius:var(--velt-border-radius-full);z-index:2;width:calc((1.5 + 0px) * var(--velt-base-rem-unit));height:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;align-items:center;justify-content:center}.velt-presence-avatar--away[_ngcontent-%COMP%]{filter:grayscale(.7)}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem}"],changeDetection:0});let n=r;return n})();var Zt=n=>({componentConfigSignal:n}),yn=(n,r)=>({condition:n,data:r}),In=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-active-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function bn(n,r){n&1&&(d(0),T(1,"p"),se(2),ce(3,"translate"),O(),u()),n&2&&(l(2),Me(le(3,1,"User online")))}function En(n,r){if(n&1&&(d(0),g(1,bn,4,3,"ng-container",2),u()),n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,In,e.template,_(1,Zt,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Pn(n,r){if(n&1&&(d(0),g(1,En,2,9,"ng-container",0),u()),n&2){let o=s().ngIf,e=s();l(),c("ngIf",(o.presenceUser==null?null:o.presenceUser.onlineStatus)===e.constants.PRESENCE_STATUS_ONLINE)}}function xn(n,r){if(n&1&&(d(0),g(1,Pn,2,1,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,yn,o.conditionSignal(),_(1,Zt,o.componentConfigSignal)))}}var Se=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-active",this.constants=p;try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-active-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"]],template:function(t,i){t&1&&g(0,xn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}p[_ngcontent-%COMP%]{margin:0;color:var(--velt-green);font-weight:400;font-size:var(--velt-font-size-xs);line-height:1}"],changeDetection:0});let n=r;return n})();var qt=n=>({componentConfigSignal:n}),Tn=(n,r)=>({condition:n,data:r}),On=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-inactive-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function kn(n,r){if(n&1&&(d(0),T(1,"p",3),se(2),ce(3,"translate"),O(),u()),n&2){let o=s(3).ngIf;l(2),ht(" ",o.calculateUserAwayTime(o.presenceUser).toString()+" "+le(3,1,"mins ago.")," ")}}function Dn(n,r){if(n&1&&(d(0),g(1,kn,4,3,"ng-container",2),u()),n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,On,e.template,_(1,qt,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function An(n,r){if(n&1&&(d(0),g(1,Dn,2,9,"ng-container",0),u()),n&2){let o=s().ngIf,e=s();l(),c("ngIf",(o.presenceUser==null?null:o.presenceUser.onlineStatus)===e.constants.PRESENCE_STATUS_AWAY)}}function Nn(n,r){if(n&1&&(d(0),g(1,An,2,1,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,Tn,o.conditionSignal(),_(1,qt,o.componentConfigSignal)))}}var Ce=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-inactive",this.constants=p;try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-inactive-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip-user-inactive-text","inactive-text"]],template:function(t,i){t&1&&g(0,Nn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}p[_ngcontent-%COMP%]{margin:0;color:var(--velt-green);font-weight:400;font-size:var(--velt-font-size-xs);line-height:1}.velt-presence-tooltip-user-inactive-text[_ngcontent-%COMP%]{color:var(--velt-text-4)}"],changeDetection:0});let n=r;return n})();var en=n=>({componentConfigSignal:n}),Fn=(n,r)=>({condition:n,data:r}),Rn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-name-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Mn(n,r){if(n&1&&(d(0),T(1,"h1"),se(2),ce(3,"translate"),O(),u()),n&2){let o=s(3).ngIf;l(2),Me(o.presenceUser!=null&&o.presenceUser.name?o.presenceUser==null?null:o.presenceUser.name:le(3,1,o.presenceUser==null?null:o.presenceUser.email))}}function Ln(n,r){n&1&&R(0,"velt-skeleton-loader-internal",5)}function jn(n,r){if(n&1&&(d(0),g(1,Mn,4,3,"ng-container",4)(2,Ln,1,0,"ng-template",null,0,ne),u()),n&2){let o=te(3),e=s(2).ngIf;l(),c("ngIf",(e.presenceUser==null?null:e.presenceUser.name)||(e.presenceUser==null?null:e.presenceUser.email))("ngIfElse",o)}}function $n(n,r){if(n&1&&(d(0),g(1,jn,4,2,"ng-container",3),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Rn,e.template,_(1,en,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Bn(n,r){if(n&1&&(d(0),g(1,$n,2,9,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",b(3,Fn,o.conditionSignal(),_(1,en,o.componentConfigSignal)))}}var _e=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-name";try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserNameComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-name-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[["loadingTemplateRef",""],[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[4,"ngIf","ngIfElse"],["height","16px","width","80px","borderRadius","20px"]],template:function(t,i){t&1&&g(0,Bn,2,6,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,Je,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}h1[_ngcontent-%COMP%]{margin:0;color:var(--velt-text-0);font-size:var(--velt-font-size-sm);line-height:calc((1rem + 0px) * var(--velt-base-rem-unit));font-weight:400}"],changeDetection:0});let n=r;return n})();var tn=n=>({componentConfigSignal:n}),zn=(n,r)=>({condition:n,data:r}),Jn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-status-container-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Gn(n,r){if(n&1&&(d(0),T(1,"div",3),R(2,"velt-presence-tooltip-user-name-internal",4)(3,"velt-presence-tooltip-user-active-internal",4)(4,"velt-presence-tooltip-user-inactive-internal",4),O(),u()),n&2){let o=s(3);l(2),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal)}}function Vn(n,r){if(n&1&&(d(0),g(1,Gn,5,3,"ng-container",2),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Jn,e.template,_(1,tn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Yn(n,r){if(n&1&&(d(0),g(1,Vn,2,9,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,zn,o.conditionSignal(),_(1,tn,o.componentConfigSignal)))}}var ye=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-status-container",this.constants=p;try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-status-container-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip-status-container","user-status-container"],[3,"componentConfigSignal"]],template:function(t,i){t&1&&g(0,Yn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,Se,Ce,_e],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}.velt-presence-tooltip-status-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;z-index:2;gap:var(--velt-spacing-xs)}"],changeDetection:0});let n=r;return n})();var nn=(n,r)=>({componentConfigSignal:n,presenceUser:r}),Qn=(n,r)=>({condition:n,data:r}),Zn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function qn(n,r){n&1&&Fe(0)}function er(n,r){if(n&1&&(T(0,"velt-shadow-dom-internal"),g(1,qn,1,0,"ng-container",4),O()),n&2){s();let o=te(3);l(),c("ngTemplateOutlet",o)}}function tr(n,r){if(n&1&&(d(0),T(1,"div",8),R(2,"velt-presence-tooltip-avatar-internal",9)(3,"velt-presence-tooltip-status-container-internal",9),O(),u()),n&2){let o=s(5);l(2),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal)}}function nr(n,r){if(n&1&&(T(0,"div",6),g(1,tr,4,2,"ng-container",7),O()),n&2){let o=s(3).ngIf,e=s();l(),c("veltDynamicTemplate",k(4,Zn,e.template,b(1,nn,e.componentConfigSignal,e.presenceUser),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function rr(n,r){if(n&1&&g(0,nr,2,10,"div",5),n&2){let o=s(2).ngIf;c("ngIf",o==null?null:o.presenceUser)}}function ir(n,r){if(n&1&&(d(0),g(1,er,2,1,"velt-shadow-dom-internal",3)(2,rr,1,1,"ng-template",null,0,ne),u()),n&2){let o=te(3),e=s().ngIf,t=s();l(),c("ngIf",e.shadowDom&&!t.template||t.template&&t.isExplicitShadowDom)("ngIfElse",o)}}function or(n,r){if(n&1&&(d(0),g(1,ir,4,2,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",b(4,Qn,o.conditionSignal(),b(1,nn,o.componentConfigSignal,o.presenceUser)))}}var Ie=(()=>{let r=class r extends ze{set shadowDom(e){this._shadowDom=e}get shadowDom(){return this._shadowDom}constructor(e,t,i,a,h){super(e,t,void 0,void 0,void 0,i,a),this.elementRef=e,this.themeService=t,this.dynamicDataService=i,this.loggingService=a,this.wireframeService=h,this._shadowDom=!0,this.isExplicitShadowDom=!1,this.constants=p,this.subscriptions=[],this.componentId="velt-presence-tooltip",this.componentConfigSignal=Ne({presenceUser:null,shadowDom:!0,calculateUserAwayTime:this.calculateUserAwayTime.bind(this)}),this.loggingService.log("%c[WB] Creating CLASS: PresenceTooltipComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;");try{let e=this.elementRef.nativeElement,t=e.getAttribute("shadow-dom")??e.getAttribute("shadowdom");this.isExplicitShadowDom=t!==null&&t!=="false",this.setupA11yAttributes(),this.dynamicDataService.applyConditionalClasses(this.elementRef.nativeElement,{componentConfigSignal:this.componentConfigSignal,presenceUser:this.presenceUser}),this.subscriptions.push(this.wireframeService.getWireframe$("velt-presence-tooltip-wireframe").subscribe(a=>{if(a){let h=document.createElement(a.tagName);h.innerHTML=a.innerHTML,this.template=h}}))}catch(e){this.loggingService.catch("Error in PresenceComponent oninit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{super.ngOnChanges(e),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(i=>(i=w(C({},i),{[t]:e[t].currentValue}),i))})}catch(t){this.loggingService.catch("Error in PresenceTooltipComponent ngOnChanges: ",t)}}ngOnDestroy(){try{super.ngOnDestroy(),this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in PresenceTooltipComponent unsubscribe: ",e)}}calculateUserAwayTime(e){try{if(e.onlineStatus===p.PRESENCE_STATUS_ONLINE)return 0;let t=me(e.timestamp);return Math.floor(t/1e3/60)}catch(t){this.loggingService.catch("Error in PresenceTooltipComponent calculateUserAwayTime: ",t)}return 0}};r.\u0275fac=function(t){return new(t||r)(m(I),m(We),m(f),m(v),m(Be))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip"]],inputs:{presenceUser:"presenceUser",shadowDom:"shadowDom",variant:"variant"},standalone:!1,features:[U,we],decls:1,vars:1,consts:[["presenceTooltipRef",""],[4,"ngIf"],[4,"veltIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["class","velt-presence-tooltip-container",4,"ngIf"],[1,"velt-presence-tooltip-container"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip","s-tooltiptext","s-presence-tooltip"],[3,"componentConfigSignal"]],template:function(t,i){t&1&&g(0,or,2,7,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,Le,N,A,fe,ye],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent);margin:calc((.5rem + 0px) * var(--velt-base-rem-unit))}[_nghost-%COMP%]:empty{display:none}[dark][_nghost-%COMP%]{--velt-green: var(--velt-dark-mode-green);--velt-magenta: var(--velt-dark-mode-magenta);--velt-amber: var(--velt-dark-mode-amber);--velt-purple: var(--velt-dark-mode-purple);--velt-cyan: var(--velt-dark-mode-cyan);--velt-orange: var(--velt-dark-mode-orange);--velt-black: var(--velt-dark-mode-black);--velt-white: var(--velt-dark-mode-white);--velt-gray: var(--velt-dark-mode-gray);--velt-error: var(--velt-dark-mode-error);--velt-error-hover: var(--velt-dark-mode-error-hover);--velt-error-foreground: var(--velt-dark-mode-error-foreground);--velt-error-light: var(--velt-dark-mode-error-light);--velt-error-transparent: var(--velt-dark-mode-error-transparent);--velt-warning: var(--velt-dark-mode-warning);--velt-warning-hover: var(--velt-dark-mode-warning-hover);--velt-warning-foreground: var(--velt-dark-mode-warning-foreground);--velt-warning-light: var(--velt-dark-mode-warning-light);--velt-warning-transparent: var(--velt-dark-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-dark-mode-success);--velt-success-hover: var(--velt-dark-mode-success-hover);--velt-success-foreground: var(--velt-dark-mode-success-foreground);--velt-success-light: var(--velt-dark-mode-success-light);--velt-success-transparent: var(--velt-dark-mode-success-transparent);--velt-accent: var(--velt-dark-mode-accent);--velt-accent-text: var(--velt-dark-mode-accent-text);--velt-accent-hover: var(--velt-dark-mode-accent-hover);--velt-accent-foreground: var(--velt-dark-mode-accent-foreground);--velt-accent-light: var(--velt-dark-mode-accent-light);--velt-accent-transparent: var(--velt-dark-mode-accent-transparent);--velt-text-0: var(--velt-dark-mode-text-0);--velt-text-1: var(--velt-dark-mode-text-1);--velt-text-2: var(--velt-dark-mode-text-2);--velt-text-3: var(--velt-dark-mode-text-3);--velt-text-4: var(--velt-dark-mode-text-4);--velt-text-5: var(--velt-dark-mode-text-5);--velt-text-6: var(--velt-dark-mode-text-6);--velt-text-7: var(--velt-dark-mode-text-7);--velt-text-8: var(--velt-dark-mode-text-8);--velt-text-9: var(--velt-dark-mode-text-9);--velt-text-10: var(--velt-dark-mode-text-10);--velt-text-11: var(--velt-dark-mode-text-11);--velt-text-12: var(--velt-dark-mode-text-12);--velt-background-0: var(--velt-dark-mode-background-0);--velt-background-1: var(--velt-dark-mode-background-1);--velt-background-2: var(--velt-dark-mode-background-2);--velt-background-3: var(--velt-dark-mode-background-3);--velt-background-4: var(--velt-dark-mode-background-4);--velt-background-5: var(--velt-dark-mode-background-5);--velt-background-6: var(--velt-dark-mode-background-6);--velt-background-7: var(--velt-dark-mode-background-7);--velt-background-8: var(--velt-dark-mode-background-8);--velt-background-9: var(--velt-dark-mode-background-9);--velt-background-10: var(--velt-dark-mode-background-10);--velt-border-0: var(--velt-dark-mode-border-0);--velt-border-1: var(--velt-dark-mode-border-1);--velt-border-2: var(--velt-dark-mode-border-2);--velt-border-3: var(--velt-dark-mode-border-3);--velt-border-4: var(--velt-dark-mode-border-4);--velt-border-5: var(--velt-dark-mode-bord