@veltdev/sdk-dev 6.0.14-beta.2 → 6.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/{chunk-I63T4QWP.js → chunk-2XFRSBAE.js} +1 -1
  2. package/{chunk-7TFVNMHJ.js → chunk-3MNQES2P.js} +1 -1
  3. package/{chunk-VJLHHQ2Z.js → chunk-6HNU2FG2.js} +1 -1
  4. package/{chunk-L4QMAEKA.js → chunk-C7NBAS5V.js} +1 -1
  5. package/{chunk-PWTBCAPJ.js → chunk-CSN6ATAA.js} +1 -1
  6. package/{chunk-KWLMOL5X.js → chunk-DEQNXKWW.js} +1 -1
  7. package/{chunk-O3FUWWWQ.js → chunk-FS6KTSNQ.js} +1 -1
  8. package/{chunk-NMPXJFDX.js → chunk-FUR2EFO6.js} +1 -1
  9. package/{chunk-HRCWTVRH.js → chunk-FWPOKU7S.js} +1 -1
  10. package/{chunk-KQPNTB77.js → chunk-GUHU4CU5.js} +1 -1
  11. package/{chunk-2KTYC2AG.js → chunk-H57PY57T.js} +1 -1
  12. package/{chunk-UI2CRSTN.js → chunk-H6ZQEQFJ.js} +1 -1
  13. package/{chunk-77FADRSO.js → chunk-HALPIS6O.js} +1 -1
  14. package/{chunk-C5JOX4MX.js → chunk-HRU6STNE.js} +1 -1
  15. package/{chunk-MRY4A7N6.js → chunk-I6ELSCG4.js} +1 -1
  16. package/{chunk-UVKIGEOH.js → chunk-KBXVJ2AO.js} +1 -1
  17. package/{chunk-IQ22I2I3.js → chunk-L5SOVVIR.js} +1 -1
  18. package/{chunk-6NWFM6PC.js → chunk-LTKCIADR.js} +1 -1
  19. package/{chunk-ZHXLO4CC.js → chunk-LUXKOQSC.js} +1 -1
  20. package/{chunk-YO4HNOAN.js → chunk-NM32S6ZH.js} +1 -1
  21. package/{chunk-IMH5OESK.js → chunk-O3CLK76M.js} +1 -1
  22. package/{chunk-VW5ND7U4.js → chunk-OBDK4TJR.js} +1 -1
  23. package/{chunk-FZSZ6AV3.js → chunk-OCCE2UTF.js} +1 -1
  24. package/{chunk-KNQJBBQA.js → chunk-PHGOP6XJ.js} +1 -1
  25. package/{chunk-WFH4HYNH.js → chunk-QQMPMQJO.js} +1 -1
  26. package/{chunk-YFBAHLK6.js → chunk-RV7ZJ7J2.js} +23 -23
  27. package/{chunk-GULBDPIM.js → chunk-SC3WVEMZ.js} +1 -1
  28. package/{chunk-TQNLXTQA.js → chunk-TAOBMSMM.js} +1 -1
  29. package/{chunk-45X5JRZ6.js → chunk-TJT3IIS7.js} +1 -1
  30. package/{chunk-DZYXTTOX.js → chunk-U4L2FEIW.js} +1 -1
  31. package/{chunk-3AL5S762.js → chunk-VOMZ73T5.js} +1 -1
  32. package/{chunk-DFEL6HM7.js → chunk-XCOVQJPR.js} +1 -1
  33. package/{chunk-WMDZMDJS.js → chunk-YNFDUIYD.js} +1 -1
  34. package/{chunk-2HGCWC7B.js → chunk-ZSCDUVYV.js} +1 -1
  35. package/package.json +1 -1
  36. package/velt-activity-log.js +1 -1
  37. package/velt-area.js +1 -1
  38. package/velt-arrow.js +1 -1
  39. package/velt-comment.js +6 -6
  40. package/velt-crdt.js +1 -1
  41. package/velt-cursor.js +1 -1
  42. package/velt-huddle.js +1 -1
  43. package/velt-live-state-sync.js +1 -1
  44. package/velt-notification.js +1 -1
  45. package/velt-portable.js +1 -1
  46. package/velt-presence.js +1 -1
  47. package/velt-reaction.js +1 -1
  48. package/velt-recorder.js +1 -1
  49. package/velt-rewriter.js +1 -1
  50. package/velt-selection.js +1 -1
  51. package/velt-tag.js +1 -1
  52. package/velt-user-invite.js +1 -1
  53. package/velt-user-request.js +1 -1
  54. package/velt-video-player.js +1 -1
  55. package/velt-views.js +1 -1
  56. package/velt.js +2 -2
