@veltdev/sdk-staging 6.0.0-beta.9 → 6.0.1

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 (69) hide show
  1. package/app/client/snippyly.model.d.ts +10 -0
  2. package/app/models/data/comment-events.data.model.d.ts +10 -0
  3. package/app/models/data/config.data.model.d.ts +154 -0
  4. package/app/models/data/notification.model.d.ts +14 -0
  5. package/app/models/data/suggestion.data.model.d.ts +52 -2
  6. package/app/utils/constants.d.ts +1 -0
  7. package/app/utils/enums.d.ts +2 -1
  8. package/chunk-26SHKRTG.js +1 -0
  9. package/chunk-3YCIOKO7.js +167 -0
  10. package/{chunk-MNGERQRW.js → chunk-4O7F5WPS.js} +1 -1
  11. package/{chunk-XAJ4ABBW.js → chunk-6MGKRXSY.js} +1 -1
  12. package/{chunk-QDQ2XJUX.js → chunk-7M7HPFJW.js} +1 -1
  13. package/{chunk-W4BGGBK5.js → chunk-BP5ABAKN.js} +1 -1
  14. package/{chunk-LAUYCNER.js → chunk-CMV6XYEA.js} +1 -1
  15. package/{chunk-GUGGWPZ7.js → chunk-CN3MG4V7.js} +1 -1
  16. package/{chunk-3OIAZGVH.js → chunk-DVLF6ZJF.js} +1 -1
  17. package/chunk-EWNEUCZN.js +2 -0
  18. package/{chunk-MJDGHV4Y.js → chunk-FXVG7I7B.js} +1 -1
  19. package/{chunk-ENIVQSM6.js → chunk-JD2Q4WUT.js} +1 -1
  20. package/chunk-JMH4W4CX.js +1 -0
  21. package/{chunk-G56O673H.js → chunk-KPEMFTQE.js} +1 -1
  22. package/chunk-LSGQWTXT.js +13 -0
  23. package/{chunk-NR3CZ6OR.js → chunk-MJHVVJAE.js} +1 -1
  24. package/{chunk-G2POMKRC.js → chunk-NWDWX5YO.js} +1 -1
  25. package/{chunk-2YJ3NBTO.js → chunk-O7QMGDXD.js} +1 -1
  26. package/chunk-OMM2AMDX.js +1 -0
  27. package/{chunk-JSZMRBOR.js → chunk-OO7EO3BV.js} +1 -1
  28. package/{chunk-MX66OK5A.js → chunk-P6UVM6B7.js} +1 -1
  29. package/{chunk-SQTBBRA3.js → chunk-PNALREKY.js} +1 -1
  30. package/{chunk-4QPJMZ5V.js → chunk-Q3SFRIYZ.js} +1 -1
  31. package/{chunk-AMBQ736A.js → chunk-QEJJ3QNA.js} +1 -1
  32. package/{chunk-DP4GMASO.js → chunk-QYUV5PXV.js} +1 -1
  33. package/{chunk-J3FNQGWW.js → chunk-RF3TL6SQ.js} +6 -6
  34. package/chunk-THHKSZTD.js +1 -0
  35. package/{chunk-3OILJMAX.js → chunk-W6OGMNHQ.js} +1 -1
  36. package/{chunk-ZMXXM7C4.js → chunk-WQRY6Y6C.js} +1 -1
  37. package/{chunk-57VK6E6U.js → chunk-WW7AGQRC.js} +1 -1
  38. package/chunk-XDHXV3V6.js +93 -0
  39. package/{chunk-XJWB3IUW.js → chunk-YBCNVNZM.js} +1 -1
  40. package/{chunk-5W33SILU.js → chunk-YQEMM6AB.js} +1 -1
  41. package/package.json +1 -1
  42. package/velt-activity-log.js +1 -1
  43. package/velt-area.js +1 -1
  44. package/velt-arrow.js +2 -2
  45. package/velt-comment.js +8 -8
  46. package/velt-crdt.js +1 -1
  47. package/velt-cursor.js +2 -2
  48. package/velt-huddle.js +3 -3
  49. package/velt-live-state-sync.js +2 -2
  50. package/velt-notification.js +1 -1
  51. package/velt-presence.js +1 -1
  52. package/velt-reaction.js +1 -1
  53. package/velt-recorder.js +1 -1
  54. package/velt-rewriter.js +2 -2
  55. package/velt-selection.js +1 -1
  56. package/velt-tag.js +1 -1
  57. package/velt-user-invite.js +1 -1
  58. package/velt-user-request.js +1 -1
  59. package/velt-video-player.js +1 -1
  60. package/velt-views.js +3 -3
  61. package/velt.js +264 -20
  62. package/chunk-52EPUXSU.js +0 -13
  63. package/chunk-5SSUFLRQ.js +0 -1
  64. package/chunk-6TORUSYX.js +0 -93
  65. package/chunk-EWNXINED.js +0 -1
  66. package/chunk-HDABOQPS.js +0 -1
  67. package/chunk-RMV5EWSF.js +0 -1
  68. package/chunk-TY3WZ4Q4.js +0 -167
  69. package/chunk-YSZQAETY.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as Zt}from"./chunk-26SHKRTG.js";import{a as Qt}from"./chunk-CN3MG4V7.js";import{$ as K,$e as q,Ai as Wt,Bf as gt,Bi as st,Cf as z,Ch as L,Df as At,Dh as tt,E as F,Ed as Nt,Ee as P,Ef as ft,Fh as Ft,Fi as kt,G as V,Gi as rt,Hh as Pt,Hi as nt,J as k,Ki as mt,L as J,M as lt,Mi as at,Ni as Jt,O as St,Od as It,Oi as Kt,Pi as qt,Qf as Ut,Rf as Tt,Sh as zt,T as I,Uf as Et,Uh as Bt,Vf as $t,W as vt,Yf as Rt,a as D,af as Q,b as T,be as Ot,bg as wt,ca as m,cg as dt,da as pt,g as E,hg as Z,ii as it,ji as xt,ki as et,l as O,li as jt,oe as yt,oi as Ht,p as G,q as ct,qh as Mt,qi as Vt,r as C,si as Lt,ti as ot,uf as bt,ui as Yt,v as N,vi as _t,w as W,xh as ht,xi as Gt,yf as Dt,zf as Ct,zh as X,zi as ut}from"./chunk-3YCIOKO7.js";var Xt=(()=>{let A=class A{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 E(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}}};A.\u0275fac=function(i){return new(i||A)(m(nt),m(et),m(rt),m(ot),m(st),m(at),m(it))},A.\u0275prov=K({token:A,factory:A.\u0275fac,providedIn:"root"});let j=A;return j})();var ji=(()=>{let A=class A{constructor(t,i,e,o,s,n,r,a,c,l,g,f,d,h,p,$,M,S,U,R,w){this.afAuth=t,this.analyticsService=i,this.authService=e,this.configService=o,this.commonDbService=s,this.commonDbUtilsService=n,this.commentUtilsService=r,this.commentAnnotationsResolverService=a,this.notificationResolverService=c,this.databaseService=l,this.docService=g,this.domService=f,this.iamService=d,this.loggingService=h,this.notificationUtilsService=p,this.usersService=$,this.functions=M,this.userPermissionService=S,this.coreActionsService=U,this.serviceBook=R,this.realtimeAdapter=w,this.endpointsService=pt(Ht),this.db=null,this.notificationsDb=null,this.documentPaths=null,this.notifications$=new O([]),this.rawNotificationsByIdMap$=new O(new Map),this.processedNotifications$=new O([]),this.userNotificationsFromServer$=new O(null),this.readNotificationsOnForYouTab$=new O(!1),this.currentDocumentOnly$=new O(!1),this.notificationViews$=new O({}),this.notificationsByIdMap$=new O(new Map),this.historyPanelVisible$=new O(!1),this.notificationsForYou$=new O(null),this.notificationsByDocumentIdMap$=new O(null),this.notificationsByDocumentIdSubscription={},this.allowedDocumentMetadataMap$=new O(null),this.maxNotificationDays$=new O(15),this.tabConfig$=new O({people:{enable:!1}}),this.settingsConfig$=new O(null),this.setSettingsConfigByOrganization$=new O(!1),this.muteAllNotifications$=new O(!1),this.enableSettings$=new O(!1),this.selfNotifications$=new O(!1),this.settingsInitialConfig$=new O([{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 O(!1),this.crossOrganizationConfig$=new O({enabled:!1}),this.crossOrgNotifications$=new O([]),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(Ft,this),this.serviceBook.observe(Bt).subscribe(v=>{this.commentService=v??void 0}),this.subscribeNotificationsData().subscribe(),this.commentUtilsService.setNotificationService(this),this.databaseService.getDb().pipe(F(v=>!!v),k(1)).subscribe(v=>{if(v){this.db=v;try{let u=this.configService.getProxyConfig(),b=this.endpointsService.getNotificationsDbUrl();Dt(b)?this.notificationsDb=null:(u?.v1DbHost&&b&&(b=Ct(b,u.v1DbHost)),this.notificationsDb=this.realtimeAdapter.getDatabaseInstance(b),u?.v1DbHost&&b&&this.databaseService.lockDatabaseHost(this.notificationsDb))}catch(u){this.loggingService.catch("Error initializing notifications DB, using default: ",u),this.notificationsDb=v}this.getDocumentIds(),this.subscribeGetNotificationsForYou()}},v=>{this.loggingService.catch("Error in NotificationService getDb subscription: ",v)}),this.authService.getUser$().subscribe(v=>{v?(this.subscribeGetNotificationsForYou(),this.getDocumentIds(),this.subscribeToUserSettings()):(Object.keys(this.notificationsByDocumentIdSubscription).forEach(u=>{this.notificationsByDocumentIdSubscription[u]?.unsubscribe()}),this.notificationForYouSubscription?.unsubscribe(),this.documentIdsSubscription?.unsubscribe(),this.resetCacheData())}),this.docService.getLocationMetadata$().subscribe(v=>{if(v){let u=this.notificationsByDocumentIdMap$.getValue()?JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue())):null;Object.keys(v||{}).forEach(b=>{let x=u?.[b]?.notifications;x?.length&&x.forEach(y=>{this.notificationUtilsService.mergeLocationWithNotification({notification:y},v)?.notification})}),this.notificationsByDocumentIdMap$.next(u)}})}catch(v){this.loggingService.catch("Error in NotificationService constructor: ",v)}}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 E(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 a=r?.values?.find(c=>c.id===r.default);s[r.id]=a||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(F(i=>i===!0),I(()=>W([this.docService.getDocumentPaths$(),this.getSettingsConfigByOrganization$(),this.docService.getOrganizationConfig$()]).pipe(F(([i,e,o])=>(e||!!i)&&!!o?.organizationId),I(([i,e,o])=>ct(this.getInitialConfigFromDB(i)).pipe(I(()=>this.commonDbService.dbListener({feature:"userConfig",properties:{useCollectionGroup:!1,isCollection:!1,documentId:e?void 0:i?.documentId,organizationId:i?.organizationId??o?.organizationId,userId:t}}).pipe(N(s=>{s?.data?.notificationsConfig&&!Z(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(),this.documentIdsSubscription=this.selfNotifications$.pipe(I(()=>this.getCurrentDocumentOnly$().pipe(I(t=>t?this.docService.getDocumentPaths$().pipe(N(i=>{})):C(void 0)))),vt(()=>{this.notificationsByDocumentIdMap$.next(null)}),I(()=>this.getDocumentIdsByLastNotificationTimestamp().pipe(lt(),N(([t,i])=>{let e=t?.map(a=>a.documentId),o=i?.map(a=>a.documentId),s=e?.filter(a=>!o?.includes(a)),n=o?.map(a=>({documentId:a,timestamp:i?.find(c=>c.documentId===a)?.timestamp})).filter(a=>!e?.includes(a.documentId)),r=o?.map(a=>{let c=i?.find(l=>l.documentId===a)?.timestamp;return{documentId:a,timestamp:c}}).filter(a=>{let c=t?.find(l=>l.documentId===a.documentId)?.timestamp;return c&&a.timestamp&&c!==a.timestamp});n?.length&&this.fetchNotificationsForDocumentIds(n),r?.length&&this.fetchNotificationsForDocumentIds(r,1),s?.forEach(a=>{this.removeNotificationsForDocumentId(a)}),i&&!i?.length&&!this.notificationsByDocumentIdMap$.getValue()&&(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([]))})))).subscribe(()=>{},t=>{this.loggingService.catch("Error in NotificationService getDocumentIds subscription: ",t)})}catch(t){this.loggingService.catch("Error in NotificationService getDocumentIds: ",t)}}getDocumentIdsByLastNotificationTimestamp(t=15){try{return this.authService.getUser$().pipe(I(i=>this.docService.getOrganizationConfig$().pipe(N(e=>{let o=null,s=this.configService.getApiKey(),n=e?.organizationId||i?.organizationId,r=e?.clientOrganizationId||i?.clientOrganizationId||"";return s&&n&&(o=new mt({apiKey:s,organizationId:n})),{user:i,documentPaths:o,clientOrganizationId:r}}))),I(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 a=n.getTime(),c=[Yt(ut("timestamp",">=",a),...this.getCurrentDocumentOnly()&&this.docService.getDocumentPaths()?.documentId?[ut("metadata.documentId","==",this.docService.getDocumentPaths()?.documentId)]:[])];this.getCurrentDocumentOnly()||(c.push(Gt("timestamp","desc")),c.push(_t(t)));let l=e?.userId??"";return ct(this.userPermissionService?.getUserPermissionsFromCacheOrFetch({organizationId:s})??Promise.resolve({})).pipe(I(g=>l&&s&&g?.[l]?.organization?.[s]?.errorCode===bt.PERMISSION_DENIED?C(null):this.commonDbService.dbListener({feature:"allLastNotificationTimestamp",properties:{organizationId:o?.organizationId,isCollection:!0,useQuery:!0,firestoreQuery:c}}).pipe(N(f=>f?.data),N(f=>{let d=[];return Object.keys(f||{}).forEach(h=>{let p=this.commonDbService.shouldUseFirestore()?f[h]?.timestamp??0:f[h],$=this.commonDbService.shouldUseFirestore()?f[h]?.deletedNotification??!1:!1;if($&&$.id&&$?.timestamp===p){let M=$.id,S=f[h]?.metadata?.documentId,U=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()??{})),R=U?.[S]??{documentMetadata:null,notifications:[]},w=R.notifications??[],v=w?.findIndex(u=>u.id===M);v!==-1&&(w.splice(v,1),this.notificationsByDocumentIdMap$.next(T(D({},U),{[S]:T(D({},R),{notifications:w})}))),this.notificationResolverService.notificationDataProviderAvailable()&&this.notificationResolverService.getNotificationById(M)&&this.notificationResolverService.deleteNotification(M,this.docService.getDocumentPaths()?.clientOrganizationId??"")}d.push({documentId:h,timestamp:p})}),d}),V(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((a,c)=>(a[c.notificationId]=c,a),{}),r=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allDocNotifications",data:n});s=Object.values(r??{})}else{let n=t[e]?.notifications?.reduce((a,c)=>(a[c.notificationId]=c,a),{}),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 c=this.getUserNotificationsFromServer()??[],l=new Set(t.map(g=>g.notificationId));o=c.filter(g=>l.has(g.notificationId)).concat(t.filter(g=>!c.some(f=>f.notificationId===g.notificationId)))}let s=o.reduce((c,l)=>(c[l.notificationId]=l,c),{}),n;if(i==="user"){let c=this.commonDbUtilsService.mergeUsersWithData({feature:"allUserNotifications",data:s});n=Object.values(c??{})}else if(i==="notification"){let c=this.commonDbUtilsService.mergeNotificationsWithResolvedData({feature:"allUserNotifications",data:s});n=Object.values(c??{})}else{let c=this.commonDbUtilsService.mergeCommentAnnotationsWithData({feature:"allUserNotifications",data:s});n=Object.values(c??{})}n.forEach(c=>{c.notification=this.getClientNotificationObject(c)});let r=this.getUserNotificationsFromServer()??[],a=new Map(r.map(c=>[c.notificationId,c]));n.forEach(c=>{a.set(c.notificationId,c)}),this.setUserNotificationsFromServer(Array.from(a.values()))}catch(o){this.loggingService.catch("Error in NotificationService resolveAndMergeUserNotifications: ",o)}}fetchNotificationsForDocumentIds(t,i=15){return E(this,null,function*(){try{if(t?.length){let e=tt(this.functions,X({url:this.endpointsService.getCloudFunctionUrl("getNotificationsForDocuments"),apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:12e5}),o=this.docService.getOrganizationConfig()?.organizationId??"";if(!o)return[];let s=this.getStartAtTimestamp(),n={};if(t.forEach(S=>{if(S?.documentId){let U=this.getAllowedDocumentMetadataByDocumentId(S.documentId);U&&(n[S.documentId]=U)}}),this.userPermissionService?.isPermissionProviderAvailable())try{let S=[];if(t.forEach(u=>{this.docService.getDocumentMetadata(u.documentId)||S.push(u.documentId)}),S.length){let u=this.authService.getUser(),b=tt(this.functions,X({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));try{let x=yield ht({methodName:"getDocumentMetadataFromIds",data:{type:"getDocumentMetadataFromIds",metadata:{organizationId:u?.clientOrganizationId,folderId:this.documentPaths?.folderId},documentIds:S},getSdkProxy:b,userId:u?.userId??""});if(x?.data?.length){let y={};x.data.forEach(H=>{H?.documentId&&(y[H.documentId]=H)}),this.docService.setAllDocumentMetadata(D(D({},this.docService.getAllDocumentMetadataMap()),y))}}catch(x){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",x)}}let U=[],R=[];t.forEach(u=>{let b=this.docService.getDocumentMetadata(u.documentId);b?.clientDocumentId?U.push({userId:this.authService.getUser()?.userId??"",resource:D({id:b.clientDocumentId,type:Q.DOCUMENT,source:q.GET_NOTIFICATIONS,organizationId:this.docService.getOrganizationConfig()?.clientOrganizationId??""},b.folderId&&{parentFolderId:b.folderId})}):R.push(u.documentId)}),R.length&&(t=t.filter(u=>!R.includes(u.documentId)));let w=$t();this.coreActionsService.triggerAction(Ot.PERMISSION_PROVIDER,{event:L.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:w,methodName:q.GET_NOTIFICATIONS,source:"internal",payload:{requests:U}});let v=yield this.userPermissionService?.onResourceAccessRequired({requests:U,uniqueId:w,methodName:q.GET_NOTIFICATIONS});v?.success&&v?.data?.length?v.data.forEach(u=>{!u.hasAccess&&u.resourceId&&(t=t.filter(b=>b.documentId!==At(u.resourceId)))}):t=[]}catch(S){this.loggingService.warn("Error in NotificationService fetchNotificationsForDocumentIds: ",S),t=[]}if(!t.length)return this.notificationsByDocumentIdMap$.getValue()||(this.notificationsByDocumentIdMap$.next({}),this.setUserNotificationsFromServer([])),[];let r=this.userPermissionService?.getPermissionsCache()?.filter(S=>S.type===Q.CONTEXT),a={organizationId:o,documentIds:t.filter(S=>!!S.documentId&&!!S.timestamp).map(S=>({documentId:S.documentId,timestamp:S.timestamp??0})),timestamp:s,limitToLast:i,selfNotifications:this.selfNotifications$.value,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),getUserNotifications:!0,isContextEnabled:this.userPermissionService?.getIsContextEnabled(),cachedData:r,isSettingsConfigByOrganization:this.getSettingsConfigByOrganization(),retryConfig:this.userPermissionService?.getPermissionProviderRetryConfig()},c=yield this.notificationUtilsService.handleNotificationEncryption({data:a}),l=yield e({veltData:c}),g=l?.data?.data?.veltData||{},f=l?.data?.data?.veltAdditionalData||{},d="notificationwithdocumentidstoencryptanddecryptonsdk"+(this.authService.getUser()?.userId??""),h=yield dt(g,d),{userNotifications:p=[],userNotificationIdsInDocNotifications:$=[],permissionResults:M=[]}=yield dt(f,d);if(this.userPermissionService?.getIsContextEnabled()){let S=[...this.userPermissionService?.getPermissionsCache()??[],...M??[]];this.userPermissionService?.setPermissionsCache(S)}if(h&&typeof h=="object"){let S=this.usersService.userDataProviderAvailable(),U=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),R=this.notificationResolverService.notificationDataProviderAvailable(),w=[],v=[],u=[];Object.keys(h).forEach((y,H)=>{let _=h[y].documentMetadata??this.docService.getAllDocumentMetadataMap()?.[y];if(_){let B=this.allowedDocumentMetadataMap$.value||{};(!B?.[y]||!Z(B?.[y],_))&&this.allowedDocumentMetadataMap$.next(T(D({},B),{[y]:_}))}let Y=h[y].notifications||[];Y.forEach(B=>{$.includes(B.notificationId)&&!p.find(ti=>ti.notificationId===B.notificationId)&&p.push(JSON.parse(JSON.stringify(B))),B.notification=this.getClientNotificationObject(B)}),this.setNotificationForDocumentIdInCache(y,_,Y),S&&(w.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:Y,shouldAwait:!0,forceResolve:!0})),w.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:p,shouldAwait:!0,forceResolve:!0}))),U&&(v.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:Y,shouldCommentAnnotationsResolverAwait:!0})),v.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:p,shouldCommentAnnotationsResolverAwait:!0}))),R&&(u.push(this.commonDbUtilsService.formatResponse({feature:"allDocNotifications",data:Y,shouldNotificationResolverAwait:!0})),u.push(this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:p,shouldNotificationResolverAwait:!0})))});let b=JSON.parse(JSON.stringify(p));this.setUserNotificationsFromServer([...this.getUserNotificationsFromServer()??[],...p]),(R||S||U)&&(()=>{let y=Promise.resolve();if(R&&(y=y.then(()=>Promise.allSettled(u)).then(()=>{this.resolveAndUpdateDocumentNotifications(h,"notification"),this.resolveAndMergeUserNotifications(b,"notification")})),S&&(y=y.then(()=>Promise.allSettled(w)).then(()=>{this.resolveAndUpdateDocumentNotifications(h,"user"),this.resolveAndMergeUserNotifications(b,"user")})),U){let H=R||S;y=y.then(()=>Promise.allSettled(v)).then(()=>{this.resolveAndUpdateDocumentNotifications(h,"comment"),this.resolveAndMergeUserNotifications(b,"comment",H)})}return y})().catch(y=>{this.loggingService.catch("Error in NotificationService resolveChain: ",y)})}}}catch(e){return this.loggingService.catch("Error in NotificationService fetchNotificationsForDocumentIds: ",e),[]}})}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(),a=r?.[t]?.notifications||[],c=this.docService.getLocationMetadatas(),l=e?.map(d=>{let h=d?.notification;return h?(h.metadata&&(h.metadata.documentName=i?.documentName||h.metadata.documentName,h.metadata.organizationMetadata=n||h.metadata.organizationMetadata,h.metadata.documentMetadata=i||h.metadata.documentMetadata),c&&(h=this.notificationUtilsService.mergeLocationWithNotification({notification:h},c)?.notification),h):null})?.filter(d=>!!d)||[],g=new Map(a.map(d=>[d.id,d]));l.forEach(d=>{g.set(d.id,d)});let f=Array.from(g.values()).sort((d,h)=>(h.timestamp||0)-(d.timestamp||0));this.notificationsByDocumentIdMap$.next(T(D({},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(I(t=>C(t).pipe(F(i=>!!i),N(i=>{let e=this.usersService.userDataProviderAvailable(),o=this.commentAnnotationsResolverService?.commentAnnotationDataProviderAvailable(),s=this.notificationResolverService?.notificationDataProviderAvailable();if(s||e||o){let r=i?.reduce((a,c)=>(a[c.notificationId]=c,a),{});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,a)=>a.timestamp-r.timestamp),i.map(r=>r.notification).filter(r=>!!r)}),I(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(N(o=>Object.values(o?.data||{}).map(s=>s?.notification)))}))),I(t=>{let i=this.docService.getOrganizationConfig()?.organizationId??"";return this.docService.getOrganizationMetadata$(i).pipe(N(()=>t))}),I(t=>this.allowedDocumentMetadataMap$.pipe(N(()=>t))),N(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 W([this.getCurrentOrgNotificationsForYou(),this.crossOrgNotifications$.asObservable()]).pipe(N(([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=a=>a?.id??a?.notificationId,n=new Set;o.forEach(a=>{let c=s(a);c!=null&&n.add(c)});let r=[...o];return e.forEach(a=>{let c=s(a);c!=null&&n.has(c)||(c!=null&&n.add(c),r.push(a))}),r.sort((a,c)=>(c?.timestamp||0)-(a?.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(T(D({},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(T(D({},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(N(t=>t?.userId),J(),F(t=>!!t),V(t=>(this.loggingService.catch("Error in NotificationService cross-org user watcher: ",t),G))).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(V(i=>(this.loggingService.catch("Error in NotificationService cross-org index listener: ",i),G))).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(N(i=>i?.organizationId??""),J(),lt(),F(([i])=>!!i),V(i=>(this.loggingService.catch("Error in NotificationService cross-org org-switch listener: ",i),G))).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=T(D({},e.metadata||{}),{organizationId:o})),e}let i=t.id??t.notificationId;return i==null?null:t.id!=null?t:T(D({},t),{id:i})}catch(i){return this.loggingService.catch("Error in NotificationService toCrossOrgClientNotification: ",i),null}}resolveCrossOrgSelfHostedData(t){return E(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 a=r?.metadata?.clientOrganizationId??r?.metadata?.organizationId??"",c=s.get(a);c?c.push(r):s.set(a,[r])}let n=[];for(let[r,a]of s){let c=a.reduce((g,f,d)=>{let h=f?.notificationId??f?.id??`__cross_org_${d}`;return g[h]=f,g},{});yield this.commonDbUtilsService.formatResponse({feature:"allUserNotifications",data:c,organizationId:r||void 0,shouldAwait:!0,shouldNotificationResolverAwait:!0,shouldCommentAnnotationsResolverAwait:!0});let l=c;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 E(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}),a=yield this.callGetCrossOrgUserNotifications(r);if(t!==this.crossOrgGeneration)return;let c=Array.isArray(a?.pendingPermissionQueries)?a.pendingPermissionQueries:[],l=!!this.userPermissionService?.isClientDevResolverActive?.(),g=!c.length||!l;if(yield this.processCrossOrgResponse(a,{fetchGeneration:t,currentOrg:e,isInitial:o,indexTimestamps:s,advanceCursors:g}),t!==this.crossOrgGeneration||g){g&&t===this.crossOrgGeneration&&this.clearCrossOrgStragglerRetry();return}yield this.runCrossOrgResolveRound(c,{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 E(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 E(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 a=r.map(l=>this.toCrossOrgClientNotification(l)).filter(l=>!!l),c;i.isInitial?c=a:c=this.mergeCrossOrgForYou(a,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(c)})}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 E(this,null,function*(){let i=this.authService.getUser(),e=tt(this.functions,X({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));return yield ht({methodName:"getCrossOrgUserNotifications",data:D({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),a=r?o.organizationIds.filter(d=>!!d).map(d=>ft(d)):[],c=(o.excludeOrganizationIds||[]).filter(d=>!!d).map(d=>ft(d)),l=new Set(c);i&&l.add(i);let g=this.userPermissionService?.getPermissionsCache?.()?.filter(d=>d?.type===Q.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(a,l));else{let d=n.filter(p=>!!p&&!l.has(p));if(r){let p=new Set(a);d=d.filter($=>p.has($))}d=Array.from(new Set(d)),f.organizationIds=d;let h={};d.forEach(p=>{h[p]=this.crossOrgSeenTimestamps[p]??this.getStartAtTimestamp()}),f.orgTimestamps=h}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 a=r?.id??r?.notificationId,c=a!=null&&e.has(a);return c&&(s=!0),!c}):i.map(r=>{let a=r?.id??r?.notificationId;return a!=null&&e.has(a)&&r?.isUnread!==!1?(s=!0,T(D({},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=gt(t)),i&&typeof i=="object"){let s=Rt(i);e=gt(JSON.stringify(s))}}catch(s){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",s)}return this.authService.getAuthState$().pipe(F(s=>!!s),I(s=>this.isFeatureAllowed({firebaseUser:s})),I(s=>s.featureAllowed?this.iamService.isUserAllowed$().pipe(N(n=>(s.featureAllowed=n,s))):C(s)),I(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(I(n=>this.docService.getDocumentPaths$().pipe(N(r=>(this.documentPaths=r,n.documentPaths=r,n)))),I(n=>this.getDataFromDocumentId(o)))))}isFeatureAllowed(t){return this.configService.getConfig$().pipe(F(i=>!!i),N(i=>T(D({},t),{config:i})),I(i=>this.authService.getUser$().pipe(N(e=>T(D({},i),{user:e})))),I(i=>Et(i.config,i.user,yt.NOTIFICATION)?C(T(D({},i),{featureAllowed:!0})):(this.loggingService.warn("Notification feature is not allowed."),C(T(D({},i),{featureAllowed:!1})))))}getDataFromDocumentId(t){return this.databaseService.getDb().pipe(F(i=>!!i),I(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+=`/${P.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.documentPaths.organizationId}`);let o=this.realtimeAdapter.rtdbRef(this.db,`${t?e+"/"+P.FIREBASE_PARTIAL_PATH_DOCS+"/"+t+"/"+P.FIREBASE_PARTIAL_PATH_VIEWS+"/":this.documentPaths?.notifications}`);return this.realtimeAdapter.rtdbObjectVal$("notification",o).pipe(V(s=>(this.loggingService.catch("Error in NotificationService getDataFromDocumentId: ",s),C(null))),N(s=>{let n=[],r=new Map;s?.raw&&(Object.keys(s?.raw||{}).forEach(c=>{let l=s?.raw[c];l?.id&&n.push(l)}),n.forEach(c=>{c.id&&r.set(c.id,c)})),this.notifications$.next(n),this.rawNotificationsByIdMap$.next(r);let a=[];s?.processed&&Object.keys(s?.processed||{}).forEach(c=>{let l=s?.processed[c];l?.id&&a.push(l)}),this.processedNotifications$.next(a),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 a=!1;(e&&r.notifyUsers?.[e]||o&&r.notifyUsers?.[o])&&(a=!0);let c={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:a,notificationSourceData:r.notificationSourceData},l=this.getRawNotificationById(c.id);if(l?.metadata&&(c.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}),c?.notificationSource==="comment"&&c?.targetAnnotationId){let g=this.commentService?.getAnnotationById(c.targetAnnotationId);g||l?.annotationData&&(g=l.annotationData),g&&(c.notificationSourceData=this.commentService?.getCommentAnnotationForClient(g))}s.set(r.id,c)}}),s.forEach((r,a)=>{r.isUnread=r?.actionUser?.userSnippylyId!==t?.userSnippylyId&&!i?.notification?.[a]?.views?.[t?.userSnippylyId],s.set(a,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 a=null;n?.email&&(a=z(n?.email));let c=null;n?.userId&&(c=z(n?.userId));let l=!1,g=!0;(a&&r.notifyUsers?.[a]||c&&r.notifyUsersByUserId?.[c])&&(l=!0),c&&o?.[c]&&(g=!1);let f={id:r.id};if(s?f=T(D(D({},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 d=this.commentService?.getAnnotationById(f.targetAnnotationId);d||s?.notificationSourceData&&(d=s?.notificationSourceData),d||i?.annotationData&&(d=i.annotationData),d&&(f.notificationSourceData=this.commentService?.getCommentAnnotationForClient(d))}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(N(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 W([this.getNotificationsByDocumentId$(),this.crossOrgNotifications$.asObservable()]).pipe(N(([t,i])=>{let e=Array.isArray(i)?i:[],o=null;return t&&(o=[],t.forEach(s=>{s.notifications.forEach(n=>{o?.push(n)})})),e.length?t?this.mergeCrossOrgForYou(o||[],e):null:t?o.sort((s,n)=>n.timestamp-s.timestamp):null}))}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 mt({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(),a=this.notificationUtilsService.formatNotification(t,r);return JSON.parse(JSON.stringify(a))}catch(i){return this.loggingService.catch("Error in NotificationService processNotificationData: ",i),null}}updateNotificationDatabase(t){try{if(!this.notificationsDb)return;let i=this.realtimeAdapter.rtdbRef(this.notificationsDb),e=this.processNotificationData(t);try{let o=Ut(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(I(i=>i?i.organizationId?this.getAllNotifications$().pipe(I(e=>this.notificationsForYou$.pipe(N(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(N(e=>Array.from(e.values())),N(e=>e.sort((o,s)=>s.timestamp-o.timestamp)),St()):C(null)),J(Mt))}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,a)=>(a==="actionUser"||a==="recipientUser")&&o[a]?i?.email&&o[a].email===i?.email||i?.userId&&o[a]?.userId===i?.userId?"You":o[a].name||o[a].email||' <velt-skeleton-loader width="50px" height="20px" border-radius="4px"></velt-skeleton-loader> ':o[a]?o[a]: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(P.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?this.historyPanelVisible$.next(t):this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${P.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`):this.historyPanelVisible$.next(t),t?this.analyticsService.trackEvent(L.Events.Notifications.NOTIFICATION_HISTORY_PANEL_OPENED):this.analyticsService.trackEvent(L.Events.Notifications.NOTIFICATION_HISTORY_PANEL_CLOSED)}catch{this.loggingService.catch("Error in NotificationService setHistoryPanelVisibility: ",`<${P.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(P.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL)?(this.historyPanelVisible$.next(!this.historyPanelVisible$.value),this.historyPanelVisible$.value?this.analyticsService.trackEvent(L.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"closed"}):this.analyticsService.trackEvent(L.Events.Notifications.NOTIFICATION_HISTORY_PANEL_TOGGLED,{action:"opened"})):this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${P.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}catch{this.loggingService.catch("Error in NotificationService toggleHistoryPanelVisibility: ",`<${P.TAGS.VELT_NOTIFICATIONS_HISTORY_PANEL}> tag is not added.`)}}getHistoryPanelVisibility$(){return this.historyPanelVisible$.asObservable()}setNotificationsAsRead(t){return E(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 a=t.slice(n,n+50).filter(g=>g?.id),c=a.map(g=>this.setNotificationAsRead({notification:g,userNotifications:JSON.parse(JSON.stringify(i))})),l=yield Promise.all(c);a.forEach((g,f)=>{let d=l[f];if(!d.some(p=>p.notificationId===g.id))i=i.filter(p=>p.notificationId!==g.id);else{let p=i.find(M=>M.notificationId===g.id),$=d.find(M=>M.notificationId===g.id);p&&$?.views&&(p.views=$.views)}})}let o=JSON.parse(JSON.stringify(this.notificationsByDocumentIdMap$.getValue()||{}));t.forEach(n=>{let r=n.metadata?.documentId;if(r&&o?.[r]){let a=o?.[r]?.notifications||[],c=a.find(l=>l.id===n.id);c&&(c.isUnread=!1),o[r].notifications=a}}),this.notificationsByDocumentIdMap$.next(o),this.markCrossOrgEntriesRead(t),!Z(i,this.getUserNotificationsFromServer())&&this.setUserNotificationsFromServer(i)}}catch(i){this.loggingService.catch("Error in NotificationService setNotificationsAsRead: ",i)}})}setAllNotificationsAsRead(t){return E(this,null,function*(){try{if(t?.tabId==="for-you"){let i=this.notificationsForYou$.value||[];this.setNotificationsAsRead(i)}else this.getNotifications$().pipe(k(1)).subscribe(i=>{i&&this.setNotificationsAsRead(i)})}catch(i){this.loggingService.catch("Error in NotificationService setAllNotificationsAsRead: ",i)}})}getUnreadNotificationsCount$(){try{return this.notificationsForYou$.pipe(N(t=>t?.filter(e=>e?.isUnread)?.length??null),I(t=>this.getNotifications$().pipe(N(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 E(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:a,documentId:c}=n;if(r&&a&&c&&s){let l=yield this.commonDbService.getData({feature:"docNotification",properties:{id:t.id,organizationId:a,documentId:c,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:a,documentId:c,apiKey:r},data:l})));let g=yield this.commonDbService.getData({feature:"userNotification",properties:{id:t.id,userId:s,documentId:c,organizationId:a}});if(g?.notificationId){if(!this.getReadNotificationsOnForYouTab())yield this.commonDbService.deleteData({feature:"userNotification",properties:{id:t.id,userId:s,documentId:c,organizationId:a}}),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(d=>d.notificationId===t.id);f&&(f.views=g.views),this.commonDbService.updateData({feature:"userNotificationViews",properties:{id:t.id,userId:s,documentId:c,organizationId:a},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 E(this,null,function*(){try{this.getNotifications$().pipe(k(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)}}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 E(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,a={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:a}})))}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}};A.\u0275fac=function(i){return new(i||A)(m(Nt),m(xt),m(ot),m(jt),m(qt),m(Jt),m(nt),m(st),m(at),m(Wt),m(kt),m(Lt),m(Qt),m(et),m(Xt),m(rt),m(It),m(Zt),m(Vt),m(it),m(Kt))},A.\u0275prov=K({token:A,factory:A.\u0275fac,providedIn:"root"});let j=A;return j})();export{Xt as a,ji as b};
@@ -1,2 +1,2 @@
1
- import{C as F,R as b,S as f,T as H,U as j,V as N,u as R,v as E,w as O,x as I}from"./chunk-J3FNQGWW.js";import{$ as y,D as v,E as l,Ga as k,J as h,Kb as A,Ua as C,Va as B,Ya as w,_a as M,a as c,aa as S,b as _,ba as p,da as r,db as D,ge as L,he as s,k as g,la as x,xb as T}from"./chunk-TY3WZ4Q4.js";function X(i,m){}var z="_mat-bottom-sheet-enter",P="_mat-bottom-sheet-exit",G=(()=>{class i extends H{_breakpointSubscription;_animationsDisabled=b();_animationState="void";_animationStateChanged=new k;_destroyed;constructor(){super();let e=r(L);this._breakpointSubscription=e.observe([s.Medium,s.Large,s.XLarge]).subscribe(()=>{let o=this._elementRef.nativeElement.classList;o.toggle("mat-bottom-sheet-container-medium",e.isMatched(s.Medium)),o.toggle("mat-bottom-sheet-container-large",e.isMatched(s.Large)),o.toggle("mat-bottom-sheet-container-xlarge",e.isMatched(s.XLarge))})}enter(){this._destroyed||(this._animationState="visible",this._changeDetectorRef.markForCheck(),this._changeDetectorRef.detectChanges(),this._animationsDisabled&&this._simulateAnimation(z))}exit(){this._destroyed||(this._elementRef.nativeElement.setAttribute("mat-exit",""),this._animationState="hidden",this._changeDetectorRef.markForCheck(),this._animationsDisabled&&this._simulateAnimation(P))}ngOnDestroy(){super.ngOnDestroy(),this._breakpointSubscription.unsubscribe(),this._destroyed=!0}_simulateAnimation(e){this._ngZone.run(()=>{this._handleAnimationEvent(!0,e),setTimeout(()=>this._handleAnimationEvent(!1,e))})}_trapFocus(){super._trapFocus({preventScroll:!0})}_handleAnimationEvent(e,o){let t=o===z;(t||o===P)&&this._animationStateChanged.emit({toState:t?"visible":"hidden",phase:e?"start":"done"})}static \u0275fac=function(o){return new(o||i)};static \u0275cmp=C({type:i,selectors:[["mat-bottom-sheet-container"]],hostAttrs:["tabindex","-1",1,"mat-bottom-sheet-container"],hostVars:9,hostBindings:function(o,t){o&1&&T("animationstart",function(a){return t._handleAnimationEvent(!0,a.animationName)})("animationend",function(a){return t._handleAnimationEvent(!1,a.animationName)})("animationcancel",function(a){return t._handleAnimationEvent(!1,a.animationName)}),o&2&&(D("role",t._config.role)("aria-modal",t._config.ariaModal)("aria-label",t._config.ariaLabel),A("mat-bottom-sheet-container-animations-enabled",!t._animationsDisabled)("mat-bottom-sheet-container-enter",t._animationState==="visible")("mat-bottom-sheet-container-exit",t._animationState==="hidden"))},features:[w],decls:1,vars:0,consts:[["cdkPortalOutlet",""]],template:function(o,t){o&1&&M(0,X,0,0,"ng-template",0)},dependencies:[R],styles:[`@keyframes _mat-bottom-sheet-enter{from{transform:translateY(100%)}to{transform:none}}@keyframes _mat-bottom-sheet-exit{from{transform:none}to{transform:translateY(100%)}}.mat-bottom-sheet-container{box-shadow:0px 8px 10px -5px rgba(0, 0, 0, 0.2), 0px 16px 24px 2px rgba(0, 0, 0, 0.14), 0px 6px 30px 5px rgba(0, 0, 0, 0.12);padding:8px 16px;min-width:100vw;box-sizing:border-box;display:block;outline:0;max-height:80vh;overflow:auto;position:relative;background:var(--mat-bottom-sheet-container-background-color, var(--mat-sys-surface-container-low));color:var(--mat-bottom-sheet-container-text-color, var(--mat-sys-on-surface));font-family:var(--mat-bottom-sheet-container-text-font, var(--mat-sys-body-large-font));font-size:var(--mat-bottom-sheet-container-text-size, var(--mat-sys-body-large-size));line-height:var(--mat-bottom-sheet-container-text-line-height, var(--mat-sys-body-large-line-height));font-weight:var(--mat-bottom-sheet-container-text-weight, var(--mat-sys-body-large-weight));letter-spacing:var(--mat-bottom-sheet-container-text-tracking, var(--mat-sys-body-large-tracking))}@media(forced-colors: active){.mat-bottom-sheet-container{outline:1px solid}}.mat-bottom-sheet-container-animations-enabled{transform:translateY(100%)}.mat-bottom-sheet-container-animations-enabled.mat-bottom-sheet-container-enter{animation:_mat-bottom-sheet-enter 195ms cubic-bezier(0, 0, 0.2, 1) forwards}.mat-bottom-sheet-container-animations-enabled.mat-bottom-sheet-container-exit{animation:_mat-bottom-sheet-exit 375ms cubic-bezier(0.4, 0, 1, 1) backwards}.mat-bottom-sheet-container-xlarge,.mat-bottom-sheet-container-large,.mat-bottom-sheet-container-medium{border-top-left-radius:var(--mat-bottom-sheet-container-shape, 28px);border-top-right-radius:var(--mat-bottom-sheet-container-shape, 28px)}.mat-bottom-sheet-container-medium{min-width:384px;max-width:calc(100vw - 128px)}.mat-bottom-sheet-container-large{min-width:512px;max-width:calc(100vw - 256px)}.mat-bottom-sheet-container-xlarge{min-width:576px;max-width:calc(100vw - 384px)}
1
+ import{C as F,R as b,S as f,T as H,U as j,V as N,u as R,v as E,w as O,x as I}from"./chunk-RF3TL6SQ.js";import{$ as y,D as v,E as l,Ga as k,J as h,Kb as A,Td as L,Ua as C,Ud as s,Va as B,Ya as w,_a as M,a as c,aa as S,b as _,ba as p,da as r,db as D,k as g,la as x,xb as T}from"./chunk-3YCIOKO7.js";function X(i,m){}var z="_mat-bottom-sheet-enter",P="_mat-bottom-sheet-exit",G=(()=>{class i extends H{_breakpointSubscription;_animationsDisabled=b();_animationState="void";_animationStateChanged=new k;_destroyed;constructor(){super();let e=r(L);this._breakpointSubscription=e.observe([s.Medium,s.Large,s.XLarge]).subscribe(()=>{let o=this._elementRef.nativeElement.classList;o.toggle("mat-bottom-sheet-container-medium",e.isMatched(s.Medium)),o.toggle("mat-bottom-sheet-container-large",e.isMatched(s.Large)),o.toggle("mat-bottom-sheet-container-xlarge",e.isMatched(s.XLarge))})}enter(){this._destroyed||(this._animationState="visible",this._changeDetectorRef.markForCheck(),this._changeDetectorRef.detectChanges(),this._animationsDisabled&&this._simulateAnimation(z))}exit(){this._destroyed||(this._elementRef.nativeElement.setAttribute("mat-exit",""),this._animationState="hidden",this._changeDetectorRef.markForCheck(),this._animationsDisabled&&this._simulateAnimation(P))}ngOnDestroy(){super.ngOnDestroy(),this._breakpointSubscription.unsubscribe(),this._destroyed=!0}_simulateAnimation(e){this._ngZone.run(()=>{this._handleAnimationEvent(!0,e),setTimeout(()=>this._handleAnimationEvent(!1,e))})}_trapFocus(){super._trapFocus({preventScroll:!0})}_handleAnimationEvent(e,o){let t=o===z;(t||o===P)&&this._animationStateChanged.emit({toState:t?"visible":"hidden",phase:e?"start":"done"})}static \u0275fac=function(o){return new(o||i)};static \u0275cmp=C({type:i,selectors:[["mat-bottom-sheet-container"]],hostAttrs:["tabindex","-1",1,"mat-bottom-sheet-container"],hostVars:9,hostBindings:function(o,t){o&1&&T("animationstart",function(a){return t._handleAnimationEvent(!0,a.animationName)})("animationend",function(a){return t._handleAnimationEvent(!1,a.animationName)})("animationcancel",function(a){return t._handleAnimationEvent(!1,a.animationName)}),o&2&&(D("role",t._config.role)("aria-modal",t._config.ariaModal)("aria-label",t._config.ariaLabel),A("mat-bottom-sheet-container-animations-enabled",!t._animationsDisabled)("mat-bottom-sheet-container-enter",t._animationState==="visible")("mat-bottom-sheet-container-exit",t._animationState==="hidden"))},features:[w],decls:1,vars:0,consts:[["cdkPortalOutlet",""]],template:function(o,t){o&1&&M(0,X,0,0,"ng-template",0)},dependencies:[R],styles:[`@keyframes _mat-bottom-sheet-enter{from{transform:translateY(100%)}to{transform:none}}@keyframes _mat-bottom-sheet-exit{from{transform:none}to{transform:translateY(100%)}}.mat-bottom-sheet-container{box-shadow:0px 8px 10px -5px rgba(0, 0, 0, 0.2), 0px 16px 24px 2px rgba(0, 0, 0, 0.14), 0px 6px 30px 5px rgba(0, 0, 0, 0.12);padding:8px 16px;min-width:100vw;box-sizing:border-box;display:block;outline:0;max-height:80vh;overflow:auto;position:relative;background:var(--mat-bottom-sheet-container-background-color, var(--mat-sys-surface-container-low));color:var(--mat-bottom-sheet-container-text-color, var(--mat-sys-on-surface));font-family:var(--mat-bottom-sheet-container-text-font, var(--mat-sys-body-large-font));font-size:var(--mat-bottom-sheet-container-text-size, var(--mat-sys-body-large-size));line-height:var(--mat-bottom-sheet-container-text-line-height, var(--mat-sys-body-large-line-height));font-weight:var(--mat-bottom-sheet-container-text-weight, var(--mat-sys-body-large-weight));letter-spacing:var(--mat-bottom-sheet-container-text-tracking, var(--mat-sys-body-large-tracking))}@media(forced-colors: active){.mat-bottom-sheet-container{outline:1px solid}}.mat-bottom-sheet-container-animations-enabled{transform:translateY(100%)}.mat-bottom-sheet-container-animations-enabled.mat-bottom-sheet-container-enter{animation:_mat-bottom-sheet-enter 195ms cubic-bezier(0, 0, 0.2, 1) forwards}.mat-bottom-sheet-container-animations-enabled.mat-bottom-sheet-container-exit{animation:_mat-bottom-sheet-exit 375ms cubic-bezier(0.4, 0, 1, 1) backwards}.mat-bottom-sheet-container-xlarge,.mat-bottom-sheet-container-large,.mat-bottom-sheet-container-medium{border-top-left-radius:var(--mat-bottom-sheet-container-shape, 28px);border-top-right-radius:var(--mat-bottom-sheet-container-shape, 28px)}.mat-bottom-sheet-container-medium{min-width:384px;max-width:calc(100vw - 128px)}.mat-bottom-sheet-container-large{min-width:512px;max-width:calc(100vw - 256px)}.mat-bottom-sheet-container-xlarge{min-width:576px;max-width:calc(100vw - 384px)}
2
2
  `],encapsulation:2})}return i})(),K=new p("MatBottomSheetData"),u=class{viewContainerRef;panelClass;direction;data=null;hasBackdrop=!0;backdropClass;disableClose=!1;ariaLabel=null;ariaModal=!1;closeOnNavigation=!0;autoFocus="first-tabbable";restoreFocus=!0;scrollStrategy;height="";minHeight;maxHeight},d=class{_ref;get instance(){return this._ref.componentInstance}get componentRef(){return this._ref.componentRef}containerInstance;disableClose;_afterOpened=new g;_result;_closeFallbackTimeout;constructor(m,e,o){this._ref=m,this.containerInstance=o,this.disableClose=e.disableClose,o._animationStateChanged.pipe(l(t=>t.phase==="done"&&t.toState==="visible"),h(1)).subscribe(()=>{this._afterOpened.next(),this._afterOpened.complete()}),o._animationStateChanged.pipe(l(t=>t.phase==="done"&&t.toState==="hidden"),h(1)).subscribe(()=>{clearTimeout(this._closeFallbackTimeout),this._ref.close(this._result)}),m.overlayRef.detachments().subscribe(()=>{this._ref.close(this._result)}),v(this.backdropClick(),this.keydownEvents().pipe(l(t=>t.keyCode===27))).subscribe(t=>{!this.disableClose&&(t.type!=="keydown"||!O(t))&&(t.preventDefault(),this.dismiss())})}dismiss(m){this.containerInstance&&(this.containerInstance._animationStateChanged.pipe(l(e=>e.phase==="start"),h(1)).subscribe(()=>{this._closeFallbackTimeout=setTimeout(()=>this._ref.close(this._result),500),this._ref.overlayRef.detachBackdrop()}),this._result=m,this.containerInstance.exit(),this.containerInstance=null)}afterDismissed(){return this._ref.closed}afterOpened(){return this._afterOpened}backdropClick(){return this._ref.backdropClick}keydownEvents(){return this._ref.keydownEvents}},U=new p("mat-bottom-sheet-default-options"),W=(()=>{class i{_injector=r(x);_parentBottomSheet=r(i,{optional:!0,skipSelf:!0});_animationsDisabled=b();_defaultOptions=r(U,{optional:!0});_bottomSheetRefAtThisLevel=null;_dialog=r(j);get _openedBottomSheetRef(){let e=this._parentBottomSheet;return e?e._openedBottomSheetRef:this._bottomSheetRefAtThisLevel}set _openedBottomSheetRef(e){this._parentBottomSheet?this._parentBottomSheet._openedBottomSheetRef=e:this._bottomSheetRefAtThisLevel=e}constructor(){}open(e,o){let t=c(c({},this._defaultOptions||new u),o),n;return this._dialog.open(e,_(c({},t),{disableClose:!0,closeOnOverlayDetachments:!1,maxWidth:"100%",container:G,scrollStrategy:t.scrollStrategy||I(this._injector),positionStrategy:F(this._injector).centerHorizontally().bottom("0"),disableAnimations:this._animationsDisabled,templateContext:()=>({bottomSheetRef:n}),providers:(a,Z,Y)=>(n=new d(a,t,Y),[{provide:d,useValue:n},{provide:K,useValue:t.data}])})),n.afterDismissed().subscribe(()=>{this._openedBottomSheetRef===n&&(this._openedBottomSheetRef=null)}),this._openedBottomSheetRef?(this._openedBottomSheetRef.afterDismissed().subscribe(()=>n.containerInstance?.enter()),this._openedBottomSheetRef.dismiss()):n.containerInstance.enter(),this._openedBottomSheetRef=n,n}dismiss(e){this._openedBottomSheetRef&&this._openedBottomSheetRef.dismiss(e)}ngOnDestroy(){this._bottomSheetRefAtThisLevel&&this._bottomSheetRefAtThisLevel.dismiss()}static \u0275fac=function(o){return new(o||i)};static \u0275prov=y({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})(),dt=(()=>{class i{static \u0275fac=function(o){return new(o||i)};static \u0275mod=B({type:i});static \u0275inj=S({providers:[W],imports:[N,f,E,f]})}return i})();export{K as a,d as b,W as c,dt as d};
@@ -1 +1 @@
1
- import{D as E,Ha as R,Ja as S,Ka as F,Ma as l,T as b,bb as V,i as g,la as I,m as y,ra as v}from"./chunk-TY3WZ4Q4.js";var Z={schedule(n,t){let e=setTimeout(n,t);return()=>clearTimeout(e)}};function D(n){return n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function M(n){return!!n&&n.nodeType===Node.ELEMENT_NODE}var h;function T(n,t){if(!h){let e=Element.prototype;h=e.matches||e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}return n.nodeType===Node.ELEMENT_NODE?h.call(n,t):!1}function C(n){let t={};return n.forEach(({propName:e,templateName:s,transform:r})=>{t[D(s)]=[e,r]}),t}function _(n,t){return t.get(l).resolveComponentFactory(n).inputs}function x(n,t){let e=n.childNodes,s=t.map(()=>[]),r=-1;t.some((c,u)=>c==="*"?(r=u,!0):!1);for(let c=0,u=e.length;c<u;++c){let o=e[c],i=O(o,t,r);i!==-1&&s[i].push(o)}return s}function O(n,t,e){let s=e;return M(n)&&t.some((r,c)=>r!=="*"&&T(n,r)?(s=c,!0):!1),s}var N=10,p=class{componentFactory;inputMap=new Map;constructor(t,e){this.componentFactory=e.get(l).resolveComponentFactory(t);for(let s of this.componentFactory.inputs)this.inputMap.set(s.propName,s.templateName)}create(t){return new m(this.componentFactory,t,this.inputMap)}},m=class{componentFactory;injector;inputMap;eventEmitters=new y(1);events=this.eventEmitters.pipe(b(t=>E(...t)));componentRef=null;scheduledDestroyFn=null;initialInputValues=new Map;ngZone;elementZone;appRef;cdScheduler;constructor(t,e,s){this.componentFactory=t,this.injector=e,this.inputMap=s,this.ngZone=this.injector.get(R),this.appRef=this.injector.get(V),this.cdScheduler=e.get(v),this.elementZone=typeof Zone>"u"?null:this.ngZone.run(()=>Zone.current)}connect(t){this.runInZone(()=>{if(this.scheduledDestroyFn!==null){this.scheduledDestroyFn(),this.scheduledDestroyFn=null;return}this.componentRef===null&&this.initializeComponent(t)})}disconnect(){this.runInZone(()=>{this.componentRef===null||this.scheduledDestroyFn!==null||(this.scheduledDestroyFn=Z.schedule(()=>{this.componentRef!==null&&(this.componentRef.destroy(),this.componentRef=null)},N))})}getInputValue(t){return this.runInZone(()=>this.componentRef===null?this.initialInputValues.get(t):this.componentRef.instance[t])}setInputValue(t,e){if(this.componentRef===null){this.initialInputValues.set(t,e);return}this.runInZone(()=>{this.componentRef.setInput(this.inputMap.get(t)??t,e),S(this.componentRef.hostView)&&(F(this.componentRef.changeDetectorRef),this.cdScheduler.notify(6))})}initializeComponent(t){let e=I.create({providers:[],parent:this.injector}),s=x(t,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(e,s,t),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.appRef.attachView(this.componentRef.hostView),this.componentRef.hostView.detectChanges()}initializeInputs(){for(let[t,e]of this.initialInputValues)this.setInputValue(t,e);this.initialInputValues.clear()}initializeOutputs(t){let e=this.componentFactory.outputs.map(({propName:s,templateName:r})=>{let c=t.instance[s];return new g(u=>{let o=c.subscribe(i=>u.next({name:r,value:i}));return()=>o.unsubscribe()})});this.eventEmitters.next(e)}runInZone(t){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(t):t()}},f=class extends HTMLElement{ngElementEventsSubscription=null};function L(n,t){let e=_(n,t.injector),s=t.strategyFactory||new p(n,t.injector),r=C(e);class c extends f{injector;static observedAttributes=Object.keys(r);get ngElementStrategy(){if(!this._ngElementStrategy){let o=this._ngElementStrategy=s.create(this.injector||t.injector);e.forEach(({propName:i,transform:a})=>{if(!this.hasOwnProperty(i))return;let d=this[i];delete this[i],o.setInputValue(i,d,a)})}return this._ngElementStrategy}_ngElementStrategy;constructor(o){super(),this.injector=o}attributeChangedCallback(o,i,a,d){let[w,j]=r[o];this.ngElementStrategy.setInputValue(w,a,j)}connectedCallback(){let o=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),o=!0),this.ngElementStrategy.connect(this),o||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(o=>{let i=new CustomEvent(o.name,{detail:o.value});this.dispatchEvent(i)})}}return e.forEach(({propName:u,transform:o})=>{Object.defineProperty(c.prototype,u,{get(){return this.ngElementStrategy.getInputValue(u)},set(i){this.ngElementStrategy.setInputValue(u,i,o)},configurable:!0,enumerable:!0})}),c}export{L as a};
1
+ import{D as E,Ha as R,Ja as S,Ka as F,Ma as l,T as b,bb as V,i as g,la as I,m as y,ra as v}from"./chunk-3YCIOKO7.js";var Z={schedule(n,t){let e=setTimeout(n,t);return()=>clearTimeout(e)}};function D(n){return n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function M(n){return!!n&&n.nodeType===Node.ELEMENT_NODE}var h;function T(n,t){if(!h){let e=Element.prototype;h=e.matches||e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}return n.nodeType===Node.ELEMENT_NODE?h.call(n,t):!1}function C(n){let t={};return n.forEach(({propName:e,templateName:s,transform:r})=>{t[D(s)]=[e,r]}),t}function _(n,t){return t.get(l).resolveComponentFactory(n).inputs}function x(n,t){let e=n.childNodes,s=t.map(()=>[]),r=-1;t.some((c,u)=>c==="*"?(r=u,!0):!1);for(let c=0,u=e.length;c<u;++c){let o=e[c],i=O(o,t,r);i!==-1&&s[i].push(o)}return s}function O(n,t,e){let s=e;return M(n)&&t.some((r,c)=>r!=="*"&&T(n,r)?(s=c,!0):!1),s}var N=10,p=class{componentFactory;inputMap=new Map;constructor(t,e){this.componentFactory=e.get(l).resolveComponentFactory(t);for(let s of this.componentFactory.inputs)this.inputMap.set(s.propName,s.templateName)}create(t){return new m(this.componentFactory,t,this.inputMap)}},m=class{componentFactory;injector;inputMap;eventEmitters=new y(1);events=this.eventEmitters.pipe(b(t=>E(...t)));componentRef=null;scheduledDestroyFn=null;initialInputValues=new Map;ngZone;elementZone;appRef;cdScheduler;constructor(t,e,s){this.componentFactory=t,this.injector=e,this.inputMap=s,this.ngZone=this.injector.get(R),this.appRef=this.injector.get(V),this.cdScheduler=e.get(v),this.elementZone=typeof Zone>"u"?null:this.ngZone.run(()=>Zone.current)}connect(t){this.runInZone(()=>{if(this.scheduledDestroyFn!==null){this.scheduledDestroyFn(),this.scheduledDestroyFn=null;return}this.componentRef===null&&this.initializeComponent(t)})}disconnect(){this.runInZone(()=>{this.componentRef===null||this.scheduledDestroyFn!==null||(this.scheduledDestroyFn=Z.schedule(()=>{this.componentRef!==null&&(this.componentRef.destroy(),this.componentRef=null)},N))})}getInputValue(t){return this.runInZone(()=>this.componentRef===null?this.initialInputValues.get(t):this.componentRef.instance[t])}setInputValue(t,e){if(this.componentRef===null){this.initialInputValues.set(t,e);return}this.runInZone(()=>{this.componentRef.setInput(this.inputMap.get(t)??t,e),S(this.componentRef.hostView)&&(F(this.componentRef.changeDetectorRef),this.cdScheduler.notify(6))})}initializeComponent(t){let e=I.create({providers:[],parent:this.injector}),s=x(t,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(e,s,t),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.appRef.attachView(this.componentRef.hostView),this.componentRef.hostView.detectChanges()}initializeInputs(){for(let[t,e]of this.initialInputValues)this.setInputValue(t,e);this.initialInputValues.clear()}initializeOutputs(t){let e=this.componentFactory.outputs.map(({propName:s,templateName:r})=>{let c=t.instance[s];return new g(u=>{let o=c.subscribe(i=>u.next({name:r,value:i}));return()=>o.unsubscribe()})});this.eventEmitters.next(e)}runInZone(t){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(t):t()}},f=class extends HTMLElement{ngElementEventsSubscription=null};function L(n,t){let e=_(n,t.injector),s=t.strategyFactory||new p(n,t.injector),r=C(e);class c extends f{injector;static observedAttributes=Object.keys(r);get ngElementStrategy(){if(!this._ngElementStrategy){let o=this._ngElementStrategy=s.create(this.injector||t.injector);e.forEach(({propName:i,transform:a})=>{if(!this.hasOwnProperty(i))return;let d=this[i];delete this[i],o.setInputValue(i,d,a)})}return this._ngElementStrategy}_ngElementStrategy;constructor(o){super(),this.injector=o}attributeChangedCallback(o,i,a,d){let[w,j]=r[o];this.ngElementStrategy.setInputValue(w,a,j)}connectedCallback(){let o=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),o=!0),this.ngElementStrategy.connect(this),o||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(o=>{let i=new CustomEvent(o.name,{detail:o.value});this.dispatchEvent(i)})}}return e.forEach(({propName:u,transform:o})=>{Object.defineProperty(c.prototype,u,{get(){return this.ngElementStrategy.getInputValue(u)},set(i){this.ngElementStrategy.setInputValue(u,i,o)},configurable:!0,enumerable:!0})}),c}export{L as a};
@@ -1 +1 @@
1
- import{Pa as s,Wc as c,Xa as a,ui as n}from"./chunk-TY3WZ4Q4.js";var f=(()=>{let i=class i{constructor(t,r){this.domService=t,this.sanitizer=r}transform(t,r=!0){try{let o=r?this.domService.sanitizeHtml(t):t;return this.sanitizer.bypassSecurityTrustHtml(o)}catch{return t}}};i.\u0275fac=function(r){return new(r||i)(s(n,16),s(c,16))},i.\u0275pipe=a({name:"safeHtml",type:i,pure:!0});let e=i;return e})();export{f as a};
1
+ import{Pa as s,Xa as a,Xc as c,si as n}from"./chunk-3YCIOKO7.js";var f=(()=>{let i=class i{constructor(t,r){this.domService=t,this.sanitizer=r}transform(t,r=!0){try{let o=r?this.domService.sanitizeHtml(t):t;return this.sanitizer.bypassSecurityTrustHtml(o)}catch{return t}}};i.\u0275fac=function(r){return new(r||i)(s(n,16),s(c,16))},i.\u0275pipe=a({name:"safeHtml",type:i,pure:!0});let e=i;return e})();export{f as a};