@veltdev/sdk 6.0.24 → 6.0.25

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 (61) hide show
  1. package/app/models/data/attachment.model.d.ts +23 -0
  2. package/{chunk-UYR6HRGI.js → chunk-2JSXDPYO.js} +1 -1
  3. package/{chunk-VSBVKZYP.js → chunk-6BTXSFDP.js} +1 -1
  4. package/{chunk-HRFML32S.js → chunk-7O3OJVW3.js} +1 -1
  5. package/{chunk-HWSQCIIL.js → chunk-AP33ZJ2C.js} +1 -1
  6. package/{chunk-K7KCPFC7.js → chunk-AWNCHHGK.js} +1 -1
  7. package/{chunk-S5U5EJSH.js → chunk-B3ZPP3EZ.js} +1 -1
  8. package/{chunk-FAOXE2LY.js → chunk-BJ5O5D7F.js} +1 -1
  9. package/{chunk-2TBFGTFV.js → chunk-BR7AO7YV.js} +1 -1
  10. package/chunk-CCZ3WXF4.js +1 -0
  11. package/{chunk-FV4CYQIJ.js → chunk-CLRO2X6T.js} +1 -1
  12. package/{chunk-U76HLU2G.js → chunk-CNB6D3KX.js} +22 -22
  13. package/{chunk-WQPVR2MY.js → chunk-DLN23S5M.js} +1 -1
  14. package/{chunk-RHUUOSBK.js → chunk-FJ6KQ3QL.js} +1 -1
  15. package/{chunk-OL2RJSA5.js → chunk-FJAMH4UH.js} +1 -1
  16. package/{chunk-4OP5FRJZ.js → chunk-G3BZ4EU4.js} +1 -1
  17. package/{chunk-Y7EFNXLS.js → chunk-GB46XS3O.js} +1 -1
  18. package/chunk-IXIU5ZJS.js +1 -0
  19. package/{chunk-2GJ6LQGO.js → chunk-JAKGBQ5D.js} +1 -1
  20. package/{chunk-AAZRCO7P.js → chunk-JICLHDU3.js} +1 -1
  21. package/{chunk-NEJKRV3M.js → chunk-JPOBXW24.js} +1 -1
  22. package/{chunk-VTMNUIEK.js → chunk-LCACRBV3.js} +1 -1
  23. package/{chunk-R7PGKNXH.js → chunk-LM54BOTU.js} +1 -1
  24. package/{chunk-T3JQYK3N.js → chunk-MEI3IAPO.js} +1 -1
  25. package/{chunk-B4MCRMP7.js → chunk-NJW4C3A2.js} +1 -1
  26. package/{chunk-3ETDYFCP.js → chunk-NNZNLREA.js} +1 -1
  27. package/{chunk-PS5CHEBA.js → chunk-NY2Q7SEG.js} +1 -1
  28. package/{chunk-D4RIWWWT.js → chunk-R4FWZKFA.js} +1 -1
  29. package/{chunk-ZN6UGTUP.js → chunk-TMLYEZEQ.js} +1 -1
  30. package/{chunk-FZKRXZIZ.js → chunk-TN7X7OZD.js} +1 -1
  31. package/{chunk-QWB3Q3X3.js → chunk-UFOCUTLN.js} +1 -1
  32. package/{chunk-ZLOF7AUP.js → chunk-VX7YLWTK.js} +1 -1
  33. package/{chunk-MKJOFE4P.js → chunk-VYZZWZPY.js} +1 -1
  34. package/{chunk-NAJL2GCA.js → chunk-W47H5WHD.js} +1 -1
  35. package/{chunk-WQQKFPTA.js → chunk-YRE3NGCE.js} +1 -1
  36. package/{chunk-5CE5EQ5I.js → chunk-Z7JR4TW6.js} +1 -1
  37. package/{chunk-N366MN5J.js → chunk-ZH5R4MP6.js} +1 -1
  38. package/package.json +1 -1
  39. package/velt-activity-log.js +1 -1
  40. package/velt-area.js +1 -1
  41. package/velt-arrow.js +1 -1
  42. package/velt-comment.js +7 -7
  43. package/velt-crdt.js +1 -1
  44. package/velt-cursor.js +1 -1
  45. package/velt-huddle.js +1 -1
  46. package/velt-live-state-sync.js +1 -1
  47. package/velt-notification.js +1 -1
  48. package/velt-portable.js +1 -1
  49. package/velt-presence.js +1 -1
  50. package/velt-reaction.js +1 -1
  51. package/velt-recorder.js +1 -1
  52. package/velt-rewriter.js +1 -1
  53. package/velt-selection.js +1 -1
  54. package/velt-tag.js +1 -1
  55. package/velt-user-invite.js +1 -1
  56. package/velt-user-request.js +1 -1
  57. package/velt-video-player.js +1 -1
  58. package/velt-views.js +1 -1
  59. package/velt.js +2 -2
  60. package/chunk-FXHOBF24.js +0 -1
  61. package/chunk-S3ZS5EPV.js +0 -1