@@ -1 +1 @@
1
- import{He as h,Yd as c}from"./chunk-YFBAHLK6.js";var d=(t,r)=>{try{let e=l(t),i=[],n=[];return e.forEach(o=>{o?.parentElement?.closest(h.TAGS.SNIPPYLY_TEXT_HIGHLIGHT)?o?.parentElement?.normalize():n.push(o)}),n.forEach(o=>{let s=a(o,r);s&&i.push(s)}),i}catch(e){return c.catch("Error in highlighter highlightRange: ",e),[]}},l=t=>{try{if(t.collapsed)return[];let r=t.commonAncestorContainer;if(t.commonAncestorContainer.nodeType!==Node.ELEMENT_NODE&&(r=t.commonAncestorContainer.parentElement),!r)return[];let e=[],i=r.ownerDocument.createNodeIterator(r,NodeFilter.SHOW_TEXT),n,o=!1;for(;n=i.nextNode();)if(t.intersectsNode(n)){let s=n?.length;t.startContainer===n&&t.startOffset>0&&(n.splitText(t.startOffset),o=!0),t.endContainer===n&&t.endOffset<s&&n.splitText(t.endOffset),e.push(n)}return o&&e.shift(),e}catch(r){return c.catch("Error in highlighter getTextNodesInRange: ",r),[]}},a=(t,r)=>{try{let e=document.createElement(r||h.TAGS.SNIPPYLY_TEXT_HIGHLIGHT);return t.parentElement?.replaceChild(e,t),e.appendChild(t),e}catch(e){return c.catch("Error in highlighter highlightNode: ",e),null}};export{d as a};
1
+ import{He as h,Yd as c}from"./chunk-RV7ZJ7J2.js";var d=(t,r)=>{try{let e=l(t),i=[],n=[];return e.forEach(o=>{o?.parentElement?.closest(h.TAGS.SNIPPYLY_TEXT_HIGHLIGHT)?o?.parentElement?.normalize():n.push(o)}),n.forEach(o=>{let s=a(o,r);s&&i.push(s)}),i}catch(e){return c.catch("Error in highlighter highlightRange: ",e),[]}},l=t=>{try{if(t.collapsed)return[];let r=t.commonAncestorContainer;if(t.commonAncestorContainer.nodeType!==Node.ELEMENT_NODE&&(r=t.commonAncestorContainer.parentElement),!r)return[];let e=[],i=r.ownerDocument.createNodeIterator(r,NodeFilter.SHOW_TEXT),n,o=!1;for(;n=i.nextNode();)if(t.intersectsNode(n)){let s=n?.length;t.startContainer===n&&t.startOffset>0&&(n.splitText(t.startOffset),o=!0),t.endContainer===n&&t.endOffset<s&&n.splitText(t.endOffset),e.push(n)}return o&&e.shift(),e}catch(r){return c.catch("Error in highlighter getTextNodesInRange: ",r),[]}},a=(t,r)=>{try{let e=document.createElement(r||h.TAGS.SNIPPYLY_TEXT_HIGHLIGHT);return t.parentElement?.replaceChild(e,t),e.appendChild(t),e}catch(e){return c.catch("Error in highlighter highlightNode: ",e),null}};export{d as a};
@@ -1,4 +1,4 @@
1
- import{b as Y}from"./chunk-O3FUWWWQ.js";import{e as _,s as x,t as Q}from"./chunk-MRY4A7N6.js";import{C as A,E as g,Ld as w,M as S,Nd as y,O as B,Od as U,Pd as O,Ti as W,U as F,Uh as P,Ui as L,V as H,Y as E,Yf as D,ba as j,ea as b,g as $,jj as R,l as C,mj as M,p as k,r as u,v as m,w as z,wj as N,xj as K}from"./chunk-YFBAHLK6.js";var he=(()=>{let p=class p{constructor(e,t,r,a,s,c,n,i,d,o){this.authService=e,this.commonDbService=t,this.databaseService=r,this.docService=a,this.domService=s,this.loggingService=c,this.metadataService=n,this.commonDbUtils=i,this.configService=d,this.realtimeAdapter=o,this.HEARTBEAT_DURATION=5*1e3,this.heartbeatEnabled$=new C(!1),this.subscriptions=[],this.heartbeatCreatedTimestamps=new Map,this.initializedHeartbeatIds=new Set;try{this.loggingService.log("%c[WB] Creating CLASS: HeartbeatService","color: blue;"),this.heartbeatEnabled$.pipe(S()).subscribe(h=>{h?this.setupHeartbeat():this.teardownHeartbeat()}),this.docService.addPreDocumentIdChangeFunction("heartbeat-service",h=>h?.documentId?this.removeDocumentHeartbeat(h):Promise.resolve())}catch(h){this.loggingService.catch("Error in HeartbeatService constructor: ",h)}}setupWebWorker(e){try{let t=`
1
+ import{b as Y}from"./chunk-FS6KTSNQ.js";import{e as _,s as x,t as Q}from"./chunk-I6ELSCG4.js";import{C as A,E as g,Ld as w,M as S,Nd as y,O as B,Od as U,Pd as O,Ti as W,U as F,Uh as P,Ui as L,V as H,Y as E,Yf as D,ba as j,ea as b,g as $,jj as R,l as C,mj as M,p as k,r as u,v as m,w as z,wj as N,xj as K}from"./chunk-RV7ZJ7J2.js";var he=(()=>{let p=class p{constructor(e,t,r,a,s,c,n,i,d,o){this.authService=e,this.commonDbService=t,this.databaseService=r,this.docService=a,this.domService=s,this.loggingService=c,this.metadataService=n,this.commonDbUtils=i,this.configService=d,this.realtimeAdapter=o,this.HEARTBEAT_DURATION=5*1e3,this.heartbeatEnabled$=new C(!1),this.subscriptions=[],this.heartbeatCreatedTimestamps=new Map,this.initializedHeartbeatIds=new Set;try{this.loggingService.log("%c[WB] Creating CLASS: HeartbeatService","color: blue;"),this.heartbeatEnabled$.pipe(S()).subscribe(h=>{h?this.setupHeartbeat():this.teardownHeartbeat()}),this.docService.addPreDocumentIdChangeFunction("heartbeat-service",h=>h?.documentId?this.removeDocumentHeartbeat(h):Promise.resolve())}catch(h){this.loggingService.catch("Error in HeartbeatService constructor: ",h)}}setupWebWorker(e){try{let t=`
2
2
  let intervalId;
3
3
  self.addEventListener('message', (event) => {
4
4
  if (event.data === 'start') {
@@ -1 +1 @@
1
- import{a as ti}from"./chunk-UI2CRSTN.js";import{a as Zt}from"./chunk-3AL5S762.js";import{a as tt,e as qt,l as it,m as et,p as ht,r as ot,s as Qt,t as Xt}from"./chunk-MRY4A7N6.js";import{$f as lt,Ag as gt,Bi as Bt,E as B,G as j,Gd as Nt,Gg as J,He as x,K as Y,M as _,O as at,Q as St,Qd as It,Qf as yt,Ri as Q,Si as xt,Ti as X,Uf as Dt,Uh as Ft,Ui as Lt,V as N,Vf as Ct,Xf as ct,Y as vt,Yf as z,Yi as jt,Zf as Ut,a as b,b as $,ba as G,bi as ft,bj as Ht,cj as Vt,di as K,ea as m,ee as Ot,ej as _t,fa as pt,g as T,gj as dt,i as ut,ji as H,jj as Yt,ki as q,l as I,lg as At,mg as Tt,mi as Rt,mj as Gt,nj as Wt,oi as Pt,p as L,q as nt,qg as Et,r as C,re as bt,rg as $t,rj as kt,tf as W,uf as k,ug as Mt,uj as Jt,v,w as V,wj as Kt,x as mt,xj as Z,zg as wt,zi as zt}from"./chunk-YFBAHLK6.js";var ii=(()=>{let y=class y{constructor(t,i,e,o,s,n,r){this.commentUtilsService=t,this.loggingService=i,this.usersService=e,this.authService=o,this.commentAnnotationsResolverService=s,this.notificationResolverService=n,this.serviceBook=r,this.serviceBook.set(Pt,this)}getUserIdsToResolveFromNotifications(t){try{let i=new Set;for(let e of t){let{notification:o}=e;switch(o?.actionUser?.userId&&i.add(o?.actionUser?.userId),o?.displayHeadlineMessageTemplateData?.actionUser?.userId&&i.add(o?.displayHeadlineMessageTemplateData?.actionUser?.userId),o?.displayHeadlineMessageTemplateData?.recipientUser?.userId&&i.add(o?.displayHeadlineMessageTemplateData?.recipientUser?.userId),o?.notificationSource){case"comment":if(o?.notificationSourceData){let s=this.commentUtilsService.getUserIdsToResolveFromComments([o?.notificationSourceData]);for(let n of s)i.add(n)}break}}return Array.from(i)}catch(i){return this.loggingService.catch("Error in ReactionUtilsService getUserIdsToResolveFromRecorders:",i),[]}}mergeStrippedDataWithNotification(t){try{if(this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeStrippedDataWithNotification","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return t;let i=this.commentAnnotationsResolverService.getAnnotationById(t?.notification?.targetAnnotationId),e=t?.raw?.targetAnnotationData?.commentId,o=i?.comments?.[e]?.commentText,s=i?.comments?.[e]?.commentHtml;return o&&s&&t?.raw?.notificationSource==="comment"&&(t.notification.displayBodyMessageTemplate=o,t.raw.targetAnnotationData.commentText=o,t.raw.targetAnnotationData.commentHtml=s),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeStrippedDataWithNotification:",i),t}}mergeLocationWithNotification(t,i){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeLocationWithNotification","color: green;");let e=t?.notification?.notificationSourceData?.location?.id,o=t?.notification?.notificationSourceData?.metadata?.documentId;if(!e||!o)return t;let s=i?.[o]?.[e];return s&&(t.notification.notificationSourceData.location=s?.location,t?.raw?.annotationData?.location&&(t.raw.annotationData.location=s?.location)),t}catch(e){return this.loggingService.catch("Error in NotificationUtilsService mergeLocationWithNotification:",e),t}}mergeNotificationWithUser(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeNotificationWithUser","color: green;");let{notification:i}=t;if(i?.actionUser?.userId){let e=this.usersService.getUserById(i?.actionUser?.userId);e&&(i.actionUser=e)}if(i?.displayHeadlineMessageTemplateData?.actionUser?.userId){let e=this.usersService.getUserById(i?.displayHeadlineMessageTemplateData?.actionUser?.userId);e&&(i.displayHeadlineMessageTemplateData.actionUser=e)}if(i?.displayHeadlineMessageTemplateData?.recipientUser?.userId){let e=this.usersService.getUserById(i?.displayHeadlineMessageTemplateData?.recipientUser?.userId);e&&(i.displayHeadlineMessageTemplateData.recipientUser=e)}return i?.notificationSource==="comment"&&i?.notificationSourceData&&this.commentUtilsService.mergeCommentWithUser(i?.notificationSourceData),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeNotificationWithUser:",i),t}}formatNotification(t,i){try{switch(typeof t=="object"&&(t=JSON.parse(JSON.stringify(t))),this.usersService.userDataProviderAvailable()&&t?.actionUser&&(t.actionUser={userId:t.actionUser.userId}),t.notificationSource){case"comment":this.commentUtilsService.formatCommentData(t.annotationData),this.commentUtilsService.formatCommentThreadData(t.targetAnnotationData);break;case"recorder":this.serviceBook.get(zt)?.formatRecorderData(t.annotationData,i);break}return t}catch(e){return this.loggingService.catch("Error in NotificationUtilsService formatNotification: ",e),t}}getTargetAnnotationIdsFromNotifications(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: getTargetAnnotationIdsFromNotifications","color: green;");let i=[];return Object.values(t).forEach(e=>{e?.notification?.targetAnnotationId&&e?.raw?.notificationSource==="comment"&&i.push(e.notification.targetAnnotationId)}),i}catch(i){return this.loggingService.catch("Error in NotificationUtilsService getTargetAnnotationIdsFromNotifications:",i),[]}}handleNotificationEncryption(i){return T(this,arguments,function*({data:t}){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: handleNotificationEncryption","color: green;");let e="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??"");return yield wt(t,e)}catch(e){return this.loggingService.catch("Error in NotificationUtilsService handleNotificationEncryption:",e),t}})}getCustomNotificationIdsToResolve(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: getCustomNotificationIdsToResolve","color: green;");let i=new Set,e=Array.isArray(t)?t:Object.values(t||{});for(let o of e)if(o?.raw?.notificationSource==="custom"){let s=o?.notification?.id||o?.notificationId;s&&i.add(s)}return Array.from(i)}catch(i){return this.loggingService.catch("Error in NotificationUtilsService getCustomNotificationIdsToResolve:",i),[]}}mergeResolvedNotificationData(t){try{if(this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeResolvedNotificationData","color: green;"),!this.notificationResolverService.notificationDataProviderAvailable()||t?.raw?.notificationSource!=="custom")return t;let i=t?.notification?.id||t?.notificationId;if(!i)return t;let e=this.notificationResolverService.getNotificationById(i);if(!e)return t;let o=["displayHeadlineMessageTemplate","displayHeadlineMessageTemplateData","displayBodyMessage","displayBodyMessageTemplate","displayBodyMessageTemplateData","notificationSourceData"];for(let s of o)e[s]!==void 0&&(t.notification&&(t.notification[s]=e[s]),t.raw&&(t.raw[s]=e[s]));return Object.keys(e).forEach(s=>{!o.includes(s)&&s!=="notificationId"&&(t.notification&&(t.notification[s]=e[s]),t.raw&&(t.raw[s]=e[s]))}),t.notification&&(t.notification.isNotificationResolverUsed=!0),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeResolvedNotificationData:",i),t}}};y.\u0275fac=function(i){return new(i||y)(m(et),m(X),m(it),m(Z),m(tt),m(ot),m(Q))},y.\u0275prov=G({token:y,factory:y.\u0275fac,providedIn:"root"});let w=y;return w})();function ei(w){if(typeof w!="number"||!Number.isFinite(w))return 25;let t=Math.floor(w);return t<1?25:Math.min(200,t)}function di(w){return new ut(y=>{let st=!0,t=w.subscribe({next:i=>{if(st){let e=i?.data??i;if(!!e&&typeof e=="object"&&Object.keys(e).length===0&&!i?.operation)return}y.next(i)},error:i=>y.error(i),complete:()=>y.complete()});return st=!1,()=>t.unsubscribe()})}var Yi=(()=>{let y=class y{constructor(t,i,e,o,s,n,r,c,a,l,g,f,h,d,S,D,A,F,O,U,P,p){this.afAuth=t,this.analyticsService=i,this.authService=e,this.configService=o,this.commonDbService=s,this.commonDbUtilsService=n,this.commentUtilsService=r,this.commentAnnotationsResolverService=c,this.notificationResolverService=a,this.databaseService=l,this.docService=g,this.domService=f,this.iamService=h,this.loggingService=d,this.notificationUtilsService=S,this.usersService=D,this.functions=A,this.userPermissionService=F,this.coreActionsService=O,this.serviceBook=U,this.realtimeAdapter=P,this.adapterSelectorService=p,this.endpointsService=pt(jt),this.db=null,this.notificationsDb=null,this.documentPaths=null,this.notifications$=new I([]),this.rawNotificationsByIdMap$=new I(new Map),this.processedNotifications$=new I([]),this.userNotificationsFromServer$=new I(null),this.readNotificationsOnForYouTab$=new I(!1),this.currentDocumentOnly$=new I(!1),this.notificationViews$=new I({}),this.notificationsByIdMap$=new I(new Map),this.historyPanelVisible$=new I(!1),this.notificationsForYou$=new I(null),this.notificationsByDocumentIdMap$=new I(null),this.notificationsByDocumentIdSubscription={},this.notificationsHubDisabled=!1,this.reportedDroppedHubPushes=new Set,this.allowedDocumentMetadataMap$=new I(null),this.portableListBoundKey=null,this.maxNotificationDays$=new I(15),this.tabConfig$=new I({people:{enable:!1}}),this.settingsConfig$=new I(null),this.setSettingsConfigByOrganization$=new I(!1),this.muteAllNotifications$=new I(!1),this.enableSettings$=new I(!1),this.selfNotifications$=new I(!1),this.userScopedNotifications$=new I({enabled:!1,limit:25}),this.settingsInitialConfig$=new I([{name:"Inbox",id:"inbox",default:"ALL",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]},{name:"Email",id:"email",default:"MINE",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]}]),this.settingsConfigGeneration=0,this.notificationsPanelVisible$=new I(!1),this.crossOrganizationConfig$=new I({enabled:!1}),this.crossOrgNotifications$=new I([]),this.crossOrgIndexOrgs=[],this.crossOrgIndexTimestamps={},this.crossOrgSeenTimestamps={},this.crossOrgInitialFetchDone=!1,this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=0,this.CROSS_ORG_FETCH_WINDOW_MS=500,this.CROSS_ORG_PAGE_SIZE=50,this.crossOrgGeneration=0,this.crossOrgResolveRoundInFlight=!1,this.crossOrgStragglerRetryUsed=!1,this.CROSS_ORG_STRAGGLER_RETRY_MS=3e4;try{this.serviceBook.set(Rt,this),this.serviceBook.observe(Bt).subscribe(u=>{this.commentService=u??void 0}),this.subscribeNotificationsData().subscribe(),this.commentUtilsService.setNotificationService(this),this.databaseService.getDb().pipe(B(u=>!!u),Y(1)).subscribe(u=>{if(u){this.db=u;try{let E=this.configService.getProxyConfig(),M=this.endpointsService.getNotificationsDbUrl();Dt(M)?(this.notificationsDb=null,this.notificationsHubDisabled=!0):(E?.v1DbHost&&M&&(M=Ct(M,E.v1DbHost)),this.notificationsDb=this.realtimeAdapter.getDatabaseInstance(M),E?.v1DbHost&&M&&this.databaseService.lockDatabaseHost(this.notificationsDb))}catch(E){this.loggingService.catch("Error initializing notifications DB, using default: ",E),this.notificationsDb=u}this.getDocumentIds(),this.subscribeGetNotificationsForYou()}},u=>{this.loggingService.catch("Error in NotificationService getDb subscription: ",u)}),this.authService.getUser$().subscribe(u=>{u?(this.subscribeGetNotificationsForYou(),this.getDocumentIds(),this.subscribeToUserSettings()):(Object.keys(this.notificationsByDocumentIdSubscription).forEach(E=>{this.notificationsByDocumentIdSubscription[E]?.unsubscribe()}),this.notificationForYouSubscription?.unsubscribe(),this.documentIdsSubscription?.unsubscribe(),this.resetCacheData())}),Wt(()=>{try{this.adapterSelectorService?.isPortableBackendActive()&&this.getDocumentIds()}catch(u){this.loggingService.catch("Error re-evaluating portable notification list on chunk registration: ",u)}}),this.docService.getLocationMetadata$().subscribe(u=>{if(u){let E=this.notificationsByDocumentIdMap$.getValue()?JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue())):null;Object.keys(u||{}).forEach(M=>{let R=E?.[M]?.notifications;R?.length&&R.forEach(rt=>{this.notificationUtilsService.mergeLocationWithNotification({notification:rt},u)?.notification})}),this.notificationsByDocumentIdMap$.next(E)}})}catch(u){this.loggingService.catch("Error in NotificationService constructor: ",u)}}setDBConfigDataToInitialConfig(t){try{let i=JSON.parse(JSON.stringify(this.settingsConfig$.getValue()??{}));Object.entries(t||{}).forEach(([e,o])=>{i[e]=o}),this.settingsConfig$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService setDBConfigDataToInitialConfig: ",i)}}getInitialConfigFromDB(t){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: getInitialConfigFromDB","color: green;");let i=++this.settingsConfigGeneration,e=z(this.authService.getUser()?.userId??""),o=yield this.commonDbService.getData({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:this.getSettingsConfigByOrganization()?void 0:t?.documentId,organizationId:t?.organizationId??this.docService.getOrganizationConfig()?.organizationId,userId:e}});if(i!==this.settingsConfigGeneration)return;if(o?.notificationsConfig)this.setDBConfigDataToInitialConfig(o?.notificationsConfig);else{this.setSettingsInitialConfig(this.settingsInitialConfig$.getValue());let s={};this.settingsInitialConfig$.getValue().forEach(r=>{if(r.enable){let c=r?.values?.find(a=>a.id===r.default);s[r.id]=c||r?.values?.[0]||{id:"NONE",name:"None"}}});let n={};Object.keys(s).forEach(r=>{n[r]=s[r].id}),yield this.updateSettingsConfigToDb(n)}}catch(i){this.loggingService.catch("Error in NotificationService getInitialConfigFromDB: ",i)}})}subscribeToUserSettings(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: subscribeToUserSettings","color: green;"),this.userSettingsSubscription&&this.userSettingsSubscription.unsubscribe();let t=z(this.authService.getUser()?.userId??"");this.userSettingsSubscription=this.enableSettings$.pipe(B(i=>i===!0),N(()=>V([this.docService.getDocumentPaths$(),this.getSettingsConfigByOrganization$(),this.docService.getOrganizationConfig$()]).pipe(B(([i,e,o])=>(e||!!i)&&!!o?.organizationId),N(([i,e,o])=>nt(this.getInitialConfigFromDB(i)).pipe(N(()=>this.commonDbService.dbListener({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:e?void 0:i?.documentId,organizationId:i?.organizationId??o?.organizationId,userId:t}}).pipe(v(s=>{s?.data?.notificationsConfig&&!J(s?.data?.notificationsConfig??{},this.settingsConfig$.getValue()??{})&&this.setDBConfigDataToInitialConfig(s?.data?.notificationsConfig)})))))))).subscribe()}catch(t){this.loggingService.catch("Error in NotificationService subscribeToUserSettings: ",t)}}resetCacheData(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: resetCacheData","color: green;"),this.setUserNotificationsFromServer(null),this.notificationsByDocumentIdMap$.next(null),this.notificationsForYou$.next(null),this.settingsConfig$.next(null),this.resetCrossOrgForUser()}catch(t){this.loggingService.catch("Error in NotificationService resetCacheData: ",t)}}subscribeGetNotificationsForYou(){try{this.notificationForYouSubscription&&this.notificationForYouSubscription.unsubscribe(),this.notificationForYouSubscription=this.getNotificationsForYou().subscribe(()=>{},t=>{this.loggingService.catch("Error in NotificationService getNotificationsForYou subscription: ",t)})}catch(t){this.loggingService.catch("Error in NotificationService subscriveGetNotificationsForYou: ",t)}}setCommentService(t){try{this.commentService=t}catch(i){this.loggingService.catch("Error in NotificationService setCommentService: ",i)}}getDocumentIds(){try{this.documentIdsSubscription&&this.documentIdsSubscription.unsubscribe();let t=!1,i=mt(()=>this.adapterSelectorService?.isPortableBackendActive()?(t=!0,this.subscribePortableUserNotificationList(),L):this.selfNotifications$.pipe(N(()=>this.getCurrentDocumentOnly$().pipe(N(e=>e?this.docService.getDocumentPaths$().pipe(v(o=>{})):C(void 0)))),vt(()=>{this.notificationsByDocumentIdMap$.next(null)}),N(()=>this.getDocumentIdsByLastNotificationTimestamp().pipe(at(),v(([e,o])=>{let s=e?.map(l=>l.documentId),n=o?.map(l=>l.documentId),r=s?.filter(l=>!n?.includes(l)),c=n?.map(l=>({documentId:l,timestamp:o?.find(g=>g.documentId===l)?.timestamp})).filter(l=>!s?.includes(l.documentId)),a=n?.map(l=>{let g=o?.find(f=>f.documentId===l)?.timestamp;return{documentId:l,timestamp:g}}).filter(l=>{let g=e?.find(f=>f.documentId===l.documentId)?.timestamp;return g&&l.timestamp&&g!==l.timestamp});c?.length&&this.fetchNotificationsForDocumentIds(c),a?.length&&this.fetchNotificationsForDocumentIds(a,1),r?.forEach(l=>{this.removeNotificationsForDocumentId(l)}),o&&!o?.length&&!this.notificationsByDocumentIdMap$.getValue()&&(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([]))}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in NotificationService getDocumentIds subscription: ",e)});t||(this.documentIdsSubscription=i)}catch(t){this.loggingService.catch("Error in NotificationService getDocumentIds: ",t)}}subscribePortableUserNotificationList(){try{this.documentIdsSubscription&&this.documentIdsSubscription.unsubscribe(),this.documentIdsSubscription=this.authService.getUser$().pipe(N(t=>t?.userId?this.docService.getOrganizationConfig$().pipe(v(i=>i?.organizationId||t.organizationId),_(),N(i=>{let e=this.configService.getApiKey();if(!e||!i)return this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([]),L;let o=z(t.userId),s=`${o}:${e}:${i}`;return this.portableListBoundKey!==null&&this.portableListBoundKey!==s&&(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([])),this.portableListBoundKey=s,di(this.commonDbService.dbListener({feature:"allUserNotifications",properties:{id:o,apiKey:e,organizationId:i}})).pipe(j(n=>(this.loggingService.catch("Error in portable user notification list listener: ",n),C({data:{},operation:null}))))})):(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([]),L))).subscribe(t=>{try{this.applyPortableUserNotificationMap(t?.data??t??{})}catch(i){this.loggingService.catch("Error applying portable user notification map: ",i)}},t=>{this.loggingService.catch("Error in portable user notification list subscription: ",t)})}catch(t){this.loggingService.catch("Error in NotificationService subscribePortableUserNotificationList: ",t)}}applyPortableUserNotificationMap(t){let i=t&&typeof t=="object"?t:{},e=Object.keys(i).map(s=>{let n=i[s];return!n||typeof n!="object"?{notificationId:s}:b({notificationId:n.notificationId??s},n)});this.setUserNotificationsFromServer(e);let o={};for(let s of e)try{if((s?.kind??s?.payload?.kind)==="digest")continue;let r=this.getClientNotificationObject(s);if(!r)continue;let c=s?.metadata?.documentId??r?.metadata?.documentId;if(!c)continue;o[c]||(o[c]={notifications:[]}),o[c].notifications.push(r)}catch(n){this.loggingService.catch("Error materializing portable notification row: ",n)}for(let s of Object.keys(o))o[s].notifications.sort((n,r)=>(r.timestamp||0)-(n.timestamp||0));this.notificationsByDocumentIdMap$.next(o)}getDocumentIdsByLastNotificationTimestamp(t=15){try{return this.authService.getUser$().pipe(N(i=>this.docService.getOrganizationConfig$().pipe(v(e=>{let o=null,s=this.configService.getApiKey(),n=e?.organizationId||i?.organizationId,r=e?.clientOrganizationId||i?.clientOrganizationId||"";return s&&n&&(o=new ht({apiKey:s,organizationId:n})),{user:i,documentPaths:o,clientOrganizationId:r}}))),N(i=>{let{user:e,documentPaths:o,clientOrganizationId:s}=i;if(this.getCurrentDocumentOnly()&&!this.docService?.getDocumentPaths()?.documentId)return C(null);if(e&&o?.organizationNotificationsLastNotificationTimestamp){let n=new Date,r=this.maxNotificationDays$.getValue()>0?this.maxNotificationDays$.getValue():15;n.setDate(n.getDate()-r);let c=n.getTime(),a=[Ht(dt("timestamp",">=",c),...this.getCurrentDocumentOnly()&&this.docService.getDocumentPaths()?.documentId?[dt("metadata.documentId","==",this.docService.getDocumentPaths()?.documentId)]:[])];this.getCurrentDocumentOnly()||(a.push(_t("timestamp","desc")),a.push(Vt(t)));let l=e?.userId??"";return nt(this.userPermissionService?.getUserPermissionsFromCacheOrFetch({organizationId:s})??Promise.resolve({})).pipe(N(g=>l&&s&&g?.[l]?.organization?.[s]?.errorCode===yt.PERMISSION_DENIED?C(null):this.commonDbService.dbListener({feature:"allLastNotificationTimestamp",properties:{organizationId:o?.organizationId,isCollection:!0,useQuery:!0,firestoreQuery:a}}).pipe(v(f=>f?.data),v(f=>{let h=[];return Object.keys(f||{}).forEach(d=>{let S=this.commonDbService.shouldUseFirestore()?f[d]?.timestamp??0:f[d],D=this.commonDbService.shouldUseFirestore()?f[d]?.deletedNotification??!1:!1;if(D&&D.id&&D?.timestamp===S){let A=D.id,F=f[d]?.metadata?.documentId,O=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()??{})),U=O?.[F]??{documentMetadata:null,notifications:[]},P=U.notifications??[],p=P?.findIndex(u=>u.id===A);p!==-1&&(P.splice(p,1),this.notificationsByDocumentIdMap$.next($(b({},O),{[F]:$(b({},U),{notifications:P})}))),this.notificationResolverService.notificationDataProviderAvailable()&&this.notificationResolverService.getNotificationById(A)&&this.notificationResolverService.deleteNotification(A,this.docService.getDocumentPaths()?.clientOrganizationId??"")}h.push({documentId:d,timestamp:S})}),h}),j(f=>(this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",f),C([]))))))}return C(null)}))}catch(i){return this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",i),C([])}}resolveAndUpdateDocumentNotifications(t,i){try{Object.keys(t).forEach(e=>{let o=t[e]?.documentMetadata||this.docService.getAllDocumentMetadataMap()?.[e]||{},s;if(i==="user")s=this.commonDbUtilsService.mergeUsersWithData({feature:"allDocNotifications",data:t[e]?.notifications||[]});else if(i==="notification"){let n=t[e]?.notifications?.reduce((c,a)=>(c[a.notificationId]=a,c),{}),r=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allDocNotifications",data:n});s=Object.values(r??{})}else{let n=t[e]?.notifications?.reduce((c,a)=>(c[a.notificationId]=a,c),{}),r=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allDocNotifications",data:n});s=Object.values(r??{})}s.forEach(n=>{n.notification=this.getClientNotificationObject(n)}),this.setNotificationForDocumentIdInCache(e,o,s)})}catch(e){this.loggingService.catch("Error in NotificationService resolveAndUpdateDocumentNotifications: ",e)}}resolveAndMergeUserNotifications(t,i,e=!1){try{let o=t;if(e&&i==="comment"){let a=this.getUserNotificationsFromServer()??[],l=new Set(t.map(g=>g.notificationId));o=a.filter(g=>l.has(g.notificationId)).concat(t.filter(g=>!a.some(f=>f.notificationId===g.notificationId)))}let s=o.reduce((a,l)=>(a[l.notificationId]=l,a),{}),n;if(i==="user"){let a=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:s});n=Object.values(a??{})}else if(i==="notification"){let a=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:s});n=Object.values(a??{})}else{let a=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:s});n=Object.values(a??{})}n.forEach(a=>{a.notification=this.getClientNotificationObject(a)});let r=this.getUserNotificationsFromServer()??[],c=new Map(r.map(a=>[a.notificationId,a]));n.forEach(a=>{c.set(a.notificationId,a)}),this.setUserNotificationsFromServer(Array.from(c.values()))}catch(o){this.loggingService.catch("Error in NotificationService resolveAndMergeUserNotifications: ",o)}}fetchNotificationsForDocumentIds(t,i=15){return T(this,null,function*(){try{if(t?.length){let e=this.docService.getOrganizationConfig()?.organizationId??"";if(!e)return[];let o=this.getStartAtTimestamp(),s={};if(t.forEach(d=>{if(d?.documentId){let S=this.getAllowedDocumentMetadataByDocumentId(d.documentId);S&&(s[d.documentId]=S)}}),this.userPermissionService?.isPermissionProviderAvailable())try{let d=[];if(t.forEach(O=>{this.docService.getDocumentMetadata(O.documentId)||d.push(O.documentId)}),d.length){let O=this.authService.getUser(),U=q(this.functions,K({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));try{let P=yield ft({methodName:"getDocumentMetadataFromIds",data:{type:"getDocumentMetadataFromIds",metadata:{organizationId:O?.clientOrganizationId,folderId:this.documentPaths?.folderId},documentIds:d},getSdkProxy:U,userId:O?.userId??""});if(P?.data?.length){let p={};P.data.forEach(u=>{u?.documentId&&(p[u.documentId]=u)}),this.docService.setAllDocumentMetadata(b(b({},this.docService.getAllDocumentMetadataMap()),p))}}catch(P){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",P)}}let S=[],D=[];t.forEach(O=>{let U=this.docService.getDocumentMetadata(O.documentId);U?.clientDocumentId?S.push({userId:this.authService.getUser()?.userId??"",resource:b({id:U.clientDocumentId,type:k.DOCUMENT,source:W.GET_NOTIFICATIONS,organizationId:this.docService.getOrganizationConfig()?.clientOrganizationId??""},U.folderId&&{parentFolderId:U.folderId})}):D.push(O.documentId)}),D.length&&(t=t.filter(O=>!D.includes(O.documentId)));let A=$t();this.coreActionsService.triggerAction(Ot.PERMISSION_PROVIDER,{event:H.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:A,methodName:W.GET_NOTIFICATIONS,source:"internal",payload:{requests:S}});let F=yield this.userPermissionService?.onResourceAccessRequired({requests:S,uniqueId:A,methodName:W.GET_NOTIFICATIONS});F?.success&&F?.data?.length?F.data.forEach(O=>{!O.hasAccess&&O.resourceId&&(t=t.filter(U=>U.documentId!==Ut(O.resourceId)))}):t=[]}catch(d){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",d),t=[]}let n=this.userScopedNotifications$.getValue(),r=!!n?.enabled&&i!==1&&!this.getCurrentDocumentOnly();if(!t.length&&(this.notificationsByDocumentIdMap$.getValue()||(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([])),!r))return[];let c=this.userPermissionService?.getPermissionsCache()?.filter(d=>d.type===k.CONTEXT),a=b({organizationId:e,documentIds:t.filter(d=>!!d.documentId&&!!d.timestamp).map(d=>({documentId:d.documentId,timestamp:d.timestamp??0})),timestamp:o,limitToLast:i,selfNotifications:this.selfNotifications$.value,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),getUserNotifications:!0,isContextEnabled:this.userPermissionService?.getIsContextEnabled(),cachedData:c,isSettingsConfigByOrganization:this.getSettingsConfigByOrganization(),retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig()},r&&{getUserNotificationsForOrganization:!0,userNotificationsLimitToLast:ei(n?.limit)}),{notificationsByDocumentId:l,userNotifications:g=[],userNotificationIdsInDocNotifications:f=[],permissionResults:h=[]}=yield this.callGetNotificationsForDocuments(a);if(this.userPermissionService?.getIsContextEnabled()){let d=[...this.userPermissionService?.getPermissionsCache()??[],...h??[]];this.userPermissionService?.setPermissionsCache(d)}if(l&&typeof l=="object"){let d=this.usersService.userDataProviderAvailable(),S=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),D=this.notificationResolverService.notificationDataProviderAvailable(),A=[],F=[],O=[];Object.keys(l).forEach((p,u)=>{let E=l[p].documentMetadata??this.docService.getAllDocumentMetadataMap()?.[p];if(E){let R=this.allowedDocumentMetadataMap$.value||{};(!R?.[p]||!J(R?.[p],E))&&this.allowedDocumentMetadataMap$.next($(b({},R),{[p]:E}))}let M=l[p].notifications||[];M.forEach(R=>{f.includes(R.notificationId)&&!g.find(rt=>rt.notificationId===R.notificationId)&&g.push(JSON.parse(JSON.stringify(R))),R.notification=this.getClientNotificationObject(R)}),this.setNotificationForDocumentIdInCache(p,E,M),d&&(A.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:M,shouldAwait:!0,forceResolve:!0})),A.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:g,shouldAwait:!0,forceResolve:!0}))),S&&(F.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:M,shouldCommentAnnotationsResolverAwait:!0})),F.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:g,shouldCommentAnnotationsResolverAwait:!0}))),D&&(O.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:M,shouldNotificationResolverAwait:!0})),O.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:g,shouldNotificationResolverAwait:!0})))});let U=JSON.parse(JSON.stringify(g));if(r){let p=new Map((this.getUserNotificationsFromServer()??[]).map(u=>[u?.notificationId,u]));g.forEach(u=>p.set(u?.notificationId,u)),this.setUserNotificationsFromServer(Array.from(p.values()))}else this.setUserNotificationsFromServer([...this.getUserNotificationsFromServer()??[],...g]);(D||d||S)&&(()=>{let p=Promise.resolve();if(D&&(p=p.then(()=>Promise.allSettled(O)).then(()=>{this.resolveAndUpdateDocumentNotifications(l,"notification"),this.resolveAndMergeUserNotifications(U,"notification")})),d&&(p=p.then(()=>Promise.allSettled(A)).then(()=>{this.resolveAndUpdateDocumentNotifications(l,"user"),this.resolveAndMergeUserNotifications(U,"user")})),S){let u=D||d;p=p.then(()=>Promise.allSettled(F)).then(()=>{this.resolveAndUpdateDocumentNotifications(l,"comment"),this.resolveAndMergeUserNotifications(U,"comment",u)})}return p})().catch(p=>{this.loggingService.catch("Error in NotificationService resolveChain: ",p)})}}}catch(e){return this.loggingService.catch("Error in NotificationService fetchNotificationsForDocumentIds: ",e),[]}})}callGetNotificationsForDocuments(t){return T(this,null,function*(){let i=q(this.functions,K({url:this.endpointsService.getCloudFunctionUrl("getNotificationsForDocuments"),apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),e=yield this.notificationUtilsService.handleNotificationEncryption({data:t}),o=yield i({veltData:e}),s=o?.data?.data?.veltData||{},n=o?.data?.data?.veltAdditionalData||{},r="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??""),c=yield gt(s,r),{userNotifications:a,userNotificationIdsInDocNotifications:l,permissionResults:g}=yield gt(n,r);return{notificationsByDocumentId:c,userNotifications:a,userNotificationIdsInDocNotifications:l,permissionResults:g}})}getUserNotificationsFromServer$(){return this.userNotificationsFromServer$.asObservable()}setUserNotificationsFromServer(t){try{let i=JSON.parse(JSON.stringify(t));i=i?.filter((e,o,s)=>o===s.findIndex(n=>n.notificationId===e.notificationId)),this.userNotificationsFromServer$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService setUserNotificationsFromServer: ",i)}}getUserNotificationsFromServer(){return this.userNotificationsFromServer$.getValue()}setNotificationForDocumentIdInCache(t,i,e,o){try{let s=this.docService.getOrganizationConfig()?.organizationId??"",n=this.docService.getOrganizationMetadata(s);i||(i=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata()||{}))),n||(n=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(s)||{})));let r=this.notificationsByDocumentIdMap$.getValue(),c=r?.[t]?.notifications||[],a=this.docService.getLocationMetadatas(),l=e?.map(h=>{let d=h?.notification;return d?(d.metadata&&(d.metadata.documentName=i?.documentName||d.metadata.documentName,d.metadata.organizationMetadata=n||d.metadata.organizationMetadata,d.metadata.documentMetadata=i||d.metadata.documentMetadata),a&&(d=this.notificationUtilsService.mergeLocationWithNotification({notification:d},a)?.notification),d):null})?.filter(h=>!!h)||[],g=new Map(c.map(h=>[h.id,h]));l.forEach(h=>{g.set(h.id,h)});let f=Array.from(g.values()).sort((h,d)=>(d.timestamp||0)-(h.timestamp||0));this.notificationsByDocumentIdMap$.next($(b({},r),{[t]:{notifications:f,documentMetadata:i}}))}catch(s){this.loggingService.catch("Error in NotificationService setNotificationForDocumentIdInCache: ",s)}}removeNotificationsForDocumentId(t){try{this.notificationsByDocumentIdSubscription[t]&&this.notificationsByDocumentIdSubscription[t].unsubscribe();let i=this.notificationsByDocumentIdMap$.getValue();delete i?.[t],this.notificationsByDocumentIdMap$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService removeNotificationsForDocumentId: ",i)}}getStartAtTimestamp(){try{let t=new Date,i=this.maxNotificationDays$.getValue()>0?this.maxNotificationDays$.getValue():15;return t.setDate(t.getDate()-i),t.getTime()}catch(t){return this.loggingService.catch("Error in NotificationService getStartAtTimestamp: ",t),0}}getCurrentOrgNotificationsForYou(){try{return this.getUserNotificationsFromServer$().pipe(N(t=>C(t).pipe(B(i=>!!i),v(i=>{let e=this.usersService.userDataProviderAvailable(),o=this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable(),s=this.notificationResolverService?.notificationDataProviderAvailable();if(s||e||o){let r=i?.reduce((c,a)=>(c[a.notificationId]=a,c),{});s&&(r=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:r||[]})),e&&(r=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:r||[]})),o&&(r=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:r||[]})),i=Object.values(r??{})}return i.forEach(r=>{r.notification=this.getClientNotificationObject(r)}),i.sort((r,c)=>c.timestamp-r.timestamp),i.map(r=>r.notification).filter(r=>!!r)}),N(i=>{let e={data:i?.reduce((o,s)=>(o[s.id]={notification:s},o),{}),operation:null};return this.commonDbUtilsService.mergeLocationMetadataWithData$({data:e,feature:"allUserNotifications"}).pipe(v(o=>Object.values(o?.data||{}).map(s=>s?.notification)))}))),N(t=>{let i=this.docService.getOrganizationConfig()?.organizationId??"";return this.docService.getOrganizationMetadata$(i).pipe(v(()=>t))}),N(t=>this.allowedDocumentMetadataMap$.pipe(v(()=>t))),v(t=>(t?.length&&(t=t.map(i=>{if(i?.metadata){let e=this.docService.getOrganizationConfig()?.organizationId??"",o=this.getAllowedDocumentMetadataByDocumentId(i.metadata.documentId),s=this.docService.getOrganizationMetadata(e);o||(o=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata()||{}))),s||(s=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(e)||{}))),i.metadata.documentName=o?.documentName||i.metadata.documentName,i.metadata.organizationMetadata=s||i.metadata.organizationMetadata,i.metadata.documentMetadata=o||i.metadata.documentMetadata}return i})),t)))}catch(t){return this.loggingService.catch("Error in NotificationService getCurrentOrgNotificationsForYou: ",t),C(null)}}getNotificationsForYou(){try{return V([this.getCurrentOrgNotificationsForYou(),this.crossOrgNotifications$.asObservable()]).pipe(v(([t,i])=>{let e=this.mergeCrossOrgForYou(t,i);return e===null?this.notificationsForYou$.next(null):e?.length?this.notificationsForYou$.next(JSON.parse(JSON.stringify(e))):this.notificationsForYou$.next([]),e}))}catch(t){return this.loggingService.catch("Error in NotificationService getNotificationsForYou: ",t),C({})}}mergeCrossOrgForYou(t,i){try{let e=Array.isArray(i)?i:[];if(!e.length)return t;let o=Array.isArray(t)?t:[],s=c=>c?.id??c?.notificationId,n=new Set;o.forEach(c=>{let a=s(c);a!=null&&n.add(a)});let r=[...o];return e.forEach(c=>{let a=s(c);a!=null&&n.has(a)||(a!=null&&n.add(a),r.push(c))}),r.sort((c,a)=>(a?.timestamp||0)-(c?.timestamp||0))}catch(e){return this.loggingService.catch("Error in NotificationService mergeCrossOrgForYou: ",e),t}}enableCrossOrganization(t){try{if(t&&typeof t=="object"&&t.enabled===!1){this.disableCrossOrganization();return}this.setCrossOrganizationConfig($(b({},t||{}),{enabled:!0})),this.crossOrgUserSubscription?this.crossOrgIndexSubscription&&(this.crossOrgInitialFetchDone=!1,this.scheduleCrossOrgFetch()):this.attachCrossOrgIndexListener()}catch(i){this.loggingService.catch("Error in NotificationService enableCrossOrganization: ",i)}}disableCrossOrganization(){try{this.teardownCrossOrg();let t=this.crossOrganizationConfig$.getValue();this.crossOrganizationConfig$.next($(b({},t||{}),{enabled:!1}))}catch(t){this.loggingService.catch("Error in NotificationService disableCrossOrganization: ",t)}}setCrossOrganizationConfig(t){try{let i=t||{},e=Array.isArray(i.feeds)&&i.feeds.length?i.feeds:["forYou"];e.includes("all")&&this.loggingService.warn('NotificationService: cross-organization notifications only support the "forYou" feed; ignoring "all".'),e=e.filter(s=>s==="forYou"),e.length||(e=["forYou"]);let o={enabled:i.enabled??!0,organizationIds:i.organizationIds,excludeOrganizationIds:i.excludeOrganizationIds,feeds:e};this.crossOrganizationConfig$.next(o)}catch(i){this.loggingService.catch("Error in NotificationService setCrossOrganizationConfig: ",i)}}getCrossOrganizationConfig(){return this.crossOrganizationConfig$.getValue()}getCrossOrganizationConfig$(){return this.crossOrganizationConfig$.asObservable()}attachCrossOrgIndexListener(){try{this.teardownCrossOrgUserWatcher(),this.crossOrgUserSubscription=this.authService.getUser$().pipe(v(t=>t?.userId),_(),B(t=>!!t),j(t=>(this.loggingService.catch("Error in NotificationService cross-org user watcher: ",t),L))).subscribe(t=>{try{this.teardownCrossOrgPerUserListeners(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.next([]),this.bindCrossOrgListenersForUser(t)}catch(i){this.loggingService.catch("Error in NotificationService cross-org user-change handler: ",i)}})}catch(t){this.loggingService.catch("Error in NotificationService attachCrossOrgIndexListener: ",t)}}bindCrossOrgListenersForUser(t){this.crossOrgIndexSubscription=this.commonDbService.dbListener({feature:"userNotificationIndex",properties:{id:z(t),isCollection:!1,useCollectionGroup:!1}}).pipe(j(i=>(this.loggingService.catch("Error in NotificationService cross-org index listener: ",i),L))).subscribe(i=>{try{let e=this.extractIndexOrgTimestamps(i);this.crossOrgIndexTimestamps=e;let o=Object.keys(e);this.crossOrgIndexOrgs=o,this.pruneCrossOrgBufferToAllowedOrgs(),o.length&&this.scheduleCrossOrgFetch()}catch(e){this.loggingService.catch("Error in NotificationService cross-org index snapshot: ",e)}}),this.crossOrgOrgSwitchSubscription=this.docService.getOrganizationConfig$().pipe(v(i=>i?.organizationId??""),_(),at(),B(([i])=>!!i),j(i=>(this.loggingService.catch("Error in NotificationService cross-org org-switch listener: ",i),L))).subscribe(()=>{this.crossOrgInitialFetchDone=!1,this.crossOrgSeenTimestamps={},this.scheduleCrossOrgFetch()})}extractIndexOrgTimestamps(t){let i={};try{let e=t?.data??t,o=e?.organizationIds??e?.orgs;return Array.isArray(o)?(o.forEach(s=>{typeof s=="string"&&s.length&&(i[s]=0)}),i):(o&&typeof o=="object"&&Object.keys(o).forEach(s=>{if(typeof s=="string"&&s.length){let n=Number(o[s]);i[s]=Number.isFinite(n)?n:0}}),i)}catch(e){return this.loggingService.catch("Error in NotificationService extractIndexOrgTimestamps: ",e),i}}scheduleCrossOrgFetch(){try{let t=Date.now();t-this.lastCrossOrgFetchTime>=this.CROSS_ORG_FETCH_WINDOW_MS?(this.lastCrossOrgFetchTime=t,this.crossOrgFetchPending=!1,this.fetchCrossOrgUserNotifications(),this.armCrossOrgTrailingTimer()):this.crossOrgFetchPending=!0}catch(t){this.loggingService.catch("Error in NotificationService scheduleCrossOrgFetch: ",t)}}pruneCrossOrgBufferToAllowedOrgs(){try{let t=this.crossOrgNotifications$.getValue();if(!t.length)return;let i=this.crossOrgIndexOrgs||[];if(!i.length){this.crossOrgNotifications$.next([]);return}let e=t.filter(o=>i.includes(o?.metadata?.organizationId));e.length!==t.length&&this.crossOrgNotifications$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService pruneCrossOrgBufferToAllowedOrgs: ",t)}}armCrossOrgTrailingTimer(){this.crossOrgFetchTimer&&clearTimeout(this.crossOrgFetchTimer),this.crossOrgFetchTimer=setTimeout(()=>{this.crossOrgFetchPending&&(this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=Date.now(),this.fetchCrossOrgUserNotifications())},this.CROSS_ORG_FETCH_WINDOW_MS)}toCrossOrgClientNotification(t){try{if(!t)return null;if(t.notification){let e=this.getClientNotificationObject(t);if(!e)return null;let o=t?.metadata?.organizationId??e?.metadata?.organizationId;return o!=null&&(e.metadata=$(b({},e.metadata||{}),{organizationId:o})),e}let i=t.id??t.notificationId;return i==null?null:t.id!=null?t:$(b({},t),{id:i})}catch(i){return this.loggingService.catch("Error in NotificationService toCrossOrgClientNotification: ",i),null}}resolveCrossOrgSelfHostedData(t){return T(this,null,function*(){try{if(!t?.length)return t;let i=!!this.notificationResolverService?.notificationDataProviderAvailable?.(),e=!!this.usersService?.userDataProviderAvailable?.(),o=!!this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable?.();if(!i&&!e&&!o)return t;let s=new Map;for(let r of t){let c=r?.metadata?.clientOrganizationId??r?.metadata?.organizationId??"",a=s.get(c);a?a.push(r):s.set(c,[r])}let n=[];for(let[r,c]of s){let a=c.reduce((g,f,h)=>{let d=f?.notificationId??f?.id??`__cross_org_${h}`;return g[d]=f,g},{});yield this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:a,organizationId:r||void 0,shouldAwait:!0,shouldNotificationResolverAwait:!0,shouldCommentAnnotationsResolverAwait:!0});let l=a;i&&(l=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:l??{}})),e&&(l=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:l??{}})),o&&(l=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:l??{}})),n.push(...Object.values(l??{}))}return n}catch(i){return this.loggingService.catch("Error in NotificationService resolveCrossOrgSelfHostedData: ",i),t}})}fetchCrossOrgUserNotifications(){return T(this,null,function*(){let t=this.crossOrgGeneration;if(this.crossOrgResolveRoundInFlight){this.crossOrgFetchPending=!0;return}this.crossOrgResolveRoundInFlight=!0;try{let i=this.crossOrganizationConfig$.getValue(),e=this.docService.getOrganizationConfig()?.organizationId??"",o=!this.crossOrgInitialFetchDone,s=this.crossOrgIndexTimestamps||{},n=o?[]:Object.keys(s).filter(f=>f!==e&&(s[f]??0)>(this.crossOrgSeenTimestamps[f]??-1));if(!o&&!n.length)return;let r=this.buildCrossOrgRequestData(i,e,{isInitial:o,bumpedOrgs:n}),c=yield this.callGetCrossOrgUserNotifications(r);if(t!==this.crossOrgGeneration)return;let a=Array.isArray(c?.pendingPermissionQueries)?c.pendingPermissionQueries:[],l=!!this.userPermissionService?.isClientDevResolverActive?.(),g=!a.length||!l;if(yield this.processCrossOrgResponse(c,{fetchGeneration:t,currentOrg:e,isInitial:o,indexTimestamps:s,advanceCursors:g}),t!==this.crossOrgGeneration||g){g&&t===this.crossOrgGeneration&&this.clearCrossOrgStragglerRetry();return}yield this.runCrossOrgResolveRound(a,{fetchGeneration:t,config:i,currentOrg:e,isInitial:o,bumpedOrgs:n,indexTimestamps:s})}catch(i){this.loggingService.catch("Error in NotificationService fetchCrossOrgUserNotifications: ",i)}finally{this.crossOrgResolveRoundInFlight=!1,this.crossOrgFetchPending&&t===this.crossOrgGeneration&&(this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=Date.now(),this.fetchCrossOrgUserNotifications())}})}runCrossOrgResolveRound(t,i){return T(this,null,function*(){try{let e=yield this.userPermissionService.resolveClientSidePermissions(t);if(i.fetchGeneration!==this.crossOrgGeneration)return;let o=this.buildCrossOrgRequestData(i.config,i.currentOrg,{isInitial:i.isInitial,bumpedOrgs:i.bumpedOrgs});o.clientResolvedResults=e;let s=yield this.callGetCrossOrgUserNotifications(o);if(i.fetchGeneration!==this.crossOrgGeneration)return;yield this.processCrossOrgResponse(s,{fetchGeneration:i.fetchGeneration,currentOrg:i.currentOrg,isInitial:i.isInitial,indexTimestamps:i.indexTimestamps,advanceCursors:!0}),i.fetchGeneration===this.crossOrgGeneration&&this.clearCrossOrgStragglerRetry()}catch(e){this.loggingService.catch("Error in NotificationService runCrossOrgResolveRound: ",e),this.armCrossOrgStragglerRetry(i.fetchGeneration)}})}processCrossOrgResponse(t,i){return T(this,null,function*(){if(this.userPermissionService?.getIsContextEnabled?.()&&t?.permissionResults?.length){let l=[...this.userPermissionService?.getPermissionsCache?.()??[],...t.permissionResults];this.userPermissionService?.setPermissionsCache?.(l)}let e=Array.isArray(t?.forYou)?t.forYou:[],o=this.crossOrgIndexOrgs||[],s=l=>o.includes(l),n=e.filter(l=>{let g=l?.metadata?.organizationId;if(g===i.currentOrg)return this.loggingService.log("%c[WB] Cross-org: dropping current-org echo: "+g,"color: orange;"),!1;let f=s(g);return f||this.loggingService.log("%c[WB] Cross-org: dropping entry from un-indexed org: "+g,"color: orange;"),f}),r=yield this.resolveCrossOrgSelfHostedData(n);if(i.fetchGeneration!==this.crossOrgGeneration)return;let c=r.map(l=>this.toCrossOrgClientNotification(l)).filter(l=>!!l),a;i.isInitial?a=c:a=this.mergeCrossOrgForYou(c,this.crossOrgNotifications$.getValue()).filter(l=>s(l?.metadata?.organizationId)),i.advanceCursors&&(Object.keys(i.indexTimestamps).forEach(l=>{this.crossOrgSeenTimestamps[l]=i.indexTimestamps[l]}),this.crossOrgInitialFetchDone=!0),this.crossOrgNotifications$.next(a)})}armCrossOrgStragglerRetry(t){this.crossOrgStragglerRetryUsed||(this.crossOrgStragglerRetryUsed=!0,this.crossOrgStragglerRetryTimer&&clearTimeout(this.crossOrgStragglerRetryTimer),this.crossOrgStragglerRetryTimer=setTimeout(()=>{this.crossOrgStragglerRetryTimer=void 0,t===this.crossOrgGeneration&&this.fetchCrossOrgUserNotifications()},this.CROSS_ORG_STRAGGLER_RETRY_MS))}clearCrossOrgStragglerRetry(){this.crossOrgStragglerRetryUsed=!1,this.crossOrgStragglerRetryTimer&&(clearTimeout(this.crossOrgStragglerRetryTimer),this.crossOrgStragglerRetryTimer=void 0)}callGetCrossOrgUserNotifications(t){return T(this,null,function*(){let i=this.authService.getUser(),e=q(this.functions,K({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield ft({methodName:"getCrossOrgUserNotifications",data:b({type:"getCrossOrgUserNotifications"},t),getSdkProxy:e,userId:i?.userId??""})})}buildCrossOrgRequestData(t,i,e){let o=t||{},s=e?.isInitial??!0,n=e?.bumpedOrgs??[],r=Array.isArray(o.organizationIds),c=r?o.organizationIds.filter(h=>!!h).map(h=>lt(h)):[],a=(o.excludeOrganizationIds||[]).filter(h=>!!h).map(h=>lt(h)),l=new Set(a);i&&l.add(i);let g=this.userPermissionService?.getPermissionsCache?.()?.filter(h=>h?.type===k.CONTEXT),f={organizationId:i,excludeOrganizationIds:Array.from(l),timestamp:this.getStartAtTimestamp(),limitToLast:this.CROSS_ORG_PAGE_SIZE,isContextEnabled:this.userPermissionService?.getIsContextEnabled?.(),cachedData:g,isSettingsConfigByOrganization:this.getSettingsConfigByOrganization(),retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig?.()};if(this.userPermissionService?.isClientDevResolverActive?.()&&(f.clientResolverAvailable=!0),s)r&&(f.organizationIds=this.dedupeIncludeOrgs(c,l));else{let h=n.filter(S=>!!S&&!l.has(S));if(r){let S=new Set(c);h=h.filter(D=>S.has(D))}h=Array.from(new Set(h)),f.organizationIds=h;let d={};h.forEach(S=>{d[S]=this.crossOrgSeenTimestamps[S]??this.getStartAtTimestamp()}),f.orgTimestamps=d}return f}dedupeIncludeOrgs(t,i){let e=new Set;return t.filter(o=>o==null||i.has(o)||e.has(o)?!1:(e.add(o),!0))}teardownCrossOrgPerUserListeners(){this.crossOrgGeneration++,this.crossOrgIndexSubscription&&(this.crossOrgIndexSubscription.unsubscribe(),this.crossOrgIndexSubscription=void 0),this.crossOrgOrgSwitchSubscription&&(this.crossOrgOrgSwitchSubscription.unsubscribe(),this.crossOrgOrgSwitchSubscription=void 0),this.crossOrgFetchTimer&&(clearTimeout(this.crossOrgFetchTimer),this.crossOrgFetchTimer=void 0),this.crossOrgFetchPending=!1,this.clearCrossOrgStragglerRetry()}teardownCrossOrgUserWatcher(){this.teardownCrossOrgPerUserListeners(),this.crossOrgUserSubscription&&(this.crossOrgUserSubscription.unsubscribe(),this.crossOrgUserSubscription=void 0)}resetCrossOrgDeltaState(){this.crossOrgIndexOrgs=[],this.crossOrgIndexTimestamps={},this.crossOrgSeenTimestamps={},this.crossOrgInitialFetchDone=!1}resetCrossOrgForUser(){this.teardownCrossOrgPerUserListeners(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.getValue().length&&this.crossOrgNotifications$.next([])}teardownCrossOrg(){this.teardownCrossOrgUserWatcher(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.next([])}markCrossOrgEntriesRead(t){try{let i=this.crossOrgNotifications$.getValue();if(!i?.length)return;let e=new Set((t||[]).map(r=>r?.id??r?.notificationId).filter(r=>r!=null));if(!e.size)return;let o=!this.getReadNotificationsOnForYouTab(),s=!1,n=o?i.filter(r=>{let c=r?.id??r?.notificationId,a=c!=null&&e.has(c);return a&&(s=!0),!a}):i.map(r=>{let c=r?.id??r?.notificationId;return c!=null&&e.has(c)&&r?.isUnread!==!1?(s=!0,$(b({},r),{isUnread:!1})):r});s&&this.crossOrgNotifications$.next(n)}catch(i){this.loggingService.catch("Error in NotificationService markCrossOrgEntriesRead: ",i)}}subscribeNotificationsData(t,i){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let e,o;try{if(t&&(o=ct(t)),i&&typeof i=="object"){let s=Mt(i);e=ct(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",s)}return this.authService.getAuthState$().pipe(B(s=>!!s),N(s=>this.isFeatureAllowed({firebaseUser:s})),N(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(v(n=>(s.featureAllowed=n,s))):C(s)),N(s=>!s.featureAllowed||s?.user?.organizationId?(this.notifications$.next([]),this.rawNotificationsByIdMap$.next(new Map),this.processedNotifications$.next([]),this.notificationsByIdMap$.next(new Map),this.notificationViews$.next({}),this.setNotificationsByIdMap(),C([])):C(s).pipe(N(n=>this.docService.getDocumentPaths$().pipe(v(r=>(this.documentPaths=r,n.documentPaths=r,n)))),N(n=>this.getDataFromDocumentId(o)))))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(B(i=>!!i),v(i=>$(b({},t),{config:i})),N(i=>this.authService.getUser$().pipe(v(e=>$(b({},i),{user:e})))),N(i=>Et(i.config,i.user,bt.NOTIFICATION)?C($(b({},i),{featureAllowed:!0})):(this.loggingService.warn("Notification feature is not allowed."),C($(b({},i),{featureAllowed:!1})))))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(B(i=>!!i),N(i=>{if(this.db=i,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.views){let e=`${this.configService.getApiKey()}`;this.documentPaths?.organizationId&&(e+=`/${x.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}`);let o=this.realtimeAdapter.rtdbRef(this.db,`${t?e+"/"+x.FIREBASE_PARTIAL_PATH_DOCS+"/"+t+"/"+x.FIREBASE_PARTIAL_PATH_VIEWS+"/":this.documentPaths?.notifications}`);return this.realtimeAdapter.rtdbObjectVal$("notification",o).pipe(j(s=>(this.loggingService.catch("Error in NotificationService getDataFromDocumentId: ",s),C(null))),v(s=>{let n=[],r=new Map;s?.raw&&(Object.keys(s?.raw||{}).forEach(a=>{let l=s?.raw[a];l?.id&&n.push(l)}),n.forEach(a=>{a.id&&r.set(a.id,a)})),this.notifications$.next(n),this.rawNotificationsByIdMap$.next(r);let c=[];s?.processed&&Object.keys(s?.processed||{}).forEach(a=>{let l=s?.processed[a];l?.id&&c.push(l)}),this.processedNotifications$.next(c),this.setNotificationsByIdMap()}))}else return C(null)}))}setNotificationsByIdMap(){try{let t=this.authService.getUser();if(t){let i=this.notificationViews$.getValue(),e;t?.email&&(e=z(t?.email));let o;t?.userId&&(o=z(t?.userId));let s=new Map;this.processedNotifications$.getValue().forEach(r=>{if(r.id&&r?.displayHeadlineMessageTemplate){let c=!1;(e&&r.notifyUsers?.[e]||o&&r.notifyUsers?.[o])&&(c=!0);let a={id:r.id,notificationSource:r.notificationSource,actionType:r.actionType,actionUser:r.actionUser,timestamp:r.timestamp,targetAnnotationId:r.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(r),displayBodyMessage:this.getNotificationBodyMessage(r),forYou:c,notificationSourceData:r.notificationSourceData},l=this.getRawNotificationById(a.id);if(l?.metadata&&(a.metadata={apiKey:l.metadata.apiKey,organizationId:l.metadata.organizationId,clientOrganizationId:l.metadata.clientOrganizationId,documentId:l.metadata.documentId,clientDocumentId:l.metadata.clientDocumentId,location:l?.location,locationId:l?.locationId}),a?.notificationSource==="comment"&&a?.targetAnnotationId){let g=this.commentService?.getAnnotationById(a.targetAnnotationId);g||l?.annotationData&&(g=l.annotationData),g&&(a.notificationSourceData=this.commentService?.getCommentAnnotationForClient(g))}s.set(r.id,a)}}),s.forEach((r,c)=>{r.isUnread=r?.actionUser?.userSnippylyId!==t?.userSnippylyId&&!i?.notification?.[c]?.views?.[t?.userSnippylyId],s.set(c,r)}),this.notificationsByIdMap$.next(s)}}catch(t){this.loggingService.catch("Error in NotificationService setNotificationsByIdMap: ",t)}}getClientNotificationObject({processed:t,raw:i,metadata:e,views:o,notification:s}){try{let n=this.authService.getUser(),r=s||t;if(r.id&&r?.displayHeadlineMessageTemplate&&n){let c=null;n?.email&&(c=z(n?.email));let a=null;n?.userId&&(a=z(n?.userId));let l=!1,g=!0;(c&&r.notifyUsers?.[c]||a&&r.notifyUsersByUserId?.[a])&&(l=!0),a&&o?.[a]&&(g=!1);let f={id:r.id};if(s?f=$(b(b({},f),s),{displayHeadlineMessage:this.getNotificationHeadlineMessage(s),displayBodyMessage:this.getNotificationBodyMessage(s),forYou:l,isUnread:g}):f={id:t.id,notificationSource:t.notificationSource,actionType:t.actionType,actionUser:t.actionUser,timestamp:t.timestamp,targetAnnotationId:t.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(t),displayBodyMessage:this.getNotificationBodyMessage(t),forYou:l,isUnread:g,metadata:e},f?.notificationSource==="comment"&&f?.targetAnnotationId){let h=this.commentService?.getAnnotationById(f.targetAnnotationId);h||s?.notificationSourceData&&(h=s?.notificationSourceData),h||i?.annotationData&&(h=i.annotationData),h&&(f.notificationSourceData=this.commentService?.getCommentAnnotationForClient(h))}return i?.targetAnnotationData?.isCommentResolverUsed&&(f.isCommentResolverUsed=i?.targetAnnotationData?.isCommentResolverUsed),s?.isNotificationResolverUsed&&(f.isNotificationResolverUsed=s.isNotificationResolverUsed),f}return}catch(n){this.loggingService.catch("Error in NotificationService getClientNotificationObject: ",n);return}}getNotificationsForYou$(){return this.notificationsForYou$.asObservable()}getNotificationsByDocumentId$(){return this.notificationsByDocumentIdMap$.asObservable().pipe(v(t=>t?Object.keys(t??{}).map(i=>{let e=t[i].notifications||[],o=e.filter(n=>n.isUnread).length,s=e.length>0&&e[0]?.timestamp||0;return{documentId:i,notifications:t[i]?.notifications,unreadNotificationsCount:o,latestNotificationTimestamp:s,documentMetadata:t[i]?.documentMetadata}}).filter(i=>i.notifications?.length>0).sort((i,e)=>e.latestNotificationTimestamp-i.latestNotificationTimestamp):null))}getAllNotifications$(){return V([this.getNotificationsByDocumentId$(),this.crossOrgNotifications$.asObservable(),this.getUserScopedAllTabRows$()]).pipe(v(([t,i,e])=>{let o=Array.isArray(i)?i:[],s=Array.isArray(e)?e:[],n=null;if(t&&(n=[],t.forEach(c=>{c.notifications.forEach(a=>{n?.push(a)})})),!o.length&&!s.length)return t?n.sort((c,a)=>a.timestamp-c.timestamp):null;if(!t)return null;let r=n||[];return s.length&&(r=this.mergeCrossOrgForYou(r,s)),o.length&&(r=this.mergeCrossOrgForYou(r,o)),r}))}getUserScopedAllTabRows$(){return V([this.userScopedNotifications$,this.userNotificationsFromServer$.asObservable()]).pipe(v(([t,i])=>!t?.enabled||!i?.length?[]:i.map(e=>e?.notification??this.getClientNotificationObject(e)).filter(e=>!!e)))}processNotificationData(t){try{let i=t?.annotationData?.metadata,e=this.docService.getOrganizationConfig()?.organizationId;t.metadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(i?.documentId)||{})),t.metadata||(t.metadata={},this.loggingService.catch("Warning in NotificationService updateNotificationDatabase: ","Document metadata not found")),delete t.metadata.locations,t.metadata.documentMetadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(i?.documentId)||{})),t?.metadata?.documentMetadata?.clientDocumentId&&t?.metadata?.documentMetadata?.documentId&&(t.metadata.documentMetadata.documentId=t?.metadata?.documentMetadata?.clientDocumentId),delete t.metadata.documentMetadata.locations,t.metadata.organizationMetadata=JSON.parse(JSON.stringify(e?this.docService.getOrganizationMetadata(e)||{}:{})),t?.metadata?.organizationMetadata?.clientOrganizationId&&t?.metadata?.organizationMetadata?.organizationId&&(t.metadata.organizationMetadata.organizationId=t?.metadata?.organizationMetadata?.clientOrganizationId);let o=this.configService.getApiKey();t.metadata.apiKey=o,t.platform=this.configService.getSF()?"sf":"sdk",t.actionUser=this.authService.getUser();let s=i?.documentId?new ht({apiKey:o,documentId:i.documentId,organizationId:i?.organizationId}):this.docService.getDocumentPaths();t?.actionUser?.organizationId&&(t.metadata.organizationId=s?.organizationId||t.actionUser.organizationId,t.metadata.clientOrganizationId=s?.clientOrganizationId||t.actionUser.clientOrganizationId);let n=this.docService.getLocation();n&&(t.location=n?.location,t.locationId=n?.locationId),this.loggingService.log(`[NOTIFICATION] ${t?.notificationSource} ${t?.actionType}`,t);let r=this.commonDbService.getServerTimestamp(),c=this.notificationUtilsService.formatNotification(t,r);return JSON.parse(JSON.stringify(c))}catch(i){return this.loggingService.catch("Error in NotificationService processNotificationData: ",i),null}}reportDroppedHubPush(t){try{if(!this.notificationsHubDisabled)return;let i=String(t?.notificationSource??"comment");if(this.reportedDroppedHubPushes.has(i))return;this.reportedDroppedHubPushes.add(i),this.loggingService.catch(`Velt [self-hosted]: a client-side notification-hub push (source '${i}') was dropped \u2014 the notifications hub is deliberately disabled on this deployment (no-egress). Whatever this push fed (in-app notification, email, or webhook fan-out) will not happen for this source.`,void 0,void 0,!0)}catch{}}updateNotificationDatabase(t){try{if(!this.notificationsDb){this.reportDroppedHubPush(t);return}let i=this.realtimeAdapter.rtdbRef(this.notificationsDb),e=this.processNotificationData(t);try{let o=At(t?.annotationData);if(o&&e&&typeof e=="object"){e.visibility=o;let s=Object.values(t?.annotationData?.subscribedUsers||{}).map(r=>r?.user?.userId).filter(r=>!!r),n=Tt(t?.annotationData,s);n.length&&(e.deniedForYouUsers=[...new Set([...e.deniedForYouUsers??[],...n])])}}catch(o){this.loggingService.catch("Error applying notification visibility in updateNotificationDatabase: ",o)}this.realtimeAdapter.rtdbPush("notificationIndex",i,JSON.parse(JSON.stringify(e)))}catch(i){this.loggingService.catch("Error in NotificationService updateNotificationDatabase: ",i)}}getRawNotifications$(){return this.notifications$.asObservable()}getProcessedNotifications$(){return this.processedNotifications$.asObservable()}getNotifications$(t){return this.authService.getUser$().pipe(N(i=>i?i.organizationId?this.getAllNotifications$().pipe(N(e=>this.notificationsForYou$.pipe(v(o=>{if(e||o){let s=new Map;return(!t?.type||["all","documents"].includes(t.type))&&(e||[]).forEach(n=>{n.id&&s.set(n.id,n)}),(!t?.type||["all","forYou"].includes(t.type))&&(o||[]).forEach(n=>{n.id&&!s.has(n.id)&&s.set(n.id,n)}),Array.from(s.values()).sort((n,r)=>(r.timestamp||0)-(n.timestamp||0))}else return null})))):this.notificationsByIdMap$.asObservable().pipe(v(e=>Array.from(e.values())),v(e=>e.sort((o,s)=>s.timestamp-o.timestamp)),St()):C(null)),_(Ft))}getRawNotificationById(t){try{return this.rawNotificationsByIdMap$.getValue()?.get(t)}catch(i){this.loggingService.catch("Error in NotificationService getRawNotificationById: ",i);return}}setNotificationViews(t){try{this.notificationViews$.next(t),this.setNotificationsByIdMap()}catch(i){this.loggingService.catch("Error in NotificationService setNotificationViews: ",i)}}getNotificationHeadlineMessage(t){try{let i=this.authService.getUser();if(t?.displayHeadlineMessageTemplate&&t?.displayHeadlineMessageTemplateData){let e=t.displayHeadlineMessageTemplate,o=t.displayHeadlineMessageTemplateData,s=/\{(\w+)\}/g,n=e.replace(s,(r,c)=>(c==="actionUser"||c==="recipientUser")&&o[c]?i?.email&&o[c].email===i?.email||i?.userId&&o[c]?.userId===i?.userId?"You":o[c].name||o[c].email||' <velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader> ':o[c]?o[c]:r);return this.domService.sanitizeHtml(n)}return this.domService.sanitizeHtml(t.displayHeadlineMessageTemplate||"")}catch(i){return this.loggingService.catch("Error in NotificationService getNotificationHeadlineMessage: ",i),""}}getNotificationBodyMessage(t){try{if(t?.displayBodyMessageTemplate&&t?.displayBodyMessageTemplateData){let i=t?.displayBodyMessageTemplate;return t?.displayBodyMessageTemplateData&&t?.displayBodyMessageTemplateData?.users?.forEach(e=>{if(e?.userId){let o=this.usersService.getUserById(e?.userId);i=i?.replaceAll(`{{${e.userId}}}`,o?.name||o?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>'),i=i?.replaceAll(`@User ${e.userId}`,o?.name||o?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>')}}),this.domService.sanitizeHtml(i)}return this.domService.sanitizeHtml(t.displayBodyMessage||"")}catch(i){return this.loggingService.catch("Error in NotificationService getNotificationBodyMessage: ",i),""}}setHistoryPanelVisibility(t,i=!1,e=!1){try{t?document.querySelector(x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?this.historyPanelVisible$.next(t):this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`):this.historyPanelVisible$.next(t),t?this.analyticsService.trackEvent(H.Events.Notifications.NOTIFICATION_HISTORY_PANEL_OPENED):this.analyticsService.trackEvent(H.Events.Notifications.NOTIFICATION_HISTORY_PANEL_CLOSED)}catch{this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}toggleHistoryPanelVisibility(t=!1,i=!1){try{this.historyPanelVisible$.value?this.historyPanelVisible$.next(!this.historyPanelVisible$.value):document.querySelector(x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?(this.historyPanelVisible$.next(!this.historyPanelVisible$.value),this.historyPanelVisible$.value?this.analyticsService.trackEvent(H.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"closed"}):this.analyticsService.trackEvent(H.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"opened"})):this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}catch{this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}getHistoryPanelVisibility$(){return this.historyPanelVisible$.asObservable()}setNotificationsAsRead(t){return T(this,null,function*(){try{let i=JSON.parse(JSON.stringify(this.getUserNotificationsFromServer()??[]));if(t?.length){for(let n=0;n<t.length;n+=50){let c=t.slice(n,n+50).filter(g=>g?.id),a=c.map(g=>this.setNotificationAsRead({notification:g,userNotifications:JSON.parse(JSON.stringify(i))})),l=yield Promise.all(a);c.forEach((g,f)=>{let h=l[f];if(!h.some(S=>S.notificationId===g.id))i=i.filter(S=>S.notificationId!==g.id);else{let S=i.find(A=>A.notificationId===g.id),D=h.find(A=>A.notificationId===g.id);S&&D?.views&&(S.views=D.views)}})}let o=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()||{}));t.forEach(n=>{let r=n.metadata?.documentId;if(r&&o?.[r]){let c=o?.[r]?.notifications||[],a=c.find(l=>l.id===n.id);a&&(a.isUnread=!1),o[r].notifications=c}}),this.notificationsByDocumentIdMap$.next(o),this.markCrossOrgEntriesRead(t),!J(i,this.getUserNotificationsFromServer())&&this.setUserNotificationsFromServer(i)}}catch(i){this.loggingService.catch("Error in NotificationService setNotificationsAsRead: ",i)}})}setAllNotificationsAsRead(t){return T(this,null,function*(){try{if(t?.tabId==="for-you"){let i=this.notificationsForYou$.value||[];this.setNotificationsAsRead(i)}else this.getNotifications$().pipe(Y(1)).subscribe(i=>{i&&this.setNotificationsAsRead(i)})}catch(i){this.loggingService.catch("Error in NotificationService setAllNotificationsAsRead: ",i)}})}getUnreadNotificationsCount$(){try{return this.notificationsForYou$.pipe(v(t=>t?.filter(e=>e?.isUnread)?.length??null),N(t=>this.getNotifications$().pipe(v(i=>{let e=i?.filter(o=>o?.isUnread)?.length??null;return{forYou:t,all:e}}))))}catch(t){return this.loggingService.catch("Error in NotificationService getUnreadNotificationsCount$: ",t),C({forYou:null,all:null})}}setNotificationAsRead(e){return T(this,arguments,function*({notification:t,userNotifications:i}){try{let o=this.authService.getUser();if(o&&t?.id){let s=z(o?.userId),{metadata:n}=t;if(n){let{apiKey:r,organizationId:c,documentId:a}=n;if(r&&c&&a&&s){let l=yield this.commonDbService.getData({feature:"docNotification",properties:{id:t.id,organizationId:c,documentId:a,apiKey:r}});l?.notificationId&&(l?.views?.[s]||(l.views||(l.views={}),l.views[s]={timestamp:Date.now()},this.commonDbService.updateData({feature:"docNotificationViews",properties:{id:t.id,organizationId:c,documentId:a,apiKey:r},data:l})));let g=yield this.commonDbService.getData({feature:"userNotification",properties:{id:t.id,userId:s,documentId:a,organizationId:c}});if(g?.notificationId){if(!this.getReadNotificationsOnForYouTab())yield this.commonDbService.deleteData({feature:"userNotification",properties:{id:t.id,userId:s,documentId:a,organizationId:c}}),i=i.filter(f=>f.notificationId!==t.id);else if(!g?.views?.[s]){g.views||(g.views={}),g.views[s]={timestamp:Date.now()};let f=i.find(h=>h.notificationId===t.id);f&&(f.views=g.views),this.commonDbService.updateData({feature:"userNotificationViews",properties:{id:t.id,userId:s,documentId:a,organizationId:c},data:g})}}}}}return i}catch(o){return this.loggingService.catch("Error in NotificationService setNotificationAsRead: ",o),i}})}setMaxDays(t){try{t>0?this.maxNotificationDays$.next(t):this.maxNotificationDays$.next(15)}catch(i){this.loggingService.catch("Error in NotificationService setMaxDays: ",i)}}setTabConfig(t){try{t&&this.tabConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setTabConfig: ",i)}}getTabConfig$(){return this.tabConfig$.asObservable()}getTabConfig(){return this.tabConfig$.value}enableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!0)}disableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!1)}getReadNotificationsOnForYouTab$(){return this.readNotificationsOnForYouTab$.asObservable()}getReadNotificationsOnForYouTab(){return this.readNotificationsOnForYouTab$.value}enableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!0)return;this.currentDocumentOnly$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableCurrentDocumentOnly: ",t)}}disableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!1)return;this.currentDocumentOnly$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableCurrentDocumentOnly: ",t)}}getCurrentDocumentOnly$(){return this.currentDocumentOnly$.asObservable()}getCurrentDocumentOnly(){return this.currentDocumentOnly$.value}markNotificationAsReadById(t){return T(this,null,function*(){try{this.getNotifications$().pipe(Y(1)).subscribe(i=>{if(i){let e=i.filter(o=>o.id===t);this.setNotificationsAsRead(e)}})}catch(i){this.loggingService.catch("Error in NotificationService markNotificationAsReadById: ",i)}})}getAllowedDocumentMetadataByDocumentId(t){try{return this.allowedDocumentMetadataMap$.value?.[t]||null}catch(i){return this.loggingService.catch("Error in NotificationService getAllowedDocumentMetadataByDocumentId: ",i),null}}setSettingsConfig(t){try{this.enableSettings$.value&&this.settingsConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setSettingsConfig: ",i)}}setSettingsConfigWithDB(t){try{this.enableSettings$.value&&(this.settingsConfig$.next(t),this.updateSettingsConfigToDb())}catch(i){this.loggingService.catch("Error in NotificationService setSettingsConfigWithDB: ",i)}}getSettingsConfig$(){return this.settingsConfig$.asObservable()}getSettingsConfig(){return this.settingsConfig$.value}setMuteAllNotifications(){try{this.muteAllNotifications$.value!==!0&&this.muteAllNotifications$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService setSettingsMuteAll: ",t)}}getMuteAllNotifications$(){return this.muteAllNotifications$.asObservable()}getMuteAllNotifications(){return this.muteAllNotifications$.value}enableSettings(){try{this.enableSettings$.value!==!0&&this.enableSettings$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSettings: ",t)}}enableSettingsConfigByOrganization(){try{this.getSettingsConfigByOrganization()!==!0&&this.setSettingsConfigByOrganization$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSettingsConfigByOrganization: ",t)}}disableSettingsConfigByOrganization(){try{this.getSettingsConfigByOrganization()!==!1&&this.setSettingsConfigByOrganization$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSettingsConfigByOrganization: ",t)}}getSettingsConfigByOrganization$(){return this.setSettingsConfigByOrganization$.asObservable()}getSettingsConfigByOrganization(){return this.setSettingsConfigByOrganization$.value}enableSelfNotifications(){try{this.selfNotifications$.value!==!0&&this.selfNotifications$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSelfNotifications: ",t)}}disableSelfNotifications(){try{this.selfNotifications$.value!==!1&&this.selfNotifications$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSelfNotifications: ",t)}}enableUserScopedNotifications(t){try{if(t&&typeof t=="object"&&t.enabled===!1){this.disableUserScopedNotifications();return}this.userScopedNotifications$.next({enabled:!0,limit:ei(t?.limit)})}catch(i){this.loggingService.catch("Error in NotificationService enableUserScopedNotifications: ",i)}}disableUserScopedNotifications(){try{this.userScopedNotifications$.value.enabled!==!1&&this.userScopedNotifications$.next({enabled:!1,limit:this.userScopedNotifications$.value.limit})}catch(t){this.loggingService.catch("Error in NotificationService disableUserScopedNotifications: ",t)}}disableSettings(){try{this.enableSettings$.value!==!1&&this.enableSettings$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSettings: ",t)}}getEnableSettings$(){return this.enableSettings$.asObservable()}getEnableSettings(){return this.enableSettings$.value}setSettingsInitialConfig(t){try{let i=!1;if(t.forEach(e=>{["email","inbox"].includes(e.id)&&(i=!e.values?.every(o=>["ALL","NONE","MINE"].includes(o.id)))}),i){this.loggingService.catch("Invalid config values for email or inbox, It should have only ALL, NONE, MINE values");return}this.settingsInitialConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setSettingsInitialConfig: ",i)}}getSettingsInitialConfig$(){return this.settingsInitialConfig$.asObservable()}getSettingsInitialConfig(){return this.settingsInitialConfig$.value}updateSettingsConfigToDb(t){return T(this,null,function*(){try{let i=this.authService.getUser(),e=z(i?.userId??""),o=this.docService.getDocumentPaths(),s=this.docService.getOrganizationConfig(),n=o?.organizationId??s?.organizationId,r=o?.clientOrganizationId??s?.clientOrganizationId,c={apiKey:this.configService.getApiKey(),organizationId:n,documentId:o?.documentId,clientOrganizationId:r,clientDocumentId:o?.clientDocumentId,userId:e,clientUserId:this.authService.getUser()?.userId};e&&this.getEnableSettings()&&this.enableSettings$.value&&(this.getSettingsConfigByOrganization()?this.docService.addUserInfoToOrganization({organizationId:r??i?.clientOrganizationId??"",user:{userId:i?.userId??""},notificationsConfig:t||this.settingsConfig$.getValue()}):o?.documentId&&(yield this.commonDbService.updateData({feature:"userConfig",properties:{documentId:o?.documentId,userId:e},data:{id:o?.documentId,notificationsConfig:t||this.settingsConfig$.getValue(),metadata:c}})))}catch(i){this.loggingService.catch("Error in NotificationService updateSettingsConfigToDb: ",i)}})}openNotificationsPanel(){try{this.notificationsPanelVisible$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService openNotificationsPanel: ",t)}}closeNotificationsPanel(){try{this.notificationsPanelVisible$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService closeNotificationsPanel: ",t)}}getNotificationsPanelVisible$(){return this.notificationsPanelVisible$.asObservable()}getNotificationsPanelVisible(){return this.notificationsPanelVisible$.value}};y.\u0275fac=function(i){return new(i||y)(m(Nt),m(xt),m(Z),m(Lt),m(Xt),m(Qt),m(et),m(tt),m(ot),m(Yt),m(qt),m(Kt),m(Zt),m(X),m(ii),m(it),m(It),m(ti),m(Jt),m(Q),m(Gt),m(kt))},y.\u0275prov=G({token:y,factory:y.\u0275fac,providedIn:"root"});let w=y;return w})();export{ii as a,Yi as b};
1
+ import{a as ti}from"./chunk-H6ZQEQFJ.js";import{a as Zt}from"./chunk-VOMZ73T5.js";import{a as tt,e as qt,l as it,m as et,p as ht,r as ot,s as Qt,t as Xt}from"./chunk-I6ELSCG4.js";import{$f as lt,Ag as gt,Bi as Bt,E as B,G as j,Gd as Nt,Gg as J,He as x,K as Y,M as _,O as at,Q as St,Qd as It,Qf as yt,Ri as Q,Si as xt,Ti as X,Uf as Dt,Uh as Ft,Ui as Lt,V as N,Vf as Ct,Xf as ct,Y as vt,Yf as z,Yi as jt,Zf as Ut,a as b,b as $,ba as G,bi as ft,bj as Ht,cj as Vt,di as K,ea as m,ee as Ot,ej as _t,fa as pt,g as T,gj as dt,i as ut,ji as H,jj as Yt,ki as q,l as I,lg as At,mg as Tt,mi as Rt,mj as Gt,nj as Wt,oi as Pt,p as L,q as nt,qg as Et,r as C,re as bt,rg as $t,rj as kt,tf as W,uf as k,ug as Mt,uj as Jt,v,w as V,wj as Kt,x as mt,xj as Z,zg as wt,zi as zt}from"./chunk-RV7ZJ7J2.js";var ii=(()=>{let y=class y{constructor(t,i,e,o,s,n,r){this.commentUtilsService=t,this.loggingService=i,this.usersService=e,this.authService=o,this.commentAnnotationsResolverService=s,this.notificationResolverService=n,this.serviceBook=r,this.serviceBook.set(Pt,this)}getUserIdsToResolveFromNotifications(t){try{let i=new Set;for(let e of t){let{notification:o}=e;switch(o?.actionUser?.userId&&i.add(o?.actionUser?.userId),o?.displayHeadlineMessageTemplateData?.actionUser?.userId&&i.add(o?.displayHeadlineMessageTemplateData?.actionUser?.userId),o?.displayHeadlineMessageTemplateData?.recipientUser?.userId&&i.add(o?.displayHeadlineMessageTemplateData?.recipientUser?.userId),o?.notificationSource){case"comment":if(o?.notificationSourceData){let s=this.commentUtilsService.getUserIdsToResolveFromComments([o?.notificationSourceData]);for(let n of s)i.add(n)}break}}return Array.from(i)}catch(i){return this.loggingService.catch("Error in ReactionUtilsService getUserIdsToResolveFromRecorders:",i),[]}}mergeStrippedDataWithNotification(t){try{if(this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeStrippedDataWithNotification","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return t;let i=this.commentAnnotationsResolverService.getAnnotationById(t?.notification?.targetAnnotationId),e=t?.raw?.targetAnnotationData?.commentId,o=i?.comments?.[e]?.commentText,s=i?.comments?.[e]?.commentHtml;return o&&s&&t?.raw?.notificationSource==="comment"&&(t.notification.displayBodyMessageTemplate=o,t.raw.targetAnnotationData.commentText=o,t.raw.targetAnnotationData.commentHtml=s),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeStrippedDataWithNotification:",i),t}}mergeLocationWithNotification(t,i){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeLocationWithNotification","color: green;");let e=t?.notification?.notificationSourceData?.location?.id,o=t?.notification?.notificationSourceData?.metadata?.documentId;if(!e||!o)return t;let s=i?.[o]?.[e];return s&&(t.notification.notificationSourceData.location=s?.location,t?.raw?.annotationData?.location&&(t.raw.annotationData.location=s?.location)),t}catch(e){return this.loggingService.catch("Error in NotificationUtilsService mergeLocationWithNotification:",e),t}}mergeNotificationWithUser(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeNotificationWithUser","color: green;");let{notification:i}=t;if(i?.actionUser?.userId){let e=this.usersService.getUserById(i?.actionUser?.userId);e&&(i.actionUser=e)}if(i?.displayHeadlineMessageTemplateData?.actionUser?.userId){let e=this.usersService.getUserById(i?.displayHeadlineMessageTemplateData?.actionUser?.userId);e&&(i.displayHeadlineMessageTemplateData.actionUser=e)}if(i?.displayHeadlineMessageTemplateData?.recipientUser?.userId){let e=this.usersService.getUserById(i?.displayHeadlineMessageTemplateData?.recipientUser?.userId);e&&(i.displayHeadlineMessageTemplateData.recipientUser=e)}return i?.notificationSource==="comment"&&i?.notificationSourceData&&this.commentUtilsService.mergeCommentWithUser(i?.notificationSourceData),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeNotificationWithUser:",i),t}}formatNotification(t,i){try{switch(typeof t=="object"&&(t=JSON.parse(JSON.stringify(t))),this.usersService.userDataProviderAvailable()&&t?.actionUser&&(t.actionUser={userId:t.actionUser.userId}),t.notificationSource){case"comment":this.commentUtilsService.formatCommentData(t.annotationData),this.commentUtilsService.formatCommentThreadData(t.targetAnnotationData);break;case"recorder":this.serviceBook.get(zt)?.formatRecorderData(t.annotationData,i);break}return t}catch(e){return this.loggingService.catch("Error in NotificationUtilsService formatNotification: ",e),t}}getTargetAnnotationIdsFromNotifications(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: getTargetAnnotationIdsFromNotifications","color: green;");let i=[];return Object.values(t).forEach(e=>{e?.notification?.targetAnnotationId&&e?.raw?.notificationSource==="comment"&&i.push(e.notification.targetAnnotationId)}),i}catch(i){return this.loggingService.catch("Error in NotificationUtilsService getTargetAnnotationIdsFromNotifications:",i),[]}}handleNotificationEncryption(i){return T(this,arguments,function*({data:t}){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: handleNotificationEncryption","color: green;");let e="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??"");return yield wt(t,e)}catch(e){return this.loggingService.catch("Error in NotificationUtilsService handleNotificationEncryption:",e),t}})}getCustomNotificationIdsToResolve(t){try{this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: getCustomNotificationIdsToResolve","color: green;");let i=new Set,e=Array.isArray(t)?t:Object.values(t||{});for(let o of e)if(o?.raw?.notificationSource==="custom"){let s=o?.notification?.id||o?.notificationId;s&&i.add(s)}return Array.from(i)}catch(i){return this.loggingService.catch("Error in NotificationUtilsService getCustomNotificationIdsToResolve:",i),[]}}mergeResolvedNotificationData(t){try{if(this.loggingService.log("%c[WB] Calling NotificationUtilsService FUNCTION: mergeResolvedNotificationData","color: green;"),!this.notificationResolverService.notificationDataProviderAvailable()||t?.raw?.notificationSource!=="custom")return t;let i=t?.notification?.id||t?.notificationId;if(!i)return t;let e=this.notificationResolverService.getNotificationById(i);if(!e)return t;let o=["displayHeadlineMessageTemplate","displayHeadlineMessageTemplateData","displayBodyMessage","displayBodyMessageTemplate","displayBodyMessageTemplateData","notificationSourceData"];for(let s of o)e[s]!==void 0&&(t.notification&&(t.notification[s]=e[s]),t.raw&&(t.raw[s]=e[s]));return Object.keys(e).forEach(s=>{!o.includes(s)&&s!=="notificationId"&&(t.notification&&(t.notification[s]=e[s]),t.raw&&(t.raw[s]=e[s]))}),t.notification&&(t.notification.isNotificationResolverUsed=!0),t}catch(i){return this.loggingService.catch("Error in NotificationUtilsService mergeResolvedNotificationData:",i),t}}};y.\u0275fac=function(i){return new(i||y)(m(et),m(X),m(it),m(Z),m(tt),m(ot),m(Q))},y.\u0275prov=G({token:y,factory:y.\u0275fac,providedIn:"root"});let w=y;return w})();function ei(w){if(typeof w!="number"||!Number.isFinite(w))return 25;let t=Math.floor(w);return t<1?25:Math.min(200,t)}function di(w){return new ut(y=>{let st=!0,t=w.subscribe({next:i=>{if(st){let e=i?.data??i;if(!!e&&typeof e=="object"&&Object.keys(e).length===0&&!i?.operation)return}y.next(i)},error:i=>y.error(i),complete:()=>y.complete()});return st=!1,()=>t.unsubscribe()})}var Yi=(()=>{let y=class y{constructor(t,i,e,o,s,n,r,c,a,l,g,f,h,d,S,D,A,F,O,U,P,p){this.afAuth=t,this.analyticsService=i,this.authService=e,this.configService=o,this.commonDbService=s,this.commonDbUtilsService=n,this.commentUtilsService=r,this.commentAnnotationsResolverService=c,this.notificationResolverService=a,this.databaseService=l,this.docService=g,this.domService=f,this.iamService=h,this.loggingService=d,this.notificationUtilsService=S,this.usersService=D,this.functions=A,this.userPermissionService=F,this.coreActionsService=O,this.serviceBook=U,this.realtimeAdapter=P,this.adapterSelectorService=p,this.endpointsService=pt(jt),this.db=null,this.notificationsDb=null,this.documentPaths=null,this.notifications$=new I([]),this.rawNotificationsByIdMap$=new I(new Map),this.processedNotifications$=new I([]),this.userNotificationsFromServer$=new I(null),this.readNotificationsOnForYouTab$=new I(!1),this.currentDocumentOnly$=new I(!1),this.notificationViews$=new I({}),this.notificationsByIdMap$=new I(new Map),this.historyPanelVisible$=new I(!1),this.notificationsForYou$=new I(null),this.notificationsByDocumentIdMap$=new I(null),this.notificationsByDocumentIdSubscription={},this.notificationsHubDisabled=!1,this.reportedDroppedHubPushes=new Set,this.allowedDocumentMetadataMap$=new I(null),this.portableListBoundKey=null,this.maxNotificationDays$=new I(15),this.tabConfig$=new I({people:{enable:!1}}),this.settingsConfig$=new I(null),this.setSettingsConfigByOrganization$=new I(!1),this.muteAllNotifications$=new I(!1),this.enableSettings$=new I(!1),this.selfNotifications$=new I(!1),this.userScopedNotifications$=new I({enabled:!1,limit:25}),this.settingsInitialConfig$=new I([{name:"Inbox",id:"inbox",default:"ALL",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]},{name:"Email",id:"email",default:"MINE",enable:!0,values:[{name:"All",id:"ALL"},{name:"Only Involved",id:"MINE"},{name:"None",id:"NONE"}]}]),this.settingsConfigGeneration=0,this.notificationsPanelVisible$=new I(!1),this.crossOrganizationConfig$=new I({enabled:!1}),this.crossOrgNotifications$=new I([]),this.crossOrgIndexOrgs=[],this.crossOrgIndexTimestamps={},this.crossOrgSeenTimestamps={},this.crossOrgInitialFetchDone=!1,this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=0,this.CROSS_ORG_FETCH_WINDOW_MS=500,this.CROSS_ORG_PAGE_SIZE=50,this.crossOrgGeneration=0,this.crossOrgResolveRoundInFlight=!1,this.crossOrgStragglerRetryUsed=!1,this.CROSS_ORG_STRAGGLER_RETRY_MS=3e4;try{this.serviceBook.set(Rt,this),this.serviceBook.observe(Bt).subscribe(u=>{this.commentService=u??void 0}),this.subscribeNotificationsData().subscribe(),this.commentUtilsService.setNotificationService(this),this.databaseService.getDb().pipe(B(u=>!!u),Y(1)).subscribe(u=>{if(u){this.db=u;try{let E=this.configService.getProxyConfig(),M=this.endpointsService.getNotificationsDbUrl();Dt(M)?(this.notificationsDb=null,this.notificationsHubDisabled=!0):(E?.v1DbHost&&M&&(M=Ct(M,E.v1DbHost)),this.notificationsDb=this.realtimeAdapter.getDatabaseInstance(M),E?.v1DbHost&&M&&this.databaseService.lockDatabaseHost(this.notificationsDb))}catch(E){this.loggingService.catch("Error initializing notifications DB, using default: ",E),this.notificationsDb=u}this.getDocumentIds(),this.subscribeGetNotificationsForYou()}},u=>{this.loggingService.catch("Error in NotificationService getDb subscription: ",u)}),this.authService.getUser$().subscribe(u=>{u?(this.subscribeGetNotificationsForYou(),this.getDocumentIds(),this.subscribeToUserSettings()):(Object.keys(this.notificationsByDocumentIdSubscription).forEach(E=>{this.notificationsByDocumentIdSubscription[E]?.unsubscribe()}),this.notificationForYouSubscription?.unsubscribe(),this.documentIdsSubscription?.unsubscribe(),this.resetCacheData())}),Wt(()=>{try{this.adapterSelectorService?.isPortableBackendActive()&&this.getDocumentIds()}catch(u){this.loggingService.catch("Error re-evaluating portable notification list on chunk registration: ",u)}}),this.docService.getLocationMetadata$().subscribe(u=>{if(u){let E=this.notificationsByDocumentIdMap$.getValue()?JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue())):null;Object.keys(u||{}).forEach(M=>{let R=E?.[M]?.notifications;R?.length&&R.forEach(rt=>{this.notificationUtilsService.mergeLocationWithNotification({notification:rt},u)?.notification})}),this.notificationsByDocumentIdMap$.next(E)}})}catch(u){this.loggingService.catch("Error in NotificationService constructor: ",u)}}setDBConfigDataToInitialConfig(t){try{let i=JSON.parse(JSON.stringify(this.settingsConfig$.getValue()??{}));Object.entries(t||{}).forEach(([e,o])=>{i[e]=o}),this.settingsConfig$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService setDBConfigDataToInitialConfig: ",i)}}getInitialConfigFromDB(t){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: getInitialConfigFromDB","color: green;");let i=++this.settingsConfigGeneration,e=z(this.authService.getUser()?.userId??""),o=yield this.commonDbService.getData({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:this.getSettingsConfigByOrganization()?void 0:t?.documentId,organizationId:t?.organizationId??this.docService.getOrganizationConfig()?.organizationId,userId:e}});if(i!==this.settingsConfigGeneration)return;if(o?.notificationsConfig)this.setDBConfigDataToInitialConfig(o?.notificationsConfig);else{this.setSettingsInitialConfig(this.settingsInitialConfig$.getValue());let s={};this.settingsInitialConfig$.getValue().forEach(r=>{if(r.enable){let c=r?.values?.find(a=>a.id===r.default);s[r.id]=c||r?.values?.[0]||{id:"NONE",name:"None"}}});let n={};Object.keys(s).forEach(r=>{n[r]=s[r].id}),yield this.updateSettingsConfigToDb(n)}}catch(i){this.loggingService.catch("Error in NotificationService getInitialConfigFromDB: ",i)}})}subscribeToUserSettings(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: subscribeToUserSettings","color: green;"),this.userSettingsSubscription&&this.userSettingsSubscription.unsubscribe();let t=z(this.authService.getUser()?.userId??"");this.userSettingsSubscription=this.enableSettings$.pipe(B(i=>i===!0),N(()=>V([this.docService.getDocumentPaths$(),this.getSettingsConfigByOrganization$(),this.docService.getOrganizationConfig$()]).pipe(B(([i,e,o])=>(e||!!i)&&!!o?.organizationId),N(([i,e,o])=>nt(this.getInitialConfigFromDB(i)).pipe(N(()=>this.commonDbService.dbListener({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:e?void 0:i?.documentId,organizationId:i?.organizationId??o?.organizationId,userId:t}}).pipe(v(s=>{s?.data?.notificationsConfig&&!J(s?.data?.notificationsConfig??{},this.settingsConfig$.getValue()??{})&&this.setDBConfigDataToInitialConfig(s?.data?.notificationsConfig)})))))))).subscribe()}catch(t){this.loggingService.catch("Error in NotificationService subscribeToUserSettings: ",t)}}resetCacheData(){try{this.loggingService.log("%c[WB] Calling NotificationService FUNCTION: resetCacheData","color: green;"),this.setUserNotificationsFromServer(null),this.notificationsByDocumentIdMap$.next(null),this.notificationsForYou$.next(null),this.settingsConfig$.next(null),this.resetCrossOrgForUser()}catch(t){this.loggingService.catch("Error in NotificationService resetCacheData: ",t)}}subscribeGetNotificationsForYou(){try{this.notificationForYouSubscription&&this.notificationForYouSubscription.unsubscribe(),this.notificationForYouSubscription=this.getNotificationsForYou().subscribe(()=>{},t=>{this.loggingService.catch("Error in NotificationService getNotificationsForYou subscription: ",t)})}catch(t){this.loggingService.catch("Error in NotificationService subscriveGetNotificationsForYou: ",t)}}setCommentService(t){try{this.commentService=t}catch(i){this.loggingService.catch("Error in NotificationService setCommentService: ",i)}}getDocumentIds(){try{this.documentIdsSubscription&&this.documentIdsSubscription.unsubscribe();let t=!1,i=mt(()=>this.adapterSelectorService?.isPortableBackendActive()?(t=!0,this.subscribePortableUserNotificationList(),L):this.selfNotifications$.pipe(N(()=>this.getCurrentDocumentOnly$().pipe(N(e=>e?this.docService.getDocumentPaths$().pipe(v(o=>{})):C(void 0)))),vt(()=>{this.notificationsByDocumentIdMap$.next(null)}),N(()=>this.getDocumentIdsByLastNotificationTimestamp().pipe(at(),v(([e,o])=>{let s=e?.map(l=>l.documentId),n=o?.map(l=>l.documentId),r=s?.filter(l=>!n?.includes(l)),c=n?.map(l=>({documentId:l,timestamp:o?.find(g=>g.documentId===l)?.timestamp})).filter(l=>!s?.includes(l.documentId)),a=n?.map(l=>{let g=o?.find(f=>f.documentId===l)?.timestamp;return{documentId:l,timestamp:g}}).filter(l=>{let g=e?.find(f=>f.documentId===l.documentId)?.timestamp;return g&&l.timestamp&&g!==l.timestamp});c?.length&&this.fetchNotificationsForDocumentIds(c),a?.length&&this.fetchNotificationsForDocumentIds(a,1),r?.forEach(l=>{this.removeNotificationsForDocumentId(l)}),o&&!o?.length&&!this.notificationsByDocumentIdMap$.getValue()&&(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([]))}))))).subscribe(()=>{},e=>{this.loggingService.catch("Error in NotificationService getDocumentIds subscription: ",e)});t||(this.documentIdsSubscription=i)}catch(t){this.loggingService.catch("Error in NotificationService getDocumentIds: ",t)}}subscribePortableUserNotificationList(){try{this.documentIdsSubscription&&this.documentIdsSubscription.unsubscribe(),this.documentIdsSubscription=this.authService.getUser$().pipe(N(t=>t?.userId?this.docService.getOrganizationConfig$().pipe(v(i=>i?.organizationId||t.organizationId),_(),N(i=>{let e=this.configService.getApiKey();if(!e||!i)return this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([]),L;let o=z(t.userId),s=`${o}:${e}:${i}`;return this.portableListBoundKey!==null&&this.portableListBoundKey!==s&&(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([])),this.portableListBoundKey=s,di(this.commonDbService.dbListener({feature:"allUserNotifications",properties:{id:o,apiKey:e,organizationId:i}})).pipe(j(n=>(this.loggingService.catch("Error in portable user notification list listener: ",n),C({data:{},operation:null}))))})):(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([]),L))).subscribe(t=>{try{this.applyPortableUserNotificationMap(t?.data??t??{})}catch(i){this.loggingService.catch("Error applying portable user notification map: ",i)}},t=>{this.loggingService.catch("Error in portable user notification list subscription: ",t)})}catch(t){this.loggingService.catch("Error in NotificationService subscribePortableUserNotificationList: ",t)}}applyPortableUserNotificationMap(t){let i=t&&typeof t=="object"?t:{},e=Object.keys(i).map(s=>{let n=i[s];return!n||typeof n!="object"?{notificationId:s}:b({notificationId:n.notificationId??s},n)});this.setUserNotificationsFromServer(e);let o={};for(let s of e)try{if((s?.kind??s?.payload?.kind)==="digest")continue;let r=this.getClientNotificationObject(s);if(!r)continue;let c=s?.metadata?.documentId??r?.metadata?.documentId;if(!c)continue;o[c]||(o[c]={notifications:[]}),o[c].notifications.push(r)}catch(n){this.loggingService.catch("Error materializing portable notification row: ",n)}for(let s of Object.keys(o))o[s].notifications.sort((n,r)=>(r.timestamp||0)-(n.timestamp||0));this.notificationsByDocumentIdMap$.next(o)}getDocumentIdsByLastNotificationTimestamp(t=15){try{return this.authService.getUser$().pipe(N(i=>this.docService.getOrganizationConfig$().pipe(v(e=>{let o=null,s=this.configService.getApiKey(),n=e?.organizationId||i?.organizationId,r=e?.clientOrganizationId||i?.clientOrganizationId||"";return s&&n&&(o=new ht({apiKey:s,organizationId:n})),{user:i,documentPaths:o,clientOrganizationId:r}}))),N(i=>{let{user:e,documentPaths:o,clientOrganizationId:s}=i;if(this.getCurrentDocumentOnly()&&!this.docService?.getDocumentPaths()?.documentId)return C(null);if(e&&o?.organizationNotificationsLastNotificationTimestamp){let n=new Date,r=this.maxNotificationDays$.getValue()>0?this.maxNotificationDays$.getValue():15;n.setDate(n.getDate()-r);let c=n.getTime(),a=[Ht(dt("timestamp",">=",c),...this.getCurrentDocumentOnly()&&this.docService.getDocumentPaths()?.documentId?[dt("metadata.documentId","==",this.docService.getDocumentPaths()?.documentId)]:[])];this.getCurrentDocumentOnly()||(a.push(_t("timestamp","desc")),a.push(Vt(t)));let l=e?.userId??"";return nt(this.userPermissionService?.getUserPermissionsFromCacheOrFetch({organizationId:s})??Promise.resolve({})).pipe(N(g=>l&&s&&g?.[l]?.organization?.[s]?.errorCode===yt.PERMISSION_DENIED?C(null):this.commonDbService.dbListener({feature:"allLastNotificationTimestamp",properties:{organizationId:o?.organizationId,isCollection:!0,useQuery:!0,firestoreQuery:a}}).pipe(v(f=>f?.data),v(f=>{let h=[];return Object.keys(f||{}).forEach(d=>{let S=this.commonDbService.shouldUseFirestore()?f[d]?.timestamp??0:f[d],D=this.commonDbService.shouldUseFirestore()?f[d]?.deletedNotification??!1:!1;if(D&&D.id&&D?.timestamp===S){let A=D.id,F=f[d]?.metadata?.documentId,O=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()??{})),U=O?.[F]??{documentMetadata:null,notifications:[]},P=U.notifications??[],p=P?.findIndex(u=>u.id===A);p!==-1&&(P.splice(p,1),this.notificationsByDocumentIdMap$.next($(b({},O),{[F]:$(b({},U),{notifications:P})}))),this.notificationResolverService.notificationDataProviderAvailable()&&this.notificationResolverService.getNotificationById(A)&&this.notificationResolverService.deleteNotification(A,this.docService.getDocumentPaths()?.clientOrganizationId??"")}h.push({documentId:d,timestamp:S})}),h}),j(f=>(this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",f),C([]))))))}return C(null)}))}catch(i){return this.loggingService.catch("Error in NotificationService getDocumentIdsByLastNotificationTimestamp: ",i),C([])}}resolveAndUpdateDocumentNotifications(t,i){try{Object.keys(t).forEach(e=>{let o=t[e]?.documentMetadata||this.docService.getAllDocumentMetadataMap()?.[e]||{},s;if(i==="user")s=this.commonDbUtilsService.mergeUsersWithData({feature:"allDocNotifications",data:t[e]?.notifications||[]});else if(i==="notification"){let n=t[e]?.notifications?.reduce((c,a)=>(c[a.notificationId]=a,c),{}),r=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allDocNotifications",data:n});s=Object.values(r??{})}else{let n=t[e]?.notifications?.reduce((c,a)=>(c[a.notificationId]=a,c),{}),r=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allDocNotifications",data:n});s=Object.values(r??{})}s.forEach(n=>{n.notification=this.getClientNotificationObject(n)}),this.setNotificationForDocumentIdInCache(e,o,s)})}catch(e){this.loggingService.catch("Error in NotificationService resolveAndUpdateDocumentNotifications: ",e)}}resolveAndMergeUserNotifications(t,i,e=!1){try{let o=t;if(e&&i==="comment"){let a=this.getUserNotificationsFromServer()??[],l=new Set(t.map(g=>g.notificationId));o=a.filter(g=>l.has(g.notificationId)).concat(t.filter(g=>!a.some(f=>f.notificationId===g.notificationId)))}let s=o.reduce((a,l)=>(a[l.notificationId]=l,a),{}),n;if(i==="user"){let a=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:s});n=Object.values(a??{})}else if(i==="notification"){let a=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:s});n=Object.values(a??{})}else{let a=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:s});n=Object.values(a??{})}n.forEach(a=>{a.notification=this.getClientNotificationObject(a)});let r=this.getUserNotificationsFromServer()??[],c=new Map(r.map(a=>[a.notificationId,a]));n.forEach(a=>{c.set(a.notificationId,a)}),this.setUserNotificationsFromServer(Array.from(c.values()))}catch(o){this.loggingService.catch("Error in NotificationService resolveAndMergeUserNotifications: ",o)}}fetchNotificationsForDocumentIds(t,i=15){return T(this,null,function*(){try{if(t?.length){let e=this.docService.getOrganizationConfig()?.organizationId??"";if(!e)return[];let o=this.getStartAtTimestamp(),s={};if(t.forEach(d=>{if(d?.documentId){let S=this.getAllowedDocumentMetadataByDocumentId(d.documentId);S&&(s[d.documentId]=S)}}),this.userPermissionService?.isPermissionProviderAvailable())try{let d=[];if(t.forEach(O=>{this.docService.getDocumentMetadata(O.documentId)||d.push(O.documentId)}),d.length){let O=this.authService.getUser(),U=q(this.functions,K({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));try{let P=yield ft({methodName:"getDocumentMetadataFromIds",data:{type:"getDocumentMetadataFromIds",metadata:{organizationId:O?.clientOrganizationId,folderId:this.documentPaths?.folderId},documentIds:d},getSdkProxy:U,userId:O?.userId??""});if(P?.data?.length){let p={};P.data.forEach(u=>{u?.documentId&&(p[u.documentId]=u)}),this.docService.setAllDocumentMetadata(b(b({},this.docService.getAllDocumentMetadataMap()),p))}}catch(P){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",P)}}let S=[],D=[];t.forEach(O=>{let U=this.docService.getDocumentMetadata(O.documentId);U?.clientDocumentId?S.push({userId:this.authService.getUser()?.userId??"",resource:b({id:U.clientDocumentId,type:k.DOCUMENT,source:W.GET_NOTIFICATIONS,organizationId:this.docService.getOrganizationConfig()?.clientOrganizationId??""},U.folderId&&{parentFolderId:U.folderId})}):D.push(O.documentId)}),D.length&&(t=t.filter(O=>!D.includes(O.documentId)));let A=$t();this.coreActionsService.triggerAction(Ot.PERMISSION_PROVIDER,{event:H.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:A,methodName:W.GET_NOTIFICATIONS,source:"internal",payload:{requests:S}});let F=yield this.userPermissionService?.onResourceAccessRequired({requests:S,uniqueId:A,methodName:W.GET_NOTIFICATIONS});F?.success&&F?.data?.length?F.data.forEach(O=>{!O.hasAccess&&O.resourceId&&(t=t.filter(U=>U.documentId!==Ut(O.resourceId)))}):t=[]}catch(d){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",d),t=[]}let n=this.userScopedNotifications$.getValue(),r=!!n?.enabled&&i!==1&&!this.getCurrentDocumentOnly();if(!t.length&&(this.notificationsByDocumentIdMap$.getValue()||(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([])),!r))return[];let c=this.userPermissionService?.getPermissionsCache()?.filter(d=>d.type===k.CONTEXT),a=b({organizationId:e,documentIds:t.filter(d=>!!d.documentId&&!!d.timestamp).map(d=>({documentId:d.documentId,timestamp:d.timestamp??0})),timestamp:o,limitToLast:i,selfNotifications:this.selfNotifications$.value,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),getUserNotifications:!0,isContextEnabled:this.userPermissionService?.getIsContextEnabled(),cachedData:c,isSettingsConfigByOrganization:this.getSettingsConfigByOrganization(),retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig()},r&&{getUserNotificationsForOrganization:!0,userNotificationsLimitToLast:ei(n?.limit)}),{notificationsByDocumentId:l,userNotifications:g=[],userNotificationIdsInDocNotifications:f=[],permissionResults:h=[]}=yield this.callGetNotificationsForDocuments(a);if(this.userPermissionService?.getIsContextEnabled()){let d=[...this.userPermissionService?.getPermissionsCache()??[],...h??[]];this.userPermissionService?.setPermissionsCache(d)}if(l&&typeof l=="object"){let d=this.usersService.userDataProviderAvailable(),S=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),D=this.notificationResolverService.notificationDataProviderAvailable(),A=[],F=[],O=[];Object.keys(l).forEach((p,u)=>{let E=l[p].documentMetadata??this.docService.getAllDocumentMetadataMap()?.[p];if(E){let R=this.allowedDocumentMetadataMap$.value||{};(!R?.[p]||!J(R?.[p],E))&&this.allowedDocumentMetadataMap$.next($(b({},R),{[p]:E}))}let M=l[p].notifications||[];M.forEach(R=>{f.includes(R.notificationId)&&!g.find(rt=>rt.notificationId===R.notificationId)&&g.push(JSON.parse(JSON.stringify(R))),R.notification=this.getClientNotificationObject(R)}),this.setNotificationForDocumentIdInCache(p,E,M),d&&(A.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:M,shouldAwait:!0,forceResolve:!0})),A.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:g,shouldAwait:!0,forceResolve:!0}))),S&&(F.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:M,shouldCommentAnnotationsResolverAwait:!0})),F.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:g,shouldCommentAnnotationsResolverAwait:!0}))),D&&(O.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:M,shouldNotificationResolverAwait:!0})),O.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:g,shouldNotificationResolverAwait:!0})))});let U=JSON.parse(JSON.stringify(g));if(r){let p=new Map((this.getUserNotificationsFromServer()??[]).map(u=>[u?.notificationId,u]));g.forEach(u=>p.set(u?.notificationId,u)),this.setUserNotificationsFromServer(Array.from(p.values()))}else this.setUserNotificationsFromServer([...this.getUserNotificationsFromServer()??[],...g]);(D||d||S)&&(()=>{let p=Promise.resolve();if(D&&(p=p.then(()=>Promise.allSettled(O)).then(()=>{this.resolveAndUpdateDocumentNotifications(l,"notification"),this.resolveAndMergeUserNotifications(U,"notification")})),d&&(p=p.then(()=>Promise.allSettled(A)).then(()=>{this.resolveAndUpdateDocumentNotifications(l,"user"),this.resolveAndMergeUserNotifications(U,"user")})),S){let u=D||d;p=p.then(()=>Promise.allSettled(F)).then(()=>{this.resolveAndUpdateDocumentNotifications(l,"comment"),this.resolveAndMergeUserNotifications(U,"comment",u)})}return p})().catch(p=>{this.loggingService.catch("Error in NotificationService resolveChain: ",p)})}}}catch(e){return this.loggingService.catch("Error in NotificationService fetchNotificationsForDocumentIds: ",e),[]}})}callGetNotificationsForDocuments(t){return T(this,null,function*(){let i=q(this.functions,K({url:this.endpointsService.getCloudFunctionUrl("getNotificationsForDocuments"),apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),e=yield this.notificationUtilsService.handleNotificationEncryption({data:t}),o=yield i({veltData:e}),s=o?.data?.data?.veltData||{},n=o?.data?.data?.veltAdditionalData||{},r="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??""),c=yield gt(s,r),{userNotifications:a,userNotificationIdsInDocNotifications:l,permissionResults:g}=yield gt(n,r);return{notificationsByDocumentId:c,userNotifications:a,userNotificationIdsInDocNotifications:l,permissionResults:g}})}getUserNotificationsFromServer$(){return this.userNotificationsFromServer$.asObservable()}setUserNotificationsFromServer(t){try{let i=JSON.parse(JSON.stringify(t));i=i?.filter((e,o,s)=>o===s.findIndex(n=>n.notificationId===e.notificationId)),this.userNotificationsFromServer$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService setUserNotificationsFromServer: ",i)}}getUserNotificationsFromServer(){return this.userNotificationsFromServer$.getValue()}setNotificationForDocumentIdInCache(t,i,e,o){try{let s=this.docService.getOrganizationConfig()?.organizationId??"",n=this.docService.getOrganizationMetadata(s);i||(i=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata()||{}))),n||(n=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(s)||{})));let r=this.notificationsByDocumentIdMap$.getValue(),c=r?.[t]?.notifications||[],a=this.docService.getLocationMetadatas(),l=e?.map(h=>{let d=h?.notification;return d?(d.metadata&&(d.metadata.documentName=i?.documentName||d.metadata.documentName,d.metadata.organizationMetadata=n||d.metadata.organizationMetadata,d.metadata.documentMetadata=i||d.metadata.documentMetadata),a&&(d=this.notificationUtilsService.mergeLocationWithNotification({notification:d},a)?.notification),d):null})?.filter(h=>!!h)||[],g=new Map(c.map(h=>[h.id,h]));l.forEach(h=>{g.set(h.id,h)});let f=Array.from(g.values()).sort((h,d)=>(d.timestamp||0)-(h.timestamp||0));this.notificationsByDocumentIdMap$.next($(b({},r),{[t]:{notifications:f,documentMetadata:i}}))}catch(s){this.loggingService.catch("Error in NotificationService setNotificationForDocumentIdInCache: ",s)}}removeNotificationsForDocumentId(t){try{this.notificationsByDocumentIdSubscription[t]&&this.notificationsByDocumentIdSubscription[t].unsubscribe();let i=this.notificationsByDocumentIdMap$.getValue();delete i?.[t],this.notificationsByDocumentIdMap$.next(i)}catch(i){this.loggingService.catch("Error in NotificationService removeNotificationsForDocumentId: ",i)}}getStartAtTimestamp(){try{let t=new Date,i=this.maxNotificationDays$.getValue()>0?this.maxNotificationDays$.getValue():15;return t.setDate(t.getDate()-i),t.getTime()}catch(t){return this.loggingService.catch("Error in NotificationService getStartAtTimestamp: ",t),0}}getCurrentOrgNotificationsForYou(){try{return this.getUserNotificationsFromServer$().pipe(N(t=>C(t).pipe(B(i=>!!i),v(i=>{let e=this.usersService.userDataProviderAvailable(),o=this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable(),s=this.notificationResolverService?.notificationDataProviderAvailable();if(s||e||o){let r=i?.reduce((c,a)=>(c[a.notificationId]=a,c),{});s&&(r=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:r||[]})),e&&(r=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:r||[]})),o&&(r=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:r||[]})),i=Object.values(r??{})}return i.forEach(r=>{r.notification=this.getClientNotificationObject(r)}),i.sort((r,c)=>c.timestamp-r.timestamp),i.map(r=>r.notification).filter(r=>!!r)}),N(i=>{let e={data:i?.reduce((o,s)=>(o[s.id]={notification:s},o),{}),operation:null};return this.commonDbUtilsService.mergeLocationMetadataWithData$({data:e,feature:"allUserNotifications"}).pipe(v(o=>Object.values(o?.data||{}).map(s=>s?.notification)))}))),N(t=>{let i=this.docService.getOrganizationConfig()?.organizationId??"";return this.docService.getOrganizationMetadata$(i).pipe(v(()=>t))}),N(t=>this.allowedDocumentMetadataMap$.pipe(v(()=>t))),v(t=>(t?.length&&(t=t.map(i=>{if(i?.metadata){let e=this.docService.getOrganizationConfig()?.organizationId??"",o=this.getAllowedDocumentMetadataByDocumentId(i.metadata.documentId),s=this.docService.getOrganizationMetadata(e);o||(o=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata()||{}))),s||(s=JSON.parse(JSON.stringify(this.docService.getOrganizationMetadata(e)||{}))),i.metadata.documentName=o?.documentName||i.metadata.documentName,i.metadata.organizationMetadata=s||i.metadata.organizationMetadata,i.metadata.documentMetadata=o||i.metadata.documentMetadata}return i})),t)))}catch(t){return this.loggingService.catch("Error in NotificationService getCurrentOrgNotificationsForYou: ",t),C(null)}}getNotificationsForYou(){try{return V([this.getCurrentOrgNotificationsForYou(),this.crossOrgNotifications$.asObservable()]).pipe(v(([t,i])=>{let e=this.mergeCrossOrgForYou(t,i);return e===null?this.notificationsForYou$.next(null):e?.length?this.notificationsForYou$.next(JSON.parse(JSON.stringify(e))):this.notificationsForYou$.next([]),e}))}catch(t){return this.loggingService.catch("Error in NotificationService getNotificationsForYou: ",t),C({})}}mergeCrossOrgForYou(t,i){try{let e=Array.isArray(i)?i:[];if(!e.length)return t;let o=Array.isArray(t)?t:[],s=c=>c?.id??c?.notificationId,n=new Set;o.forEach(c=>{let a=s(c);a!=null&&n.add(a)});let r=[...o];return e.forEach(c=>{let a=s(c);a!=null&&n.has(a)||(a!=null&&n.add(a),r.push(c))}),r.sort((c,a)=>(a?.timestamp||0)-(c?.timestamp||0))}catch(e){return this.loggingService.catch("Error in NotificationService mergeCrossOrgForYou: ",e),t}}enableCrossOrganization(t){try{if(t&&typeof t=="object"&&t.enabled===!1){this.disableCrossOrganization();return}this.setCrossOrganizationConfig($(b({},t||{}),{enabled:!0})),this.crossOrgUserSubscription?this.crossOrgIndexSubscription&&(this.crossOrgInitialFetchDone=!1,this.scheduleCrossOrgFetch()):this.attachCrossOrgIndexListener()}catch(i){this.loggingService.catch("Error in NotificationService enableCrossOrganization: ",i)}}disableCrossOrganization(){try{this.teardownCrossOrg();let t=this.crossOrganizationConfig$.getValue();this.crossOrganizationConfig$.next($(b({},t||{}),{enabled:!1}))}catch(t){this.loggingService.catch("Error in NotificationService disableCrossOrganization: ",t)}}setCrossOrganizationConfig(t){try{let i=t||{},e=Array.isArray(i.feeds)&&i.feeds.length?i.feeds:["forYou"];e.includes("all")&&this.loggingService.warn('NotificationService: cross-organization notifications only support the "forYou" feed; ignoring "all".'),e=e.filter(s=>s==="forYou"),e.length||(e=["forYou"]);let o={enabled:i.enabled??!0,organizationIds:i.organizationIds,excludeOrganizationIds:i.excludeOrganizationIds,feeds:e};this.crossOrganizationConfig$.next(o)}catch(i){this.loggingService.catch("Error in NotificationService setCrossOrganizationConfig: ",i)}}getCrossOrganizationConfig(){return this.crossOrganizationConfig$.getValue()}getCrossOrganizationConfig$(){return this.crossOrganizationConfig$.asObservable()}attachCrossOrgIndexListener(){try{this.teardownCrossOrgUserWatcher(),this.crossOrgUserSubscription=this.authService.getUser$().pipe(v(t=>t?.userId),_(),B(t=>!!t),j(t=>(this.loggingService.catch("Error in NotificationService cross-org user watcher: ",t),L))).subscribe(t=>{try{this.teardownCrossOrgPerUserListeners(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.next([]),this.bindCrossOrgListenersForUser(t)}catch(i){this.loggingService.catch("Error in NotificationService cross-org user-change handler: ",i)}})}catch(t){this.loggingService.catch("Error in NotificationService attachCrossOrgIndexListener: ",t)}}bindCrossOrgListenersForUser(t){this.crossOrgIndexSubscription=this.commonDbService.dbListener({feature:"userNotificationIndex",properties:{id:z(t),isCollection:!1,useCollectionGroup:!1}}).pipe(j(i=>(this.loggingService.catch("Error in NotificationService cross-org index listener: ",i),L))).subscribe(i=>{try{let e=this.extractIndexOrgTimestamps(i);this.crossOrgIndexTimestamps=e;let o=Object.keys(e);this.crossOrgIndexOrgs=o,this.pruneCrossOrgBufferToAllowedOrgs(),o.length&&this.scheduleCrossOrgFetch()}catch(e){this.loggingService.catch("Error in NotificationService cross-org index snapshot: ",e)}}),this.crossOrgOrgSwitchSubscription=this.docService.getOrganizationConfig$().pipe(v(i=>i?.organizationId??""),_(),at(),B(([i])=>!!i),j(i=>(this.loggingService.catch("Error in NotificationService cross-org org-switch listener: ",i),L))).subscribe(()=>{this.crossOrgInitialFetchDone=!1,this.crossOrgSeenTimestamps={},this.scheduleCrossOrgFetch()})}extractIndexOrgTimestamps(t){let i={};try{let e=t?.data??t,o=e?.organizationIds??e?.orgs;return Array.isArray(o)?(o.forEach(s=>{typeof s=="string"&&s.length&&(i[s]=0)}),i):(o&&typeof o=="object"&&Object.keys(o).forEach(s=>{if(typeof s=="string"&&s.length){let n=Number(o[s]);i[s]=Number.isFinite(n)?n:0}}),i)}catch(e){return this.loggingService.catch("Error in NotificationService extractIndexOrgTimestamps: ",e),i}}scheduleCrossOrgFetch(){try{let t=Date.now();t-this.lastCrossOrgFetchTime>=this.CROSS_ORG_FETCH_WINDOW_MS?(this.lastCrossOrgFetchTime=t,this.crossOrgFetchPending=!1,this.fetchCrossOrgUserNotifications(),this.armCrossOrgTrailingTimer()):this.crossOrgFetchPending=!0}catch(t){this.loggingService.catch("Error in NotificationService scheduleCrossOrgFetch: ",t)}}pruneCrossOrgBufferToAllowedOrgs(){try{let t=this.crossOrgNotifications$.getValue();if(!t.length)return;let i=this.crossOrgIndexOrgs||[];if(!i.length){this.crossOrgNotifications$.next([]);return}let e=t.filter(o=>i.includes(o?.metadata?.organizationId));e.length!==t.length&&this.crossOrgNotifications$.next(e)}catch(t){this.loggingService.catch("Error in NotificationService pruneCrossOrgBufferToAllowedOrgs: ",t)}}armCrossOrgTrailingTimer(){this.crossOrgFetchTimer&&clearTimeout(this.crossOrgFetchTimer),this.crossOrgFetchTimer=setTimeout(()=>{this.crossOrgFetchPending&&(this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=Date.now(),this.fetchCrossOrgUserNotifications())},this.CROSS_ORG_FETCH_WINDOW_MS)}toCrossOrgClientNotification(t){try{if(!t)return null;if(t.notification){let e=this.getClientNotificationObject(t);if(!e)return null;let o=t?.metadata?.organizationId??e?.metadata?.organizationId;return o!=null&&(e.metadata=$(b({},e.metadata||{}),{organizationId:o})),e}let i=t.id??t.notificationId;return i==null?null:t.id!=null?t:$(b({},t),{id:i})}catch(i){return this.loggingService.catch("Error in NotificationService toCrossOrgClientNotification: ",i),null}}resolveCrossOrgSelfHostedData(t){return T(this,null,function*(){try{if(!t?.length)return t;let i=!!this.notificationResolverService?.notificationDataProviderAvailable?.(),e=!!this.usersService?.userDataProviderAvailable?.(),o=!!this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable?.();if(!i&&!e&&!o)return t;let s=new Map;for(let r of t){let c=r?.metadata?.clientOrganizationId??r?.metadata?.organizationId??"",a=s.get(c);a?a.push(r):s.set(c,[r])}let n=[];for(let[r,c]of s){let a=c.reduce((g,f,h)=>{let d=f?.notificationId??f?.id??`__cross_org_${h}`;return g[d]=f,g},{});yield this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:a,organizationId:r||void 0,shouldAwait:!0,shouldNotificationResolverAwait:!0,shouldCommentAnnotationsResolverAwait:!0});let l=a;i&&(l=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:l??{}})),e&&(l=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:l??{}})),o&&(l=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:l??{}})),n.push(...Object.values(l??{}))}return n}catch(i){return this.loggingService.catch("Error in NotificationService resolveCrossOrgSelfHostedData: ",i),t}})}fetchCrossOrgUserNotifications(){return T(this,null,function*(){let t=this.crossOrgGeneration;if(this.crossOrgResolveRoundInFlight){this.crossOrgFetchPending=!0;return}this.crossOrgResolveRoundInFlight=!0;try{let i=this.crossOrganizationConfig$.getValue(),e=this.docService.getOrganizationConfig()?.organizationId??"",o=!this.crossOrgInitialFetchDone,s=this.crossOrgIndexTimestamps||{},n=o?[]:Object.keys(s).filter(f=>f!==e&&(s[f]??0)>(this.crossOrgSeenTimestamps[f]??-1));if(!o&&!n.length)return;let r=this.buildCrossOrgRequestData(i,e,{isInitial:o,bumpedOrgs:n}),c=yield this.callGetCrossOrgUserNotifications(r);if(t!==this.crossOrgGeneration)return;let a=Array.isArray(c?.pendingPermissionQueries)?c.pendingPermissionQueries:[],l=!!this.userPermissionService?.isClientDevResolverActive?.(),g=!a.length||!l;if(yield this.processCrossOrgResponse(c,{fetchGeneration:t,currentOrg:e,isInitial:o,indexTimestamps:s,advanceCursors:g}),t!==this.crossOrgGeneration||g){g&&t===this.crossOrgGeneration&&this.clearCrossOrgStragglerRetry();return}yield this.runCrossOrgResolveRound(a,{fetchGeneration:t,config:i,currentOrg:e,isInitial:o,bumpedOrgs:n,indexTimestamps:s})}catch(i){this.loggingService.catch("Error in NotificationService fetchCrossOrgUserNotifications: ",i)}finally{this.crossOrgResolveRoundInFlight=!1,this.crossOrgFetchPending&&t===this.crossOrgGeneration&&(this.crossOrgFetchPending=!1,this.lastCrossOrgFetchTime=Date.now(),this.fetchCrossOrgUserNotifications())}})}runCrossOrgResolveRound(t,i){return T(this,null,function*(){try{let e=yield this.userPermissionService.resolveClientSidePermissions(t);if(i.fetchGeneration!==this.crossOrgGeneration)return;let o=this.buildCrossOrgRequestData(i.config,i.currentOrg,{isInitial:i.isInitial,bumpedOrgs:i.bumpedOrgs});o.clientResolvedResults=e;let s=yield this.callGetCrossOrgUserNotifications(o);if(i.fetchGeneration!==this.crossOrgGeneration)return;yield this.processCrossOrgResponse(s,{fetchGeneration:i.fetchGeneration,currentOrg:i.currentOrg,isInitial:i.isInitial,indexTimestamps:i.indexTimestamps,advanceCursors:!0}),i.fetchGeneration===this.crossOrgGeneration&&this.clearCrossOrgStragglerRetry()}catch(e){this.loggingService.catch("Error in NotificationService runCrossOrgResolveRound: ",e),this.armCrossOrgStragglerRetry(i.fetchGeneration)}})}processCrossOrgResponse(t,i){return T(this,null,function*(){if(this.userPermissionService?.getIsContextEnabled?.()&&t?.permissionResults?.length){let l=[...this.userPermissionService?.getPermissionsCache?.()??[],...t.permissionResults];this.userPermissionService?.setPermissionsCache?.(l)}let e=Array.isArray(t?.forYou)?t.forYou:[],o=this.crossOrgIndexOrgs||[],s=l=>o.includes(l),n=e.filter(l=>{let g=l?.metadata?.organizationId;if(g===i.currentOrg)return this.loggingService.log("%c[WB] Cross-org: dropping current-org echo: "+g,"color: orange;"),!1;let f=s(g);return f||this.loggingService.log("%c[WB] Cross-org: dropping entry from un-indexed org: "+g,"color: orange;"),f}),r=yield this.resolveCrossOrgSelfHostedData(n);if(i.fetchGeneration!==this.crossOrgGeneration)return;let c=r.map(l=>this.toCrossOrgClientNotification(l)).filter(l=>!!l),a;i.isInitial?a=c:a=this.mergeCrossOrgForYou(c,this.crossOrgNotifications$.getValue()).filter(l=>s(l?.metadata?.organizationId)),i.advanceCursors&&(Object.keys(i.indexTimestamps).forEach(l=>{this.crossOrgSeenTimestamps[l]=i.indexTimestamps[l]}),this.crossOrgInitialFetchDone=!0),this.crossOrgNotifications$.next(a)})}armCrossOrgStragglerRetry(t){this.crossOrgStragglerRetryUsed||(this.crossOrgStragglerRetryUsed=!0,this.crossOrgStragglerRetryTimer&&clearTimeout(this.crossOrgStragglerRetryTimer),this.crossOrgStragglerRetryTimer=setTimeout(()=>{this.crossOrgStragglerRetryTimer=void 0,t===this.crossOrgGeneration&&this.fetchCrossOrgUserNotifications()},this.CROSS_ORG_STRAGGLER_RETRY_MS))}clearCrossOrgStragglerRetry(){this.crossOrgStragglerRetryUsed=!1,this.crossOrgStragglerRetryTimer&&(clearTimeout(this.crossOrgStragglerRetryTimer),this.crossOrgStragglerRetryTimer=void 0)}callGetCrossOrgUserNotifications(t){return T(this,null,function*(){let i=this.authService.getUser(),e=q(this.functions,K({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield ft({methodName:"getCrossOrgUserNotifications",data:b({type:"getCrossOrgUserNotifications"},t),getSdkProxy:e,userId:i?.userId??""})})}buildCrossOrgRequestData(t,i,e){let o=t||{},s=e?.isInitial??!0,n=e?.bumpedOrgs??[],r=Array.isArray(o.organizationIds),c=r?o.organizationIds.filter(h=>!!h).map(h=>lt(h)):[],a=(o.excludeOrganizationIds||[]).filter(h=>!!h).map(h=>lt(h)),l=new Set(a);i&&l.add(i);let g=this.userPermissionService?.getPermissionsCache?.()?.filter(h=>h?.type===k.CONTEXT),f={organizationId:i,excludeOrganizationIds:Array.from(l),timestamp:this.getStartAtTimestamp(),limitToLast:this.CROSS_ORG_PAGE_SIZE,isContextEnabled:this.userPermissionService?.getIsContextEnabled?.(),cachedData:g,isSettingsConfigByOrganization:this.getSettingsConfigByOrganization(),retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig?.()};if(this.userPermissionService?.isClientDevResolverActive?.()&&(f.clientResolverAvailable=!0),s)r&&(f.organizationIds=this.dedupeIncludeOrgs(c,l));else{let h=n.filter(S=>!!S&&!l.has(S));if(r){let S=new Set(c);h=h.filter(D=>S.has(D))}h=Array.from(new Set(h)),f.organizationIds=h;let d={};h.forEach(S=>{d[S]=this.crossOrgSeenTimestamps[S]??this.getStartAtTimestamp()}),f.orgTimestamps=d}return f}dedupeIncludeOrgs(t,i){let e=new Set;return t.filter(o=>o==null||i.has(o)||e.has(o)?!1:(e.add(o),!0))}teardownCrossOrgPerUserListeners(){this.crossOrgGeneration++,this.crossOrgIndexSubscription&&(this.crossOrgIndexSubscription.unsubscribe(),this.crossOrgIndexSubscription=void 0),this.crossOrgOrgSwitchSubscription&&(this.crossOrgOrgSwitchSubscription.unsubscribe(),this.crossOrgOrgSwitchSubscription=void 0),this.crossOrgFetchTimer&&(clearTimeout(this.crossOrgFetchTimer),this.crossOrgFetchTimer=void 0),this.crossOrgFetchPending=!1,this.clearCrossOrgStragglerRetry()}teardownCrossOrgUserWatcher(){this.teardownCrossOrgPerUserListeners(),this.crossOrgUserSubscription&&(this.crossOrgUserSubscription.unsubscribe(),this.crossOrgUserSubscription=void 0)}resetCrossOrgDeltaState(){this.crossOrgIndexOrgs=[],this.crossOrgIndexTimestamps={},this.crossOrgSeenTimestamps={},this.crossOrgInitialFetchDone=!1}resetCrossOrgForUser(){this.teardownCrossOrgPerUserListeners(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.getValue().length&&this.crossOrgNotifications$.next([])}teardownCrossOrg(){this.teardownCrossOrgUserWatcher(),this.resetCrossOrgDeltaState(),this.crossOrgNotifications$.next([])}markCrossOrgEntriesRead(t){try{let i=this.crossOrgNotifications$.getValue();if(!i?.length)return;let e=new Set((t||[]).map(r=>r?.id??r?.notificationId).filter(r=>r!=null));if(!e.size)return;let o=!this.getReadNotificationsOnForYouTab(),s=!1,n=o?i.filter(r=>{let c=r?.id??r?.notificationId,a=c!=null&&e.has(c);return a&&(s=!0),!a}):i.map(r=>{let c=r?.id??r?.notificationId;return c!=null&&e.has(c)&&r?.isUnread!==!1?(s=!0,$(b({},r),{isUnread:!1})):r});s&&this.crossOrgNotifications$.next(n)}catch(i){this.loggingService.catch("Error in NotificationService markCrossOrgEntriesRead: ",i)}}subscribeNotificationsData(t,i){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let e,o;try{if(t&&(o=ct(t)),i&&typeof i=="object"){let s=Mt(i);e=ct(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",s)}return this.authService.getAuthState$().pipe(B(s=>!!s),N(s=>this.isFeatureAllowed({firebaseUser:s})),N(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(v(n=>(s.featureAllowed=n,s))):C(s)),N(s=>!s.featureAllowed||s?.user?.organizationId?(this.notifications$.next([]),this.rawNotificationsByIdMap$.next(new Map),this.processedNotifications$.next([]),this.notificationsByIdMap$.next(new Map),this.notificationViews$.next({}),this.setNotificationsByIdMap(),C([])):C(s).pipe(N(n=>this.docService.getDocumentPaths$().pipe(v(r=>(this.documentPaths=r,n.documentPaths=r,n)))),N(n=>this.getDataFromDocumentId(o)))))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(B(i=>!!i),v(i=>$(b({},t),{config:i})),N(i=>this.authService.getUser$().pipe(v(e=>$(b({},i),{user:e})))),N(i=>Et(i.config,i.user,bt.NOTIFICATION)?C($(b({},i),{featureAllowed:!0})):(this.loggingService.warn("Notification feature is not allowed."),C($(b({},i),{featureAllowed:!1})))))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(B(i=>!!i),N(i=>{if(this.db=i,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.views){let e=`${this.configService.getApiKey()}`;this.documentPaths?.organizationId&&(e+=`/${x.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}`);let o=this.realtimeAdapter.rtdbRef(this.db,`${t?e+"/"+x.FIREBASE_PARTIAL_PATH_DOCS+"/"+t+"/"+x.FIREBASE_PARTIAL_PATH_VIEWS+"/":this.documentPaths?.notifications}`);return this.realtimeAdapter.rtdbObjectVal$("notification",o).pipe(j(s=>(this.loggingService.catch("Error in NotificationService getDataFromDocumentId: ",s),C(null))),v(s=>{let n=[],r=new Map;s?.raw&&(Object.keys(s?.raw||{}).forEach(a=>{let l=s?.raw[a];l?.id&&n.push(l)}),n.forEach(a=>{a.id&&r.set(a.id,a)})),this.notifications$.next(n),this.rawNotificationsByIdMap$.next(r);let c=[];s?.processed&&Object.keys(s?.processed||{}).forEach(a=>{let l=s?.processed[a];l?.id&&c.push(l)}),this.processedNotifications$.next(c),this.setNotificationsByIdMap()}))}else return C(null)}))}setNotificationsByIdMap(){try{let t=this.authService.getUser();if(t){let i=this.notificationViews$.getValue(),e;t?.email&&(e=z(t?.email));let o;t?.userId&&(o=z(t?.userId));let s=new Map;this.processedNotifications$.getValue().forEach(r=>{if(r.id&&r?.displayHeadlineMessageTemplate){let c=!1;(e&&r.notifyUsers?.[e]||o&&r.notifyUsers?.[o])&&(c=!0);let a={id:r.id,notificationSource:r.notificationSource,actionType:r.actionType,actionUser:r.actionUser,timestamp:r.timestamp,targetAnnotationId:r.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(r),displayBodyMessage:this.getNotificationBodyMessage(r),forYou:c,notificationSourceData:r.notificationSourceData},l=this.getRawNotificationById(a.id);if(l?.metadata&&(a.metadata={apiKey:l.metadata.apiKey,organizationId:l.metadata.organizationId,clientOrganizationId:l.metadata.clientOrganizationId,documentId:l.metadata.documentId,clientDocumentId:l.metadata.clientDocumentId,location:l?.location,locationId:l?.locationId}),a?.notificationSource==="comment"&&a?.targetAnnotationId){let g=this.commentService?.getAnnotationById(a.targetAnnotationId);g||l?.annotationData&&(g=l.annotationData),g&&(a.notificationSourceData=this.commentService?.getCommentAnnotationForClient(g))}s.set(r.id,a)}}),s.forEach((r,c)=>{r.isUnread=r?.actionUser?.userSnippylyId!==t?.userSnippylyId&&!i?.notification?.[c]?.views?.[t?.userSnippylyId],s.set(c,r)}),this.notificationsByIdMap$.next(s)}}catch(t){this.loggingService.catch("Error in NotificationService setNotificationsByIdMap: ",t)}}getClientNotificationObject({processed:t,raw:i,metadata:e,views:o,notification:s}){try{let n=this.authService.getUser(),r=s||t;if(r.id&&r?.displayHeadlineMessageTemplate&&n){let c=null;n?.email&&(c=z(n?.email));let a=null;n?.userId&&(a=z(n?.userId));let l=!1,g=!0;(c&&r.notifyUsers?.[c]||a&&r.notifyUsersByUserId?.[a])&&(l=!0),a&&o?.[a]&&(g=!1);let f={id:r.id};if(s?f=$(b(b({},f),s),{displayHeadlineMessage:this.getNotificationHeadlineMessage(s),displayBodyMessage:this.getNotificationBodyMessage(s),forYou:l,isUnread:g}):f={id:t.id,notificationSource:t.notificationSource,actionType:t.actionType,actionUser:t.actionUser,timestamp:t.timestamp,targetAnnotationId:t.targetAnnotationId,displayHeadlineMessage:this.getNotificationHeadlineMessage(t),displayBodyMessage:this.getNotificationBodyMessage(t),forYou:l,isUnread:g,metadata:e},f?.notificationSource==="comment"&&f?.targetAnnotationId){let h=this.commentService?.getAnnotationById(f.targetAnnotationId);h||s?.notificationSourceData&&(h=s?.notificationSourceData),h||i?.annotationData&&(h=i.annotationData),h&&(f.notificationSourceData=this.commentService?.getCommentAnnotationForClient(h))}return i?.targetAnnotationData?.isCommentResolverUsed&&(f.isCommentResolverUsed=i?.targetAnnotationData?.isCommentResolverUsed),s?.isNotificationResolverUsed&&(f.isNotificationResolverUsed=s.isNotificationResolverUsed),f}return}catch(n){this.loggingService.catch("Error in NotificationService getClientNotificationObject: ",n);return}}getNotificationsForYou$(){return this.notificationsForYou$.asObservable()}getNotificationsByDocumentId$(){return this.notificationsByDocumentIdMap$.asObservable().pipe(v(t=>t?Object.keys(t??{}).map(i=>{let e=t[i].notifications||[],o=e.filter(n=>n.isUnread).length,s=e.length>0&&e[0]?.timestamp||0;return{documentId:i,notifications:t[i]?.notifications,unreadNotificationsCount:o,latestNotificationTimestamp:s,documentMetadata:t[i]?.documentMetadata}}).filter(i=>i.notifications?.length>0).sort((i,e)=>e.latestNotificationTimestamp-i.latestNotificationTimestamp):null))}getAllNotifications$(){return V([this.getNotificationsByDocumentId$(),this.crossOrgNotifications$.asObservable(),this.getUserScopedAllTabRows$()]).pipe(v(([t,i,e])=>{let o=Array.isArray(i)?i:[],s=Array.isArray(e)?e:[],n=null;if(t&&(n=[],t.forEach(c=>{c.notifications.forEach(a=>{n?.push(a)})})),!o.length&&!s.length)return t?n.sort((c,a)=>a.timestamp-c.timestamp):null;if(!t)return null;let r=n||[];return s.length&&(r=this.mergeCrossOrgForYou(r,s)),o.length&&(r=this.mergeCrossOrgForYou(r,o)),r}))}getUserScopedAllTabRows$(){return V([this.userScopedNotifications$,this.userNotificationsFromServer$.asObservable()]).pipe(v(([t,i])=>!t?.enabled||!i?.length?[]:i.map(e=>e?.notification??this.getClientNotificationObject(e)).filter(e=>!!e)))}processNotificationData(t){try{let i=t?.annotationData?.metadata,e=this.docService.getOrganizationConfig()?.organizationId;t.metadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(i?.documentId)||{})),t.metadata||(t.metadata={},this.loggingService.catch("Warning in NotificationService updateNotificationDatabase: ","Document metadata not found")),delete t.metadata.locations,t.metadata.documentMetadata=JSON.parse(JSON.stringify(this.docService.getDocumentMetadata(i?.documentId)||{})),t?.metadata?.documentMetadata?.clientDocumentId&&t?.metadata?.documentMetadata?.documentId&&(t.metadata.documentMetadata.documentId=t?.metadata?.documentMetadata?.clientDocumentId),delete t.metadata.documentMetadata.locations,t.metadata.organizationMetadata=JSON.parse(JSON.stringify(e?this.docService.getOrganizationMetadata(e)||{}:{})),t?.metadata?.organizationMetadata?.clientOrganizationId&&t?.metadata?.organizationMetadata?.organizationId&&(t.metadata.organizationMetadata.organizationId=t?.metadata?.organizationMetadata?.clientOrganizationId);let o=this.configService.getApiKey();t.metadata.apiKey=o,t.platform=this.configService.getSF()?"sf":"sdk",t.actionUser=this.authService.getUser();let s=i?.documentId?new ht({apiKey:o,documentId:i.documentId,organizationId:i?.organizationId}):this.docService.getDocumentPaths();t?.actionUser?.organizationId&&(t.metadata.organizationId=s?.organizationId||t.actionUser.organizationId,t.metadata.clientOrganizationId=s?.clientOrganizationId||t.actionUser.clientOrganizationId);let n=this.docService.getLocation();n&&(t.location=n?.location,t.locationId=n?.locationId),this.loggingService.log(`[NOTIFICATION] ${t?.notificationSource} ${t?.actionType}`,t);let r=this.commonDbService.getServerTimestamp(),c=this.notificationUtilsService.formatNotification(t,r);return JSON.parse(JSON.stringify(c))}catch(i){return this.loggingService.catch("Error in NotificationService processNotificationData: ",i),null}}reportDroppedHubPush(t){try{if(!this.notificationsHubDisabled)return;let i=String(t?.notificationSource??"comment");if(this.reportedDroppedHubPushes.has(i))return;this.reportedDroppedHubPushes.add(i),this.loggingService.catch(`Velt [self-hosted]: a client-side notification-hub push (source '${i}') was dropped \u2014 the notifications hub is deliberately disabled on this deployment (no-egress). Whatever this push fed (in-app notification, email, or webhook fan-out) will not happen for this source.`,void 0,void 0,!0)}catch{}}updateNotificationDatabase(t){try{if(!this.notificationsDb){this.reportDroppedHubPush(t);return}let i=this.realtimeAdapter.rtdbRef(this.notificationsDb),e=this.processNotificationData(t);try{let o=At(t?.annotationData);if(o&&e&&typeof e=="object"){e.visibility=o;let s=Object.values(t?.annotationData?.subscribedUsers||{}).map(r=>r?.user?.userId).filter(r=>!!r),n=Tt(t?.annotationData,s);n.length&&(e.deniedForYouUsers=[...new Set([...e.deniedForYouUsers??[],...n])])}}catch(o){this.loggingService.catch("Error applying notification visibility in updateNotificationDatabase: ",o)}this.realtimeAdapter.rtdbPush("notificationIndex",i,JSON.parse(JSON.stringify(e)))}catch(i){this.loggingService.catch("Error in NotificationService updateNotificationDatabase: ",i)}}getRawNotifications$(){return this.notifications$.asObservable()}getProcessedNotifications$(){return this.processedNotifications$.asObservable()}getNotifications$(t){return this.authService.getUser$().pipe(N(i=>i?i.organizationId?this.getAllNotifications$().pipe(N(e=>this.notificationsForYou$.pipe(v(o=>{if(e||o){let s=new Map;return(!t?.type||["all","documents"].includes(t.type))&&(e||[]).forEach(n=>{n.id&&s.set(n.id,n)}),(!t?.type||["all","forYou"].includes(t.type))&&(o||[]).forEach(n=>{n.id&&!s.has(n.id)&&s.set(n.id,n)}),Array.from(s.values()).sort((n,r)=>(r.timestamp||0)-(n.timestamp||0))}else return null})))):this.notificationsByIdMap$.asObservable().pipe(v(e=>Array.from(e.values())),v(e=>e.sort((o,s)=>s.timestamp-o.timestamp)),St()):C(null)),_(Ft))}getRawNotificationById(t){try{return this.rawNotificationsByIdMap$.getValue()?.get(t)}catch(i){this.loggingService.catch("Error in NotificationService getRawNotificationById: ",i);return}}setNotificationViews(t){try{this.notificationViews$.next(t),this.setNotificationsByIdMap()}catch(i){this.loggingService.catch("Error in NotificationService setNotificationViews: ",i)}}getNotificationHeadlineMessage(t){try{let i=this.authService.getUser();if(t?.displayHeadlineMessageTemplate&&t?.displayHeadlineMessageTemplateData){let e=t.displayHeadlineMessageTemplate,o=t.displayHeadlineMessageTemplateData,s=/\{(\w+)\}/g,n=e.replace(s,(r,c)=>(c==="actionUser"||c==="recipientUser")&&o[c]?i?.email&&o[c].email===i?.email||i?.userId&&o[c]?.userId===i?.userId?"You":o[c].name||o[c].email||' <velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader> ':o[c]?o[c]:r);return this.domService.sanitizeHtml(n)}return this.domService.sanitizeHtml(t.displayHeadlineMessageTemplate||"")}catch(i){return this.loggingService.catch("Error in NotificationService getNotificationHeadlineMessage: ",i),""}}getNotificationBodyMessage(t){try{if(t?.displayBodyMessageTemplate&&t?.displayBodyMessageTemplateData){let i=t?.displayBodyMessageTemplate;return t?.displayBodyMessageTemplateData&&t?.displayBodyMessageTemplateData?.users?.forEach(e=>{if(e?.userId){let o=this.usersService.getUserById(e?.userId);i=i?.replaceAll(`{{${e.userId}}}`,o?.name||o?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>'),i=i?.replaceAll(`@User ${e.userId}`,o?.name||o?.email||'<velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader>')}}),this.domService.sanitizeHtml(i)}return this.domService.sanitizeHtml(t.displayBodyMessage||"")}catch(i){return this.loggingService.catch("Error in NotificationService getNotificationBodyMessage: ",i),""}}setHistoryPanelVisibility(t,i=!1,e=!1){try{t?document.querySelector(x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?this.historyPanelVisible$.next(t):this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`):this.historyPanelVisible$.next(t),t?this.analyticsService.trackEvent(H.Events.Notifications.NOTIFICATION_HISTORY_PANEL_OPENED):this.analyticsService.trackEvent(H.Events.Notifications.NOTIFICATION_HISTORY_PANEL_CLOSED)}catch{this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}toggleHistoryPanelVisibility(t=!1,i=!1){try{this.historyPanelVisible$.value?this.historyPanelVisible$.next(!this.historyPanelVisible$.value):document.querySelector(x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?(this.historyPanelVisible$.next(!this.historyPanelVisible$.value),this.historyPanelVisible$.value?this.analyticsService.trackEvent(H.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"closed"}):this.analyticsService.trackEvent(H.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"opened"})):this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}catch{this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${x.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}getHistoryPanelVisibility$(){return this.historyPanelVisible$.asObservable()}setNotificationsAsRead(t){return T(this,null,function*(){try{let i=JSON.parse(JSON.stringify(this.getUserNotificationsFromServer()??[]));if(t?.length){for(let n=0;n<t.length;n+=50){let c=t.slice(n,n+50).filter(g=>g?.id),a=c.map(g=>this.setNotificationAsRead({notification:g,userNotifications:JSON.parse(JSON.stringify(i))})),l=yield Promise.all(a);c.forEach((g,f)=>{let h=l[f];if(!h.some(S=>S.notificationId===g.id))i=i.filter(S=>S.notificationId!==g.id);else{let S=i.find(A=>A.notificationId===g.id),D=h.find(A=>A.notificationId===g.id);S&&D?.views&&(S.views=D.views)}})}let o=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()||{}));t.forEach(n=>{let r=n.metadata?.documentId;if(r&&o?.[r]){let c=o?.[r]?.notifications||[],a=c.find(l=>l.id===n.id);a&&(a.isUnread=!1),o[r].notifications=c}}),this.notificationsByDocumentIdMap$.next(o),this.markCrossOrgEntriesRead(t),!J(i,this.getUserNotificationsFromServer())&&this.setUserNotificationsFromServer(i)}}catch(i){this.loggingService.catch("Error in NotificationService setNotificationsAsRead: ",i)}})}setAllNotificationsAsRead(t){return T(this,null,function*(){try{if(t?.tabId==="for-you"){let i=this.notificationsForYou$.value||[];this.setNotificationsAsRead(i)}else this.getNotifications$().pipe(Y(1)).subscribe(i=>{i&&this.setNotificationsAsRead(i)})}catch(i){this.loggingService.catch("Error in NotificationService setAllNotificationsAsRead: ",i)}})}getUnreadNotificationsCount$(){try{return this.notificationsForYou$.pipe(v(t=>t?.filter(e=>e?.isUnread)?.length??null),N(t=>this.getNotifications$().pipe(v(i=>{let e=i?.filter(o=>o?.isUnread)?.length??null;return{forYou:t,all:e}}))))}catch(t){return this.loggingService.catch("Error in NotificationService getUnreadNotificationsCount$: ",t),C({forYou:null,all:null})}}setNotificationAsRead(e){return T(this,arguments,function*({notification:t,userNotifications:i}){try{let o=this.authService.getUser();if(o&&t?.id){let s=z(o?.userId),{metadata:n}=t;if(n){let{apiKey:r,organizationId:c,documentId:a}=n;if(r&&c&&a&&s){let l=yield this.commonDbService.getData({feature:"docNotification",properties:{id:t.id,organizationId:c,documentId:a,apiKey:r}});l?.notificationId&&(l?.views?.[s]||(l.views||(l.views={}),l.views[s]={timestamp:Date.now()},this.commonDbService.updateData({feature:"docNotificationViews",properties:{id:t.id,organizationId:c,documentId:a,apiKey:r},data:l})));let g=yield this.commonDbService.getData({feature:"userNotification",properties:{id:t.id,userId:s,documentId:a,organizationId:c}});if(g?.notificationId){if(!this.getReadNotificationsOnForYouTab())yield this.commonDbService.deleteData({feature:"userNotification",properties:{id:t.id,userId:s,documentId:a,organizationId:c}}),i=i.filter(f=>f.notificationId!==t.id);else if(!g?.views?.[s]){g.views||(g.views={}),g.views[s]={timestamp:Date.now()};let f=i.find(h=>h.notificationId===t.id);f&&(f.views=g.views),this.commonDbService.updateData({feature:"userNotificationViews",properties:{id:t.id,userId:s,documentId:a,organizationId:c},data:g})}}}}}return i}catch(o){return this.loggingService.catch("Error in NotificationService setNotificationAsRead: ",o),i}})}setMaxDays(t){try{t>0?this.maxNotificationDays$.next(t):this.maxNotificationDays$.next(15)}catch(i){this.loggingService.catch("Error in NotificationService setMaxDays: ",i)}}setTabConfig(t){try{t&&this.tabConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setTabConfig: ",i)}}getTabConfig$(){return this.tabConfig$.asObservable()}getTabConfig(){return this.tabConfig$.value}enableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!0)}disableReadNotificationsOnForYouTab(){this.readNotificationsOnForYouTab$.next(!1)}getReadNotificationsOnForYouTab$(){return this.readNotificationsOnForYouTab$.asObservable()}getReadNotificationsOnForYouTab(){return this.readNotificationsOnForYouTab$.value}enableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!0)return;this.currentDocumentOnly$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableCurrentDocumentOnly: ",t)}}disableCurrentDocumentOnly(){try{if(this.currentDocumentOnly$.value===!1)return;this.currentDocumentOnly$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableCurrentDocumentOnly: ",t)}}getCurrentDocumentOnly$(){return this.currentDocumentOnly$.asObservable()}getCurrentDocumentOnly(){return this.currentDocumentOnly$.value}markNotificationAsReadById(t){return T(this,null,function*(){try{this.getNotifications$().pipe(Y(1)).subscribe(i=>{if(i){let e=i.filter(o=>o.id===t);this.setNotificationsAsRead(e)}})}catch(i){this.loggingService.catch("Error in NotificationService markNotificationAsReadById: ",i)}})}getAllowedDocumentMetadataByDocumentId(t){try{return this.allowedDocumentMetadataMap$.value?.[t]||null}catch(i){return this.loggingService.catch("Error in NotificationService getAllowedDocumentMetadataByDocumentId: ",i),null}}setSettingsConfig(t){try{this.enableSettings$.value&&this.settingsConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setSettingsConfig: ",i)}}setSettingsConfigWithDB(t){try{this.enableSettings$.value&&(this.settingsConfig$.next(t),this.updateSettingsConfigToDb())}catch(i){this.loggingService.catch("Error in NotificationService setSettingsConfigWithDB: ",i)}}getSettingsConfig$(){return this.settingsConfig$.asObservable()}getSettingsConfig(){return this.settingsConfig$.value}setMuteAllNotifications(){try{this.muteAllNotifications$.value!==!0&&this.muteAllNotifications$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService setSettingsMuteAll: ",t)}}getMuteAllNotifications$(){return this.muteAllNotifications$.asObservable()}getMuteAllNotifications(){return this.muteAllNotifications$.value}enableSettings(){try{this.enableSettings$.value!==!0&&this.enableSettings$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSettings: ",t)}}enableSettingsConfigByOrganization(){try{this.getSettingsConfigByOrganization()!==!0&&this.setSettingsConfigByOrganization$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSettingsConfigByOrganization: ",t)}}disableSettingsConfigByOrganization(){try{this.getSettingsConfigByOrganization()!==!1&&this.setSettingsConfigByOrganization$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSettingsConfigByOrganization: ",t)}}getSettingsConfigByOrganization$(){return this.setSettingsConfigByOrganization$.asObservable()}getSettingsConfigByOrganization(){return this.setSettingsConfigByOrganization$.value}enableSelfNotifications(){try{this.selfNotifications$.value!==!0&&this.selfNotifications$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService enableSelfNotifications: ",t)}}disableSelfNotifications(){try{this.selfNotifications$.value!==!1&&this.selfNotifications$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSelfNotifications: ",t)}}enableUserScopedNotifications(t){try{if(t&&typeof t=="object"&&t.enabled===!1){this.disableUserScopedNotifications();return}this.userScopedNotifications$.next({enabled:!0,limit:ei(t?.limit)})}catch(i){this.loggingService.catch("Error in NotificationService enableUserScopedNotifications: ",i)}}disableUserScopedNotifications(){try{this.userScopedNotifications$.value.enabled!==!1&&this.userScopedNotifications$.next({enabled:!1,limit:this.userScopedNotifications$.value.limit})}catch(t){this.loggingService.catch("Error in NotificationService disableUserScopedNotifications: ",t)}}disableSettings(){try{this.enableSettings$.value!==!1&&this.enableSettings$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService disableSettings: ",t)}}getEnableSettings$(){return this.enableSettings$.asObservable()}getEnableSettings(){return this.enableSettings$.value}setSettingsInitialConfig(t){try{let i=!1;if(t.forEach(e=>{["email","inbox"].includes(e.id)&&(i=!e.values?.every(o=>["ALL","NONE","MINE"].includes(o.id)))}),i){this.loggingService.catch("Invalid config values for email or inbox, It should have only ALL, NONE, MINE values");return}this.settingsInitialConfig$.next(t)}catch(i){this.loggingService.catch("Error in NotificationService setSettingsInitialConfig: ",i)}}getSettingsInitialConfig$(){return this.settingsInitialConfig$.asObservable()}getSettingsInitialConfig(){return this.settingsInitialConfig$.value}updateSettingsConfigToDb(t){return T(this,null,function*(){try{let i=this.authService.getUser(),e=z(i?.userId??""),o=this.docService.getDocumentPaths(),s=this.docService.getOrganizationConfig(),n=o?.organizationId??s?.organizationId,r=o?.clientOrganizationId??s?.clientOrganizationId,c={apiKey:this.configService.getApiKey(),organizationId:n,documentId:o?.documentId,clientOrganizationId:r,clientDocumentId:o?.clientDocumentId,userId:e,clientUserId:this.authService.getUser()?.userId};e&&this.getEnableSettings()&&this.enableSettings$.value&&(this.getSettingsConfigByOrganization()?this.docService.addUserInfoToOrganization({organizationId:r??i?.clientOrganizationId??"",user:{userId:i?.userId??""},notificationsConfig:t||this.settingsConfig$.getValue()}):o?.documentId&&(yield this.commonDbService.updateData({feature:"userConfig",properties:{documentId:o?.documentId,userId:e},data:{id:o?.documentId,notificationsConfig:t||this.settingsConfig$.getValue(),metadata:c}})))}catch(i){this.loggingService.catch("Error in NotificationService updateSettingsConfigToDb: ",i)}})}openNotificationsPanel(){try{this.notificationsPanelVisible$.next(!0)}catch(t){this.loggingService.catch("Error in NotificationService openNotificationsPanel: ",t)}}closeNotificationsPanel(){try{this.notificationsPanelVisible$.next(!1)}catch(t){this.loggingService.catch("Error in NotificationService closeNotificationsPanel: ",t)}}getNotificationsPanelVisible$(){return this.notificationsPanelVisible$.asObservable()}getNotificationsPanelVisible(){return this.notificationsPanelVisible$.value}};y.\u0275fac=function(i){return new(i||y)(m(Nt),m(xt),m(Z),m(Lt),m(Xt),m(Qt),m(et),m(tt),m(ot),m(Yt),m(qt),m(Kt),m(Zt),m(X),m(ii),m(it),m(It),m(ti),m(Jt),m(Q),m(Gt),m(kt))},y.\u0275prov=G({token:y,factory:y.\u0275fac,providedIn:"root"});let w=y;return w})();export{ii as a,Yi as b};
@@ -1 +1 @@
1
- import{x as Z}from"./chunk-C5JOX4MX.js";import{b as N}from"./chunk-GULBDPIM.js";import{xa as T,ya as B}from"./chunk-I63T4QWP.js";import{Bb as f,Eh as z,Ha as a,Hc as A,He as j,Ic as E,Kb as k,Mb as P,Pb as d,Qb as b,Ra as y,Rb as u,Re as R,Ti as F,Wa as I,ab as w,fb as L,g as V,ja as v,ka as g,la as D,ma as S,mc as p,nb as h,nc as m,ob as r,pb as s,qb as _,xb as M,zb as C}from"./chunk-YFBAHLK6.js";function G(o,l){if(o&1){let n=M();r(0,"div",18),C("click",function(){let i=v(n).$implicit,e=f(2);return g(e.selectAudioDevice(i))}),d(1),p(2,"translate"),s()}if(o&2){let n=l.$implicit,t=f(2);P("selected",n.deviceId===(t.selectedAudioDevice==null?null:t.selectedAudioDevice.deviceId)),a(),u(" ",m(2,3,n.label)," ")}}function H(o,l){if(o&1&&(r(0,"div",12)(1,"div",13),d(2),p(3,"translate"),s(),d(4),p(5,"translate"),r(6,"div",14)(7,"div",15),w(8,G,3,5,"div",16),s(),d(9),p(10,"translate"),D(),r(11,"svg",4),_(12,"path",17),s()()()),o&2){let n=f();a(2),b(m(3,4,"Audio")),a(2),u(" ",m(5,6,"Microphone")," "),a(4),h("ngForOf",n.audioDevices),a(),u(" ",m(10,8,n.selectedAudioDevice==null?null:n.selectedAudioDevice.label)," ")}}function U(o,l){if(o&1){let n=M();r(0,"div",18),C("click",function(){let i=v(n).$implicit,e=f(2);return g(e.selectVideoDevice(i))}),d(1),p(2,"translate"),s()}if(o&2){let n=l.$implicit,t=f(2);P("selected",n.deviceId===(t.selectedVideoDevice==null?null:t.selectedVideoDevice.deviceId)),a(),u(" ",m(2,3,n.label)," ")}}function $(o,l){if(o&1&&(r(0,"div",12)(1,"div",13),d(2),p(3,"translate"),s(),d(4),p(5,"translate"),r(6,"div",14)(7,"div",15),w(8,U,3,5,"div",16),s(),d(9),p(10,"translate"),D(),r(11,"svg",4),_(12,"path",17),s()()()),o&2){let n=f();a(2),b(m(3,4,"Video")),a(2),u(" ",m(5,6,"Camera")," "),a(4),h("ngForOf",n.videoDevices),a(),u(" ",m(10,8,n.selectedVideoDevice==null?null:n.selectedVideoDevice.label)," ")}}var ne=(()=>{let l=class l{constructor(t,i,e){this.loggingService=t,this.dialogRef=i,this.devices=[],this.audioDevices=[],this.videoDevices=[],this.settingsVisible={audio:!0,video:!0},this.defaultMediaSourceOptions=z(),this.veltElement=!0;try{e&&(this.selectedAudioDevice=e.selectedAudioDevice,this.selectedVideoDevice=e.selectedVideoDevice,e.settingsVisible&&(this.settingsVisible=e.settingsVisible)),this.getDevices()}catch(c){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent constructor: ",c)}}ngOnInit(){try{this.dialogRef.addPanelClass("snippyly-media-source-options-dialog")}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent ngOnInit: ",t)}}getDevices(){return V(this,null,function*(){try{let t=new R;if(t.getBrowserName()?.toLowerCase()==="safari"||t.getBrowserName()?.toLowerCase()==="firefox")try{let i=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!0});i&&i.getTracks().forEach(e=>e.stop())}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices getUserMedia catch: ",i)}navigator.mediaDevices.enumerateDevices().then(i=>{if(this.devices=i.filter(e=>e.kind==="audioinput"||e.kind==="videoinput"),this.audioDevices=this.devices.filter(e=>e.kind==="audioinput"),this.videoDevices=this.devices.filter(e=>e.kind==="videoinput"),this.audioDevices.length>0&&!this.selectedAudioDevice){if(this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId){let e=this.audioDevices.find(c=>c.deviceId===this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId);e&&(this.selectedAudioDevice=e)}this.selectedAudioDevice||(this.selectedAudioDevice=this.audioDevices[0])}if(this.videoDevices.length>0&&!this.selectedVideoDevice){if(this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId){let e=this.videoDevices.find(c=>c.deviceId===this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId);e&&(this.selectedVideoDevice=e)}this.selectedVideoDevice||(this.selectedVideoDevice=this.videoDevices[0])}}).catch(i=>{this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices enumerateDevices catch: ",i)})}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices: ",t)}})}selectAudioDevice(t){try{this.selectedAudioDevice=t}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectAudioDevice: ",i)}}selectVideoDevice(t){try{this.selectedVideoDevice=t}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectVideoDevice: ",i)}}saveChanges(){try{let t={};this.settingsVisible.audio&&(t.selectedAudioDevice=this.selectedAudioDevice),this.settingsVisible.video&&(t.selectedVideoDevice=this.selectedVideoDevice),localStorage.setItem(j.LOCAL_STORAGE.SNIPPYLY_DEFAULT_MEDIA_SOURCE_OPTIONS,JSON.stringify(t||{})),this.closeDialog(t)}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent saveChanges: ",t)}}closeDialog(t){try{this.dialogRef.close(t)}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent closeDialog: ",i)}}};l.\u0275fac=function(i){return new(i||l)(y(F),y(T),y(B,8))},l.\u0275cmp=I({type:l,selectors:[["snippyly-media-source-options-dialog"]],hostVars:1,hostBindings:function(i,e){i&2&&L("data-velt-element",e.veltElement)},standalone:!1,decls:17,vars:10,consts:[["mediaSourceOptionsDialogRef",""],[1,"s-video-settings-modal",3,"pointerdown","pointerup","click","snippylyOverlay","snippylyOverlayZIndex"],[1,"s-video-header"],[1,"s-video-header-name"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M19.5 12C19.5 11.77 19.49 11.55 19.47 11.32L21.33 9.91C21.73 9.61 21.84 9.05 21.59 8.61L19.72 5.38C19.47 4.94 18.93 4.76 18.47 4.96L16.32 5.87C15.95 5.61 15.56 5.38 15.15 5.19L14.86 2.88C14.8 2.38 14.37 2 13.87 2H10.14C9.63 2 9.2 2.38 9.14 2.88L8.85 5.19C8.44 5.38 8.05 5.61 7.68 5.87L5.53 4.96C5.07 4.76 4.53 4.94 4.28 5.38L2.41 8.62C2.16 9.06 2.27 9.61 2.67 9.92L4.53 11.33C4.51 11.55 4.5 11.77 4.5 12C4.5 12.23 4.51 12.45 4.53 12.68L2.67 14.09C2.27 14.39 2.16 14.95 2.41 15.39L4.28 18.62C4.53 19.06 5.07 19.24 5.53 19.04L7.68 18.13C8.05 18.39 8.44 18.62 8.85 18.81L9.14 21.12C9.2 21.62 9.63 22 10.13 22H13.86C14.36 22 14.79 21.62 14.85 21.12L15.14 18.81C15.55 18.62 15.94 18.39 16.31 18.13L18.46 19.04C18.92 19.24 19.46 19.06 19.71 18.62L21.58 15.39C21.83 14.95 21.72 14.4 21.32 14.09L19.46 12.68C19.49 12.45 19.5 12.23 19.5 12ZM12.04 15.5C10.11 15.5 8.54 13.93 8.54 12C8.54 10.07 10.11 8.5 12.04 8.5C13.97 8.5 15.54 10.07 15.54 12C15.54 13.93 13.97 15.5 12.04 15.5Z","fill","white"],[1,"s-icon-button",3,"click"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M4.41076 4.41058C4.7362 4.08514 5.26384 4.08514 5.58928 4.41058L10 8.82133L14.4108 4.41058C14.7362 4.08514 15.2638 4.08514 15.5893 4.41058C15.9147 4.73602 15.9147 5.26366 15.5893 5.58909L11.1785 9.99984L15.5893 14.4106C15.9147 14.736 15.9147 15.2637 15.5893 15.5891C15.2638 15.9145 14.7362 15.9145 14.4108 15.5891L10 11.1783L5.58928 15.5891C5.26384 15.9145 4.7362 15.9145 4.41076 15.5891C4.08533 15.2637 4.08533 14.736 4.41076 14.4106L8.82151 9.99984L4.41076 5.58909C4.08533 5.26366 4.08533 4.73602 4.41076 4.41058Z","fill","white"],["class","s-video-settings-modal-item",4,"ngIf"],[1,"s-flex-fill"],[1,"s-button","s-primary","s-save-button",3,"click"],[1,"s-video-settings-modal-item"],[1,"s-heading"],[1,"s-input","dropdown"],[1,"dropdown-content"],["class","dropdown-item",3,"selected","click",4,"ngFor","ngForOf"],["fill-rule","evenodd","clip-rule","evenodd","d","M16.2071 9.79289C15.8166 9.40237 15.1834 9.40237 14.7929 9.79289L12 12.5858L9.20711 9.79289C8.81658 9.40237 8.18342 9.40237 7.79289 9.79289C7.40237 10.1834 7.40237 10.8166 7.79289 11.2071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L16.2071 11.2071C16.5976 10.8166 16.5976 10.1834 16.2071 9.79289Z","fill","#80808A"],[1,"dropdown-item",3,"click"]],template:function(i,e){if(i&1){let c=M();r(0,"div",1,0),C("pointerdown",function(x){return v(c),g(x.stopPropagation())})("pointerup",function(x){return v(c),g(x.stopPropagation())})("click",function(x){return v(c),g(x.stopPropagation())}),r(2,"div",2)(3,"div",3),D(),r(4,"svg",4),_(5,"path",5),s(),d(6),p(7,"translate"),s(),S(),r(8,"div",6),C("click",function(){return v(c),g(e.closeDialog())}),D(),r(9,"svg",7),_(10,"path",8),s()()(),w(11,H,13,10,"div",9)(12,$,13,10,"div",9),S(),_(13,"div",10),r(14,"div",11),C("click",function(){return v(c),g(e.saveChanges())}),d(15),p(16,"translate"),s()()}if(i&2){let c=k(1);h("snippylyOverlay",c)("snippylyOverlayZIndex",3e3),a(6),u(" ",m(7,6,"Settings")," "),a(5),h("ngIf",e.settingsVisible==null?null:e.settingsVisible.audio),a(),h("ngIf",e.settingsVisible==null?null:e.settingsVisible.video),a(3),b(m(16,8,"Save changes"))}},dependencies:[A,E,Z,N],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}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){height:unset;width:unset}*[_ngcontent-%COMP%]:empty:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){display:revert!important}.s-video-settings-modal[_ngcontent-%COMP%], .s-video-header[_ngcontent-%COMP%], .s-video-header-name[_ngcontent-%COMP%], .s-video-settings-modal-item[_ngcontent-%COMP%], .s-input[_ngcontent-%COMP%]{display:flex!important;color:#fff!important}.s-video-settings-modal-item[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-start!important;justify-content:flex-start!important;width:100%!important;color:#91919c!important;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-video-settings-modal[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-end!important;padding:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;background:#141416!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:calc((40rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important}.s-video-header[_ngcontent-%COMP%]{justify-content:space-between!important;width:100%!important;align-items:center!important}.s-video-header-name[_ngcontent-%COMP%]{gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;font-weight:600!important;font-size:calc((1.2rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important}.s-button[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;justify-content:center!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((2rem + 0px) * var(--velt-base-rem-unit))!important;border-radius:calc((4rem + 0px) * var(--velt-base-rem-unit))!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;transition:.1s ease!important;cursor:pointer!important}.s-primary[_ngcontent-%COMP%]{background:#625df5!important;color:#fff!important}.s-primary[_ngcontent-%COMP%]:hover{background:#4f4bbf!important}.s-video-settings-modal-item[_ngcontent-%COMP%] .s-heading[_ngcontent-%COMP%]{font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#fff!important;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) 0!important}.s-input[_ngcontent-%COMP%]{position:relative!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#91919c!important;width:100%!important;justify-content:space-between!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;align-items:center!important;cursor:pointer!important;transition:.2s ease!important}.s-input[_ngcontent-%COMP%]:hover{background:#303034!important}.dropdown[_ngcontent-%COMP%] .dropdown-content[_ngcontent-%COMP%]{position:absolute!important;top:0!important;right:0!important;z-index:1!important}.dropdown-content[_ngcontent-%COMP%]{width:100%!important;overflow:hidden!important;display:flex!important;flex-direction:column!important;justify-content:flex-start!important;align-items:flex-start!important;border-radius:calc((.9rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;color:#91919c!important;background:#141416!important;cursor:pointer!important;visibility:hidden!important;opacity:0!important;transition:all .1s ease!important}.dropdown[_ngcontent-%COMP%]:hover .dropdown-content[_ngcontent-%COMP%]{visibility:visible!important;opacity:1!important}.dropdown-item[_ngcontent-%COMP%]{padding:calc((1.2rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:100%!important;display:flex!important;justify-content:flex-start!important;align-items:center!important;gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;transition:all .1s ease!important;color:#91919c!important}.dropdown-item.selected[_ngcontent-%COMP%]{color:#fff!important}.dropdown-item[_ngcontent-%COMP%]:hover{background:#303034!important;color:#fff!important}.s-icon-button[_ngcontent-%COMP%]{padding:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important;justify-content:center!important;border-radius:100px!important;cursor:pointer!important}.s-icon-button[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#777e91!important}.s-icon-button[_ngcontent-%COMP%]:hover{background:#222226!important}.s-icon-button[_ngcontent-%COMP%]:hover svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#fff!important}.s-flex-fill[_ngcontent-%COMP%]{flex-grow:1!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog{max-width:unset} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{background-color:transparent!important;padding:0!important;margin:0!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}@media screen and (max-width:768px){.s-video-settings-modal[_ngcontent-%COMP%]{width:calc(.8 * var(--legacy-velt-viewport-width))!important}}@media screen and (max-width:425px){ .velt-mat-dialog-container.snippyly-media-source-options-dialog{width:calc(1 * var(--legacy-velt-viewport-width))!important;max-width:calc(1 * var(--legacy-velt-viewport-width))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:calc((0rem + 0px) * var(--velt-base-rem-unit))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-video-settings-modal{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:0!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-save-button{width:100%!important}}"],changeDetection:0});let o=l;return o})();export{ne as a};
1
+ import{x as Z}from"./chunk-HRU6STNE.js";import{b as N}from"./chunk-SC3WVEMZ.js";import{xa as T,ya as B}from"./chunk-2XFRSBAE.js";import{Bb as f,Eh as z,Ha as a,Hc as A,He as j,Ic as E,Kb as k,Mb as P,Pb as d,Qb as b,Ra as y,Rb as u,Re as R,Ti as F,Wa as I,ab as w,fb as L,g as V,ja as v,ka as g,la as D,ma as S,mc as p,nb as h,nc as m,ob as r,pb as s,qb as _,xb as M,zb as C}from"./chunk-RV7ZJ7J2.js";function G(o,l){if(o&1){let n=M();r(0,"div",18),C("click",function(){let i=v(n).$implicit,e=f(2);return g(e.selectAudioDevice(i))}),d(1),p(2,"translate"),s()}if(o&2){let n=l.$implicit,t=f(2);P("selected",n.deviceId===(t.selectedAudioDevice==null?null:t.selectedAudioDevice.deviceId)),a(),u(" ",m(2,3,n.label)," ")}}function H(o,l){if(o&1&&(r(0,"div",12)(1,"div",13),d(2),p(3,"translate"),s(),d(4),p(5,"translate"),r(6,"div",14)(7,"div",15),w(8,G,3,5,"div",16),s(),d(9),p(10,"translate"),D(),r(11,"svg",4),_(12,"path",17),s()()()),o&2){let n=f();a(2),b(m(3,4,"Audio")),a(2),u(" ",m(5,6,"Microphone")," "),a(4),h("ngForOf",n.audioDevices),a(),u(" ",m(10,8,n.selectedAudioDevice==null?null:n.selectedAudioDevice.label)," ")}}function U(o,l){if(o&1){let n=M();r(0,"div",18),C("click",function(){let i=v(n).$implicit,e=f(2);return g(e.selectVideoDevice(i))}),d(1),p(2,"translate"),s()}if(o&2){let n=l.$implicit,t=f(2);P("selected",n.deviceId===(t.selectedVideoDevice==null?null:t.selectedVideoDevice.deviceId)),a(),u(" ",m(2,3,n.label)," ")}}function $(o,l){if(o&1&&(r(0,"div",12)(1,"div",13),d(2),p(3,"translate"),s(),d(4),p(5,"translate"),r(6,"div",14)(7,"div",15),w(8,U,3,5,"div",16),s(),d(9),p(10,"translate"),D(),r(11,"svg",4),_(12,"path",17),s()()()),o&2){let n=f();a(2),b(m(3,4,"Video")),a(2),u(" ",m(5,6,"Camera")," "),a(4),h("ngForOf",n.videoDevices),a(),u(" ",m(10,8,n.selectedVideoDevice==null?null:n.selectedVideoDevice.label)," ")}}var ne=(()=>{let l=class l{constructor(t,i,e){this.loggingService=t,this.dialogRef=i,this.devices=[],this.audioDevices=[],this.videoDevices=[],this.settingsVisible={audio:!0,video:!0},this.defaultMediaSourceOptions=z(),this.veltElement=!0;try{e&&(this.selectedAudioDevice=e.selectedAudioDevice,this.selectedVideoDevice=e.selectedVideoDevice,e.settingsVisible&&(this.settingsVisible=e.settingsVisible)),this.getDevices()}catch(c){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent constructor: ",c)}}ngOnInit(){try{this.dialogRef.addPanelClass("snippyly-media-source-options-dialog")}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent ngOnInit: ",t)}}getDevices(){return V(this,null,function*(){try{let t=new R;if(t.getBrowserName()?.toLowerCase()==="safari"||t.getBrowserName()?.toLowerCase()==="firefox")try{let i=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!0});i&&i.getTracks().forEach(e=>e.stop())}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices getUserMedia catch: ",i)}navigator.mediaDevices.enumerateDevices().then(i=>{if(this.devices=i.filter(e=>e.kind==="audioinput"||e.kind==="videoinput"),this.audioDevices=this.devices.filter(e=>e.kind==="audioinput"),this.videoDevices=this.devices.filter(e=>e.kind==="videoinput"),this.audioDevices.length>0&&!this.selectedAudioDevice){if(this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId){let e=this.audioDevices.find(c=>c.deviceId===this.defaultMediaSourceOptions?.selectedAudioDevice?.deviceId);e&&(this.selectedAudioDevice=e)}this.selectedAudioDevice||(this.selectedAudioDevice=this.audioDevices[0])}if(this.videoDevices.length>0&&!this.selectedVideoDevice){if(this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId){let e=this.videoDevices.find(c=>c.deviceId===this.defaultMediaSourceOptions?.selectedVideoDevice?.deviceId);e&&(this.selectedVideoDevice=e)}this.selectedVideoDevice||(this.selectedVideoDevice=this.videoDevices[0])}}).catch(i=>{this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices enumerateDevices catch: ",i)})}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent getDevices: ",t)}})}selectAudioDevice(t){try{this.selectedAudioDevice=t}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectAudioDevice: ",i)}}selectVideoDevice(t){try{this.selectedVideoDevice=t}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent selectVideoDevice: ",i)}}saveChanges(){try{let t={};this.settingsVisible.audio&&(t.selectedAudioDevice=this.selectedAudioDevice),this.settingsVisible.video&&(t.selectedVideoDevice=this.selectedVideoDevice),localStorage.setItem(j.LOCAL_STORAGE.SNIPPYLY_DEFAULT_MEDIA_SOURCE_OPTIONS,JSON.stringify(t||{})),this.closeDialog(t)}catch(t){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent saveChanges: ",t)}}closeDialog(t){try{this.dialogRef.close(t)}catch(i){this.loggingService.catch("Error in MediaSourceOptionsDialogComponent closeDialog: ",i)}}};l.\u0275fac=function(i){return new(i||l)(y(F),y(T),y(B,8))},l.\u0275cmp=I({type:l,selectors:[["snippyly-media-source-options-dialog"]],hostVars:1,hostBindings:function(i,e){i&2&&L("data-velt-element",e.veltElement)},standalone:!1,decls:17,vars:10,consts:[["mediaSourceOptionsDialogRef",""],[1,"s-video-settings-modal",3,"pointerdown","pointerup","click","snippylyOverlay","snippylyOverlayZIndex"],[1,"s-video-header"],[1,"s-video-header-name"],["width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M19.5 12C19.5 11.77 19.49 11.55 19.47 11.32L21.33 9.91C21.73 9.61 21.84 9.05 21.59 8.61L19.72 5.38C19.47 4.94 18.93 4.76 18.47 4.96L16.32 5.87C15.95 5.61 15.56 5.38 15.15 5.19L14.86 2.88C14.8 2.38 14.37 2 13.87 2H10.14C9.63 2 9.2 2.38 9.14 2.88L8.85 5.19C8.44 5.38 8.05 5.61 7.68 5.87L5.53 4.96C5.07 4.76 4.53 4.94 4.28 5.38L2.41 8.62C2.16 9.06 2.27 9.61 2.67 9.92L4.53 11.33C4.51 11.55 4.5 11.77 4.5 12C4.5 12.23 4.51 12.45 4.53 12.68L2.67 14.09C2.27 14.39 2.16 14.95 2.41 15.39L4.28 18.62C4.53 19.06 5.07 19.24 5.53 19.04L7.68 18.13C8.05 18.39 8.44 18.62 8.85 18.81L9.14 21.12C9.2 21.62 9.63 22 10.13 22H13.86C14.36 22 14.79 21.62 14.85 21.12L15.14 18.81C15.55 18.62 15.94 18.39 16.31 18.13L18.46 19.04C18.92 19.24 19.46 19.06 19.71 18.62L21.58 15.39C21.83 14.95 21.72 14.4 21.32 14.09L19.46 12.68C19.49 12.45 19.5 12.23 19.5 12ZM12.04 15.5C10.11 15.5 8.54 13.93 8.54 12C8.54 10.07 10.11 8.5 12.04 8.5C13.97 8.5 15.54 10.07 15.54 12C15.54 13.93 13.97 15.5 12.04 15.5Z","fill","white"],[1,"s-icon-button",3,"click"],["width","20","height","20","viewBox","0 0 20 20","fill","none","xmlns","http://www.w3.org/2000/svg"],["fill-rule","evenodd","clip-rule","evenodd","d","M4.41076 4.41058C4.7362 4.08514 5.26384 4.08514 5.58928 4.41058L10 8.82133L14.4108 4.41058C14.7362 4.08514 15.2638 4.08514 15.5893 4.41058C15.9147 4.73602 15.9147 5.26366 15.5893 5.58909L11.1785 9.99984L15.5893 14.4106C15.9147 14.736 15.9147 15.2637 15.5893 15.5891C15.2638 15.9145 14.7362 15.9145 14.4108 15.5891L10 11.1783L5.58928 15.5891C5.26384 15.9145 4.7362 15.9145 4.41076 15.5891C4.08533 15.2637 4.08533 14.736 4.41076 14.4106L8.82151 9.99984L4.41076 5.58909C4.08533 5.26366 4.08533 4.73602 4.41076 4.41058Z","fill","white"],["class","s-video-settings-modal-item",4,"ngIf"],[1,"s-flex-fill"],[1,"s-button","s-primary","s-save-button",3,"click"],[1,"s-video-settings-modal-item"],[1,"s-heading"],[1,"s-input","dropdown"],[1,"dropdown-content"],["class","dropdown-item",3,"selected","click",4,"ngFor","ngForOf"],["fill-rule","evenodd","clip-rule","evenodd","d","M16.2071 9.79289C15.8166 9.40237 15.1834 9.40237 14.7929 9.79289L12 12.5858L9.20711 9.79289C8.81658 9.40237 8.18342 9.40237 7.79289 9.79289C7.40237 10.1834 7.40237 10.8166 7.79289 11.2071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L16.2071 11.2071C16.5976 10.8166 16.5976 10.1834 16.2071 9.79289Z","fill","#80808A"],[1,"dropdown-item",3,"click"]],template:function(i,e){if(i&1){let c=M();r(0,"div",1,0),C("pointerdown",function(x){return v(c),g(x.stopPropagation())})("pointerup",function(x){return v(c),g(x.stopPropagation())})("click",function(x){return v(c),g(x.stopPropagation())}),r(2,"div",2)(3,"div",3),D(),r(4,"svg",4),_(5,"path",5),s(),d(6),p(7,"translate"),s(),S(),r(8,"div",6),C("click",function(){return v(c),g(e.closeDialog())}),D(),r(9,"svg",7),_(10,"path",8),s()()(),w(11,H,13,10,"div",9)(12,$,13,10,"div",9),S(),_(13,"div",10),r(14,"div",11),C("click",function(){return v(c),g(e.saveChanges())}),d(15),p(16,"translate"),s()()}if(i&2){let c=k(1);h("snippylyOverlay",c)("snippylyOverlayZIndex",3e3),a(6),u(" ",m(7,6,"Settings")," "),a(5),h("ngIf",e.settingsVisible==null?null:e.settingsVisible.audio),a(),h("ngIf",e.settingsVisible==null?null:e.settingsVisible.video),a(3),b(m(16,8,"Save changes"))}},dependencies:[A,E,Z,N],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}*[_ngcontent-%COMP%]{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0)!important;outline:none!important;margin:0!important;padding:0!important;line-height:1.5!important;color:#000!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*[_ngcontent-%COMP%]:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){height:unset;width:unset}*[_ngcontent-%COMP%]:empty:not(svg,rect,circle,ellipse,line,polyline,polygon,path,text,g,use,image,defs,hr){display:revert!important}.s-video-settings-modal[_ngcontent-%COMP%], .s-video-header[_ngcontent-%COMP%], .s-video-header-name[_ngcontent-%COMP%], .s-video-settings-modal-item[_ngcontent-%COMP%], .s-input[_ngcontent-%COMP%]{display:flex!important;color:#fff!important}.s-video-settings-modal-item[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-start!important;justify-content:flex-start!important;width:100%!important;color:#91919c!important;font-size:calc((.8rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}.s-video-settings-modal[_ngcontent-%COMP%]{flex-direction:column!important;align-items:flex-end!important;padding:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;gap:calc((2rem + 0px) * var(--velt-base-rem-unit))!important;background:#141416!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:calc((40rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important}.s-video-header[_ngcontent-%COMP%]{justify-content:space-between!important;width:100%!important;align-items:center!important}.s-video-header-name[_ngcontent-%COMP%]{gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;font-weight:600!important;font-size:calc((1.2rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important}.s-button[_ngcontent-%COMP%]{display:flex!important;align-items:center!important;justify-content:center!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit)) calc((2rem + 0px) * var(--velt-base-rem-unit))!important;border-radius:calc((4rem + 0px) * var(--velt-base-rem-unit))!important;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;transition:.1s ease!important;cursor:pointer!important}.s-primary[_ngcontent-%COMP%]{background:#625df5!important;color:#fff!important}.s-primary[_ngcontent-%COMP%]:hover{background:#4f4bbf!important}.s-video-settings-modal-item[_ngcontent-%COMP%] .s-heading[_ngcontent-%COMP%]{font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#fff!important;padding:calc((.5rem + 0px) * var(--velt-base-rem-unit)) 0!important}.s-input[_ngcontent-%COMP%]{position:relative!important;padding:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;color:#91919c!important;width:100%!important;justify-content:space-between!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;align-items:center!important;cursor:pointer!important;transition:.2s ease!important}.s-input[_ngcontent-%COMP%]:hover{background:#303034!important}.dropdown[_ngcontent-%COMP%] .dropdown-content[_ngcontent-%COMP%]{position:absolute!important;top:0!important;right:0!important;z-index:1!important}.dropdown-content[_ngcontent-%COMP%]{width:100%!important;overflow:hidden!important;display:flex!important;flex-direction:column!important;justify-content:flex-start!important;align-items:flex-start!important;border-radius:calc((.9rem + 0px) * var(--velt-base-rem-unit))!important;border:2px solid #303034!important;color:#91919c!important;background:#141416!important;cursor:pointer!important;visibility:hidden!important;opacity:0!important;transition:all .1s ease!important}.dropdown[_ngcontent-%COMP%]:hover .dropdown-content[_ngcontent-%COMP%]{visibility:visible!important;opacity:1!important}.dropdown-item[_ngcontent-%COMP%]{padding:calc((1.2rem + 0px) * var(--velt-base-rem-unit)) calc((1rem + 0px) * var(--velt-base-rem-unit))!important;width:100%!important;display:flex!important;justify-content:flex-start!important;align-items:center!important;gap:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;transition:all .1s ease!important;color:#91919c!important}.dropdown-item.selected[_ngcontent-%COMP%]{color:#fff!important}.dropdown-item[_ngcontent-%COMP%]:hover{background:#303034!important;color:#fff!important}.s-icon-button[_ngcontent-%COMP%]{padding:calc((.5rem + 0px) * var(--velt-base-rem-unit))!important;display:flex!important;align-items:center!important;justify-content:center!important;border-radius:100px!important;cursor:pointer!important}.s-icon-button[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#777e91!important}.s-icon-button[_ngcontent-%COMP%]:hover{background:#222226!important}.s-icon-button[_ngcontent-%COMP%]:hover svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:#fff!important}.s-flex-fill[_ngcontent-%COMP%]{flex-grow:1!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog{max-width:unset} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{background-color:transparent!important;padding:0!important;margin:0!important;border-radius:calc((1rem + 0px) * var(--velt-base-rem-unit))!important}@media screen and (max-width:768px){.s-video-settings-modal[_ngcontent-%COMP%]{width:calc(.8 * var(--legacy-velt-viewport-width))!important}}@media screen and (max-width:425px){ .velt-mat-dialog-container.snippyly-media-source-options-dialog{width:calc(1 * var(--legacy-velt-viewport-width))!important;max-width:calc(1 * var(--legacy-velt-viewport-width))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:calc((0rem + 0px) * var(--velt-base-rem-unit))!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-video-settings-modal{width:calc(1 * var(--legacy-velt-viewport-width))!important;height:calc(1 * var(--legacy-velt-viewport-height))!important;border-radius:0!important} .velt-mat-dialog-container.snippyly-media-source-options-dialog mat-dialog-container .mat-mdc-dialog-surface.mdc-dialog__surface .s-save-button{width:100%!important}}"],changeDetection:0});let o=l;return o})();export{ne as a};