package/velt-views.js CHANGED
@@ -1,3 +1,3 @@
1
- import{t as dt}from"./chunk-5CE5EQ5I.js";import"./chunk-N366MN5J.js";import"./chunk-S5U5EJSH.js";import{a as We,c as Je,d as Ke}from"./chunk-2GJ6LQGO.js";import{a as gt}from"./chunk-NEJKRV3M.js";import"./chunk-UYR6HRGI.js";import{a as ct}from"./chunk-Y7EFNXLS.js";import{a as vt}from"./chunk-NAJL2GCA.js";import"./chunk-FZKRXZIZ.js";import"./chunk-3ETDYFCP.js";import{b as at,d as lt}from"./chunk-4OP5FRJZ.js";import{a as mt}from"./chunk-FXHOBF24.js";import{a as Re}from"./chunk-VTMNUIEK.js";import{A as Fe,Fa as rt,G as Ne,H as Le,Ha as st,I as Me}from"./chunk-PS5CHEBA.js";import{a as ut}from"./chunk-T3JQYK3N.js";import{B as ot,C as ve,h as ge}from"./chunk-2TBFGTFV.js";import{$j as ue,Bb as x,E as B,Ej as Se,G as De,Gd as je,Gi as ye,Ha as h,Hc as ze,He as E,Ia as re,Ic as le,Ji as Ze,Jj as z,K as te,Kb as se,M as q,Mb as ae,Mj as tt,O as xe,Pb as _,Qb as K,Ra as I,Rb as R,Rc as Pe,Sj as it,Tb as Te,U as _e,V as S,Va as Ue,Vd as qe,Wa as Q,Wd as Ge,Xa as ke,Y as Ee,Yi as fe,Zf as we,_ as ie,a as m,ab as T,ak as nt,b as y,ba as Oe,bi as Qe,ca as Be,cc as $e,di as de,ea as k,g as j,ja as F,jj as Xe,ka as N,l as $,la as H,ma as Y,mc as A,mj as me,nb as D,nc as U,ob as v,oj as C,pb as w,pj as et,qb as L,qe as He,r as b,rc as ce,sa as ne,t as Ce,ub as G,v as f,vb as W,w as Z,wa as Ae,xb as J,xg as Ye,ya as oe,zb as M}from"./chunk-U76HLU2G.js";var P=(()=>{let c=class c{constructor(e,t,n,i,o,a,l,s,u,p){this.afAuth=e,this.authService=t,this.configService=n,this.databaseService=i,this.docService=o,this.commonDbService=a,this.iamService=l,this.loggingService=s,this.userPermissionService=u,this.serviceBook=p,this.documentPaths=null,this.views$=new $({}),this.commentViews$=new $({}),this.documentViews$=new $({}),this.locationViews$=new $({}),this.commentViewsByOrganizationIdAndDocumentId$=new $({}),this.documentViewsByOrganizationIdAndDocumentId$=new $({}),this.locationViewsByOrganizationIdAndLocationId$=new $({}),this.documentViewsEnabled$=new $(!1),this.documentViewsSetByDocumentId={},this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: ViewsService","color: blue;");try{this.serviceBook.observe(fe).subscribe(g=>{this.commentService=g??void 0}),this.serviceBook.observe(Ze).subscribe(g=>{this.notificationService=g??null}),this.viewsDbReadyGate$().pipe(te(1)).subscribe(()=>{this.subscribeViewsData().subscribe(),this.getNotificationFeatureViews$().subscribe(g=>{this.notificationService?.setNotificationViews(g)}),this.authService.getUser$().pipe(B(g=>!!g),S(g=>this.documentViewsEnabled$.pipe(B(V=>V),f(()=>g))),S(g=>this.docService.getDocumentPaths$().pipe(_e(null),xe(),f(([V,O])=>(V?.documentId!==O?.documentId&&this.views$.next({}),O)),f(V=>(this.documentPaths=V,this.setDocumentAsRead({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),{_user:g,_documentPaths:V})),S(V=>this.docService.getDocumentIds$().pipe(S(O=>(O?.length&&(O.find(ee=>ee.documentId===this.documentPaths?.documentId)||O.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),O.forEach(ee=>{this.setDocumentAsRead({documentId:ee.documentId,clientDocumentId:ee.clientDocumentId})})),b(V))))))),S(g=>this.docService.getDocumentMetadata$().pipe(B(V=>!!V),f(V=>y(m({},g),{_documentMetadata:V}))))).subscribe(),this.authService.getUser$().pipe(B(g=>!!g),S(g=>this.documentViewsEnabled$.pipe(B(V=>V),f(()=>g))),S(g=>this.docService.getLocation$().pipe(B(V=>!!V))),S(g=>this.docService.getDocumentIds$().pipe(S(V=>(V.find(O=>O.documentId===this.documentPaths?.documentId)||V.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),V.forEach(O=>{this.setLocationAsRead({documentId:O.documentId,clientDocumentId:O.clientDocumentId})}),b(g)))))).subscribe()},g=>{this.loggingService.catch("Error in ViewsService getDb subscription: ",g)})}catch(g){this.loggingService.catch("Error in ViewsService constructor: ",g)}}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in ViewsService","color: green;");try{this.documentPaths=null,this.documentViews$.next({}),this.views$.next({}),this.commentViews$.next({}),this.locationViews$.next({}),this.commentViewsByOrganizationIdAndDocumentId$.next({}),this.documentViewsByOrganizationIdAndDocumentId$.next({}),this.locationViewsByOrganizationIdAndLocationId$.next({})}catch(e){this.loggingService.catch("Error in ViewsService clearCache: ",e)}}subscribeViewsData(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let n,i;try{if(e&&(i=we(e)),t&&typeof t=="object"){let o=Ye(t);n=we(JSON.stringify(o))}}catch(o){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",o)}return this.authService.getAuthState$().pipe(B(o=>!!o),S(o=>this.isFeatureAllowed({firebaseUser:o})),S(o=>o.featureAllowed?this.iamService.isUserAllowed$().pipe(f(a=>(o.featureAllowed=a,o))):b(o)),S(o=>o.featureAllowed?b(o).pipe(S(a=>this.docService.getDocumentPaths$().pipe(f(l=>(this.documentPaths=l,a.documentPaths=l,a)))),S(a=>i?this.getDataFromDocumentIds([i]):this.docService.getDocumentIds$().pipe(S(l=>{let s=l?.length>0?l.map(u=>u.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(s)})))):b([])))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(B(t=>!!t),f(t=>y(m({},e),{config:t})),S(t=>this.authService.getUser$().pipe(f(n=>y(m({},t),{user:n})))),S(t=>t.user?b(y(m({},t),{featureAllowed:!0})):b(y(m({},t),{featureAllowed:!1}))),q((t,n)=>t?.featureAllowed===n?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getCommentViewsById(e){try{return this.commentViews$.value?.[e]?this.commentViews$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in ViewsService getCommentViewsById: ",t);return}}getDocumentViewsById(e){try{return this.documentViews$.value?.[e]}catch(t){this.loggingService.catch("Error in ViewsService getDocumentViewsById: ",t);return}}getLocationViewsById(e){try{return this.locationViews$.value?.[e]}catch(t){this.loggingService.catch("Error in ViewsService getLocationViewsById: ",t);return}}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t,filters:n}=e;return t?.some(i=>!i)||!this.documentPaths?b([]):this.documentViewsEnabled$.pipe(S(i=>i?Z([this.getCommentViewsDataFromDocuments(),this.getDocumentViewsDataFromDocuments(t),this.getLocationViewsDataFromDocuments(t)]):Z([this.getCommentViewsDataFromDocuments()])))}else return b(null)}getCommentViews(e){try{let t={};Object.entries(e??{}).forEach(([n,i])=>{let o=i.metadata?.documentId,a=i.views;!o||!a||(t[o]||(t[o]={}),t[o][i.annotationId]=a)}),Object.entries(t??{}).forEach(([n,i])=>{this.setCommentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:n,commentViews:i})})}catch(t){this.loggingService.catch("Error in ViewsService getCommentViews: ",t)}}getCommentViewsDataFromDocuments(){try{return this.serviceBook.observe(fe).pipe(q(),S(e=>{if(!e)return b([]);try{return e.getAllCommentAnnotations({detectGhostComments:!0,addFilterCommentsOnDomCheck:!0,fromCommentSidebar:!0,skipPositionCalculation:!0,analytics:{enabled:!0,properties:{source:"internal",sourceId:"commentsContainer"}}}).pipe(B(t=>!!t),Ee(t=>{this.getCommentViews(t)}),De(t=>(this.loggingService.catch("Error in ViewsService getCommentViewsDataFromDocuments: ",t),b([]))))}catch(t){return this.loggingService.catch("Error in ViewsService getCommentViewsDataFromDocuments: ",t),b([])}}))}catch(e){return this.loggingService.catch("Error in ViewsService getCommentViewsDataFromDocuments: ",e),b([])}}viewsDbReadyGate$(){return it({isPortableFeedActive:()=>this.commonDbService?.usesPortableChannelFeed(ge),firebaseDb$:()=>this.databaseService.getDb(),onError:(e,t)=>this.loggingService.catch(`Error in ViewsService viewsDbReadyGate$ ${e}: `,t)})}getDocumentViewsDataFromDocuments(e){let t=this.docService.getDocumentPaths()?.veltFolderId,n=b([]),i={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(i.documentId=e?.length?e[0]:void 0,i.organizationId=this.documentPaths?.organizationId),this.commonDbService.usesPortableChannelFeed(ge))n=this.commonDbService.dbListener({feature:"allDocumentViews",properties:y(m({},i),{organizationId:this.documentPaths?.organizationId,documentIds:e})}).pipe(ie(),f(o=>de(JSON.parse(JSON.stringify([o])))));else{let o=[];for(let a=0;a<(e?.length??0);a+=E.LISTENER_BATCH_SIZE)o.push(e?.slice(a,a+E.LISTENER_BATCH_SIZE)??[]);n=Z(o.map(a=>this.commonDbService.dbListener({feature:"allDocumentViews",properties:y(m({},i),{firestoreQuery:[Se(z("metadata.apiKey","==",this.configService?.getApiKey()),z("metadata.documentId","in",a),z("metadata.organizationId","==",this.documentPaths?.organizationId),...t?[z("metadata.veltFolderId","==",t)]:[])]})}).pipe(ie()))).pipe(f(a=>de(a)))}return n.pipe(f(o=>({data:o?.data,operation:o?.operation})),f(({data:o,operation:a})=>{let l={};return e?(Object.entries(o??{}).forEach(([s,u])=>{let p=u.metadata?.documentId;p&&(l[p]||(l[p]={}),l[p][s]=u)}),{data:o,documentMap:l,operation:a}):{data:o,documentMap:l,operation:a}}),f(({data:o,documentMap:a,operation:l})=>{if(l?.type==="removed"){if(l?.ids?.length){let s=this.documentViews$.value;l?.ids?.forEach(u=>{delete s?.[u]}),this.documentViews$.next(s)}}else Object.entries(a??{}).forEach(([s,u])=>{this.setDocumentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:s,documentViews:u})})}))}getLocationViewsDataFromDocuments(e){let t=this.docService.getDocumentPaths()?.veltFolderId,n=b([]),i={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(i.documentId=e?.length?e[0]:void 0,i.organizationId=this.documentPaths?.organizationId);let o=[];for(let a=0;a<(e?.length??0);a+=E.LISTENER_BATCH_SIZE)o.push(e?.slice(a,a+E.LISTENER_BATCH_SIZE)??[]);return n=Z(o.map(a=>this.commonDbService.dbListener({feature:"allLocationViews",properties:y(m({},i),{firestoreQuery:[Se(z("metadata.apiKey","==",this.configService?.getApiKey()),z("metadata.documentId","in",a),z("metadata.organizationId","==",this.documentPaths?.organizationId),...t?[z("metadata.veltFolderId","==",t)]:[])]})}).pipe(ie()))).pipe(f(a=>de(a))),n.pipe(f(a=>({data:a?.data,operation:a?.operation})),f(({data:a,operation:l})=>{let s={};return e?(Object.entries(a??{}).forEach(([u,p])=>{let g=p.metadata?.documentId;g&&(s[g]||(s[g]={}),s[g][u]=p)}),{data:a,documentMap:s,operation:l}):{data:a,documentMap:s,operation:l}}),f(({data:a,documentMap:l,operation:s})=>{if(s?.type==="removed"){if(s?.ids?.length){let u=this.locationViews$.value;s?.ids?.forEach(p=>{delete u?.[p]}),this.locationViews$.next(u)}}else Object.entries(l??{}).forEach(([u,p])=>{this.setLocationViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:u,locationViews:p})})}))}setViewsData(e){try{this.views$.next(m(m({},this.views$.getValue()),e||{}))}catch(t){this.loggingService.catch("Error in ViewsService setViewsData:",t)}}setCommentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,commentViews:n,queryHash:i}){try{if(n||(n={}),t){e||(e=E.NO_ORGANIZATION_ID),i||(i=E.DEFAULT_QUERY_HASH);let o=m(m({},this.commentViews$.value),n);this.commentViews$.next(o),this.commentViewsByOrganizationIdAndDocumentId$.next(y(m({},this.commentViewsByOrganizationIdAndDocumentId$.value),{[e]:y(m({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]),{[t]:y(m({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]?.[t]),{[i]:n})})}))}}catch(o){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",o)}}setDocumentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,documentViews:n,queryHash:i}){try{if(n||(n={}),t){e||(e=E.NO_ORGANIZATION_ID),i||(i=E.DEFAULT_QUERY_HASH);let o=m(m({},this.documentViews$.value),n);this.documentViews$.next(o),this.documentViewsByOrganizationIdAndDocumentId$.next(y(m({},this.documentViewsByOrganizationIdAndDocumentId$.value),{[e]:y(m({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]),{[t]:y(m({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]?.[t]),{[i]:n})})}))}}catch(o){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",o)}}setLocationViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,locationViews:n,queryHash:i}){try{if(n||(n={}),t){e||(e=E.NO_ORGANIZATION_ID),i||(i=E.DEFAULT_QUERY_HASH);let o=m(m({},this.locationViews$.value),n);this.locationViews$.next(o),this.locationViewsByOrganizationIdAndLocationId$.next(y(m({},this.locationViewsByOrganizationIdAndLocationId$.value),{[e]:y(m({},this.locationViewsByOrganizationIdAndLocationId$.value[e]),{[t]:y(m({},this.locationViewsByOrganizationIdAndLocationId$.value[e]?.[t]),{[i]:n})})}))}}catch(o){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",o)}}getCommentFeatureViews$(){return this.commentViews$.pipe(q((e,t)=>JSON.stringify(e||{})===JSON.stringify(t||{})))}setCommentAnnotationAsRead(e){return j(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){if(e.annotationId.startsWith("TEMP_COMPOSER_"))return;this.updateCommentAnnotationViews(e);let n=e?.metadata?.organizationId??this.documentPaths?.organizationId??"",i=e?.metadata?.documentId??this.documentPaths?.documentId??"";if(e?.isDraft)return;yield this.commonDbService.setData({feature:"comment",properties:{id:e.annotationId,documentId:i,organizationId:n,metadata:{apiKey:this.configService.getApiKey(),organizationId:n,veltFolderId:e?.metadata?.veltFolderId,documentId:i}},data:JSON.parse(JSON.stringify(e))})}}catch(t){this.loggingService.catch("Error in ViewsService setCommentAnnotationAsRead:",t)}})}setCommentAnnotationAsUnread(e){return j(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){if(e.annotationId.startsWith("TEMP_COMPOSER_"))return;this.removeCommentAnnotationViews(e);let n=e?.metadata?.organizationId??this.documentPaths?.organizationId??"",i=e?.metadata?.documentId??this.documentPaths?.documentId??"";if(e?.isDraft)return;yield this.commonDbService.setData({feature:"comment",properties:{id:e.annotationId,documentId:i,organizationId:n,metadata:{apiKey:this.configService.getApiKey(),organizationId:n,veltFolderId:e?.metadata?.veltFolderId,documentId:i}},data:JSON.parse(JSON.stringify(e))})}}catch(t){this.loggingService.catch("Error in ViewsService setCommentAnnotationAsRead:",t)}})}updateCommentAnnotationViews(e){try{let t=this.authService.getUser(),n={views:{},comments:{}};if(t){let i={},o=e?.views?.comments||{},a=new Date().getTime()+this.commonDbService.getOffset();e.comments?.forEach(s=>{o[s.commentId]||(o[s.commentId]={views:{}}),o[s.commentId].views||(o[s.commentId].views={}),o[s.commentId].views[t.userSnippylyId]||(o[s.commentId].views[t.userSnippylyId]={timestamp:a})});let l=new Set(e.comments?.map(s=>s.commentId+""));if(Object.keys(o??{}).forEach(s=>{l.has(s)||delete o[s]}),e.comments?.length){let s=o[e.comments[0].commentId]?.views||{},u=Object.keys(s??{}).filter(p=>e.comments?.every(g=>o[g.commentId]?.views?.[p]));u.forEach(p=>{i[p]={timestamp:s[p].timestamp}}),e.viewedByUserIds=u}n.views=i,n.comments=o,e.views=n}return n}catch(t){return this.loggingService.catch("Error in ViewsService updateCommentAnnotationViews:",t),{views:{},comments:{}}}}removeCommentAnnotationViews(e){try{let t=this.authService.getUser(),n={views:{},comments:{}};if(t){let i={},o=e?.views?.comments||{};e.comments?.forEach(l=>{o[l.commentId]?.views?.[t.userSnippylyId]&&delete o[l.commentId].views[t.userSnippylyId]});let a=new Set(e.comments?.map(l=>l.commentId+""));if(Object.keys(o??{}).forEach(l=>{a.has(l)||delete o[l]}),e.comments?.length){let l=o[e.comments[0].commentId]?.views||{},s=Object.keys(l??{}).filter(u=>e.comments?.every(p=>o[p.commentId]?.views?.[u]));s.forEach(u=>{i[u]={timestamp:l[u].timestamp}}),e.viewedByUserIds=s}else e.viewedByUserIds=[];n.views=i,n.comments=o,e.views=n}return n}catch(t){return this.loggingService.catch("Error in ViewsService removeCommentAnnotationViews:",t),{views:{},comments:{}}}}getNotificationFeatureViews$(){return this.views$.pipe(q((e,t)=>JSON.stringify(e?.notification||{})===JSON.stringify(t?.notification||{})))}setNotificationsAsRead(e){try{let t=this.authService.getUser();if(t){let n=new Date().getTime()+this.commonDbService.getOffset();e.forEach(i=>{this.commonDbService.updateData({feature:"notificationViewsTimestamp",properties:{id:i,user:t.userSnippylyId,documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??""},data:{timestamp:n}})})}}catch(t){this.loggingService.catch("Error in ViewsService setNotificationAsRead:",t)}}getDocumentViews$(){return this.views$.pipe(q((e,t)=>JSON.stringify(e?.documentViews||{})===JSON.stringify(t?.documentViews||{})))}getUniqueViewsByUser(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(S(t=>(this.documentPaths=t,e?this.locationViews$.pipe(f(n=>{let i=Object.keys(n||{}).find(o=>n?.[o]?.location?.id===e);return i?n?.[i]?.users||{}:{}})):this.documentViews$.pipe(f(n=>{let i=this.documentPaths?.documentId;return i?n?.[i]?.users||{}:{}})))),q(Qe))}catch(t){return this.loggingService.catch("Error in ViewsService getUniqueViewsByUser:",t),b({})}}getUniqueViewsByDate(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(S(t=>(this.documentPaths=t,e?this.locationViews$.pipe(f(n=>{let i=Object.keys(n||{}).find(o=>n?.[o]?.location?.id===e);return i?n?.[i]?.day||{}:{}})):this.documentViews$.pipe(f(n=>{let i=this.documentPaths?.documentId;return i?n?.[i]?.day||{}:{}})))))}catch(t){return this.loggingService.catch("Error in ViewsService getUniqueViewsByDate:",t),b({})}}enableDocumentViews(){try{if(this.documentViewsEnabled$.value===!0)return;this.documentViewsEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in ViewsService enableDocumentViews:",e)}}disableDocumentViews(){try{if(this.documentViewsEnabled$.value===!1)return;this.documentViewsEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in ViewsService disableDocumentViews:",e)}}setDocumentAsRead(n){return j(this,arguments,function*({documentId:e,clientDocumentId:t}){try{let i=this.authService.getUser();if(i&&e&&this.userPermissionService?.hasEditAccess({documentId:e??"",folderId:this.documentPaths?.allDocuments&&this.documentPaths?.veltFolderId?this.documentPaths?.veltFolderId:void 0})){if(this.documentViewsSetByDocumentId[e])return;this.documentViewsSetByDocumentId[e]=!0;let o=new Date().getTime()+this.commonDbService.getOffset(),a=new Date().toISOString().split("T")[0];if(this.commonDbService.usesPortableChannelFeed(ge)){let s=yield Ce(this.docService.getDocumentPaths$().pipe(f(u=>u?.organizationId),B(u=>!!u)));yield this.commonDbService.whenPortableRealtimeReady(),this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:a,user:i.userSnippylyId,documentId:e,organizationId:s},data:{}}),this.checkAndTriggerNotification(i);return}let l=this.getDocumentViewsById(e);if(l){let s=new Date().toISOString().split("T")[0];l?.users[i.userSnippylyId]||(l.users[i.userSnippylyId]={}),l.users[i.userSnippylyId][s]={timestamp:this.timestamp},l?.day[s]||(l.day[s]={}),l.day[s][i.userSnippylyId]={timestamp:this.timestamp},l.metadata=this.docService.getBaseMetadata("documentViews",{clientDocumentId:t}),this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:s,user:i.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??""},data:l})}else this.commonDbService.updateData({feature:"documentDayViews",properties:{id:e,date:a,user:i.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:o}}),this.commonDbService.updateData({feature:"documentUsersViews",properties:{id:e,user:i.userSnippylyId,date:a,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:o}}),this.commonDbService.updateData({feature:"documentMetadataViews",properties:{id:e,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:this.docService.getBaseMetadata("documentViews",{clientDocumentId:t})}),this.docService.getDocumentMetadata$(e).pipe(B(s=>s!==null),te(1)).subscribe(()=>{let s={day:{[a]:{[i.userSnippylyId]:{timestamp:o}}},users:{[i.userSnippylyId]:{[a]:{timestamp:o}}},metadata:this.docService.getBaseMetadata("documentViews",{clientDocumentId:t})};this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:a,user:i.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0},data:s})});this.checkAndTriggerNotification(i)}}catch(i){this.loggingService.catch("Error in ViewsService setDocumentAsRead:",i)}})}checkAndTriggerNotification(e){try{this.getUniqueViewsByUser().pipe(te(1)).subscribe(t=>{if(Object.keys(t??{}).length===2){let n=this.docService.getDocumentMetadata();if(n?.creator?.email&&n?.creator?.email!==e.email){let i=[n.creator.email];this.updateNotificationsDatabase(He.FIRST_VIEWED,{documentViews:{emails:i}})}}})}catch(t){this.loggingService.catch("Error in checkAndTriggerNotification:",t)}}setLocationAsRead(n){return j(this,arguments,function*({documentId:e,clientDocumentId:t}){try{let i=this.authService.getUser(),o=this.docService.getLocation(),a=o?.locationId,l=o?.location;if(i&&a&&l){let s=new Date().getTime()+this.commonDbService.getOffset(),u=new Date().toISOString().split("T")[0],p=this.getLocationViewsById(a);if(p){let g=new Date().toISOString().split("T")[0];p?.users[i.userSnippylyId]||(p.users[i.userSnippylyId]={}),p.users[i.userSnippylyId][g]={timestamp:this.timestamp},p?.day[g]||(p.day[g]={}),p.day[g][i.userSnippylyId]={timestamp:this.timestamp},p.metadata=this.docService.getBaseMetadata("locationViews",{clientDocumentId:t}),this.commonDbService.updateData({feature:"location",data:p,properties:{id:a,documentId:e,organizationId:this.documentPaths?.organizationId??""}})}else{this.commonDbService.updateData({feature:"locationViews",data:l,properties:{id:a,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}}),this.commonDbService.updateData({feature:"locationUsersViews",properties:{id:a,user:i.userSnippylyId,date:u,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:s}}),this.commonDbService.updateData({feature:"locationDayViews",properties:{id:a,date:u,user:i.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:s}}),this.commonDbService.updateData({feature:"locationMetadataViews",properties:{id:a,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:this.docService.getBaseMetadata("locationViews",{clientDocumentId:t})});let g={day:{[u]:{[i.userSnippylyId]:{timestamp:s}}},users:{[i.userSnippylyId]:{[u]:{timestamp:s}}},metadata:this.docService.getBaseMetadata("locationViews",{clientDocumentId:t}),location:l};this.commonDbService.updateData({feature:"location",data:g,properties:{id:a,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0}})}}}catch(i){this.loggingService.catch("Error in ViewsService setLocationAsRead:",i)}})}updateNotificationsDatabase(e,t={}){try{let n=m({actionType:e,notificationSource:"documentViews"},t);this.notificationService?.updateNotificationDatabase(n)}catch(n){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",n)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};c.\u0275fac=function(t){return new(t||c)(k(je),k(nt),k(et),k(tt),k(ve),k(ot),k(mt),k(C),k(gt),k(me))},c.\u0275prov=Oe({token:c,factory:c.\u0275fac,providedIn:"root"});let d=c;return d})();function St(d,c){if(d&1&&(G(0),v(1,"div",21)(2,"div",22),L(3,"snippyly-user-avatar",23),w(),v(4,"div",24)(5,"div",25),_(6),A(7,"translate"),w()(),v(8,"div",26),_(9),A(10,"timeAgo"),w()(),W()),d&2){let r=c.$implicit;h(3),D("user",r==null?null:r.user)("size",32),h(3),R(" ",U(7,4,(r==null||r.user==null?null:r.user.name)||(r==null||r.user==null?null:r.user.email))," "),h(3),R(" ",U(10,6,r==null?null:r.timestamp)," ")}}function bt(d,c){if(d&1&&(v(0,"div",19),T(1,St,11,8,"ng-container",20),w()),d&2){let r=x(2).ngIf;h(),D("ngForOf",r.userViews)}}function Vt(d,c){if(d&1){let r=J();G(0),v(1,"div",4)(2,"button",5),M("click",function(){F(r);let t=x(2);return N(t.closeTrendDialog())}),H(),v(3,"svg",6),L(4,"path",7),w(),Y(),v(5,"span"),_(6),A(7,"translate"),w()()(),v(8,"div",8)(9,"div",9)(10,"div",10),_(11),w(),v(12,"div",11),H(),v(13,"svg",12),L(14,"path",13)(15,"path",14),w(),Y(),v(16,"span"),_(17),A(18,"translate"),w()()(),v(19,"div",15)(20,"div",16),_(21),w(),v(22,"div",17)(23,"span"),_(24),A(25,"translate"),w()()()(),T(26,bt,2,1,"div",18),W()}if(d&2){let r=x().ngIf;h(6),K(U(7,6,"Go Back")),h(5),R(" ",r.totalUniqueViewsCount," "),h(6),K(U(18,8,"Total Views")),h(4),R(" ",r.todayViewsCount," "),h(3),K(U(25,10,"Views Today")),h(2),D("ngIf",r.userViews==null?null:r.userViews.length)}}function It(d,c){if(d&1&&(G(0),v(1,"div",21)(2,"div",22),L(3,"snippyly-user-avatar",23),w(),v(4,"div",24)(5,"div",25),_(6),A(7,"translate"),w(),v(8,"div",26),_(9),A(10,"timeAgo"),w()()(),W()),d&2){let r=c.$implicit;h(3),D("user",r==null?null:r.user)("size",32),h(3),R(" ",U(7,4,(r==null||r.user==null?null:r.user.name)||(r==null||r.user==null?null:r.user.email))," "),h(3),R(" ",U(10,6,r==null?null:r.timestamp)," ")}}function Ct(d,c){if(d&1&&(v(0,"div",29)(1,"div",19),T(2,It,11,8,"ng-container",20),w()()),d&2){let r=x(2).ngIf;h(2),D("ngForOf",r.userViews)}}function Dt(d,c){if(d&1&&(v(0,"div",27)(1,"div",9)(2,"div",10),_(3),w(),v(4,"div",11),H(),v(5,"svg",12),L(6,"path",13)(7,"path",14),w(),Y(),v(8,"span"),_(9),A(10,"translate"),w()()(),v(11,"div",15),_(12),A(13,"translate"),A(14,"translate"),A(15,"translate"),w()(),T(16,Ct,3,1,"div",28)),d&2){let r=x().ngIf;h(3),R(" ",r.totalUniqueViewsCount," "),h(6),K(U(10,6,"Total Views")),h(3),Te(" ",r.todayViewsCount," ",r.todayViewsCount===1?U(13,8,"View"):U(14,10,"Views")," ",U(15,12,"Today")," "),h(4),D("ngIf",r.userViews==null?null:r.userViews.length)}}function xt(d,c){if(d&1){let r=J();G(0),v(1,"div",2),M("clickOutside",function(){F(r);let t=x();return N(t.closeTrendDialog())}),T(2,Vt,27,12,"ng-container",3)(3,Dt,17,14,"ng-template",null,0,ce),w(),W()}if(d&2){let r=c.ngIf,e=se(4);h(),ae("bottom-sheet",r.bottomSheetMode),h(),D("ngIf",r.bottomSheetMode)("ngIfElse",e)}}var X=(()=>{let c=class c{constructor(e,t,n,i,o,a,l){this.contactService=e,this.loggingService=t,this.viewsService=n,this.themeService=i,this.elementRef=o,this.domService=a,this.bottomSheetData=l,this.close=new re,this.componentConfigSignal=ne({today:new Date().toISOString().split("T")[0],todayViews:{},todayViewsCount:0,totalUniqueViews:{},totalUniqueViewsCount:0,views:{},usersMap:{},userViews:[],bottomSheetMode:!1}),this.subscriptions=[];try{l&&(this.componentConfigSignal.update(s=>(s=y(m({},s),{bottomSheetMode:!0}),s)),this.clientLocationId=l.clientLocationId,this.closeBottomSheetFn=l.closeBottomSheetFn),this.subscriptions.push(this.contactService.getUsersMap$().subscribe(s=>{this.componentConfigSignal.update(u=>(u=y(m({},u),{usersMap:s||{}}),u)),this.setLatestViewsByUsers()},s=>{this.loggingService.catch("Error in ViewAnalyticsDialogComponent getUsersMap$ subscription: ",s)})),this.subscriptions.push(this.themeService.getDarkMode$().subscribe(s=>{s?this.elementRef.nativeElement.setAttribute("dark",""):this.elementRef.nativeElement.removeAttribute("dark")}))}catch(s){this.loggingService.catch("Error in ViewAnalyticsDialogComponent constructor: ",s)}}ngOnInit(){this.getDocumentViews()}ngAfterViewInit(){try{this.subscriptions.push(this.domService.subscribeInjectCustomCss(this.elementRef))}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent ngAfterViewInit: ",e)}}trackByUserIdAndTimestamp(e,t){return`${t?.user?.userSnippylyId}-${t.timestamp}`}getDocumentViews(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentViews","color: green;"),this.uniqueViewsByUserSubscription&&(this.componentConfigSignal.update(e=>(e=y(m({},e),{totalUniqueViews:{},totalUniqueViewsCount:0}),e)),this.uniqueViewsByUserSubscription.unsubscribe()),this.uniqueViewsByDateSubscription&&(this.componentConfigSignal.update(e=>(e=y(m({},e),{todayViews:{},todayViewsCount:0}),e)),this.uniqueViewsByDateSubscription.unsubscribe()),this.uniqueViewsByUserSubscription=this.viewsService.getUniqueViewsByUser(this.clientLocationId).subscribe(e=>{this.componentConfigSignal.update(t=>(t=y(m({},t),{totalUniqueViews:e||{},totalUniqueViewsCount:Object.keys(e||{})?.length||0}),t)),this.setLatestViewsByUsers()},e=>{this.loggingService.catch("Error in ViewAnalyticsDialogComponent getUniqueViewsByUser subscription: ",e)}),this.uniqueViewsByDateSubscription=this.viewsService.getUniqueViewsByDate(this.clientLocationId).subscribe(e=>{this.componentConfigSignal.update(t=>(t=m({},t),t.todayViews=e&&e[t.today]?e[t.today]:{},t.todayViewsCount=Object.keys(t.todayViews||{})?.length||0,t)),this.setLatestViewsByUsers()},e=>{this.loggingService.catch("Error in ViewAnalyticsDialogComponent getUniqueViewsByDate subscription: ",e)})}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent getDocumentViews: ",e)}}setLatestViewsByUsers(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLatestViewsByUsers","color: green;"),Object.keys(this.componentConfigSignal().todayViews||{}).forEach(e=>{let t=this.componentConfigSignal().usersMap[e],n=this.componentConfigSignal().todayViews[e]?.timestamp;t&&n&&(this.componentConfigSignal().userViews.find(o=>o.user.userSnippylyId===e)||this.componentConfigSignal.update(o=>(o=y(m({},o),{userViews:[...o.userViews,{user:t,timestamp:n}]}),o)))}),this.componentConfigSignal.update(e=>(e=m({},e),e.userViews.sort((t,n)=>n.timestamp-t.timestamp),e.userViews=e.userViews.slice(0,3),e))}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent setLatestViewsByUsers: ",e)}}closeTrendDialog(){try{this.close.emit(),this.closeBottomSheetFn&&this.closeBottomSheetFn?.()}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent onClose: ",e)}}ngOnDestroy(){try{this.subscriptions.forEach(e=>{e.unsubscribe()}),this.uniqueViewsByDateSubscription?.unsubscribe(),this.uniqueViewsByUserSubscription?.unsubscribe()}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent ngOnDestroy: ",e)}}};c.\u0275fac=function(t){return new(t||c)(I(rt),I(C),I(P),I(st),I(oe),I(ue),I(We,8))},c.\u0275cmp=Q({type:c,selectors:[["velt-view-analytics-dialog"]],inputs:{clientLocationId:"clientLocationId"},outputs:{close:"close"},standalone:!1,decls:1,vars:1,consts:[["defaultDialogRef",""],[4,"ngIf"],["snippylyClickOutside","",1,"v-view-analytics-dialog-container",3,"clickOutside"],[4,"ngIf","ngIfElse"],[1,"v-back-btn-container"],[1,"v-back-btn",3,"click"],["width","16","height","16","viewBox","0 0 16 16","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M9.99988 4L5.99988 8L9.99988 12","stroke","currentColor","stroke-width","1.33333","stroke-linecap","round","stroke-linejoin","round"],[1,"v-view-analytics-count-container"],[1,"v-total-views-container"],[1,"v-total-views-count"],[1,"v-total-views-text"],["width","18","height","18","viewBox","0 0 18 18","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M7.5 9C7.5 9.39782 7.65804 9.77936 7.93934 10.0607C8.22064 10.342 8.60218 10.5 9 10.5C9.39782 10.5 9.77936 10.342 10.0607 10.0607C10.342 9.77936 10.5 9.39782 10.5 9C10.5 8.60218 10.342 8.22064 10.0607 7.93934C9.77936 7.65804 9.39782 7.5 9 7.5C8.60218 7.5 8.22064 7.65804 7.93934 7.93934C7.65804 8.22064 7.5 8.60218 7.5 9Z","stroke","#625DF5","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["d","M15.75 9C13.95 12 11.7 13.5 9 13.5C6.3 13.5 4.05 12 2.25 9C4.05 6 6.3 4.5 9 4.5C11.7 4.5 13.95 6 15.75 9Z","stroke","#625DF5","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],[1,"v-today-views-container"],[1,"v-today-views-count"],[1,"v-today-views-text"],["class","v-users-container",4,"ngIf"],[1,"v-users-container"],[4,"ngFor","ngForOf"],[1,"v-user"],[1,"v-user-image"],[3,"user","size"],[1,"v-user-view-details"],[1,"v-user-name"],[1,"v-user-view-time"],[1,"v-document-viewer-tread-left"],["class","v-document-viewer-tread-right",4,"ngIf"],[1,"v-document-viewer-tread-right"]],template:function(t,n){t&1&&T(0,xt,5,4,"ng-container",1),t&2&&D("ngIf",n.componentConfigSignal())},dependencies:[ze,le,ct,lt,at,vt],styles:[`.v-view-analytics-dialog-container{border-radius:var(--legacy-velt-view-analytics-dialog-border-radius);border:var(--legacy-velt-view-analytics-dialog-border);background:var(--legacy-velt-view-analytics-dialog-bg-color);box-shadow:var(--legacy-velt-view-analytics-dialog-box-shadow);padding:var(--legacy-velt-view-analytics-dialog-padding);display:flex;gap:16px}.v-view-analytics-dialog-container .v-document-viewer-tread-left{display:flex;flex-direction:column;gap:4px}.v-view-analytics-dialog-container .v-document-viewer-tread-left .v-total-views-container{width:140px;height:110px;flex-shrink:0;border-radius:8px;background:var(--legacy-velt-view-analytics-dialog-views-container-bg-color);box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:10px}.v-view-analytics-dialog-container .v-document-viewer-tread-left .v-total-views-container .v-total-views-count{color:var(--legacy-velt-view-analytics-dialog-total-views-count-color);font-size:32px;font-style:normal;font-weight:600;line-height:100%}.v-view-analytics-dialog-container .v-document-viewer-tread-left .v-total-views-container .v-total-views-text{color:var(--legacy-velt-view-analytics-dialog-total-views-text-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase;display:flex;gap:4px;align-items:center}.v-view-analytics-dialog-container .v-document-viewer-tread-left .v-today-views-container{display:flex;width:140px;padding:8px 4px;justify-content:center;align-items:center;gap:4px;border-radius:8px;background:var(--legacy-velt-view-analytics-dialog-views-container-bg-color);box-sizing:border-box;color:var(--legacy-velt-view-analytics-dialog-today-views-text-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase}.v-view-analytics-dialog-container .v-document-viewer-tread-right{padding:8px 0}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container{display:inline-flex;flex-direction:column;align-items:flex-start;gap:16px;margin-right:16px}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user{display:flex;align-items:center;gap:12px}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user snippyly-user-avatar{display:flex}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user .v-user-view-details{display:flex;flex-direction:column;gap:8px}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user .v-user-view-details .v-user-name{color:var(--legacy-velt-view-analytics-dialog-user-name-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user .v-user-view-details .v-user-view-time{color:var(--legacy-velt-view-analytics-dialog-user-timestamp-color);font-size:10px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase}.v-view-analytics-dialog-container.bottom-sheet{display:flex;flex-direction:column;border-bottom-left-radius:0;border-bottom-right-radius:0}.v-view-analytics-dialog-container.bottom-sheet .v-back-btn-container{display:flex;padding:8px 8px 0}.v-view-analytics-dialog-container.bottom-sheet .v-back-btn-container .v-back-btn{background:transparent;border:0;outline:0;display:flex;align-items:center;gap:8px;color:var(--legacy-velt-view-analytics-dialog-back-btn-color);cursor:pointer;font-size:16px;font-style:normal;font-weight:400;line-height:normal}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container{display:flex;flex:1;gap:10px}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-total-views-container{display:flex;padding:25px 20px;flex-direction:column;justify-content:center;align-items:center;gap:10px;flex:1 0 0;border-radius:8px;background:var(--legacy-velt-view-analytics-dialog-views-container-bg-color)}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-total-views-container .v-total-views-count{color:var(--legacy-velt-view-analytics-dialog-total-views-count-color);font-size:32px;font-style:normal;font-weight:600;line-height:100%}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-total-views-container .v-total-views-text{color:var(--legacy-velt-view-analytics-dialog-total-views-text-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase;display:flex;gap:4px;align-items:center}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-today-views-container{display:flex;padding:25px 20px;flex-direction:column;justify-content:center;align-items:center;gap:10px;flex:1 0 0;border-radius:8px;background:var(--legacy-velt-view-analytics-dialog-views-container-bg-color)}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-today-views-container .v-today-views-count{color:var(--legacy-velt-view-analytics-dialog-today-views-text-color);font-size:32px;font-style:normal;font-weight:600;line-height:100%}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-today-views-container .v-today-views-text{color:var(--legacy-velt-view-analytics-dialog-today-views-text-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase;display:flex;gap:4px;align-items:center}.v-view-analytics-dialog-container.bottom-sheet .v-users-container{display:inline-flex;flex-direction:column;align-items:flex-start;gap:16px;margin-right:16px}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user{display:flex;align-items:center;gap:12px;width:100%}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user snippyly-user-avatar{display:flex}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user .v-user-view-details{display:flex;flex-direction:column;gap:8px;flex:1}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user .v-user-view-details .v-user-name{color:var(--legacy-velt-view-analytics-dialog-user-name-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user .v-user-view-time{color:var(--legacy-velt-view-analytics-dialog-user-timestamp-color);font-size:10px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase}
1
+ import{t as dt}from"./chunk-Z7JR4TW6.js";import"./chunk-ZH5R4MP6.js";import"./chunk-B3ZPP3EZ.js";import{a as We,c as Je,d as Ke}from"./chunk-JAKGBQ5D.js";import{a as gt}from"./chunk-JPOBXW24.js";import"./chunk-2JSXDPYO.js";import{a as ct}from"./chunk-GB46XS3O.js";import{a as vt}from"./chunk-W47H5WHD.js";import"./chunk-TN7X7OZD.js";import"./chunk-NNZNLREA.js";import{b as at,d as lt}from"./chunk-G3BZ4EU4.js";import{a as mt}from"./chunk-CCZ3WXF4.js";import{a as Re}from"./chunk-LCACRBV3.js";import{A as Fe,Fa as rt,G as Ne,H as Le,Ha as st,I as Me}from"./chunk-NY2Q7SEG.js";import{a as ut}from"./chunk-MEI3IAPO.js";import{C as ot,D as ve,i as ge}from"./chunk-BR7AO7YV.js";import{Bb as x,E as B,Fj as Se,G as De,Gd as je,Gi as ye,Ha as h,Hc as ze,He as E,Ia as re,Ic as le,Ji as Ze,K as te,Kb as se,Kj as z,M as q,Mb as ae,Nj as tt,O as xe,Pb as _,Qb as K,Ra as I,Rb as R,Rc as Pe,Tb as Te,Tj as it,U as _e,V as S,Va as Ue,Vd as qe,Wa as Q,Wd as Ge,Xa as ke,Y as Ee,Yi as fe,Zf as we,_ as ie,a as m,ab as T,b as y,ba as Oe,bi as Qe,bk as ue,ca as Be,cc as $e,ck as nt,di as de,ea as k,g as j,ja as F,jj as Xe,ka as N,l as $,la as H,ma as Y,mc as A,mj as me,nb as D,nc as U,ob as v,oj as C,pb as w,pj as et,qb as L,qe as He,r as b,rc as ce,sa as ne,t as Ce,ub as G,v as f,vb as W,w as Z,wa as Ae,xb as J,xg as Ye,ya as oe,zb as M}from"./chunk-CNB6D3KX.js";var P=(()=>{let c=class c{constructor(e,t,n,i,o,a,l,s,u,p){this.afAuth=e,this.authService=t,this.configService=n,this.databaseService=i,this.docService=o,this.commonDbService=a,this.iamService=l,this.loggingService=s,this.userPermissionService=u,this.serviceBook=p,this.documentPaths=null,this.views$=new $({}),this.commentViews$=new $({}),this.documentViews$=new $({}),this.locationViews$=new $({}),this.commentViewsByOrganizationIdAndDocumentId$=new $({}),this.documentViewsByOrganizationIdAndDocumentId$=new $({}),this.locationViewsByOrganizationIdAndLocationId$=new $({}),this.documentViewsEnabled$=new $(!1),this.documentViewsSetByDocumentId={},this.notificationService=null,this.loggingService.log("%c[WB] Creating CLASS: ViewsService","color: blue;");try{this.serviceBook.observe(fe).subscribe(g=>{this.commentService=g??void 0}),this.serviceBook.observe(Ze).subscribe(g=>{this.notificationService=g??null}),this.viewsDbReadyGate$().pipe(te(1)).subscribe(()=>{this.subscribeViewsData().subscribe(),this.getNotificationFeatureViews$().subscribe(g=>{this.notificationService?.setNotificationViews(g)}),this.authService.getUser$().pipe(B(g=>!!g),S(g=>this.documentViewsEnabled$.pipe(B(V=>V),f(()=>g))),S(g=>this.docService.getDocumentPaths$().pipe(_e(null),xe(),f(([V,O])=>(V?.documentId!==O?.documentId&&this.views$.next({}),O)),f(V=>(this.documentPaths=V,this.setDocumentAsRead({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),{_user:g,_documentPaths:V})),S(V=>this.docService.getDocumentIds$().pipe(S(O=>(O?.length&&(O.find(ee=>ee.documentId===this.documentPaths?.documentId)||O.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),O.forEach(ee=>{this.setDocumentAsRead({documentId:ee.documentId,clientDocumentId:ee.clientDocumentId})})),b(V))))))),S(g=>this.docService.getDocumentMetadata$().pipe(B(V=>!!V),f(V=>y(m({},g),{_documentMetadata:V}))))).subscribe(),this.authService.getUser$().pipe(B(g=>!!g),S(g=>this.documentViewsEnabled$.pipe(B(V=>V),f(()=>g))),S(g=>this.docService.getLocation$().pipe(B(V=>!!V))),S(g=>this.docService.getDocumentIds$().pipe(S(V=>(V.find(O=>O.documentId===this.documentPaths?.documentId)||V.push({documentId:this.documentPaths?.documentId??"",clientDocumentId:this.documentPaths?.clientDocumentId??""}),V.forEach(O=>{this.setLocationAsRead({documentId:O.documentId,clientDocumentId:O.clientDocumentId})}),b(g)))))).subscribe()},g=>{this.loggingService.catch("Error in ViewsService getDb subscription: ",g)})}catch(g){this.loggingService.catch("Error in ViewsService constructor: ",g)}}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in ViewsService","color: green;");try{this.documentPaths=null,this.documentViews$.next({}),this.views$.next({}),this.commentViews$.next({}),this.locationViews$.next({}),this.commentViewsByOrganizationIdAndDocumentId$.next({}),this.documentViewsByOrganizationIdAndDocumentId$.next({}),this.locationViewsByOrganizationIdAndLocationId$.next({})}catch(e){this.loggingService.catch("Error in ViewsService clearCache: ",e)}}subscribeViewsData(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeViewsData","color: green;");let n,i;try{if(e&&(i=we(e)),t&&typeof t=="object"){let o=Ye(t);n=we(JSON.stringify(o))}}catch(o){this.loggingService.catch("Error in ViewsService subscribeViewsData: ",o)}return this.authService.getAuthState$().pipe(B(o=>!!o),S(o=>this.isFeatureAllowed({firebaseUser:o})),S(o=>o.featureAllowed?this.iamService.isUserAllowed$().pipe(f(a=>(o.featureAllowed=a,o))):b(o)),S(o=>o.featureAllowed?b(o).pipe(S(a=>this.docService.getDocumentPaths$().pipe(f(l=>(this.documentPaths=l,a.documentPaths=l,a)))),S(a=>i?this.getDataFromDocumentIds([i]):this.docService.getDocumentIds$().pipe(S(l=>{let s=l?.length>0?l.map(u=>u.documentId):[this.documentPaths?.documentId??""];return this.getDataFromDocumentIds(s)})))):b([])))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(B(t=>!!t),f(t=>y(m({},e),{config:t})),S(t=>this.authService.getUser$().pipe(f(n=>y(m({},t),{user:n})))),S(t=>t.user?b(y(m({},t),{featureAllowed:!0})):b(y(m({},t),{featureAllowed:!1}))),q((t,n)=>t?.featureAllowed===n?.featureAllowed))}getDataFromDocumentIds(e,t){return this.getDataFromDocuments({documentIds:e,filters:t})}getCommentViewsById(e){try{return this.commentViews$.value?.[e]?this.commentViews$.value?.[e]:void 0}catch(t){this.loggingService.catch("Error in ViewsService getCommentViewsById: ",t);return}}getDocumentViewsById(e){try{return this.documentViews$.value?.[e]}catch(t){this.loggingService.catch("Error in ViewsService getDocumentViewsById: ",t);return}}getLocationViewsById(e){try{return this.locationViews$.value?.[e]}catch(t){this.loggingService.catch("Error in ViewsService getLocationViewsById: ",t);return}}getDataFromDocuments(e){if(this.configService?.getApiKey()){let{documentIds:t,filters:n}=e;return t?.some(i=>!i)||!this.documentPaths?b([]):this.documentViewsEnabled$.pipe(S(i=>i?Z([this.getCommentViewsDataFromDocuments(),this.getDocumentViewsDataFromDocuments(t),this.getLocationViewsDataFromDocuments(t)]):Z([this.getCommentViewsDataFromDocuments()])))}else return b(null)}getCommentViews(e){try{let t={};Object.entries(e??{}).forEach(([n,i])=>{let o=i.metadata?.documentId,a=i.views;!o||!a||(t[o]||(t[o]={}),t[o][i.annotationId]=a)}),Object.entries(t??{}).forEach(([n,i])=>{this.setCommentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:n,commentViews:i})})}catch(t){this.loggingService.catch("Error in ViewsService getCommentViews: ",t)}}getCommentViewsDataFromDocuments(){try{return this.serviceBook.observe(fe).pipe(q(),S(e=>{if(!e)return b([]);try{return e.getAllCommentAnnotations({detectGhostComments:!0,addFilterCommentsOnDomCheck:!0,fromCommentSidebar:!0,skipPositionCalculation:!0,analytics:{enabled:!0,properties:{source:"internal",sourceId:"commentsContainer"}}}).pipe(B(t=>!!t),Ee(t=>{this.getCommentViews(t)}),De(t=>(this.loggingService.catch("Error in ViewsService getCommentViewsDataFromDocuments: ",t),b([]))))}catch(t){return this.loggingService.catch("Error in ViewsService getCommentViewsDataFromDocuments: ",t),b([])}}))}catch(e){return this.loggingService.catch("Error in ViewsService getCommentViewsDataFromDocuments: ",e),b([])}}viewsDbReadyGate$(){return it({isPortableFeedActive:()=>this.commonDbService?.usesPortableChannelFeed(ge),firebaseDb$:()=>this.databaseService.getDb(),onError:(e,t)=>this.loggingService.catch(`Error in ViewsService viewsDbReadyGate$ ${e}: `,t)})}getDocumentViewsDataFromDocuments(e){let t=this.docService.getDocumentPaths()?.veltFolderId,n=b([]),i={useCollectionGroup:!0,isCollection:!0,useQuery:!0};if(this.commonDbService.shouldUseFirestore()||(i.documentId=e?.length?e[0]:void 0,i.organizationId=this.documentPaths?.organizationId),this.commonDbService.usesPortableChannelFeed(ge))n=this.commonDbService.dbListener({feature:"allDocumentViews",properties:y(m({},i),{organizationId:this.documentPaths?.organizationId,documentIds:e})}).pipe(ie(),f(o=>de(JSON.parse(JSON.stringify([o])))));else{let o=[];for(let a=0;a<(e?.length??0);a+=E.LISTENER_BATCH_SIZE)o.push(e?.slice(a,a+E.LISTENER_BATCH_SIZE)??[]);n=Z(o.map(a=>this.commonDbService.dbListener({feature:"allDocumentViews",properties:y(m({},i),{firestoreQuery:[Se(z("metadata.apiKey","==",this.configService?.getApiKey()),z("metadata.documentId","in",a),z("metadata.organizationId","==",this.documentPaths?.organizationId),...t?[z("metadata.veltFolderId","==",t)]:[])]})}).pipe(ie()))).pipe(f(a=>de(a)))}return n.pipe(f(o=>({data:o?.data,operation:o?.operation})),f(({data:o,operation:a})=>{let l={};return e?(Object.entries(o??{}).forEach(([s,u])=>{let p=u.metadata?.documentId;p&&(l[p]||(l[p]={}),l[p][s]=u)}),{data:o,documentMap:l,operation:a}):{data:o,documentMap:l,operation:a}}),f(({data:o,documentMap:a,operation:l})=>{if(l?.type==="removed"){if(l?.ids?.length){let s=this.documentViews$.value;l?.ids?.forEach(u=>{delete s?.[u]}),this.documentViews$.next(s)}}else Object.entries(a??{}).forEach(([s,u])=>{this.setDocumentViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:s,documentViews:u})})}))}getLocationViewsDataFromDocuments(e){let t=this.docService.getDocumentPaths()?.veltFolderId,n=b([]),i={useCollectionGroup:!0,isCollection:!0,useQuery:!0};this.commonDbService.shouldUseFirestore()||(i.documentId=e?.length?e[0]:void 0,i.organizationId=this.documentPaths?.organizationId);let o=[];for(let a=0;a<(e?.length??0);a+=E.LISTENER_BATCH_SIZE)o.push(e?.slice(a,a+E.LISTENER_BATCH_SIZE)??[]);return n=Z(o.map(a=>this.commonDbService.dbListener({feature:"allLocationViews",properties:y(m({},i),{firestoreQuery:[Se(z("metadata.apiKey","==",this.configService?.getApiKey()),z("metadata.documentId","in",a),z("metadata.organizationId","==",this.documentPaths?.organizationId),...t?[z("metadata.veltFolderId","==",t)]:[])]})}).pipe(ie()))).pipe(f(a=>de(a))),n.pipe(f(a=>({data:a?.data,operation:a?.operation})),f(({data:a,operation:l})=>{let s={};return e?(Object.entries(a??{}).forEach(([u,p])=>{let g=p.metadata?.documentId;g&&(s[g]||(s[g]={}),s[g][u]=p)}),{data:a,documentMap:s,operation:l}):{data:a,documentMap:s,operation:l}}),f(({data:a,documentMap:l,operation:s})=>{if(s?.type==="removed"){if(s?.ids?.length){let u=this.locationViews$.value;s?.ids?.forEach(p=>{delete u?.[p]}),this.locationViews$.next(u)}}else Object.entries(l??{}).forEach(([u,p])=>{this.setLocationViewsByOrganizationIdAndDocumentId({organizationId:this.documentPaths?.organizationId,documentId:u,locationViews:p})})}))}setViewsData(e){try{this.views$.next(m(m({},this.views$.getValue()),e||{}))}catch(t){this.loggingService.catch("Error in ViewsService setViewsData:",t)}}setCommentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,commentViews:n,queryHash:i}){try{if(n||(n={}),t){e||(e=E.NO_ORGANIZATION_ID),i||(i=E.DEFAULT_QUERY_HASH);let o=m(m({},this.commentViews$.value),n);this.commentViews$.next(o),this.commentViewsByOrganizationIdAndDocumentId$.next(y(m({},this.commentViewsByOrganizationIdAndDocumentId$.value),{[e]:y(m({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]),{[t]:y(m({},this.commentViewsByOrganizationIdAndDocumentId$.value[e]?.[t]),{[i]:n})})}))}}catch(o){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",o)}}setDocumentViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,documentViews:n,queryHash:i}){try{if(n||(n={}),t){e||(e=E.NO_ORGANIZATION_ID),i||(i=E.DEFAULT_QUERY_HASH);let o=m(m({},this.documentViews$.value),n);this.documentViews$.next(o),this.documentViewsByOrganizationIdAndDocumentId$.next(y(m({},this.documentViewsByOrganizationIdAndDocumentId$.value),{[e]:y(m({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]),{[t]:y(m({},this.documentViewsByOrganizationIdAndDocumentId$.value[e]?.[t]),{[i]:n})})}))}}catch(o){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",o)}}setLocationViewsByOrganizationIdAndDocumentId({organizationId:e,documentId:t,locationViews:n,queryHash:i}){try{if(n||(n={}),t){e||(e=E.NO_ORGANIZATION_ID),i||(i=E.DEFAULT_QUERY_HASH);let o=m(m({},this.locationViews$.value),n);this.locationViews$.next(o),this.locationViewsByOrganizationIdAndLocationId$.next(y(m({},this.locationViewsByOrganizationIdAndLocationId$.value),{[e]:y(m({},this.locationViewsByOrganizationIdAndLocationId$.value[e]),{[t]:y(m({},this.locationViewsByOrganizationIdAndLocationId$.value[e]?.[t]),{[i]:n})})}))}}catch(o){this.loggingService.catch("Error in CommentService setCommentAnnotationsByOrganizationIdAndDocumentId:",o)}}getCommentFeatureViews$(){return this.commentViews$.pipe(q((e,t)=>JSON.stringify(e||{})===JSON.stringify(t||{})))}setCommentAnnotationAsRead(e){return j(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){if(e.annotationId.startsWith("TEMP_COMPOSER_"))return;this.updateCommentAnnotationViews(e);let n=e?.metadata?.organizationId??this.documentPaths?.organizationId??"",i=e?.metadata?.documentId??this.documentPaths?.documentId??"";if(e?.isDraft)return;yield this.commonDbService.setData({feature:"comment",properties:{id:e.annotationId,documentId:i,organizationId:n,metadata:{apiKey:this.configService.getApiKey(),organizationId:n,veltFolderId:e?.metadata?.veltFolderId,documentId:i}},data:JSON.parse(JSON.stringify(e))})}}catch(t){this.loggingService.catch("Error in ViewsService setCommentAnnotationAsRead:",t)}})}setCommentAnnotationAsUnread(e){return j(this,null,function*(){try{if(this.authService.getUser()&&e?.annotationId){if(e.annotationId.startsWith("TEMP_COMPOSER_"))return;this.removeCommentAnnotationViews(e);let n=e?.metadata?.organizationId??this.documentPaths?.organizationId??"",i=e?.metadata?.documentId??this.documentPaths?.documentId??"";if(e?.isDraft)return;yield this.commonDbService.setData({feature:"comment",properties:{id:e.annotationId,documentId:i,organizationId:n,metadata:{apiKey:this.configService.getApiKey(),organizationId:n,veltFolderId:e?.metadata?.veltFolderId,documentId:i}},data:JSON.parse(JSON.stringify(e))})}}catch(t){this.loggingService.catch("Error in ViewsService setCommentAnnotationAsRead:",t)}})}updateCommentAnnotationViews(e){try{let t=this.authService.getUser(),n={views:{},comments:{}};if(t){let i={},o=e?.views?.comments||{},a=new Date().getTime()+this.commonDbService.getOffset();e.comments?.forEach(s=>{o[s.commentId]||(o[s.commentId]={views:{}}),o[s.commentId].views||(o[s.commentId].views={}),o[s.commentId].views[t.userSnippylyId]||(o[s.commentId].views[t.userSnippylyId]={timestamp:a})});let l=new Set(e.comments?.map(s=>s.commentId+""));if(Object.keys(o??{}).forEach(s=>{l.has(s)||delete o[s]}),e.comments?.length){let s=o[e.comments[0].commentId]?.views||{},u=Object.keys(s??{}).filter(p=>e.comments?.every(g=>o[g.commentId]?.views?.[p]));u.forEach(p=>{i[p]={timestamp:s[p].timestamp}}),e.viewedByUserIds=u}n.views=i,n.comments=o,e.views=n}return n}catch(t){return this.loggingService.catch("Error in ViewsService updateCommentAnnotationViews:",t),{views:{},comments:{}}}}removeCommentAnnotationViews(e){try{let t=this.authService.getUser(),n={views:{},comments:{}};if(t){let i={},o=e?.views?.comments||{};e.comments?.forEach(l=>{o[l.commentId]?.views?.[t.userSnippylyId]&&delete o[l.commentId].views[t.userSnippylyId]});let a=new Set(e.comments?.map(l=>l.commentId+""));if(Object.keys(o??{}).forEach(l=>{a.has(l)||delete o[l]}),e.comments?.length){let l=o[e.comments[0].commentId]?.views||{},s=Object.keys(l??{}).filter(u=>e.comments?.every(p=>o[p.commentId]?.views?.[u]));s.forEach(u=>{i[u]={timestamp:l[u].timestamp}}),e.viewedByUserIds=s}else e.viewedByUserIds=[];n.views=i,n.comments=o,e.views=n}return n}catch(t){return this.loggingService.catch("Error in ViewsService removeCommentAnnotationViews:",t),{views:{},comments:{}}}}getNotificationFeatureViews$(){return this.views$.pipe(q((e,t)=>JSON.stringify(e?.notification||{})===JSON.stringify(t?.notification||{})))}setNotificationsAsRead(e){try{let t=this.authService.getUser();if(t){let n=new Date().getTime()+this.commonDbService.getOffset();e.forEach(i=>{this.commonDbService.updateData({feature:"notificationViewsTimestamp",properties:{id:i,user:t.userSnippylyId,documentId:this.documentPaths?.documentId??"",organizationId:this.documentPaths?.organizationId??""},data:{timestamp:n}})})}}catch(t){this.loggingService.catch("Error in ViewsService setNotificationAsRead:",t)}}getDocumentViews$(){return this.views$.pipe(q((e,t)=>JSON.stringify(e?.documentViews||{})===JSON.stringify(t?.documentViews||{})))}getUniqueViewsByUser(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(S(t=>(this.documentPaths=t,e?this.locationViews$.pipe(f(n=>{let i=Object.keys(n||{}).find(o=>n?.[o]?.location?.id===e);return i?n?.[i]?.users||{}:{}})):this.documentViews$.pipe(f(n=>{let i=this.documentPaths?.documentId;return i?n?.[i]?.users||{}:{}})))),q(Qe))}catch(t){return this.loggingService.catch("Error in ViewsService getUniqueViewsByUser:",t),b({})}}getUniqueViewsByDate(e){try{return this.enableDocumentViews(),this.docService.getDocumentPaths$().pipe(S(t=>(this.documentPaths=t,e?this.locationViews$.pipe(f(n=>{let i=Object.keys(n||{}).find(o=>n?.[o]?.location?.id===e);return i?n?.[i]?.day||{}:{}})):this.documentViews$.pipe(f(n=>{let i=this.documentPaths?.documentId;return i?n?.[i]?.day||{}:{}})))))}catch(t){return this.loggingService.catch("Error in ViewsService getUniqueViewsByDate:",t),b({})}}enableDocumentViews(){try{if(this.documentViewsEnabled$.value===!0)return;this.documentViewsEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in ViewsService enableDocumentViews:",e)}}disableDocumentViews(){try{if(this.documentViewsEnabled$.value===!1)return;this.documentViewsEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in ViewsService disableDocumentViews:",e)}}setDocumentAsRead(n){return j(this,arguments,function*({documentId:e,clientDocumentId:t}){try{let i=this.authService.getUser();if(i&&e&&this.userPermissionService?.hasEditAccess({documentId:e??"",folderId:this.documentPaths?.allDocuments&&this.documentPaths?.veltFolderId?this.documentPaths?.veltFolderId:void 0})){if(this.documentViewsSetByDocumentId[e])return;this.documentViewsSetByDocumentId[e]=!0;let o=new Date().getTime()+this.commonDbService.getOffset(),a=new Date().toISOString().split("T")[0];if(this.commonDbService.usesPortableChannelFeed(ge)){let s=yield Ce(this.docService.getDocumentPaths$().pipe(f(u=>u?.organizationId),B(u=>!!u)));yield this.commonDbService.whenPortableRealtimeReady(),this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:a,user:i.userSnippylyId,documentId:e,organizationId:s},data:{}}),this.checkAndTriggerNotification(i);return}let l=this.getDocumentViewsById(e);if(l){let s=new Date().toISOString().split("T")[0];l?.users[i.userSnippylyId]||(l.users[i.userSnippylyId]={}),l.users[i.userSnippylyId][s]={timestamp:this.timestamp},l?.day[s]||(l.day[s]={}),l.day[s][i.userSnippylyId]={timestamp:this.timestamp},l.metadata=this.docService.getBaseMetadata("documentViews",{clientDocumentId:t}),this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:s,user:i.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??""},data:l})}else this.commonDbService.updateData({feature:"documentDayViews",properties:{id:e,date:a,user:i.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:o}}),this.commonDbService.updateData({feature:"documentUsersViews",properties:{id:e,user:i.userSnippylyId,date:a,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:o}}),this.commonDbService.updateData({feature:"documentMetadataViews",properties:{id:e,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:this.docService.getBaseMetadata("documentViews",{clientDocumentId:t})}),this.docService.getDocumentMetadata$(e).pipe(B(s=>s!==null),te(1)).subscribe(()=>{let s={day:{[a]:{[i.userSnippylyId]:{timestamp:o}}},users:{[i.userSnippylyId]:{[a]:{timestamp:o}}},metadata:this.docService.getBaseMetadata("documentViews",{clientDocumentId:t})};this.commonDbService.updateData({feature:"documentViews",properties:{id:e,date:a,user:i.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0},data:s})});this.checkAndTriggerNotification(i)}}catch(i){this.loggingService.catch("Error in ViewsService setDocumentAsRead:",i)}})}checkAndTriggerNotification(e){try{this.getUniqueViewsByUser().pipe(te(1)).subscribe(t=>{if(Object.keys(t??{}).length===2){let n=this.docService.getDocumentMetadata();if(n?.creator?.email&&n?.creator?.email!==e.email){let i=[n.creator.email];this.updateNotificationsDatabase(He.FIRST_VIEWED,{documentViews:{emails:i}})}}})}catch(t){this.loggingService.catch("Error in checkAndTriggerNotification:",t)}}setLocationAsRead(n){return j(this,arguments,function*({documentId:e,clientDocumentId:t}){try{let i=this.authService.getUser(),o=this.docService.getLocation(),a=o?.locationId,l=o?.location;if(i&&a&&l){let s=new Date().getTime()+this.commonDbService.getOffset(),u=new Date().toISOString().split("T")[0],p=this.getLocationViewsById(a);if(p){let g=new Date().toISOString().split("T")[0];p?.users[i.userSnippylyId]||(p.users[i.userSnippylyId]={}),p.users[i.userSnippylyId][g]={timestamp:this.timestamp},p?.day[g]||(p.day[g]={}),p.day[g][i.userSnippylyId]={timestamp:this.timestamp},p.metadata=this.docService.getBaseMetadata("locationViews",{clientDocumentId:t}),this.commonDbService.updateData({feature:"location",data:p,properties:{id:a,documentId:e,organizationId:this.documentPaths?.organizationId??""}})}else{this.commonDbService.updateData({feature:"locationViews",data:l,properties:{id:a,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0}}),this.commonDbService.updateData({feature:"locationUsersViews",properties:{id:a,user:i.userSnippylyId,date:u,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:s}}),this.commonDbService.updateData({feature:"locationDayViews",properties:{id:a,date:u,user:i.userSnippylyId,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:{timestamp:s}}),this.commonDbService.updateData({feature:"locationMetadataViews",properties:{id:a,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipFirestore:!0},data:this.docService.getBaseMetadata("locationViews",{clientDocumentId:t})});let g={day:{[u]:{[i.userSnippylyId]:{timestamp:s}}},users:{[i.userSnippylyId]:{[u]:{timestamp:s}}},metadata:this.docService.getBaseMetadata("locationViews",{clientDocumentId:t}),location:l};this.commonDbService.updateData({feature:"location",data:g,properties:{id:a,documentId:e,organizationId:this.documentPaths?.organizationId??"",skipRtdb:!0}})}}}catch(i){this.loggingService.catch("Error in ViewsService setLocationAsRead:",i)}})}updateNotificationsDatabase(e,t={}){try{let n=m({actionType:e,notificationSource:"documentViews"},t);this.notificationService?.updateNotificationDatabase(n)}catch(n){this.loggingService.catch("Error in CommentService updateNotificationsDatabase: ",n)}}get timestamp(){return this.commonDbService.getServerTimestamp()}};c.\u0275fac=function(t){return new(t||c)(k(je),k(nt),k(et),k(tt),k(ve),k(ot),k(mt),k(C),k(gt),k(me))},c.\u0275prov=Oe({token:c,factory:c.\u0275fac,providedIn:"root"});let d=c;return d})();function St(d,c){if(d&1&&(G(0),v(1,"div",21)(2,"div",22),L(3,"snippyly-user-avatar",23),w(),v(4,"div",24)(5,"div",25),_(6),A(7,"translate"),w()(),v(8,"div",26),_(9),A(10,"timeAgo"),w()(),W()),d&2){let r=c.$implicit;h(3),D("user",r==null?null:r.user)("size",32),h(3),R(" ",U(7,4,(r==null||r.user==null?null:r.user.name)||(r==null||r.user==null?null:r.user.email))," "),h(3),R(" ",U(10,6,r==null?null:r.timestamp)," ")}}function bt(d,c){if(d&1&&(v(0,"div",19),T(1,St,11,8,"ng-container",20),w()),d&2){let r=x(2).ngIf;h(),D("ngForOf",r.userViews)}}function Vt(d,c){if(d&1){let r=J();G(0),v(1,"div",4)(2,"button",5),M("click",function(){F(r);let t=x(2);return N(t.closeTrendDialog())}),H(),v(3,"svg",6),L(4,"path",7),w(),Y(),v(5,"span"),_(6),A(7,"translate"),w()()(),v(8,"div",8)(9,"div",9)(10,"div",10),_(11),w(),v(12,"div",11),H(),v(13,"svg",12),L(14,"path",13)(15,"path",14),w(),Y(),v(16,"span"),_(17),A(18,"translate"),w()()(),v(19,"div",15)(20,"div",16),_(21),w(),v(22,"div",17)(23,"span"),_(24),A(25,"translate"),w()()()(),T(26,bt,2,1,"div",18),W()}if(d&2){let r=x().ngIf;h(6),K(U(7,6,"Go Back")),h(5),R(" ",r.totalUniqueViewsCount," "),h(6),K(U(18,8,"Total Views")),h(4),R(" ",r.todayViewsCount," "),h(3),K(U(25,10,"Views Today")),h(2),D("ngIf",r.userViews==null?null:r.userViews.length)}}function It(d,c){if(d&1&&(G(0),v(1,"div",21)(2,"div",22),L(3,"snippyly-user-avatar",23),w(),v(4,"div",24)(5,"div",25),_(6),A(7,"translate"),w(),v(8,"div",26),_(9),A(10,"timeAgo"),w()()(),W()),d&2){let r=c.$implicit;h(3),D("user",r==null?null:r.user)("size",32),h(3),R(" ",U(7,4,(r==null||r.user==null?null:r.user.name)||(r==null||r.user==null?null:r.user.email))," "),h(3),R(" ",U(10,6,r==null?null:r.timestamp)," ")}}function Ct(d,c){if(d&1&&(v(0,"div",29)(1,"div",19),T(2,It,11,8,"ng-container",20),w()()),d&2){let r=x(2).ngIf;h(2),D("ngForOf",r.userViews)}}function Dt(d,c){if(d&1&&(v(0,"div",27)(1,"div",9)(2,"div",10),_(3),w(),v(4,"div",11),H(),v(5,"svg",12),L(6,"path",13)(7,"path",14),w(),Y(),v(8,"span"),_(9),A(10,"translate"),w()()(),v(11,"div",15),_(12),A(13,"translate"),A(14,"translate"),A(15,"translate"),w()(),T(16,Ct,3,1,"div",28)),d&2){let r=x().ngIf;h(3),R(" ",r.totalUniqueViewsCount," "),h(6),K(U(10,6,"Total Views")),h(3),Te(" ",r.todayViewsCount," ",r.todayViewsCount===1?U(13,8,"View"):U(14,10,"Views")," ",U(15,12,"Today")," "),h(4),D("ngIf",r.userViews==null?null:r.userViews.length)}}function xt(d,c){if(d&1){let r=J();G(0),v(1,"div",2),M("clickOutside",function(){F(r);let t=x();return N(t.closeTrendDialog())}),T(2,Vt,27,12,"ng-container",3)(3,Dt,17,14,"ng-template",null,0,ce),w(),W()}if(d&2){let r=c.ngIf,e=se(4);h(),ae("bottom-sheet",r.bottomSheetMode),h(),D("ngIf",r.bottomSheetMode)("ngIfElse",e)}}var X=(()=>{let c=class c{constructor(e,t,n,i,o,a,l){this.contactService=e,this.loggingService=t,this.viewsService=n,this.themeService=i,this.elementRef=o,this.domService=a,this.bottomSheetData=l,this.close=new re,this.componentConfigSignal=ne({today:new Date().toISOString().split("T")[0],todayViews:{},todayViewsCount:0,totalUniqueViews:{},totalUniqueViewsCount:0,views:{},usersMap:{},userViews:[],bottomSheetMode:!1}),this.subscriptions=[];try{l&&(this.componentConfigSignal.update(s=>(s=y(m({},s),{bottomSheetMode:!0}),s)),this.clientLocationId=l.clientLocationId,this.closeBottomSheetFn=l.closeBottomSheetFn),this.subscriptions.push(this.contactService.getUsersMap$().subscribe(s=>{this.componentConfigSignal.update(u=>(u=y(m({},u),{usersMap:s||{}}),u)),this.setLatestViewsByUsers()},s=>{this.loggingService.catch("Error in ViewAnalyticsDialogComponent getUsersMap$ subscription: ",s)})),this.subscriptions.push(this.themeService.getDarkMode$().subscribe(s=>{s?this.elementRef.nativeElement.setAttribute("dark",""):this.elementRef.nativeElement.removeAttribute("dark")}))}catch(s){this.loggingService.catch("Error in ViewAnalyticsDialogComponent constructor: ",s)}}ngOnInit(){this.getDocumentViews()}ngAfterViewInit(){try{this.subscriptions.push(this.domService.subscribeInjectCustomCss(this.elementRef))}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent ngAfterViewInit: ",e)}}trackByUserIdAndTimestamp(e,t){return`${t?.user?.userSnippylyId}-${t.timestamp}`}getDocumentViews(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentViews","color: green;"),this.uniqueViewsByUserSubscription&&(this.componentConfigSignal.update(e=>(e=y(m({},e),{totalUniqueViews:{},totalUniqueViewsCount:0}),e)),this.uniqueViewsByUserSubscription.unsubscribe()),this.uniqueViewsByDateSubscription&&(this.componentConfigSignal.update(e=>(e=y(m({},e),{todayViews:{},todayViewsCount:0}),e)),this.uniqueViewsByDateSubscription.unsubscribe()),this.uniqueViewsByUserSubscription=this.viewsService.getUniqueViewsByUser(this.clientLocationId).subscribe(e=>{this.componentConfigSignal.update(t=>(t=y(m({},t),{totalUniqueViews:e||{},totalUniqueViewsCount:Object.keys(e||{})?.length||0}),t)),this.setLatestViewsByUsers()},e=>{this.loggingService.catch("Error in ViewAnalyticsDialogComponent getUniqueViewsByUser subscription: ",e)}),this.uniqueViewsByDateSubscription=this.viewsService.getUniqueViewsByDate(this.clientLocationId).subscribe(e=>{this.componentConfigSignal.update(t=>(t=m({},t),t.todayViews=e&&e[t.today]?e[t.today]:{},t.todayViewsCount=Object.keys(t.todayViews||{})?.length||0,t)),this.setLatestViewsByUsers()},e=>{this.loggingService.catch("Error in ViewAnalyticsDialogComponent getUniqueViewsByDate subscription: ",e)})}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent getDocumentViews: ",e)}}setLatestViewsByUsers(){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLatestViewsByUsers","color: green;"),Object.keys(this.componentConfigSignal().todayViews||{}).forEach(e=>{let t=this.componentConfigSignal().usersMap[e],n=this.componentConfigSignal().todayViews[e]?.timestamp;t&&n&&(this.componentConfigSignal().userViews.find(o=>o.user.userSnippylyId===e)||this.componentConfigSignal.update(o=>(o=y(m({},o),{userViews:[...o.userViews,{user:t,timestamp:n}]}),o)))}),this.componentConfigSignal.update(e=>(e=m({},e),e.userViews.sort((t,n)=>n.timestamp-t.timestamp),e.userViews=e.userViews.slice(0,3),e))}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent setLatestViewsByUsers: ",e)}}closeTrendDialog(){try{this.close.emit(),this.closeBottomSheetFn&&this.closeBottomSheetFn?.()}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent onClose: ",e)}}ngOnDestroy(){try{this.subscriptions.forEach(e=>{e.unsubscribe()}),this.uniqueViewsByDateSubscription?.unsubscribe(),this.uniqueViewsByUserSubscription?.unsubscribe()}catch(e){this.loggingService.catch("Error in ViewAnalyticsDialogComponent ngOnDestroy: ",e)}}};c.\u0275fac=function(t){return new(t||c)(I(rt),I(C),I(P),I(st),I(oe),I(ue),I(We,8))},c.\u0275cmp=Q({type:c,selectors:[["velt-view-analytics-dialog"]],inputs:{clientLocationId:"clientLocationId"},outputs:{close:"close"},standalone:!1,decls:1,vars:1,consts:[["defaultDialogRef",""],[4,"ngIf"],["snippylyClickOutside","",1,"v-view-analytics-dialog-container",3,"clickOutside"],[4,"ngIf","ngIfElse"],[1,"v-back-btn-container"],[1,"v-back-btn",3,"click"],["width","16","height","16","viewBox","0 0 16 16","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M9.99988 4L5.99988 8L9.99988 12","stroke","currentColor","stroke-width","1.33333","stroke-linecap","round","stroke-linejoin","round"],[1,"v-view-analytics-count-container"],[1,"v-total-views-container"],[1,"v-total-views-count"],[1,"v-total-views-text"],["width","18","height","18","viewBox","0 0 18 18","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M7.5 9C7.5 9.39782 7.65804 9.77936 7.93934 10.0607C8.22064 10.342 8.60218 10.5 9 10.5C9.39782 10.5 9.77936 10.342 10.0607 10.0607C10.342 9.77936 10.5 9.39782 10.5 9C10.5 8.60218 10.342 8.22064 10.0607 7.93934C9.77936 7.65804 9.39782 7.5 9 7.5C8.60218 7.5 8.22064 7.65804 7.93934 7.93934C7.65804 8.22064 7.5 8.60218 7.5 9Z","stroke","#625DF5","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],["d","M15.75 9C13.95 12 11.7 13.5 9 13.5C6.3 13.5 4.05 12 2.25 9C4.05 6 6.3 4.5 9 4.5C11.7 4.5 13.95 6 15.75 9Z","stroke","#625DF5","stroke-width","1.25","stroke-linecap","round","stroke-linejoin","round"],[1,"v-today-views-container"],[1,"v-today-views-count"],[1,"v-today-views-text"],["class","v-users-container",4,"ngIf"],[1,"v-users-container"],[4,"ngFor","ngForOf"],[1,"v-user"],[1,"v-user-image"],[3,"user","size"],[1,"v-user-view-details"],[1,"v-user-name"],[1,"v-user-view-time"],[1,"v-document-viewer-tread-left"],["class","v-document-viewer-tread-right",4,"ngIf"],[1,"v-document-viewer-tread-right"]],template:function(t,n){t&1&&T(0,xt,5,4,"ng-container",1),t&2&&D("ngIf",n.componentConfigSignal())},dependencies:[ze,le,ct,lt,at,vt],styles:[`.v-view-analytics-dialog-container{border-radius:var(--legacy-velt-view-analytics-dialog-border-radius);border:var(--legacy-velt-view-analytics-dialog-border);background:var(--legacy-velt-view-analytics-dialog-bg-color);box-shadow:var(--legacy-velt-view-analytics-dialog-box-shadow);padding:var(--legacy-velt-view-analytics-dialog-padding);display:flex;gap:16px}.v-view-analytics-dialog-container .v-document-viewer-tread-left{display:flex;flex-direction:column;gap:4px}.v-view-analytics-dialog-container .v-document-viewer-tread-left .v-total-views-container{width:140px;height:110px;flex-shrink:0;border-radius:8px;background:var(--legacy-velt-view-analytics-dialog-views-container-bg-color);box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:10px}.v-view-analytics-dialog-container .v-document-viewer-tread-left .v-total-views-container .v-total-views-count{color:var(--legacy-velt-view-analytics-dialog-total-views-count-color);font-size:32px;font-style:normal;font-weight:600;line-height:100%}.v-view-analytics-dialog-container .v-document-viewer-tread-left .v-total-views-container .v-total-views-text{color:var(--legacy-velt-view-analytics-dialog-total-views-text-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase;display:flex;gap:4px;align-items:center}.v-view-analytics-dialog-container .v-document-viewer-tread-left .v-today-views-container{display:flex;width:140px;padding:8px 4px;justify-content:center;align-items:center;gap:4px;border-radius:8px;background:var(--legacy-velt-view-analytics-dialog-views-container-bg-color);box-sizing:border-box;color:var(--legacy-velt-view-analytics-dialog-today-views-text-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase}.v-view-analytics-dialog-container .v-document-viewer-tread-right{padding:8px 0}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container{display:inline-flex;flex-direction:column;align-items:flex-start;gap:16px;margin-right:16px}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user{display:flex;align-items:center;gap:12px}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user snippyly-user-avatar{display:flex}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user .v-user-view-details{display:flex;flex-direction:column;gap:8px}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user .v-user-view-details .v-user-name{color:var(--legacy-velt-view-analytics-dialog-user-name-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%}.v-view-analytics-dialog-container .v-document-viewer-tread-right .v-users-container .v-user .v-user-view-details .v-user-view-time{color:var(--legacy-velt-view-analytics-dialog-user-timestamp-color);font-size:10px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase}.v-view-analytics-dialog-container.bottom-sheet{display:flex;flex-direction:column;border-bottom-left-radius:0;border-bottom-right-radius:0}.v-view-analytics-dialog-container.bottom-sheet .v-back-btn-container{display:flex;padding:8px 8px 0}.v-view-analytics-dialog-container.bottom-sheet .v-back-btn-container .v-back-btn{background:transparent;border:0;outline:0;display:flex;align-items:center;gap:8px;color:var(--legacy-velt-view-analytics-dialog-back-btn-color);cursor:pointer;font-size:16px;font-style:normal;font-weight:400;line-height:normal}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container{display:flex;flex:1;gap:10px}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-total-views-container{display:flex;padding:25px 20px;flex-direction:column;justify-content:center;align-items:center;gap:10px;flex:1 0 0;border-radius:8px;background:var(--legacy-velt-view-analytics-dialog-views-container-bg-color)}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-total-views-container .v-total-views-count{color:var(--legacy-velt-view-analytics-dialog-total-views-count-color);font-size:32px;font-style:normal;font-weight:600;line-height:100%}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-total-views-container .v-total-views-text{color:var(--legacy-velt-view-analytics-dialog-total-views-text-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase;display:flex;gap:4px;align-items:center}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-today-views-container{display:flex;padding:25px 20px;flex-direction:column;justify-content:center;align-items:center;gap:10px;flex:1 0 0;border-radius:8px;background:var(--legacy-velt-view-analytics-dialog-views-container-bg-color)}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-today-views-container .v-today-views-count{color:var(--legacy-velt-view-analytics-dialog-today-views-text-color);font-size:32px;font-style:normal;font-weight:600;line-height:100%}.v-view-analytics-dialog-container.bottom-sheet .v-view-analytics-count-container .v-today-views-container .v-today-views-text{color:var(--legacy-velt-view-analytics-dialog-today-views-text-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase;display:flex;gap:4px;align-items:center}.v-view-analytics-dialog-container.bottom-sheet .v-users-container{display:inline-flex;flex-direction:column;align-items:flex-start;gap:16px;margin-right:16px}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user{display:flex;align-items:center;gap:12px;width:100%}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user snippyly-user-avatar{display:flex}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user .v-user-view-details{display:flex;flex-direction:column;gap:8px;flex:1}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user .v-user-view-details .v-user-name{color:var(--legacy-velt-view-analytics-dialog-user-name-color);font-size:12px;font-style:normal;font-weight:500;line-height:100%}.v-view-analytics-dialog-container.bottom-sheet .v-users-container .v-user .v-user-view-time{color:var(--legacy-velt-view-analytics-dialog-user-timestamp-color);font-size:10px;font-style:normal;font-weight:500;line-height:100%;text-transform:uppercase}
2
2
  `],encapsulation:3,changeDetection:0});let d=c;return d})();var Ve=(()=>{let c=class c{constructor(e,t){this.bottomSheet=e,this.loggingService=t,this.close=new re,this.subscriptions=[]}ngOnInit(){}ngAfterViewInit(){this.openBottomSheet()}openBottomSheet(){return j(this,null,function*(){try{this.bottomSheetRef=this.bottomSheet.open(X,{data:{clientLocationId:this.clientLocationId,closeBottomSheetFn:()=>{this.onClose(),this.bottomSheetRef?.dismiss()}},panelClass:["v-view-analytics-bottom-sheet-container","velt-mat-bottom-sheet-container"]}),this.subscriptions.push(this.bottomSheetRef.backdropClick().subscribe(()=>{this.onClose()},e=>{this.loggingService.catch("Error in ViewAnalyticsBottomSheetComponent backdropClick subscription: ",e)}))}catch(e){this.loggingService.catch("Error in ViewAnalyticsBottomSheetComponent openBottomSheet: ",e)}})}onClose(){try{this.close.emit()}catch(e){this.loggingService.catch("Error in ViewAnalyticsBottomSheetComponent onClose: ",e)}}ngOnDestroy(){try{this.subscriptions.forEach(e=>{e.unsubscribe()})}catch(e){this.loggingService.catch("Error in ViewAnalyticsBottomSheetComponent ngOnDestroy: ",e)}}};c.\u0275fac=function(t){return new(t||c)(I(Je),I(C))},c.\u0275cmp=Q({type:c,selectors:[["velt-view-analytics-bottom-sheet-internal"]],inputs:{clientLocationId:"clientLocationId"},outputs:{close:"close"},standalone:!1,decls:0,vars:0,template:function(t,n){},styles:[".velt-mat-bottom-sheet-container.v-view-analytics-bottom-sheet-container{padding:0!important} .velt-mat-bottom-sheet-container.v-view-analytics-bottom-sheet-container .mat-bottom-sheet-container{padding:0!important}"],changeDetection:0});let d=c;return d})();var Ot=()=>["snippyly-overlay-panel","v-view-analytics-overlay-panel","velt-overlay-panel"];function Bt(d,c){if(d&1){let r=J();v(0,"velt-view-analytics-dialog",11),M("close",function(){F(r);let t=x(2);return N(t.toggleTrends())}),w()}if(d&2){let r=x(2);D("clientLocationId",r.clientLocationId)}}function At(d,c){if(d&1){let r=J();v(0,"velt-view-analytics-bottom-sheet-internal",11),M("close",function(){F(r);let t=x(2);return N(t.closeTrends())}),w()}if(d&2){let r=x(2);D("clientLocationId",r.clientLocationId)}}function Ut(d,c){if(d&1){let r=J();G(0),v(1,"div",3,0),M("click",function(t){return F(r),x().toggleTrends(),N(t.stopPropagation())}),v(3,"slot",4),M("slotchange",function(){F(r);let t=x();return N(t.onButtonSlotChange())}),v(4,"div",5),H(),v(5,"svg",6),L(6,"path",7),w(),Y(),v(7,"span",8),_(8),w()()()(),T(9,Bt,1,1,"ng-template",9,1,ce)(11,At,1,1,"velt-view-analytics-bottom-sheet-internal",10),W()}if(d&2){let r=c.ngIf,e=se(2),t=x();h(4),ae("active",r.treadsVisible),h(4),K(r.totalUniqueViewsCount),h(),D("cdkConnectedOverlayOrigin",e)("cdkConnectedOverlayOpen",!r.isPhone&&r.treadsVisible)("cdkConnectedOverlayPanelClass",$e(11,Ot))("cdkConnectedOverlayBackdropClass","snippyly-overlay-backdrop")("cdkConnectedOverlayGrowAfterOpen",!0)("cdkConnectedOverlayPositions",t.positions)("cdkConnectedOverlayDisableClose",!0),h(2),D("ngIf",r.isPhone&&r.treadsVisible)}}var Ie=(()=>{let c=class c{constructor(e,t,n,i,o,a){this.breakpointObserver=e,this.docService=t,this.loggingService=n,this.viewsService=i,this.elementRef=o,this.domService=a,this.type="document",this.componentConfigSignal=ne({today:new Date().toISOString().split("T")[0],todayViews:{},todayViewsCount:0,totalUniqueViews:{},totalUniqueViewsCount:0,treadsVisible:!1,customButtonAdded:!1,isPhone:!1,componentId:Math.random().toString(36).substring(2)}),this.positions=E.OVERLAY_POSITIONS.map(l=>new Fe({originX:l.originX,originY:l.originY},{overlayX:l.overlayX,overlayY:l.overlayY})),this.subscriptions=[]}ngOnInit(){try{this.getUniqueViewsByUser(),this.subscriptions.push(this.breakpointObserver.observe(Ge.XSmall).subscribe(e=>{this.componentConfigSignal.update(t=>(t=m({},t),t.isPhone=!!e.matches,t))},e=>{this.loggingService.catch("Error in ViewAnalyticsComponent breakpointObserver subscription: ",e)})),this.subscriptions.push(this.docService.getLocation$().subscribe(e=>{e?.location?.id&&(this.clientLocationId=e?.location?.id,this.getUniqueViewsByUser())}))}catch(e){this.loggingService.catch("Error in ViewAnalyticsComponent ngOnInit: ",e)}}ngOnChanges(e){try{(e.type||e.clientLocationId)&&this.getUniqueViewsByUser()}catch(t){this.loggingService.catch("Error in ViewAnalyticsComponent ngOnChanges: ",t)}}ngAfterViewInit(){try{this.subscriptions.push(this.domService.subscribeInjectCustomCss(this.elementRef))}catch(e){this.loggingService.catch("Error in ViewAnalyticsComponent ngAfterViewInit: ",e)}}getUniqueViewsByUser(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentViews","color: green;"),this.uniqueViewsByUserSubscription&&(this.componentConfigSignal.update(t=>(t=m({},t),t.totalUniqueViews={},t.totalUniqueViewsCount=0,t)),this.uniqueViewsByUserSubscription.unsubscribe());let e=this.type==="location"&&this.clientLocationId?this.clientLocationId:void 0;this.uniqueViewsByUserSubscription=this.viewsService.getUniqueViewsByUser(e).subscribe(t=>{this.componentConfigSignal.update(n=>(n=m({},n),n.totalUniqueViews=t||{},n.totalUniqueViewsCount=Object.keys(n.totalUniqueViews||{})?.length||0,n))},t=>{this.loggingService.catch("Error in ViewAnalyticsComponent getUniqueViewsByUser subscription: ",t)})}catch(e){this.loggingService.catch("Error in ViewAnalyticsComponent getDocumentViews: ",e)}}toggleTrends(){try{this.loggingService.log("%c[WB] Calling FUNCTION: toggleTrends","color: green;"),this.componentConfigSignal.update(e=>(e=m({},e),e.treadsVisible=!e.treadsVisible,e))}catch(e){this.loggingService.catch("Error in ViewAnalyticsComponent toggleTrends: ",e)}}openTrends(){try{this.loggingService.log("%c[WB] Calling FUNCTION: openTrends","color: green;"),this.componentConfigSignal.update(e=>(e=m({},e),e.treadsVisible=!0,e))}catch(e){this.loggingService.catch("Error in ViewAnalyticsComponent openTrends: ",e)}}closeTrends(){try{this.loggingService.log("%c[WB] Calling FUNCTION: closeTrends","color: green;"),this.componentConfigSignal.update(e=>(e=m({},e),e.treadsVisible=!1,e))}catch(e){this.loggingService.catch("Error in ViewAnalyticsComponent closeTrends: ",e)}}onButtonSlotChange(){this.componentConfigSignal.update(e=>(e=m({},e),e.customButtonAdded=!0,e))}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[],this.uniqueViewsByUserSubscription&&this.uniqueViewsByUserSubscription.unsubscribe()}catch(e){this.loggingService.catch("Error in ViewAnalyticsComponent unsubscribe: ",e)}}ngOnDestroy(){try{this.unsubscribe()}catch(e){this.loggingService.catch("Error in ViewAnalyticsComponent ngOnDestroy: ",e)}}};c.\u0275fac=function(t){return new(t||c)(I(qe),I(ve),I(C),I(P),I(oe),I(ue))},c.\u0275cmp=Q({type:c,selectors:[["velt-view-analytics-internal"]],inputs:{type:"type",clientLocationId:[0,"locationId","clientLocationId"]},standalone:!1,features:[Ae],decls:1,vars:1,consts:[["trigger","cdkOverlayOrigin"],["overlay","cdkConnectedOverlay"],[4,"ngIf"],["part","container","cdkOverlayOrigin","",1,"v-document-viewer-tread-container",3,"click"],["name","button",3,"slotchange"],["part","button-container",1,"action-btn"],["part","button-icon","width","24","height","24","viewBox","0 0 24 24","fill","none","xmlns","http://www.w3.org/2000/svg",1,"action-btn-icon"],["d","M4.5 16.1667L9.5 11.1667L12.8333 14.5L19.5 7.83334M19.5 7.83334H13.6667M19.5 7.83334V13.6667","stroke","currentColor","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round"],["part","button-label",1,"action-btn-label"],["cdkConnectedOverlay","",3,"cdkConnectedOverlayOrigin","cdkConnectedOverlayOpen","cdkConnectedOverlayPanelClass","cdkConnectedOverlayBackdropClass","cdkConnectedOverlayGrowAfterOpen","cdkConnectedOverlayPositions","cdkConnectedOverlayDisableClose"],[3,"clientLocationId","close",4,"ngIf"],[3,"close","clientLocationId"]],template:function(t,n){t&1&&T(0,Ut,12,12,"ng-container",2),t&2&&D("ngIf",n.componentConfigSignal())},dependencies:[le,Le,Ne,X,Ve],styles:[`html{--velt-base-rem-unit: 1}*[data-snippyly-element=true],*[data-velt-element=true]{font-family:var(--velt-default-font-family)}velt-wireframe{display:none!important}body.velt-pin-dragging iframe{pointer-events:none!important}*{box-sizing:border-box;-webkit-tap-highlight-color:rgba(255,255,255,0);outline:none;margin:0;padding:0;height:unset;width:unset;text-align:left;line-height:1.5;font-size:calc((1rem + 0px) * var(--velt-base-rem-unit))}*:empty{display:revert}.v-document-viewer-tread-container{display:inline-block}.action-btn{display:inline-flex;justify-content:center;align-items:center;padding:6px;border-radius:var(--legacy-velt-tool-border-radius);border:var(--legacy-velt-tool-border);background-color:var(--legacy-velt-tool-bg-color);color:var(--legacy-velt-tool-icon-color);cursor:pointer}.action-btn .action-btn-label{font-size:calc((.9rem + 0px) * var(--velt-base-rem-unit));padding:0 12px 0 4px;font-weight:700;color:currentColor}.action-btn .action-btn-icon{width:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-icon-size) + 0px) * var(--velt-base-rem-unit));color:currentColor;padding-left:8px;box-sizing:content-box}.action-btn .toolbar-icon-dropdown-arrow{width:16px;height:16px;color:currentColor}.action-btn:focus{border-radius:var(--legacy-velt-tool-focus-border-radius);border:var(--legacy-velt-tool-focus-border);background-color:var(--legacy-velt-tool-focus-bg-color);color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:focus .action-btn-icon{width:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-focus-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:focus .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-focus-icon-color)}.action-btn:hover{border-radius:var(--legacy-velt-tool-hover-border-radius);border:var(--legacy-velt-tool-hover-border);background-color:var(--legacy-velt-tool-hover-bg-color);color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:hover .action-btn-icon{width:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-hover-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:hover .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-hover-icon-color)}.action-btn:active,.action-btn.active{border-radius:var(--legacy-velt-tool-active-border-radius);border:var(--legacy-velt-tool-active-border);background-color:var(--legacy-velt-tool-active-bg-color);color:var(--legacy-velt-tool-active-icon-color)}.action-btn:active .action-btn-icon,.action-btn.active .action-btn-icon{width:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit));height:calc((var(--legacy-velt-tool-active-icon-size) + 0px) * var(--velt-base-rem-unit))}.action-btn:active .toolbar-icon-dropdown-arrow,.action-btn.active .toolbar-icon-dropdown-arrow{color:var(--legacy-velt-tool-active-icon-color)}
3
3
  `],encapsulation:3,changeDetection:0});let d=c;return d})();var he=class extends ut{constructor(c){super(c),this.getService(C).log("%c[WB] Creating CLASS: ViewsElement","color: blue;"),this.getUniqueViewsByUser=this._getUniqueViewsByUser,this.getUniqueViewsByDate=this._getUniqueViewsByDate}_getUniqueViewsByUser(c){this.getService(C).log("%c[WB] Calling FUNCTION: _getUniqueViewsByUser","color: green;");try{return this.trackEvent(ye.Events.Views.GET_UNIQUE_VIEWS_BY_USER_TRIGGERED,{payload:{clientLocationId:c}}),this.getService(P).getUniqueViewsByUser(c)}catch(r){return this.getService(C).catch("Error in getUniqueViewsByUser: ",r),b({})}}_getUniqueViewsByDate(c){this.getService(C).log("%c[WB] Calling FUNCTION: _getUniqueViewsByDate","color: green;");try{return this.trackEvent(ye.Events.Views.GET_UNIQUE_VIEWS_BY_DATE_TRIGGERED,{payload:{clientLocationId:c}}),this.getService(P).getUniqueViewsByDate(c)}catch(r){return this.getService(C).catch("Error in getUniqueViewsByDate: ",r),b({})}}};var ht=(()=>{let c=class c{};c.\u0275fac=function(t){return new(t||c)},c.\u0275mod=ke({type:c}),c.\u0275inj=Be({imports:[Pe,Me,Ke,dt]});let d=c;return d})();function kt(d){d.get(C).log("%c[WB] Loading view feature chunk","color: blue;"),d.get(me).set(Xe,d.get(P));let t=Ue(ht,d).injector;return Tt(t,E.TAGS.VELT_VIEW_ANALYTICS,Ie),new he(d)}function Tt(d,c,r){if(customElements.get(c))return;let e=Re(r,d);customElements.define(c,e)}export{kt as default};
package/velt.js CHANGED
@@ -1,7 +1,7 @@
1
- var SNIPPYLY_VERSION = '6.0.24';
1
+ var SNIPPYLY_VERSION = '6.0.25';
2
2
  Promise.allSettled||(Promise.allSettled=function(t){return Promise.all(t.map(function(r){return Promise.resolve(r).then(function(e){return{status:"fulfilled",value:e}}).catch(function(e){return{status:"rejected",reason:e}})}))});
3
3
 
4
- import{a as ws}from"./chunk-VSBVKZYP.js";import{a as Ls}from"./chunk-ZN6UGTUP.js";import{d as T}from"./chunk-D4RIWWWT.js";import{b as ko,d as re}from"./chunk-AAZRCO7P.js";import"./chunk-FV4CYQIJ.js";import{a as jo,d as Wo}from"./chunk-HWSQCIIL.js";import{b as Ds,c as xs,j as Ps,q as hi,t as Ns}from"./chunk-5CE5EQ5I.js";import"./chunk-N366MN5J.js";import"./chunk-R7PGKNXH.js";import"./chunk-OL2RJSA5.js";import{l as Ho,m as $o,o as Xo,r as Jo,s as ts,u as is,v as rs,w as ns}from"./chunk-S5U5EJSH.js";import{d as Ao}from"./chunk-FAOXE2LY.js";import{d as Zo}from"./chunk-2GJ6LQGO.js";import{a as pi}from"./chunk-NEJKRV3M.js";import{a as Ms}from"./chunk-UYR6HRGI.js";import"./chunk-Y7EFNXLS.js";import"./chunk-RHUUOSBK.js";import"./chunk-NAJL2GCA.js";import"./chunk-MKJOFE4P.js";import{A as Rs,B as ks,C as Pr,F as ye,G as Te,a as Ye,b as ai,f as li,g as st,i as Cs,j as ci,k as di,l as ui,m as At,n as bs,o as Ss,p as Es,q as Ts,r as Os,y as Is,z as As}from"./chunk-FZKRXZIZ.js";import{a as _s}from"./chunk-3ETDYFCP.js";import{a as Ke,b as xe,c as Rt,d as mi}from"./chunk-4OP5FRJZ.js";import{a as at}from"./chunk-FXHOBF24.js";import{a as xr}from"./chunk-VTMNUIEK.js";import{Ea as es,Fa as ee,Ha as It,I as ri,l as To,na as Yo,o as Oo,p as Io,ta as bt,v as Ro,y as Dr}from"./chunk-PS5CHEBA.js";import{a as Pe}from"./chunk-T3JQYK3N.js";import{C as D,n as Ot,o as ms,p as ps,r as gs,s as fs,t as vs,x as ys}from"./chunk-2TBFGTFV.js";import{$ as I,$j as ve,Ad as Po,Ba as Sr,Bb as B,Bd as Mo,Ca as ho,Cb as Ge,Db as je,Dd as No,E as no,Ea as mo,Ed as wo,Fa as po,Fb as Kt,Fd as Lo,Gb as Xt,Gi as g,Ha as W,Hb as Jt,Hc as ei,He as A,Ia as go,Ic as Qe,Id as Fo,Ja as Er,Jd as zo,K as oo,Kb as Or,Kd as Uo,M as so,Mb as yt,Md as qo,Nc as Ct,Pa as fo,Pb as We,Pe as ni,Qb as Ir,Qe as as,Ra as R,Rb as _t,Rd as Bo,Re as Et,Rg as cs,Sc as ti,Sd as Vo,Tc as Co,Td as Go,Uc as bo,Vc as ii,Vd as Qo,Wa as H,Wd as Ko,Xa as ke,Xc as So,Xd as St,Xj as si,Yc as Eo,Yd as fe,Yf as ls,_a as Tr,_f as oi,a as k,ab as ue,ac as Ar,ak as ie,b as j,ba as le,bc as De,c as Zn,ca as Re,cc as vo,d as fl,da as ao,e as Gt,ea as U,ec as Zt,ee as os,f as eo,fa as Fe,fb as Ue,g as L,hb as qe,hc as yo,i as jt,ib as Be,ja as Wt,ka as Ht,l as to,la as $t,li as ds,m as M,mc as He,na as Ee,nb as q,nc as $e,nj as Tt,oa as br,ob as $,od as Do,oj as l,pb as J,pj as V,qa as lo,qb as Z,r as x,rc as Rr,re as C,rj as us,sa as co,sc as _o,sj as hs,ub as ft,ue as ss,v as io,vb as vt,w as ro,wa as Qt,xa as uo,xb as Yt,ya as ze,zb as Ve,zc as kr,zd as xo}from"./chunk-U76HLU2G.js";var $n=fl((Sv,Hn)=>{"use strict";var p={};p.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)};p.localCName=p.generateIdentifier();p.splitLines=function(r){return r.trim().split(`
4
+ import{a as ws}from"./chunk-6BTXSFDP.js";import{a as Ls}from"./chunk-TMLYEZEQ.js";import{d as T}from"./chunk-R4FWZKFA.js";import{b as ko,d as re}from"./chunk-JICLHDU3.js";import"./chunk-CLRO2X6T.js";import{a as jo,d as Wo}from"./chunk-AP33ZJ2C.js";import{b as Ds,c as xs,j as Ps,q as hi,t as Ns}from"./chunk-Z7JR4TW6.js";import"./chunk-ZH5R4MP6.js";import"./chunk-LM54BOTU.js";import"./chunk-FJAMH4UH.js";import{l as Ho,m as $o,o as Xo,r as Jo,s as ts,u as is,v as rs,w as ns}from"./chunk-B3ZPP3EZ.js";import{d as Ao}from"./chunk-BJ5O5D7F.js";import{d as Zo}from"./chunk-JAKGBQ5D.js";import{a as pi}from"./chunk-JPOBXW24.js";import{a as Ms}from"./chunk-2JSXDPYO.js";import"./chunk-GB46XS3O.js";import"./chunk-FJ6KQ3QL.js";import"./chunk-W47H5WHD.js";import"./chunk-VYZZWZPY.js";import{A as Rs,B as ks,C as Pr,F as ye,G as Te,a as Ye,b as ai,f as li,g as st,i as Cs,j as ci,k as di,l as ui,m as At,n as bs,o as Ss,p as Es,q as Ts,r as Os,y as Is,z as As}from"./chunk-TN7X7OZD.js";import{a as _s}from"./chunk-NNZNLREA.js";import{a as Ke,b as xe,c as Rt,d as mi}from"./chunk-G3BZ4EU4.js";import{a as at}from"./chunk-CCZ3WXF4.js";import{a as xr}from"./chunk-LCACRBV3.js";import{Ea as es,Fa as ee,Ha as It,I as ri,l as To,na as Yo,o as Oo,p as Io,ta as bt,v as Ro,y as Dr}from"./chunk-NY2Q7SEG.js";import{a as Pe}from"./chunk-MEI3IAPO.js";import{D,o as Ot,p as ms,q as ps,s as gs,t as fs,u as vs,y as ys}from"./chunk-BR7AO7YV.js";import{$ as I,Ad as Po,Ba as Sr,Bb as B,Bd as Mo,Ca as ho,Cb as Ge,Db as je,Dd as No,E as no,Ea as mo,Ed as wo,Fa as po,Fb as Kt,Fd as Lo,Gb as Xt,Gi as g,Ha as W,Hb as Jt,Hc as ei,He as A,Ia as go,Ic as Qe,Id as Fo,Ja as Er,Jd as zo,K as oo,Kb as Or,Kd as Uo,M as so,Mb as yt,Md as qo,Nc as Ct,Pa as fo,Pb as We,Pe as ni,Qb as Ir,Qe as as,Ra as R,Rb as _t,Rd as Bo,Re as Et,Rg as cs,Sc as ti,Sd as Vo,Tc as Co,Td as Go,Uc as bo,Vc as ii,Vd as Qo,Wa as H,Wd as Ko,Xa as ke,Xc as So,Xd as St,Yc as Eo,Yd as fe,Yf as ls,Zj as si,_a as Tr,_f as oi,a as k,ab as ue,ac as Ar,b as j,ba as le,bc as De,bk as ve,c as Zn,ca as Re,cc as vo,ck as ie,d as fl,da as ao,e as Gt,ea as U,ec as Zt,ee as os,f as eo,fa as Fe,fb as Ue,g as L,hb as qe,hc as yo,i as jt,ib as Be,ja as Wt,ka as Ht,l as to,la as $t,li as ds,m as M,mc as He,na as Ee,nb as q,nc as $e,nj as Tt,oa as br,ob as $,od as Do,oj as l,pb as J,pj as V,qa as lo,qb as Z,r as x,rc as Rr,re as C,rj as us,sa as co,sc as _o,sj as hs,ub as ft,ue as ss,v as io,vb as vt,w as ro,wa as Qt,xa as uo,xb as Yt,ya as ze,zb as Ve,zc as kr,zd as xo}from"./chunk-CNB6D3KX.js";var $n=fl((Sv,Hn)=>{"use strict";var p={};p.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)};p.localCName=p.generateIdentifier();p.splitLines=function(r){return r.trim().split(`
5
5
  `).map(e=>e.trim())};p.splitSections=function(r){return r.split(`
6
6
  m=`).map((t,i)=>(i>0?"m="+t:t).trim()+`\r
7
7
  `)};p.getDescription=function(r){let e=p.splitSections(r);return e&&e[0]};p.getMediaSections=function(r){let e=p.splitSections(r);return e.shift(),e};p.matchPrefix=function(r,e){return p.splitLines(r).filter(t=>t.indexOf(e)===0)};p.parseCandidate=function(r){let e;r.indexOf("a=candidate:")===0?e=r.substring(12).split(" "):e=r.substring(10).split(" ");let t={foundation:e[0],component:{1:"rtp",2:"rtcp"}[e[1]]||e[1],protocol:e[2].toLowerCase(),priority:parseInt(e[3],10),ip:e[4],address:e[4],port:parseInt(e[5],10),type:e[7]};for(let i=8;i<e.length;i+=2)switch(e[i]){case"raddr":t.relatedAddress=e[i+1];break;case"rport":t.relatedPort=parseInt(e[i+1],10);break;case"tcptype":t.tcpType=e[i+1];break;case"ufrag":t.ufrag=e[i+1],t.usernameFragment=e[i+1];break;default:t[e[i]]===void 0&&(t[e[i]]=e[i+1]);break}return t};p.writeCandidate=function(r){let e=[];e.push(r.foundation);let t=r.component;t==="rtp"?e.push(1):t==="rtcp"?e.push(2):e.push(t),e.push(r.protocol.toUpperCase()),e.push(r.priority),e.push(r.address||r.ip),e.push(r.port);let i=r.type;return e.push("typ"),e.push(i),i!=="host"&&r.relatedAddress&&r.relatedPort&&(e.push("raddr"),e.push(r.relatedAddress),e.push("rport"),e.push(r.relatedPort)),r.tcpType&&r.protocol.toLowerCase()==="tcp"&&(e.push("tcptype"),e.push(r.tcpType)),(r.usernameFragment||r.ufrag)&&(e.push("ufrag"),e.push(r.usernameFragment||r.ufrag)),"candidate:"+e.join(" ")};p.parseIceOptions=function(r){return r.substring(14).split(" ")};p.parseRtpMap=function(r){let e=r.substring(9).split(" "),t={payloadType:parseInt(e.shift(),10)};return e=e[0].split("/"),t.name=e[0],t.clockRate=parseInt(e[1],10),t.channels=e.length===3?parseInt(e[2],10):1,t.numChannels=t.channels,t};p.writeRtpMap=function(r){let e=r.payloadType;r.preferredPayloadType!==void 0&&(e=r.preferredPayloadType);let t=r.channels||r.numChannels||1;return"a=rtpmap:"+e+" "+r.name+"/"+r.clockRate+(t!==1?"/"+t:"")+`\r
package/chunk-FXHOBF24.js DELETED
@@ -1 +0,0 @@
1
- import{Fa as F}from"./chunk-PS5CHEBA.js";import{B as C,C as w}from"./chunk-2TBFGTFV.js";import{E as h,G as d,Gi as D,He as $,K as v,M as l,Mj as k,V as n,_f as g,ak as U,ba as A,bi as I,ea as s,l as p,nf as M,nj as E,oj as R,pj as y,r as u,v as c,we as a,xe as m}from"./chunk-U76HLU2G.js";var Z=(()=>{let o=class o{constructor(e,t,r,b,f,W,T,j){this.analyticsService=e,this.authService=t,this.contactService=r,this.databaseService=b,this.docService=f,this.configService=W,this.loggingService=T,this.commonDbService=j,this.documentIAM$=new p(null),this.workspaceIAM$=new p(null),this.roles$=new p([]),this.getDocumentIamSubscription=null,this.getOrganizationIamSubscription=null,this.getWorkspaceIamSubscription=null;try{this.authService.setIamService(this),this.databaseService.getDb().pipe(h(i=>!!i),v(1)).subscribe(i=>{i&&(this.getUser(),this.getDocumentPaths())},i=>{this.loggingService.catch("Error in CommentService getDb subscription: ",i)}),this.getRole$().pipe(v(1)).subscribe(i=>{this.authService?.getUser()&&!i&&this.analyticsService.trackEvent(D.Events.Iam.USER_ACCESS_DENIED)}),this.documentIAM$.subscribe(i=>{i?.accessType&&this.contactService.setDocumentAccessType(i.accessType)})}catch(i){this.loggingService.catch("Error in IamService constructor: ",i)}}clearCache(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCache in IamService","color: green;");try{this.documentIAM$.next(null),this.workspaceIAM$.next(null),this.roles$.next([]),this.documentPaths=null}catch(e){this.loggingService.catch("Error in IamService clearCache: ",e)}}getUser(){try{this.authService.getUser$().pipe(h(e=>!!e)).subscribe(e=>{this.user=e,this.user?this.getDocumentIam():(this.getDocumentIamSubscription?.unsubscribe(),this.getOrganizationIamSubscription?.unsubscribe(),this.getWorkspaceIamSubscription?.unsubscribe())},e=>{this.loggingService.catch("Error in IamService getUser$ subscription: ",e)})}catch(e){this.loggingService.catch("Error in IamService getUser: ",e)}}getDocumentPaths(){try{this.docService.getDocumentPaths$().pipe(h(e=>!!e)).subscribe(e=>{this.documentPaths=e,this.getDocumentIam(),this.getWorkspaceIam()},e=>{this.loggingService.catch("Error in IamService getDocumentPaths$ subscription: ",e)})}catch(e){this.loggingService.catch("Error in IamService getDocumentPaths: ",e)}}getDocumentIam(){try{this.getDocumentIamSubscription&&(this.getDocumentIamSubscription.unsubscribe(),this.getDocumentIamSubscription=null),this.user?this.getDocumentIamSubscription=this.docService.getDocumentIam$().subscribe(e=>{let t=e||new M;this.documentIAM$.next(t)},e=>{this.loggingService.catch("Error in IamService getDocumentIam$ subscription: ",e)}):this.documentIAM$.next(null)}catch(e){this.loggingService.catch("Error in IamService getDocumentIam: ",e)}}getWorkspaceIam(){try{this.getWorkspaceIamSubscription||(this.getWorkspaceIamSubscription=this.commonDbService.dbListener({feature:"workspaceIam",properties:{skipFirestore:!0}}).pipe(d(e=>u(null))).subscribe(e=>{this.workspaceIAM$.next(e?.data),this.roles$.next(e?.data?.roles||[])}))}catch(e){this.loggingService.catch("Error in IamService getWorkspaceIam: ",e)}}isUserAllowed$(){return this.getRole$().pipe(c(e=>!!e),l())}getDocumentIAM$(){return this.documentIAM$.asObservable()}getRoles$(){return this.roles$.asObservable().pipe(c(e=>e?.length?e:$.WorkspaceRoles))}getFeaturesAccessLevel$(){return this.documentIAM$.asObservable().pipe(c(e=>e?.features),n(e=>this.getRole$().pipe(c(t=>(t===a.ADMIN&&(e=e&&JSON.parse(JSON.stringify(e||{})),e?.all?.disabled&&(e.all.disabled=!1)),e)))))}hasRole(e){try{return e===this.getRole()}catch(t){return this.loggingService.catch("Error in IamService hasRole: ",t),!1}}hasRoleAny(e=[]){try{return e?.includes(this.getRole()||"")}catch(t){return this.loggingService.catch("Error in IamService hasRoleAny: ",t),!1}}hasRole$(e){try{return this.authService.getUser$().pipe(n(()=>this.documentIAM$.pipe(h(t=>!!t),n(()=>this.workspaceIAM$.pipe(c(()=>e===this.getRole()))))))}catch(t){return this.loggingService.catch("Error in IamService hasRole$: ",t),u(!1)}}getRole$(){try{return this.authService.getUser$().pipe(n(()=>this.configService.getSF$()),n(()=>this.configService.getSF()?this.contactService.isUserGlobalContact$():u(null)),n(()=>this.configService.getSF()?this.documentIAM$.pipe(h(e=>!!e),l(I)):u(null)),n(()=>this.workspaceIAM$.pipe(l(I))),c(()=>this.getRole()))}catch(e){return this.loggingService.catch("Error in IamService getRole$: ",e),u(null)}}getRole(){try{let e=this.configService.getSF();if(this.user?.isAdmin)return a.ADMIN;return a.COMMENTER;if(this.user)switch((this.documentIAM$.value?this.documentIAM$.value?.features?.all?.restricted:!1)?m.RESTRICTED:this.documentIAM$.value?this.documentIAM$.value?.documentAccessType||m.PUBLIC:null){case m.PUBLIC:r=this.getUserFromDocumentIAM(this.user?.email,this.user?.userId),r||(r=this.getUserFromWorkspaceIAM(this.user?.email,this.user?.userId)),t=r?.role?.name||a.COMMENTER;break;case m.RESTRICTED:r=this.getUserFromDocumentIAM(this.user?.email,this.user?.userId),r||(r=this.getUserFromWorkspaceIAM(this.user?.email,this.user?.userId)),t=r?.role?.name||null;break;default:break}}catch(e){this.loggingService.catch("Error in IamService getRole: ",e)}return null}isUserAdmin$(){return this.getRole$().pipe(c(e=>e===a.ADMIN),l())}isUserAdmin(){try{return this.getRole()===a.ADMIN}catch(e){return this.loggingService.catch("Error in IamService isUserAdmin: ",e),!1}}getUserFromDocumentIAM(e,t){try{if(e||t){let r;return e&&(r=this.documentIAM$.value?.users?.[g(e)]),!r&&t&&(r=this.documentIAM$.value?.users?.[g(t)]),r}else return}catch(r){this.loggingService.catch("Error in IamService getUserFromDocumentIAM: ",r)}}getUserFromWorkspaceIAM(e,t){try{if(e||t){let r;return e&&(r=this.workspaceIAM$.value?.users?.[g(e)]),!r&&t&&(r=this.workspaceIAM$.value?.users?.[g(t)]),r}else return}catch(r){this.loggingService.catch("Error in IamService getUserFromWorkspaceIAM: ",r)}}};o.\u0275fac=function(t){return new(t||o)(s(E),s(U),s(F),s(k),s(w),s(y),s(R),s(C))},o.\u0275prov=A({token:o,factory:o.\u0275fac,providedIn:"root"});let S=o;return S})();export{Z as a};
package/chunk-S3ZS5EPV.js DELETED
@@ -1 +0,0 @@
1
- import{b as x,c as R,d as f,e as F,f as k}from"./chunk-HWSQCIIL.js";import{p as N}from"./chunk-2TBFGTFV.js";import{Gi as E,He as I,Ie as C,Xj as D,Yd as u,Yj as P,_d as y,ak as j,ba as v,bf as S,ea as d,ee as A,g,oj as L,pj as O,ug as w}from"./chunk-U76HLU2G.js";var z=l=>{try{let n={USE_PROFILES:{svg:!0,svgFilters:!0},FORBID_ATTR:["onerror","onload","onclick","onmouseover","onmouseout","onmouseenter","onmouseleave","onmousemove","onmousedown","onmouseup","onwheel","onscroll","onkeydown","onkeyup","onkeypress","onfocus","onblur","onchange","onsubmit","on*"],FORBID_TAGS:["script","style","iframe","object","embed","form"]};return P.sanitize(l,n)}catch(n){return u.catch("Error in File utils sanitizeSvg: ",n),""}},U=l=>{try{return l.name.split(".").slice(0,-1).join(".")}catch(n){u.catch("Error in File utils getFileName: ",n);return}},T=l=>{try{return/(?:\.([^.]+))?$/.exec(l?.name)[1]}catch(n){u.catch("Error in File utils getFileExtension: ",n);return}},M=(l,n)=>{try{let h=l.slice(0,-1,l.type);return new File([h],n+"."+T(l),{type:l.type})}catch(h){u.catch("Error in File utils updateFile: ",h);return}};var b={mp4:"video/mp4",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",flv:"video/x-flv",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",webm:"video/webm",mkv:"video/x-matroska",m4v:"video/x-m4v",m4a:"audio/x-m4a",aac:"audio/aac","3gp":"video/3gpp","3g2":"video/3gpp2",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",odt:"application/vnd.oasis.opendocument.text",ods:"application/vnd.oasis.opendocument.spreadsheet",zip:"application/zip",rar:"application/x-rar-compressed",txt:"text/plain",rtf:"application/rtf",html:"text/html",htm:"text/html",csv:"text/csv",ics:"text/calendar",vcf:"text/x-vcard",js:"application/javascript",css:"text/css",json:"application/json",xml:"application/xml",swf:"application/x-shockwave-flash"};var _=(()=>{let n=class n{getStorageInstance(t){return t?f(void 0,t):f()}ref(t,e){return F(t,e)}uploadBytesResumable(t,e,o){return k(t,e,o)}getDownloadURL(t){return R(t)}deleteObject(t){return x(t)}};n.\u0275fac=function(e){return new(e||n)},n.\u0275prov=v({token:n,factory:n.\u0275fac,providedIn:"root"});let l=n;return l})();var ae=(()=>{let n=class n{constructor(t,e,o,a,c,s){this.authService=t,this.configService=e,this.coreActionsService=o,this.loggingService=a,this.attachmentResolverService=c,this.storageAdapter=s,this.storage=this.storageAdapter.getStorageInstance();try{this.configService.getApiKey$().subscribe(r=>{this.apiKey=r}),this.authService.getFirebaseConfig$().subscribe(r=>{if(r&&r.firebaseOptions?.storageBucket){this.storage=this.storageAdapter.getStorageInstance(r?.firebaseOptions?.storageBucket);let i=this.configService.getProxyConfig();i?.storageHost&&(this.storage.host=i.storageHost)}},r=>{this.loggingService.catch("Error in StorageService constructor: ",r)})}catch(r){this.loggingService.catch("Error in StorageService constructor:",r)}}createAttachment({path:t,file:e}){try{let o=new C;o.name=e.name;let a=M(e,`${o.attachmentId}_${U(e)}`),c=`${this.apiKey}/${t}/${a?.name}`;return o.bucketPath=c,o.size=e.size,o.type=T(e),o?.type&&(o.mimeType=b[o?.type]),o}catch(o){return this.loggingService.catch("Error in StorageService createAttachment: ",o),null}}sanitizeSvgFile(t){return g(this,null,function*(){if(t.type===b.svg)try{let e=yield t.text(),o=z(e);return new File([o],t.name,{type:t.type})}catch(e){return this.loggingService.catch("Error in StorageService sanitizeSvgFile: ",e),t}return t})}uploadAttachmentToStorage(c){return g(this,arguments,function*({attachment:t,file:e,resolve:o,reject:a}){try{let s=this.storageAdapter.ref(this.storage,t.bucketPath),r=this.storageAdapter.uploadBytesResumable(s,e,{cacheControl:"public,max-age=3600"});r.on("state_changed",i=>{let m=i.bytesTransferred/i.totalBytes*100},i=>{a(i)},()=>{this.storageAdapter.getDownloadURL(r.snapshot.ref).then(i=>{t.url=i,o(t)})})}catch(s){this.loggingService.catch("Error in StorageService uploadAttachmentToStorage: ",s),a(s)}})}uploadToResolver(r){return g(this,arguments,function*({file:t,attachment:e,metadata:o,resolve:a,reject:c,scope:s}){try{o.attachmentId=e.attachmentId;let i={attachmentId:e.attachmentId,name:e.name,file:t,metadata:o,mimeType:e.mimeType},m=w();this.coreActionsService.triggerAction(A.ATTACHMENT_RESOLVER,{event:E.Events.Resolver.ATTACHMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:m,methodName:S.UPLOAD_TO_RESOLVER,source:"internal",payload:{attachment:i,eventType:y.ATTACHMENT_ADD}});let p=yield this.attachmentResolverService.saveAttachment({attachment:i,eventType:y.ATTACHMENT_ADD},m,s);p&&p.data?.url?(e.url=p.data?.url,a(e)):c(new Error("Failed to upload attachment to resolver"))}catch(i){this.loggingService.catch("Error in StorageService uploadToResolver: ",i),c(i)}})}uploadFile({path:t,file:e,useAttachmentResolver:o,metadata:a,attachmentScope:c}){return new Promise((s,r)=>g(this,null,function*(){try{if(!this.apiKey)throw new Error("API key not configured");let i=yield this.sanitizeSvgFile(e),m=this.createAttachment({path:t,file:i});if(!m)throw new Error("Attachment not created");o?this.uploadToResolver({file:i,attachment:m,metadata:a,resolve:s,reject:r,scope:c}):this.uploadAttachmentToStorage({attachment:m,file:i,resolve:s,reject:r})}catch(i){this.loggingService.catch("Error in StorageService uploadFile:",i),r(i)}}))}uploadChunk(t,e,o,a){return new Promise((c,s)=>{try{if(a?.useAttachmentResolver){let r=this.createAttachment({path:t,file:e});if(!r){s(new Error("Attachment not created for chunk upload"));return}this.uploadToResolver({file:e,attachment:r,metadata:a.metadata,resolve:i=>c(i.url),reject:s,scope:a.attachmentScope});return}if(this.apiKey){let r=`${this.apiKey}/${t}/${e.name}`,i=this.storageAdapter.ref(this.storage,r),m=this.storageAdapter.uploadBytesResumable(i,e,{cacheControl:"public,max-age=3600"});m.on("state_changed",p=>{let H=p.bytesTransferred/p.totalBytes*100},p=>{s(p)},()=>{this.storageAdapter.getDownloadURL(m.snapshot.ref).then(p=>{c(p)}).catch(p=>{this.loggingService.catch(`[uploadChunk] Error getting download URL for chunk ${o}:`,p),s(p)})})}else{let r=new Error("API key not available");this.loggingService.catch("[uploadChunk] API key not available",r),s(r)}}catch(r){this.loggingService.catch(`[uploadChunk] Error in StorageService uploadChunk for chunk ${o}: `,r),s(r)}})}downloadAttachment(t){try{if(t.url){let e=new XMLHttpRequest;e.responseType="blob",e.onload=()=>{let o=e.response,a=document.createElement("a"),c=window.URL.createObjectURL(o);a.setAttribute("type","hidden"),a.setAttribute(I.ATTRIBUTES.VELT_DOWNLOAD_BUTTON,"true"),a.classList.add("snippyly-overlay-panel"),a.href=c,t?.name&&(a.download=t?.name),document.body.appendChild(a);let s=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(s),window.URL.revokeObjectURL(c),a.remove()},e.onerror=()=>{window.open(t.url,"_blank")},e.open("GET",t.url),e.send()}}catch(e){this.loggingService.catch("Error in StorageService downloadAttachment: ",e)}}deleteAttachment({attachment:t,metadata:e,useAttachmentResolver:o,attachmentScope:a}){return new Promise((c,s)=>{if(o){let r=w();this.coreActionsService.triggerAction(A.ATTACHMENT_RESOLVER,{event:E.Events.Resolver.ATTACHMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:S.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:t.attachmentId,metadata:e}}),this.attachmentResolverService.deleteAttachment({attachmentId:t.attachmentId,metadata:e},r,a).then(()=>{c(null)}).catch(i=>{s(i)})}else{let r=this.storageAdapter.ref(this.storage,t.bucketPath);this.storageAdapter.deleteObject(r).then(()=>{c(null)}).catch(i=>{c(null)})}})}deleteFileFromPath(t){return new Promise((e,o)=>{let a=this.storageAdapter.ref(this.storage,t);this.storageAdapter.deleteObject(a).then(()=>{e(null)}).catch(c=>{o(c)})})}};n.\u0275fac=function(e){return new(e||n)(d(j),d(O),d(D),d(L),d(N),d(_))},n.\u0275prov=v({token:n,factory:n.\u0275fac,providedIn:"root"});let l=n;return l})();export{ae as a};