@veltdev/sdk-staging 6.0.13 → 6.0.14-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/models/element/activity-element.model.d.ts +9 -0
- package/app/models/element/autocomplete-element.model.d.ts +10 -0
- package/app/models/element/comment-element.model.d.ts +72 -0
- package/app/models/element/notification-element.model.d.ts +17 -0
- package/app/utils/constants.d.ts +1 -0
- package/{chunk-DZYVUUMS.js → chunk-2HGCWC7B.js} +1 -1
- package/chunk-2KTYC2AG.js +1 -0
- package/{chunk-5XJDGVGO.js → chunk-3AL5S762.js} +1 -1
- package/{chunk-TE4S24VF.js → chunk-45X5JRZ6.js} +1 -1
- package/chunk-6NWFM6PC.js +1 -0
- package/{chunk-IKXUU4LK.js → chunk-77FADRSO.js} +1 -1
- package/chunk-7TFVNMHJ.js +2 -0
- package/{chunk-NFQ33NZA.js → chunk-C5JOX4MX.js} +1 -1
- package/{chunk-XXU7YXMF.js → chunk-DFEL6HM7.js} +1 -1
- package/{chunk-Q2XHYKCH.js → chunk-DZYXTTOX.js} +1 -1
- package/{chunk-GHWFNVK2.js → chunk-FZSZ6AV3.js} +1 -1
- package/{chunk-MUMFBRNH.js → chunk-GULBDPIM.js} +1 -1
- package/{chunk-EMCGVIKG.js → chunk-HRCWTVRH.js} +1 -1
- package/{chunk-V32SISMC.js → chunk-HWS7Y4LE.js} +1 -1
- package/chunk-I63T4QWP.js +6 -0
- package/{chunk-ZUQTUSHK.js → chunk-IMH5OESK.js} +1 -1
- package/chunk-IQ22I2I3.js +1 -0
- package/{chunk-NYRQTKJA.js → chunk-KNQJBBQA.js} +1 -1
- package/chunk-KQPNTB77.js +1 -0
- package/chunk-KWLMOL5X.js +193 -0
- package/chunk-L4QMAEKA.js +1 -0
- package/chunk-MRY4A7N6.js +1 -0
- package/{chunk-4VEJIKFU.js → chunk-NMPXJFDX.js} +1 -1
- package/chunk-O3FUWWWQ.js +1 -0
- package/{chunk-LOLURD74.js → chunk-PWTBCAPJ.js} +1 -1
- package/{chunk-4BAHMWIE.js → chunk-TQNLXTQA.js} +1 -1
- package/{chunk-STNBRDN3.js → chunk-UI2CRSTN.js} +1 -1
- package/{chunk-YTVKKNRL.js → chunk-UVKIGEOH.js} +1 -1
- package/{chunk-4YEJYNMX.js → chunk-VJLHHQ2Z.js} +1 -1
- package/chunk-VW5ND7U4.js +93 -0
- package/{chunk-2LJHR77K.js → chunk-WMDZMDJS.js} +1 -1
- package/{chunk-SYWOQU23.js → chunk-YFBAHLK6.js} +26 -26
- package/chunk-YO4HNOAN.js +1 -0
- package/{chunk-IQIWMWKJ.js → chunk-ZHXLO4CC.js} +1 -1
- package/package.json +1 -1
- package/velt-activity-log.js +1 -1
- package/velt-area.js +1 -1
- package/velt-arrow.js +2 -2
- package/velt-comment.js +7 -7
- package/velt-crdt.js +1 -1
- package/velt-cursor.js +2 -2
- package/velt-huddle.js +2 -2
- package/velt-live-state-sync.js +2 -2
- package/velt-notification.js +1 -1
- package/velt-portable.js +1 -1
- package/velt-presence.js +1 -1
- package/velt-reaction.js +1 -1
- package/velt-recorder.js +1 -1
- package/velt-rewriter.js +2 -2
- package/velt-selection.js +1 -1
- package/velt-tag.js +1 -1
- package/velt-user-invite.js +2 -2
- package/velt-user-request.js +1 -1
- package/velt-video-player.js +1 -1
- package/velt-views.js +2 -2
- package/velt.js +6 -6
- package/chunk-6YGRELTV.js +0 -2
- package/chunk-7TNGPXR5.js +0 -1
- package/chunk-A4HLP4VU.js +0 -1
- package/chunk-A6I23DJF.js +0 -1
- package/chunk-DAUJEOMM.js +0 -193
- package/chunk-IEOSSENF.js +0 -1
- package/chunk-KJN6PDWN.js +0 -93
- package/chunk-KKKGHIG4.js +0 -1
- package/chunk-RSCWN2VG.js +0 -1
- package/chunk-SZUD6M7J.js +0 -6
- package/chunk-TG2UOHTU.js +0 -1
- package/chunk-UY5BYX47.js +0 -1
package/chunk-KKKGHIG4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$d as re,$e as nt,$f as Le,$h as gi,B as Qt,Bg as at,Bi as Ii,D as Yt,E as ge,G as it,Gg as le,He as d,I as Zt,J as Xt,Je as L,Jg as Qe,K as _e,Ke as He,Le as xe,M as J,N as ei,Ni as Ei,Oe as ti,Of as li,Pg as wt,Qd as we,Qf as ye,Ri as pe,Si as te,Ti as F,Uh as Q,Ui as Ue,V as ie,Vg as Be,Vh as Z,Wg as ct,Xe as ii,Xf as $e,Xg as lt,Xh as W,Y as rt,Yd as $t,Yf as Ke,Yh as H,Yi as Me,Zd as _,Ze as ri,Zf as De,Zh as ui,_d as q,_e as ne,_f as Ft,a as E,af as B,ag as me,ai as mi,b as w,ba as $,bf as Re,bi as dt,bj as vt,c as Gt,cf as M,df as Ge,di as Oe,ea as A,ee as S,ef as qe,fa as be,ff as V,g as T,gf as Je,gi as vi,gj as ce,h as qt,hf as X,hi as fi,hj as ft,i as Ae,if as ni,ii as Si,ij as Ai,jf as oe,ji as v,jj as St,k as Jt,kf as oi,ki as Ce,kj as Ri,l as b,lf as ee,lg as di,li as ht,lj as It,mg as hi,mj as Ti,ne as Lt,nj as Bt,of as si,oi as de,p as tt,pf as ai,qi as ut,r as P,rg as p,rj as Et,sj as At,tf as se,ti as gt,uf as Te,ug as ot,uj as j,v as G,vi as mt,w as ke,wj as yi,x as Kt,xe as Pe,xj as ve,yf as ci,zg as st,zi as ae}from"./chunk-SYWOQU23.js";var fe=(()=>{let l=class l{constructor(t,e,i){this.coreActionsService=t,this.loggingService=e,this.analyticsService=i,this.resolveTimeout=60*1e3,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.commentAnnotationDataProvider$=new b(null),this.commentAnnotationById$=new b({}),this.fieldsToRemove=[],this.additionalFields=[],this.additionalSaveEvents=[],this.getCommentAnnotationById=r=>{try{return this.commentAnnotationDataProviderAvailable()?this.commentAnnotationById$.value?.[r]:void 0}catch(n){this.loggingService.catch("Error in CommentAnnotationsResolverService getCommentAnnotationById:",n);return}};try{this.loggingService.log("CommentAnnotationsResolverService initialized"),this.commentAnnotationDataProvider$.subscribe(r=>{r&&(r.config?.resolveTimeout&&(this.resolveTimeout=r.config.resolveTimeout),r.config?.saveRetryConfig&&(this.retrySaveConfig=r.config.saveRetryConfig),r.config?.deleteRetryConfig&&(this.retryDeleteConfig=r.config.deleteRetryConfig),r.config?.getRetryConfig&&(this.retryGetConfig=r.config.getRetryConfig),r.config?.fieldsToRemove&&(this.fieldsToRemove=r.config.fieldsToRemove),r.config?.additionalFields&&(this.additionalFields=r.config.additionalFields||[]),this.additionalSaveEvents=(r.config?.additionalSaveEvents||[]).map(n=>n?.event).filter(n=>!!n))})}catch(r){this.loggingService.catch("Error in CommentAnnotationsResolverService constructor:",r)}}getProvider(){try{let t=this.commentAnnotationDataProvider$.getValue();return t||void 0}catch(t){this.loggingService.catch("Error in CommentAnnotationsResolverService getProvider:",t);return}}ngOnDestroy(){try{this.commentAnnotationById$.next({})}catch(t){this.loggingService.catch("Error in CommentAnnotationsResolverService ngOnDestroy:",t)}}resolveCommentAnnotations(r){return T(this,arguments,function*({request:t,uniqueId:e,moduleName:i}){try{if(this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: resolveCommentAnnotations","color: green;"),!this.commentAnnotationDataProviderAvailable())return{};let n,s=!1,a=!1,o=()=>{n&&(clearTimeout(n),n=void 0,a=!0)};return new Promise((c,h)=>{n=setTimeout(()=>{if(!a){s=!0,o();let D=e||p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:D,methodName:B.RESOLVE_COMMENT_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:new Error("Comment annotation resolution timeout"),request:t}}),h(new Error("Comment annotation resolution timeout"))}},this.commentAnnotationDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let m=this.getProvider();if(!m)return o(),c({});let f={},u=[...new Set(t.commentAnnotationIds||[])],g=w(E({},t),{commentAnnotationIds:u});T(this,null,function*(){try{if(u.length>0||t.documentIds?.length||t.folderId){let D=e||p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:D,methodName:B.RESOLVE_COMMENT_ANNOTATIONS,moduleName:i,source:"internal",payload:{request:g}});let U=W(()=>m?.config?.getConfig?.url?H(m.config.getConfig.url,m.config.getConfig.headers,g,!0,m.config.getConfig.credentials):m?.get?.(g)||Promise.resolve(void 0),"getCommentAnnotations",this.retryGetConfig).then(I=>s?{}:(o(),I&&I.statusCode!==200?(this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:D,methodName:B.RESOLVE_COMMENT_ANNOTATIONS,moduleName:i,source:"internal",payload:{result:I,request:g}}),this.loggingService.catch(I?.message??"Error in CommentAnnotationsResolverService resolveCommentAnnotations:"),{}):I?.data)).catch(I=>{throw o(),I});try{f=(yield U)||{},this.analyticsService.trackEvent(v.Events.Resolver.COMMENT_RESOLVER_GET,{sourceMethod:"resolveCommentAnnotations",source:"sdk",commentAnnotationIds:u});let I={};Object.entries(f).forEach(([R,C])=>{let N=this.commentAnnotationById$.value?.[R];N?N&&JSON.stringify(N)!==JSON.stringify(C)&&(I[R]=C):I[R]=C}),Object.keys(I).length>0&&this.commentAnnotationById$.next(E(E({},this.commentAnnotationById$.getValue()),I)),this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:D,methodName:B.RESOLVE_COMMENT_ANNOTATIONS,moduleName:i,source:"internal",payload:{result:I,request:g}}),c(I)}catch(I){let R=e||p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:R,methodName:B.RESOLVE_COMMENT_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:I,request:g}}),s||h(I),c(f)}}else o(),c({})}catch(D){o();let U=e||p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:U,methodName:B.RESOLVE_COMMENT_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:D,request:g}}),h(D)}})})}catch(n){this.loggingService.catch("Error in CommentAnnotationsResolverService resolveCommentAnnotations:",n);let s=e||p();return this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:B.RESOLVE_COMMENT_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:n,request:t}}),{}}})}saveCommentAnnotation(t,e){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: saveCommentAnnotation","color: green;");let i=this.getProvider();if(!this.commentAnnotationDataProviderAvailable())throw new Error("Comment annotation save data provider not available");let r=e||p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:r,methodName:B.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{request:t}});let n=JSON.parse(JSON.stringify(this.commentAnnotationById$.getValue()));this.commentAnnotationById$._value=E(E({},n),t.commentAnnotation);let s=this.getTargetComment(t.commentAnnotation,t.commentId),a=yield W(()=>{if(i?.config?.saveConfig?.url){let o={commentAnnotation:t.commentAnnotation,event:t.eventType,commentId:t.commentId,targetComment:s,metadata:Object.values(t.commentAnnotation??{})?.[0]?.metadata};return H(i.config.saveConfig.url,i.config.saveConfig.headers,o,!1,i.config.saveConfig.credentials)}return i?.save?.({commentAnnotation:t.commentAnnotation,event:t.eventType,commentId:t.commentId,targetComment:s,metadata:Object.values(t.commentAnnotation??{})?.[0]?.metadata})||Promise.resolve(void 0)},"saveCommentAnnotation",this.retrySaveConfig);return a&&a.statusCode!==200?(this.retrySaveConfig.revertOnFailure&&(this.commentAnnotationById$._value=n),this.loggingService.catch(a?.message??"Error in CommentAnnotationsResolverService saveCommentAnnotation:"),this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:r,methodName:B.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{error:a,request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.COMMENT_RESOLVER_SAVE,{sourceMethod:"saveCommentAnnotation",source:"sdk",commentAnnotationIds:Object.keys(t.commentAnnotation),eventType:t.eventType,commentId:t.commentId}),this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:r,methodName:B.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0},request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0})}catch(i){this.loggingService.warn("Error in CommentAnnotationsResolverService saveCommentAnnotation:",i);let r=e||p();return this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:r,methodName:B.SAVE_COMMENT_ANNOTATION,source:"internal",payload:{error:i,request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0}}})}getTargetComment(t,e){if(!(!e||!t))for(let i of Object.values(t)){let r=i?.comments?.[e];if(r)return r}}deleteCommentAnnotation(t,e,i){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: deleteCommentAnnotation","color: green;");let r=this.getProvider();if(!this.commentAnnotationDataProviderAvailable())throw new Error("Comment annotation delete data provider not available");let n=this.commentAnnotationById$.getValue(),a=n?.[t]?.metadata??(e?Z(e):void 0),o=a?E({apiKey:a.apiKey??null,documentId:a.documentId??null,organizationId:a.organizationId??null},a.folderId&&{folderId:a.folderId}):void 0,c=i||p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:c,methodName:B.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{commentAnnotationId:t.toString(),metadata:o}});let h=E({},n);delete h?.[t],this.commentAnnotationById$._value=h;let m=yield W(()=>{if(r?.config?.deleteConfig?.url){let f={commentAnnotationId:t.toString(),metadata:o,event:q.COMMENT_ANNOTATION_DELETE};return H(r.config.deleteConfig.url,r.config.deleteConfig.headers,f,!1,r.config.deleteConfig.credentials)}return r?.delete?.({commentAnnotationId:t.toString(),metadata:o,event:q.COMMENT_ANNOTATION_DELETE})||Promise.resolve(void 0)},"deleteCommentAnnotation",this.retryDeleteConfig);return m&&m.statusCode!==200?(this.retryDeleteConfig.revertOnFailure&&(this.commentAnnotationById$._value=n),this.loggingService.catch(m?.message??"Error in CommentAnnotationsResolverService deleteCommentAnnotation:"),this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:c,methodName:B.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{error:m,commentAnnotationId:t.toString(),metadata:o}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.COMMENT_RESOLVER_DELETE,{sourceMethod:"deleteCommentAnnotation",source:"sdk",commentAnnotationId:t.toString()}),this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:c,methodName:B.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},commentAnnotationId:t.toString(),metadata:o}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(r){this.loggingService.warn("Error in CommentAnnotationsResolverService deleteCommentAnnotation:",r);let n=i||p(),s=e?Z(e):void 0;return this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:n,methodName:B.DELETE_COMMENT_ANNOTATION,source:"internal",payload:{error:r,commentAnnotationId:t.toString(),metadata:s}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}getCommentAnnotationsById$(){try{return this.commentAnnotationDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling CommentAnnotationsResolverService FUNCTION: getCommentAnnotationsById$","color: green;"),this.commentAnnotationById$.asObservable()):P(void 0)}catch(t){return this.loggingService.catch("Error in CommentAnnotationsResolverService getCommentAnnotationsById$:",t),P(void 0)}}getAnnotationById(t){try{return this.commentAnnotationDataProviderAvailable()?this.commentAnnotationById$.getValue()?.[t]:void 0}catch(e){this.loggingService.catch("Error in CommentAnnotationsResolverService getAnnotationById:",e);return}}getFieldsToRemove(){try{return this.fieldsToRemove}catch(t){return this.loggingService.catch("Error in CommentAnnotationsResolverService getFieldsToRemove:",t),this.fieldsToRemove}}getAdditionalFields(){try{return this.additionalFields}catch(t){return this.loggingService.catch("Error in CommentAnnotationsResolverService getAdditionalFields:",t),this.additionalFields}}getAdditionalSaveEvents(){try{return this.additionalSaveEvents}catch(t){return this.loggingService.catch("Error in CommentAnnotationsResolverService getAdditionalSaveEvents:",t),this.additionalSaveEvents}}setCommentAnnotationDataProvider(t){try{if(t){this.loggingService.log("Setting comment annotation data provider");let e=t.config,i=[{method:"get",configKey:"getConfig"},{method:"save",configKey:"saveConfig"},{method:"delete",configKey:"deleteConfig"}],r=[];if(i.forEach(({method:n,configKey:s})=>{let a=e?.[s]?.url,o=n in t&&typeof t[n]=="function";!a&&!o&&r.push(n)}),r.length>0){let n=`DataProviders.comment is invalid. The following methods are missing or are not functions (and no corresponding config provided): ${r.join(", ")}.`;this.loggingService.catch(n);return}else this.commentAnnotationDataProvider$.next(t)}}catch(e){this.loggingService.catch("Error in CommentAnnotationsResolverService setCommentAnnotationDataProvider:",e)}}commentAnnotationDataProviderAvailable(){try{return!!this.commentAnnotationDataProvider$.getValue()}catch(t){return this.loggingService.catch("Error in CommentAnnotationsResolverService commentAnnotationDataProviderAvailable:",t),!1}}};l.\u0275fac=function(e){return new(e||l)(A(j),A(F),A(te))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Se=(()=>{let l=class l{constructor(t,e,i){this.coreActionsService=t,this.loggingService=e,this.analyticsService=i,this.resolveTimeout=60*1e3,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.reactionAnnotationDataProvider$=new b(null),this.reactionAnnotationById$=new b({}),this.fieldsToRemove=[],this.getReactionAnnotationById=r=>{try{return this.reactionAnnotationDataProviderAvailable()?this.reactionAnnotationById$.value?.[r]:void 0}catch(n){this.loggingService.catch("Error in ReactionAnnotationsResolverService getReactionAnnotationById:",n);return}};try{this.loggingService.log("ReactionAnnotationsResolverService initialized"),this.reactionAnnotationDataProvider$.subscribe(r=>{r&&(r.config?.resolveTimeout&&(this.resolveTimeout=r.config.resolveTimeout),r.config?.saveRetryConfig&&(this.retrySaveConfig=r.config.saveRetryConfig),r.config?.deleteRetryConfig&&(this.retryDeleteConfig=r.config.deleteRetryConfig),r.config?.getRetryConfig&&(this.retryGetConfig=r.config.getRetryConfig),r.config?.fieldsToRemove&&(this.fieldsToRemove=r.config.fieldsToRemove||[]))})}catch(r){this.loggingService.catch("Error in ReactionAnnotationsResolverService constructor:",r)}}getProvider(){try{let t=this.reactionAnnotationDataProvider$.getValue();return t||void 0}catch(t){this.loggingService.catch("Error in ReactionAnnotationsResolverService getProvider:",t);return}}ngOnDestroy(){try{this.reactionAnnotationById$.next({})}catch(t){this.loggingService.catch("Error in ReactionAnnotationsResolverService ngOnDestroy:",t)}}getFieldsToRemove(){try{return this.fieldsToRemove}catch(t){return this.loggingService.catch("Error in ReactionAnnotationsResolverService getFieldsToRemove:",t),this.fieldsToRemove}}resolveReactionAnnotations(r){return T(this,arguments,function*({request:t,uniqueId:e,moduleName:i}){try{if(this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: resolveReactionAnnotations","color: green;"),!this.reactionAnnotationDataProviderAvailable())return{};let n,s=!1,a=!1,o=()=>{n&&(clearTimeout(n),n=void 0,a=!0)};return new Promise((c,h)=>{n=setTimeout(()=>{if(!a){s=!0,o();let D=e||p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:D,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:new Error("Reaction annotation resolution timeout"),request:t}}),h(new Error("Reaction annotation resolution timeout"))}},this.reactionAnnotationDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let m=this.getProvider();if(!m)return o(),c({});let f={},u=[...new Set(t.reactionAnnotationIds||[])],g=w(E({},t),{reactionAnnotationIds:u});T(this,null,function*(){try{if(u.length>0||t.documentIds?.length||t.folderId){let D=e||p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:D,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:i,source:"internal",payload:{request:g}});let U=W(()=>m?.config?.getConfig?.url?H(m.config.getConfig.url,m.config.getConfig.headers,g,!0,m.config.getConfig.credentials):m?.get?.(g)||Promise.resolve(void 0),"getReactionAnnotations",this.retryGetConfig).then(I=>s?{}:(o(),I&&I.statusCode!==200?(this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:D,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:i,source:"internal",payload:{result:I,request:g}}),this.loggingService.catch(I?.message??"Error in ReactionAnnotationsResolverService resolveReactionAnnotations:"),{}):I?.data)).catch(I=>{throw o(),I});try{f=(yield U)||{},this.analyticsService.trackEvent(v.Events.Resolver.REACTION_RESOLVER_GET,{sourceMethod:"resolveReactionAnnotations",source:"sdk",reactionAnnotationIds:u});let I={};Object.entries(f).forEach(([R,C])=>{let N=this.reactionAnnotationById$.value?.[R];N?N&&JSON.stringify(N)!==JSON.stringify(C)&&(I[R]=C):I[R]=C}),Object.keys(I).length>0&&this.reactionAnnotationById$.next(E(E({},this.reactionAnnotationById$.getValue()),I)),this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:D,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:i,source:"internal",payload:{result:I,request:g}}),c(I)}catch(I){let R=e||p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:R,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:I,request:g}}),s||h(I),c(f)}}else o(),c({})}catch(D){o();let U=e||p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:U,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:D,request:g}}),h(D)}})})}catch(n){this.loggingService.catch("Error in ReactionAnnotationsResolverService resolveReactionAnnotations:",n);let s=e||p();return this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:n,request:t}}),{}}})}saveReactionAnnotation(t,e){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: saveReactionAnnotation","color: green;");let i=this.getProvider();if(!this.reactionAnnotationDataProviderAvailable())throw new Error("Reaction annotation save data provider not available");let r=e||p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:r,methodName:M.SAVE_REACTION_ANNOTATION,source:"internal",payload:{request:t}});let n=JSON.parse(JSON.stringify(this.reactionAnnotationById$.getValue()));this.reactionAnnotationById$._value=E(E({},n),t);let s={reactionAnnotation:t,event:q.REACTION_ADD,metadata:Object.values(t??{})?.[0]?.metadata},a=yield W(()=>i?.config?.saveConfig?.url?H(i.config.saveConfig.url,i.config.saveConfig.headers,s,!1,i.config.saveConfig.credentials):i?.save?.(s)||Promise.resolve(void 0),"saveReactionAnnotation",this.retrySaveConfig);return a&&a.statusCode!==200?(this.retrySaveConfig.revertOnFailure&&(this.reactionAnnotationById$._value=n),this.loggingService.catch(a?.message??"Error in ReactionAnnotationsResolverService saveReactionAnnotation:"),this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:r,methodName:M.SAVE_REACTION_ANNOTATION,source:"internal",payload:{error:a,request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.REACTION_RESOLVER_SAVE,{sourceMethod:"saveReactionAnnotation",source:"sdk",reactionAnnotationIds:Object.keys(t),eventType:s.event}),this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:r,methodName:M.SAVE_REACTION_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0},request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0})}catch(i){this.loggingService.warn("Error in ReactionAnnotationsResolverService saveReactionAnnotation:",i);let r=e||p();return this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:r,methodName:M.SAVE_REACTION_ANNOTATION,source:"internal",payload:{error:i,request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0}}})}deleteReactionAnnotation(t,e,i){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: deleteReactionAnnotation","color: green;");let r=this.getProvider();if(!this.reactionAnnotationDataProviderAvailable())throw new Error("Reaction annotation delete data provider not available");let n=JSON.parse(JSON.stringify(this.reactionAnnotationById$.getValue())),s=e??n?.[t]?.metadata,a=s?Z(s):void 0,o=a?E({apiKey:a.apiKey??null,documentId:a.documentId??null,organizationId:a.organizationId??null},a.folderId&&{folderId:a.folderId}):void 0,c=i||p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:c,methodName:M.DELETE_REACTION_ANNOTATION,source:"internal",payload:{reactionAnnotationId:t.toString(),metadata:o}});let h=E({},n);delete h?.[t],this.reactionAnnotationById$._value=h;let m=yield W(()=>{if(r?.config?.deleteConfig?.url){let f={reactionAnnotationId:t.toString(),metadata:o,event:q.REACTION_DELETE};return H(r.config.deleteConfig.url,r.config.deleteConfig.headers,f,!1,r.config.deleteConfig.credentials)}return r?.delete?.({reactionAnnotationId:t.toString(),metadata:o,event:q.REACTION_DELETE})||Promise.resolve(void 0)},"deleteReactionAnnotation",this.retryDeleteConfig);return m&&m.statusCode!==200?(this.retryDeleteConfig.revertOnFailure&&(this.reactionAnnotationById$._value=n),this.loggingService.catch(m?.message??"Error in ReactionAnnotationsResolverService deleteReactionAnnotation:"),this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:c,methodName:M.DELETE_REACTION_ANNOTATION,source:"internal",payload:{error:m,reactionAnnotationId:t.toString(),metadata:o}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.REACTION_RESOLVER_DELETE,{sourceMethod:"deleteReactionAnnotation",source:"sdk",reactionAnnotationId:t.toString()}),this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:c,methodName:M.DELETE_REACTION_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},reactionAnnotationId:t.toString(),metadata:o}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(r){this.loggingService.warn("Error in ReactionAnnotationsResolverService deleteReactionAnnotation:",r);let n=i||p(),s=e?Z(e):void 0;return this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:n,methodName:M.DELETE_REACTION_ANNOTATION,source:"internal",payload:{error:r,reactionAnnotationId:t.toString(),metadata:s}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}getReactionAnnotationsById$(){try{return this.reactionAnnotationDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling ReactionAnnotationsResolverService FUNCTION: getReactionAnnotationsById$","color: green;"),this.reactionAnnotationById$.asObservable()):P(void 0)}catch(t){return this.loggingService.catch("Error in ReactionAnnotationsResolverService getReactionAnnotationsById$:",t),P(void 0)}}getAnnotationById(t){try{return this.reactionAnnotationDataProviderAvailable()?this.reactionAnnotationById$.getValue()?.[t]:void 0}catch(e){this.loggingService.catch("Error in ReactionAnnotationsResolverService getAnnotationById:",e);return}}setReactionAnnotationDataProvider(t){try{if(t){this.loggingService.log("Setting reaction annotation data provider");let e=t.config,i=[{method:"get",configKey:"getConfig"},{method:"save",configKey:"saveConfig"},{method:"delete",configKey:"deleteConfig"}],r=[];if(i.forEach(({method:n,configKey:s})=>{let a=e?.[s]?.url,o=n in t&&typeof t[n]=="function";!a&&!o&&r.push(n)}),r.length>0){let n=`DataProviders.reaction is invalid. The following methods are missing or are not functions (and no corresponding config provided): ${r.join(", ")}.`;this.loggingService.catch(n);return}else this.reactionAnnotationDataProvider$.next(t)}}catch(e){this.loggingService.catch("Error in ReactionAnnotationsResolverService setReactionAnnotationDataProvider:",e)}}reactionAnnotationDataProviderAvailable(){try{return!!this.reactionAnnotationDataProvider$.getValue()}catch(t){return this.loggingService.catch("Error in ReactionAnnotationsResolverService reactionAnnotationDataProviderAvailable:",t),!1}}};l.\u0275fac=function(e){return new(e||l)(A(j),A(F),A(te))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Ve=(()=>{let l=class l{constructor(t,e,i){this.coreActionsService=t,this.loggingService=e,this.analyticsService=i,this.providers=new Map,this.retrySaveConfigs=new Map,this.retryDeleteConfigs=new Map,this.defaultRetryConfig={retryCount:0,retryDelay:0,revertOnFailure:!1};try{this.loggingService.log("AttachmentResolverService initialized")}catch(r){this.loggingService.catch("Error in AttachmentResolverService constructor:",r)}}getProvider(t){try{let e=t||"default";return this.providers.get(e)||void 0}catch(e){this.loggingService.catch("Error in AttachmentResolverService getProvider:",e);return}}getRetrySaveConfig(t){let e=t||"default";return this.retrySaveConfigs.get(e)||this.defaultRetryConfig}getRetryDeleteConfig(t){let e=t||"default";return this.retryDeleteConfigs.get(e)||this.defaultRetryConfig}makeAttachmentConfigBasedRequest(t,e,i,r,n){return T(this,null,function*(){try{let s=typeof e=="function"?yield e():e||{},a=new FormData;a.append("file",i);let o={attachment:{attachmentId:r.attachment.attachmentId,name:r.attachment.name,mimeType:r.attachment.mimeType},metadata:r.metadata,event:r.event};a.append("request",JSON.stringify(o));let c={};Object.entries(s).forEach(([f,u])=>{f.toLowerCase()!=="content-type"&&(c[f]=u)});let h=yield fetch(t,E({method:"POST",headers:c,body:a},n?{credentials:n}:{}));return h.ok?{data:(yield h.json())?.data??{},success:!0,statusCode:200}:($t.catch(`Error in makeAttachmentConfigBasedRequest: ${h.status} ${h.statusText}`),{data:{},success:!1,statusCode:h.status})}catch(s){return $t.catch("Error in makeAttachmentConfigBasedRequest:",s),{data:{},success:!1,statusCode:500}}})}saveAttachment(t,e,i){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling AttachmentResolverService FUNCTION: saveAttachment","color: green;");let r=this.getProvider(i);if(!this.attachmentDataProviderAvailable(i))throw new Error("Attachment save data provider not available");let n=this.getRetrySaveConfig(i),s=e||p();this.coreActionsService.triggerAction(S.ATTACHMENT_RESOLVER,{event:v.Events.Resolver.ATTACHMENT_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:s,methodName:Re.SAVE_ATTACHMENT,source:"internal",payload:{request:t}});let a=yield W(()=>T(this,null,function*(){if(r?.config?.saveConfig?.url){let o=t.attachment,{file:c}=o,h=Gt(o,["file"]);return this.makeAttachmentConfigBasedRequest(r.config.saveConfig.url,r.config.saveConfig.headers,c,{attachment:h,event:t.eventType,metadata:t.attachment.metadata},r.config.saveConfig.credentials)}return r?.save?.({attachment:t.attachment,event:t.eventType,metadata:t.attachment.metadata})||Promise.resolve(void 0)}),"saveAttachment",n);if(a?.statusCode!==200){this.loggingService.catch(a?.message??"Error in AttachmentResolverService saveAttachment:"),this.coreActionsService.triggerAction(S.ATTACHMENT_RESOLVER,{event:v.Events.Resolver.ATTACHMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:Re.SAVE_ATTACHMENT,source:"internal",payload:{error:a,request:t}});return}return this.analyticsService.trackEvent(v.Events.Resolver.ATTACHMENT_RESOLVER_SAVE,{sourceMethod:"saveAttachment",source:"sdk",attachmentId:t.attachment.attachmentId,eventType:t.eventType}),this.coreActionsService.triggerAction(S.ATTACHMENT_RESOLVER,{event:v.Events.Resolver.ATTACHMENT_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:s,methodName:Re.SAVE_ATTACHMENT,source:"internal",payload:{result:a,request:t}}),a}catch(r){this.loggingService.warn("Error in AttachmentResolverService saveAttachment:",r);let n=e||p();this.coreActionsService.triggerAction(S.ATTACHMENT_RESOLVER,{event:v.Events.Resolver.ATTACHMENT_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:n,methodName:Re.SAVE_ATTACHMENT,source:"internal",payload:{error:r,request:t}});return}})}deleteAttachment(n,s,a){return T(this,arguments,function*({attachmentId:t,metadata:e},i,r){try{this.loggingService.log("%c[WB] Calling AttachmentResolverService FUNCTION: deleteAttachment","color: green;");let o=this.getProvider(r);if(!this.attachmentDataProviderAvailable(r))throw new Error("Attachment delete data provider not available");let c=e?E({apiKey:e.apiKey??null,documentId:e.documentId??null,organizationId:e.organizationId??null},e.folderId&&{folderId:e.folderId}):void 0,h=this.getRetryDeleteConfig(r),m=i||p();this.coreActionsService.triggerAction(S.ATTACHMENT_RESOLVER,{event:v.Events.Resolver.ATTACHMENT_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:m,methodName:Re.DELETE_ATTACHMENT,source:"internal",payload:{attachmentId:t,metadata:c}});let f=yield W(()=>{if(o?.config?.deleteConfig?.url){let u={attachmentId:t,metadata:c,event:q.ATTACHMENT_DELETE};return H(o.config.deleteConfig.url,o.config.deleteConfig.headers,u,!1,o.config.deleteConfig.credentials)}return o?.delete?.({attachmentId:t,metadata:c,event:q.ATTACHMENT_DELETE})||Promise.resolve(void 0)},"deleteAttachment",h);return f?.statusCode!==200?(this.loggingService.catch(f?.message??"Error in AttachmentResolverService deleteAttachment:"),this.coreActionsService.triggerAction(S.ATTACHMENT_RESOLVER,{event:v.Events.Resolver.ATTACHMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:m,methodName:Re.DELETE_ATTACHMENT,source:"internal",payload:{error:f,attachmentId:t,metadata:c}}),{revertOnFailure:h.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.ATTACHMENT_RESOLVER_DELETE,{sourceMethod:"deleteAttachment",source:"sdk",attachmentId:t}),this.coreActionsService.triggerAction(S.ATTACHMENT_RESOLVER,{event:v.Events.Resolver.ATTACHMENT_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:m,methodName:Re.DELETE_ATTACHMENT,source:"internal",payload:{result:{revertOnFailure:h.revertOnFailure,isSuccess:!0},attachmentId:t,metadata:c}}),{revertOnFailure:h.revertOnFailure,isSuccess:!0})}catch(o){this.loggingService.warn("Error in AttachmentResolverService deleteAttachment:",o);let c=this.getRetryDeleteConfig(r),h=i||p(),m=e?E({apiKey:e.apiKey??null,documentId:e.documentId??null,organizationId:e.organizationId??null},e.folderId&&{folderId:e.folderId}):void 0;return this.coreActionsService.triggerAction(S.ATTACHMENT_RESOLVER,{event:v.Events.Resolver.ATTACHMENT_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:h,methodName:Re.DELETE_ATTACHMENT,source:"internal",payload:{error:o,attachmentId:t,metadata:m}}),{revertOnFailure:c.revertOnFailure,isSuccess:!0}}})}setAttachmentDataProvider(t,e="default"){try{if(t){this.loggingService.log(`Setting attachment data provider for scope: ${e}`);let i=t.config,r=[{method:"save",configKey:"saveConfig"},{method:"delete",configKey:"deleteConfig"}],n=[];if(r.forEach(({method:s,configKey:a})=>{let o=i?.[a]?.url,c=s in t&&typeof t[s]=="function";!o&&!c&&n.push(s)}),n.length>0){let s=`DataProviders.attachment is invalid. The following methods are missing or are not functions (and no corresponding config provided): ${n.join(", ")}.`;this.loggingService.catch(s);return}else this.providers.set(e,t),t.config?.saveRetryConfig&&this.retrySaveConfigs.set(e,t.config.saveRetryConfig),t.config?.deleteRetryConfig&&this.retryDeleteConfigs.set(e,t.config.deleteRetryConfig)}}catch(i){this.loggingService.catch("Error in AttachmentResolverService setAttachmentDataProvider:",i)}}attachmentDataProviderAvailable(t){try{let e=t||"default";return this.providers.has(e)}catch(e){return this.loggingService.catch("Error in AttachmentResolverService attachmentDataProviderAvailable:",e),!1}}};l.\u0275fac=function(e){return new(e||l)(A(j),A(F),A(te))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Ne=(()=>{let l=class l{constructor(t,e,i,r){this.coreActionsService=t,this.loggingService=e,this.analyticsService=i,this.attachmentResolverService=r,this.resolveTimeout=60*1e3,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.recorderAnnotationDataProvider$=new b(null),this.recorderAnnotationById$=new b({}),this.additionalFields=[],this.fieldsToRemove=[],this.uploadChunks=!1,this.getRecorderAnnotationById=n=>{try{return this.recorderAnnotationDataProviderAvailable()?this.recorderAnnotationById$.value?.[n]:void 0}catch(s){this.loggingService.catch("Error in RecorderAnnotationsResolverService getRecorderAnnotationById:",s);return}};try{this.loggingService.log("RecorderAnnotationsResolverService initialized"),this.recorderAnnotationDataProvider$.subscribe(n=>{n&&(n.config?.resolveTimeout&&(this.resolveTimeout=n.config.resolveTimeout),n.config?.saveRetryConfig&&(this.retrySaveConfig=n.config.saveRetryConfig),n.config?.deleteRetryConfig&&(this.retryDeleteConfig=n.config.deleteRetryConfig),n.config?.getRetryConfig&&(this.retryGetConfig=n.config.getRetryConfig),n.config?.additionalFields&&(this.additionalFields=n.config.additionalFields||[]),n.config?.fieldsToRemove&&(this.fieldsToRemove=n.config.fieldsToRemove||[]),this.uploadChunks=n.uploadChunks??!1)})}catch(n){this.loggingService.catch("Error in RecorderAnnotationsResolverService constructor:",n)}}getProvider(){try{let t=this.recorderAnnotationDataProvider$.getValue();return t||void 0}catch(t){this.loggingService.catch("Error in RecorderAnnotationsResolverService getProvider:",t);return}}ngOnDestroy(){try{this.recorderAnnotationById$.next({})}catch(t){this.loggingService.catch("Error in RecorderAnnotationsResolverService ngOnDestroy:",t)}}resolveRecorderAnnotations(r){return T(this,arguments,function*({request:t,uniqueId:e,moduleName:i}){try{if(this.loggingService.log("%c[WB] Calling RecorderAnnotationsResolverService FUNCTION: resolveRecorderAnnotations","color: green;"),!this.recorderAnnotationDataProviderAvailable())return{};let n,s=!1,a=!1,o=()=>{n&&(clearTimeout(n),n=void 0,a=!0)};return new Promise((c,h)=>{n=setTimeout(()=>{if(!a){s=!0,o();let D=e||p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:D,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:new Error("Recorder annotation resolution timeout"),request:t}}),h(new Error("Recorder annotation resolution timeout"))}},this.recorderAnnotationDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let m=this.getProvider();if(!m)return o(),c({});let f={},u=[...new Set(t.recorderAnnotationIds||[])],g=w(E({},t),{recorderAnnotationIds:u});T(this,null,function*(){try{if(u.length>0||t.documentIds?.length){let D=e||p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:D,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:i,source:"internal",payload:{request:g}});let U=W(()=>m?.config?.getConfig?.url?H(m.config.getConfig.url,m.config.getConfig.headers,g,!0,m.config.getConfig.credentials):m?.get?.(g)||Promise.resolve(void 0),"getRecorderAnnotations",this.retryGetConfig).then(I=>s?{}:(o(),I&&I.statusCode!==200?(this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:D,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:i,source:"internal",payload:{result:I,request:g}}),this.loggingService.catch(I?.message??"Error in RecorderAnnotationsResolverService resolveRecorderAnnotations:"),{}):I?.data)).catch(I=>{throw o(),I});try{f=(yield U)||{},this.analyticsService.trackEvent(v.Events.Resolver.RECORDER_RESOLVER_GET,{sourceMethod:"resolveRecorderAnnotations",source:"sdk",recorderAnnotationIds:u});let I={};Object.entries(f).forEach(([R,C])=>{let N=this.recorderAnnotationById$.value?.[R];N?N&&JSON.stringify(N)!==JSON.stringify(C)&&(I[R]=C):I[R]=C}),Object.keys(I).length>0&&this.recorderAnnotationById$.next(E(E({},this.recorderAnnotationById$.getValue()),I)),this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:D,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:i,source:"internal",payload:{result:I,request:g}}),c(I)}catch(I){let R=e||p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:R,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:I,request:g}}),s||h(I),c(f)}}else o(),c({})}catch(D){o();let U=e||p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:U,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:D,request:g}}),h(D)}})})}catch(n){this.loggingService.catch("Error in RecorderAnnotationsResolverService resolveRecorderAnnotations:",n);let s=e||p();return this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:i,source:"internal",payload:{error:n,request:t}}),{}}})}saveRecorderAnnotation(t,e){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling RecorderAnnotationsResolverService FUNCTION: saveRecorderAnnotation","color: green;");let i=this.getProvider();if(!this.recorderAnnotationDataProviderAvailable())throw new Error("Recorder annotation save data provider not available");let r=e||p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:r,methodName:V.SAVE_RECORDER_ANNOTATION,source:"internal",payload:{request:t}});let n=JSON.parse(JSON.stringify(this.recorderAnnotationById$.getValue()));this.recorderAnnotationById$._value=E(E({},n),t.recorderAnnotation);let s=yield W(()=>{if(i?.config?.saveConfig?.url){let a={recorderAnnotation:t.recorderAnnotation,event:t.eventType,metadata:Object.values(t.recorderAnnotation??{})?.[0]?.metadata};return H(i.config.saveConfig.url,i.config.saveConfig.headers,a,!1,i.config.saveConfig.credentials)}return i?.save?.({recorderAnnotation:t.recorderAnnotation,event:t.eventType,metadata:Object.values(t.recorderAnnotation??{})?.[0]?.metadata})||Promise.resolve(void 0)},"saveRecorderAnnotation",this.retrySaveConfig);return s&&s.statusCode!==200?(this.retrySaveConfig.revertOnFailure&&(this.recorderAnnotationById$._value=n),this.loggingService.catch(s?.message??"Error in RecorderAnnotationsResolverService saveRecorderAnnotation:"),this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:r,methodName:V.SAVE_RECORDER_ANNOTATION,source:"internal",payload:{error:s,request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.RECORDER_RESOLVER_SAVE,{sourceMethod:"saveRecorderAnnotation",source:"sdk",recorderAnnotationIds:Object.keys(t.recorderAnnotation),eventType:t.eventType}),this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:r,methodName:V.SAVE_RECORDER_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0},request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0})}catch(i){this.loggingService.warn("Error in RecorderAnnotationsResolverService saveRecorderAnnotation:",i);let r=e||p();return this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:r,methodName:V.SAVE_RECORDER_ANNOTATION,source:"internal",payload:{error:i,request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0}}})}deleteRecorderAnnotation(t,e,i){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling RecorderAnnotationsResolverService FUNCTION: deleteRecorderAnnotation","color: green;");let r=this.getProvider();if(!this.recorderAnnotationDataProviderAvailable())throw new Error("Recorder annotation delete data provider not available");let n=this.recorderAnnotationById$.getValue(),a=n?.[t]?.metadata??(e?Z(e):void 0),o=a?E({apiKey:a.apiKey??null,documentId:a.documentId??null,organizationId:a.organizationId??null},a.folderId&&{folderId:a.folderId}):void 0,c=i||p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:c,methodName:V.DELETE_RECORDER_ANNOTATION,source:"internal",payload:{recorderAnnotationId:t.toString(),metadata:o}});let h=E({},n);delete h?.[t],this.recorderAnnotationById$._value=h;let m=yield W(()=>{if(r?.config?.deleteConfig?.url){let f={recorderAnnotationId:t.toString(),metadata:o,event:q.RECORDER_ANNOTATION_DELETE};return H(r.config.deleteConfig.url,r.config.deleteConfig.headers,f,!1,r.config.deleteConfig.credentials)}return r?.delete?.({recorderAnnotationId:t.toString(),metadata:o,event:q.RECORDER_ANNOTATION_DELETE})||Promise.resolve(void 0)},"deleteRecorderAnnotation",this.retryDeleteConfig);return m&&m.statusCode!==200?(this.retryDeleteConfig.revertOnFailure&&(this.recorderAnnotationById$._value=n),this.loggingService.catch(m?.message??"Error in RecorderAnnotationsResolverService deleteRecorderAnnotation:"),this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:c,methodName:V.DELETE_RECORDER_ANNOTATION,source:"internal",payload:{error:m,recorderAnnotationId:t.toString(),metadata:o}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.RECORDER_RESOLVER_DELETE,{sourceMethod:"deleteRecorderAnnotation",source:"sdk",recorderAnnotationId:t.toString()}),this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:c,methodName:V.DELETE_RECORDER_ANNOTATION,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},recorderAnnotationId:t.toString(),metadata:o}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(r){this.loggingService.warn("Error in RecorderAnnotationsResolverService deleteRecorderAnnotation:",r);let n=i||p(),s=e?Z(e):void 0;return this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:n,methodName:V.DELETE_RECORDER_ANNOTATION,source:"internal",payload:{error:r,recorderAnnotationId:t.toString(),metadata:s}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}getRecorderAnnotationsById$(){try{return this.recorderAnnotationDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling RecorderAnnotationsResolverService FUNCTION: getRecorderAnnotationsById$","color: green;"),this.recorderAnnotationById$.asObservable()):P(void 0)}catch(t){return this.loggingService.catch("Error in RecorderAnnotationsResolverService getRecorderAnnotationsById$:",t),P(void 0)}}getAnnotationById(t){try{return this.recorderAnnotationDataProviderAvailable()?this.recorderAnnotationById$.getValue()?.[t]:void 0}catch(e){this.loggingService.catch("Error in RecorderAnnotationsResolverService getAnnotationById:",e);return}}getAdditionalFields(){try{return this.additionalFields}catch(t){return this.loggingService.catch("Error in RecorderAnnotationsResolverService getAdditionalFields:",t),this.additionalFields}}getFieldsToRemove(){try{return this.fieldsToRemove}catch(t){return this.loggingService.catch("Error in RecorderAnnotationsResolverService getFieldsToRemove:",t),this.fieldsToRemove}}shouldUploadChunks(){return this.uploadChunks}shouldUploadFullRecording(){return this.recorderAnnotationDataProviderAvailable()&&!this.uploadChunks}setRecorderAnnotationDataProvider(t){try{if(t){this.loggingService.log("Setting recorder annotation data provider");let e=t.config,i=[{method:"get",configKey:"getConfig"},{method:"save",configKey:"saveConfig"},{method:"delete",configKey:"deleteConfig"}],r=[];if(i.forEach(({method:n,configKey:s})=>{let a=e?.[s]?.url,o=n in t&&typeof t[n]=="function";!a&&!o&&r.push(n)}),r.length>0){let n=`DataProviders.recorder is invalid. The following methods are missing or are not functions (and no corresponding config provided): ${r.join(", ")}.`;this.loggingService.catch(n);return}else t.storage&&this.attachmentResolverService.setAttachmentDataProvider(t.storage,"recorder"),this.attachmentResolverService.attachmentDataProviderAvailable("recorder")||this.loggingService.catch("Recording resolver is configured without storage resolver. Recording files (chunks, thumbnails) will be stored on Velt's infrastructure. Configure storage resolver for full self-hosting.",void 0,void 0,!0),this.recorderAnnotationDataProvider$.next(t)}}catch(e){this.loggingService.catch("Error in RecorderAnnotationsResolverService setRecorderAnnotationDataProvider:",e)}}recorderAnnotationDataProviderAvailable(){try{return!!this.recorderAnnotationDataProvider$.getValue()}catch(t){return this.loggingService.catch("Error in RecorderAnnotationsResolverService recorderAnnotationDataProviderAvailable:",t),!1}}};l.\u0275fac=function(e){return new(e||l)(A(j),A(F),A(te),A(Ve))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Tt=class{};var ze=(()=>{let l=class l{constructor(t,e,i,r,n,s,a,o,c,h,m,f){this.analyticsService=t,this.authService=e,this.databaseService=i,this.domService=r,this.configService=n,this.loggingService=s,this.commentResolverService=a,this.reactionResolverService=o,this.recorderResolverService=c,this.coreActionsService=h,this.functions=m,this.serviceBook=f,this.endpointsService=be(Me),this.adapterSelectorService=be(Et),this.documentPaths$=new b(null),this.docContext$=new b(null),this.documentIds$=new b([]),this.organizationConfig$=new b(null),this.firestorePaths$=new b(null),this.location$=new b(null),this.excludedLocationIds$=new b([]),this.organizationMetadata$=new b(null),this.documentMetadata$=new b(null),this.locationMetadata$=new b(null),this.customerMetadata$=new b(null),this.currentDocumentId=null,this.isCustomDocId=!1,this.locations$=new b({}),this.preDocumentIdChangeFunctions=new Map,this.draftDocuments=[],this.clientDocumentMetadataMap={},this.uiState=new b({}),this.lastSetDocumentIdExecutionTime=0,this.lastSetDocumentIdCallTime=0,this.setDocumentIdSubject=new Jt,this.DEBOUNCE_TIME=5e3,this.currentDebounceTime=this.DEBOUNCE_TIME,this.MAX_QUEUE_SIZE=100,this.queueSize=0,this.isDocumentIdInDebounceQueue=!1,this.currentValidationToken=null,this.pendingDocumentIds=[],this.pendingOptions={},this.draftLocationMap={locations:[],options:void 0},this.reportedOrgProfileDenials=new Set;try{this.loggingService.log("%c[WB] Creating CLASS: DocService","color: blue;"),this.domService.setDocService(this),this.authService.setDocService(this),this.serviceBook.observe(Ii).subscribe(u=>{this.commentService=u??void 0}),ti(()=>this.documentPaths$.value?.clientDocumentId),this.setDocumentIdSubject.pipe(Zt(()=>Qt(this.currentDebounceTime))).subscribe({next:u=>T(this,null,function*(){try{yield this.setDocumentIdImpl(u.documentId,u.clientOrganizationId,u.options),this.lastSetDocumentIdExecutionTime=Date.now(),this.isDocumentIdInDebounceQueue=!1,this.draftLocationMap.locations.length&&(yield this.setLocations({locations:this.draftLocationMap.locations,options:this.draftLocationMap.options,source:"internal"})),this.draftLocationMap={locations:[],options:void 0}}finally{this.queueSize--}}),error:u=>{this.loggingService.catch("Error in setDocumentId subscription:",u),this.queueSize--}}),this.databaseService.getDb().pipe(ge(u=>!!u),_e(1)).subscribe(u=>{u&&(this.db=u)}),this.configService.getApiKey$().subscribe(u=>{if(this.apiKey=u,this.apiKey){if(!this.isCustomDocId){let g=lt(window.location.href);this.currentUrl=g}this.analyticsService.updateDefaultProperties({apiKey:u})}}),this.authService.getUser$().subscribe(u=>T(this,null,function*(){if(u&&(this.analyticsService.updateDefaultProperties({organizationId:u?.organizationId,clientOrganizationId:u?.clientOrganizationId}),this.draftDocuments?.length?(yield this.setDocuments({documents:this.draftDocuments,options:this.draftOptions??void 0,source:"internal"}),this.draftDocuments=[],this.draftOptions=void 0,this.draftLocationMap.locations.length&&(yield this.setLocations({locations:this.draftLocationMap.locations,options:this.draftLocationMap.options,source:"internal"}).then(()=>this.draftLocationMap={locations:[],options:void 0}))):this.documentPaths$?.value&&u?.organizationId&&this.documentPaths$.value?.organizationId!==u?.organizationId&&(yield this.setDocuments({documents:this.documentIds$.value.length?this.documentIds$.value.map(g=>({id:g.clientDocumentId})):[{id:this.documentPaths$.value?.clientDocumentId}],options:void 0,source:"internal"})),setTimeout(()=>{this.documentPaths$.value||this.loggingService.catch("Error in DocService constructor:","Please set document id to continue.")},1e4),u?.organizationId&&u?.clientOrganizationId)){let g={organizationId:u?.organizationId,clientOrganizationId:u?.clientOrganizationId};this.getOrganizationConfig()||this.setOrganizationConfig({organizationId:u?.organizationId,clientOrganizationId:u?.clientOrganizationId}),yield this.updateOrganizationMetadata(g)}})),this.documentPaths$.subscribe(u=>{let g={documentId:u?.documentId,clientDocumentId:u?.clientDocumentId,folderId:u?.folderId,allDocuments:u?.allDocuments,veltFolderId:u?.veltFolderId};u?.organizationId&&(g.organizationId=u.organizationId,g.clientOrganizationId=u.clientOrganizationId),this.analyticsService.updateDefaultProperties(g),this.domService.resetSelectedAnnotationsMap()}),this.location$.subscribe(u=>{this.analyticsService.updateDefaultProperties({clientLocation:u?.location,locationId:u?.locationId})}),this.organizationMetadata$.subscribe(u=>{this.authService.setUserOrganization(u?.[this.documentPaths$.value?.organizationId])}),this.documentPaths$.pipe(ge(u=>!!u),_e(1)).subscribe(()=>{try{this.subscribeToCustomerMetadata()}catch(u){this.loggingService.catch("Error in DocService subscribeToCustomerMetadata:",u)}},u=>{this.loggingService.catch("Error in DocService subscribeToCustomerMetadata:",u)}),this.loggingService.log("%c[WB] Creating CLASS: DocService 2","color: blue;"),this.onWindowPopstate(),this.onWindowClick()}catch(u){this.loggingService.catch("Error in DocService constructor:",u)}}getOptionsFromDocumentPaths(){try{return this.documentPaths$.value?{organizationId:this.documentPaths$.value?.clientOrganizationId,folderId:this.documentPaths$.value?.folderId,allDocuments:this.documentPaths$.value?.allDocuments,locationId:this.documentPaths$.value?.locationId,optimisticPermissions:this.documentPaths$.value?.optimisticPermissions}:null}catch(t){return this.loggingService.catch("Error in getOptionsFromDocumentPaths:",t),null}}clearCacheOnUserCascade(){this.loggingService.log("%c[WB] Calling FUNCTION: clearCacheOnUserCascade in DocService","color: green;");try{this.setOrganizationConfig(null),this.organizationMetadata$.next(null),this.customerMetadata$.next(null),this.customerMetadataSubscription?.unsubscribe(),this.documentPaths$.value&&(this.draftOptions=this.getOptionsFromDocumentPaths(),this.draftDocuments=this.documentIds$.value.map(t=>({id:t.clientDocumentId})),this.draftLocationMap={locations:[this.location$.value?.location??null,...Object.values(this.locations$.value||{}).map(t=>t.location)].filter(t=>t!==null),options:{rootLocationId:this.location$.value?.location?.id}},this.currentDocumentId=null,this.documentPaths$.next(null),this.firestorePaths$.next(null)),this.unsetDocuments({source:"internal"})}catch(t){this.loggingService.catch("Error in DocService clearCacheOnUserCascade: ",t)}}setUsersService(t){try{this.usersService=t}catch(e){this.loggingService.catch("Error in setUsersService:",e)}}setCommonDbService(t){try{this.commonDbService=t}catch(e){this.loggingService.catch("Error in setCommonDbService:",e)}}setUserPermissionService(t){try{this.userPermissionService=t}catch(e){this.loggingService.catch("Error in setUserPermissionService:",e)}}setCommentService(t){try{this.commentService=t}catch(e){this.loggingService.catch("Error in setCommentService:",e)}}onWindowPopstate(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowPopstate","color: green;");try{this.domService.onWindowPopState$().subscribe(()=>{this.loggingService.log("location",location.href);let t=lt(location.href);this.currentUrl!==t&&(this.currentUrl=t,!this.isCustomDocId&&this.apiKey&&this.loggingService.log("current url in doc service",this.currentUrl))},t=>{this.loggingService.catch("Error in DocService onWindowPopstate subscription: ",t)})}catch(t){this.loggingService.catch("Error in onWindowPopstate: ",t)}}onWindowClick(){this.loggingService.log("%c[WB] Calling FUNCTION: onWindowClick","color: green;");try{this.domService.onWindowClick$().subscribe(()=>{let t=lt(location.href);this.currentUrl!==t&&(this.currentUrl=t,this.isCustomDocId||this.loggingService.log("current url in doc service",this.currentUrl))},t=>{this.loggingService.catch("Error in DocService onWindowClick subscription: ",t)})}catch(t){this.loggingService.catch("Error in onWindowClick: ",t)}}setDocument(n){return T(this,arguments,function*({documentId:t,documentMetadata:e,options:i,source:r="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocument","color: green;"),r==="internal"&&this.analyticsService.trackEvent(v.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{id:t,documentMetadata:e,methodName:"setDocument",source:r}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:ee.SET_DOCUMENTS,source:r,payload:{documentId:t,documentMetadata:e,options:i}}),yield this.setDocumentsImpl({documents:[{id:t,metadata:e}],options:E({organizationId:e?.organizationId},i??{}),source:r})}catch(s){this.loggingService.catch("Error in DocService setDocument:",s)}})}getEffectiveCompareOptions(t={}){let e=this.authService.getUser(),i=E({},t);return i.organizationId==null&&e?.organizationId&&e?.clientOrganizationId&&(i.organizationId=e.clientOrganizationId),ct(i)??{}}shouldSetDocumentsAgain(t,e={}){try{this.loggingService.log("%c[WB] Calling FUNCTION: shouldSetDocumentsAgain","color: green;");let i=this.getEffectiveCompareOptions(e),r=t.some(h=>h?.metadata&&typeof h.metadata=="object"&&!le(this.clientDocumentMetadataMap[h.id],h.metadata));if(this.pendingDocumentIds.length>0&&!r&&t.length===this.pendingDocumentIds.length&&t.every(m=>this.pendingDocumentIds.includes(m.id))&&le(i,this.pendingOptions))return!1;let n=this.documentPaths$.value?.clientDocumentId,s=e?.rootDocumentId??t[0]?.id,a=this.documentIds$.value.map(h=>h.clientDocumentId),o=ct(this.getOptionsFromDocumentPaths()??{})??{};return!((e?.allDocuments===!0||t.length===a.length)&&t.every(h=>a.includes(h.id)))||r||!le(o,i)||n!==s}catch(i){return this.loggingService.catch("Error in DocService shouldSetDocumentsAgain:",i),!0}}getDocumentIdsFromDocuments({documents:t,setClientDocumentMetadataMap:e=!1}){try{let i=[];return t.forEach(r=>{let n=r.id,s=`${$e(n)}`;e&&r?.metadata&&typeof r.metadata=="object"&&(this.clientDocumentMetadataMap[n]=r.metadata),i.push({documentId:s,clientDocumentId:n})}),i}catch(i){return this.loggingService.catch("Error in DocService getDocumentIdsFromDocuments:",i),[]}}setDocuments(n){return T(this,arguments,function*({documents:t,options:e,source:i="internal",skipPermissionValidation:r=!1}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocuments","color: green;"),i==="internal"&&this.analyticsService.trackEvent(v.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{documents:t,options:e,methodName:"setDocuments",source:i}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:ee.SET_DOCUMENTS,source:i,payload:{documents:t,options:e}}),yield this.setDocumentsImpl({documents:t,options:e??{},source:i,skipPermissionValidation:r})}catch(s){this.loggingService.catch("Error in DocService setDocuments:",s)}})}setRootDocument(i){return T(this,arguments,function*({document:t,source:e="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRootDocument","color: green;"),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.SET_ROOT_DOCUMENT_TRIGGERED,methodName:ee.SET_ROOT_DOCUMENT,source:e,payload:{document:t}});let r=this.getOptionsFromDocumentPaths()??{},n=this.documentIds$.value.map(s=>s.clientDocumentId);if(!n.includes(t.id)){let s=[...n.map(o=>({id:o})),{id:t.id}],a=this.getDocumentIdsFromDocuments({documents:s,setClientDocumentMetadataMap:!0});this.documentIds$.next(a)}yield this.setDocumentIdImpl(t.id,this.documentPaths$.value?.clientOrganizationId,r)}catch(r){this.loggingService.catch("Error in DocService setRootDocument:",r)}})}setDocContext(t){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocContext","color: green;");let e=JSON.parse(JSON.stringify(t??null));this.docContext$.next(e)}catch(e){this.loggingService.catch("Error in setDocContext: ",e)}}getDocContext(){return this.docContext$.getValue()}getDocContext$(){return this.docContext$.asObservable().pipe(J(Q))}getProcessedDocContext(){return ui(this.getDocContext())}filterRelevantDocuments(r){return T(this,arguments,function*({options:t,documentIds:e,skipPermissionValidation:i=!1}){try{let n=this.authService.getUser();return!n||!this.commonDbService?.shouldUseFirestore()||(e=yield this.fetchDocumentsFromFolder(t,e,n),yield this.handlePermissionProvider(t,e,n),e=yield this.filterDocumentsByPermissions(t,e,n,i),e=e.slice(0,50)),e}catch(n){return this.loggingService.catch("Error in DocService filterRelevantDocuments:",n),e}})}fetchDocumentsFromFolder(t,e,i){return T(this,null,function*(){if(!t?.folderId||!t?.allDocuments)return e;try{let r=Ce(this.functions,Oe({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));(yield dt({methodName:"getDocuments",data:{type:"getDocuments",metadata:{organizationId:t?.organizationId??i?.clientOrganizationId,folderId:t?.folderId}},getSdkProxy:r,userId:i?.userId??""}))?.data?.forEach(s=>{e.find(a=>a.clientDocumentId===s.id)||e.push({documentId:De(s.id),clientDocumentId:s.id})})}catch(r){this.loggingService.warn("Error in DocService fetchDocumentsFromFolder:",r)}return e})}buildPermissionRequests(t,e,i){try{let r=[];return t.organizationId&&t.organizationId!==i.clientOrganizationId&&r.push({userId:i.userId,resource:{id:t.organizationId,type:Te.ORGANIZATION,source:se.SET_DOCUMENTS,organizationId:t.organizationId,context:t?.context}}),t.folderId&&r.push({userId:i.userId,resource:{id:t.folderId,type:Te.FOLDER,source:se.SET_DOCUMENTS,organizationId:t?.organizationId??i?.clientOrganizationId??"",context:t?.context}}),e&&e.forEach(n=>{r.push({userId:i.userId,resource:E({id:n.clientDocumentId,type:Te.DOCUMENT,source:se.SET_DOCUMENTS,organizationId:t?.organizationId??i?.clientOrganizationId??"",context:t?.context},t?.folderId&&{parentFolderId:t.folderId})})}),t?.context&&this.userPermissionService?.getIsContextEnabled()&&gi({input:t?.context}).forEach(s=>{let a=JSON.stringify(s.access);r.push({userId:i.userId,resource:{id:a,type:Te.CONTEXT,source:se.SET_DOCUMENTS,organizationId:t?.organizationId??i?.clientOrganizationId??"",context:s}})}),r}catch(r){return this.loggingService.catch("Error in buildPermissionRequests:",r),[]}}processAccessibleContexts(t,e){try{if(!t?.success||!t?.data?.length||!this.userPermissionService?.getIsContextEnabled())return;let i=t.data.filter(r=>r.type===Te.CONTEXT&&r.hasAccess).map(r=>r.resourceId);if(this.loggingService.logContext("[CONTEXT] processAccessibleContexts called with accessibleContextIds:",JSON.parse(JSON.stringify(i??"nil"))),i?.length){let r=e.filter(s=>i.includes(s.resource.id)).map(s=>s.resource.context).filter(s=>!!s),n=mi({input:r});this.loggingService.logContext("[CONTEXT] processAccessibleContexts called with accessibleContext:",JSON.parse(JSON.stringify(n??"nil"))),n?.access&&(this.loggingService.logContext("[CONTEXT] setting accessibleContext in docContext:",JSON.parse(JSON.stringify(n??"nil"))),this.setDocContext(n))}}catch(i){this.loggingService.catch("Error in processAccessibleContexts:",i)}}handlePermissionProvider(t,e,i){return T(this,null,function*(){if(this.userPermissionService?.isPermissionProviderAvailable())try{this.loggingService.logContext("[CONTEXT] handlePermissionProvider called with options:",JSON.parse(JSON.stringify(t??"nil")),"documentIds:",JSON.parse(JSON.stringify(e??"nil")),"user:",JSON.parse(JSON.stringify(i??"nil")));let r=this.buildPermissionRequests(t,e,i),n=p();this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:v.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,methodName:se.SET_DOCUMENTS,uniqueId:n,timestamp:new Date().getTime(),source:"internal",payload:{requests:r}}),this.userPermissionService?.cancelPendingRevokes(r);let s=yield this.userPermissionService?.onResourceAccessRequired({requests:r,uniqueId:n,methodName:se.SET_DOCUMENTS,fromCache:!1});this.loggingService.logContext("[CONTEXT] handlePermissionProvider called with res:",JSON.parse(JSON.stringify(s??"nil")),"requests:",JSON.parse(JSON.stringify(r??"nil"))),this.processAccessibleContexts(s,r)}catch(r){this.loggingService.catch("Error in handlePermissionProvider:",r)}})}filterDocumentsByPermissions(t,e,i,r=!1){return T(this,null,function*(){if(r)return e;if(this.loggingService.logContext("[CONTEXT] filterDocumentsByPermissions called with options:",JSON.parse(JSON.stringify(t??"nil")),"documentIds:",JSON.parse(JSON.stringify(e??"nil")),"user:",JSON.parse(JSON.stringify(i??"nil"))),!(t?.optimisticPermissions!==!1))return yield this.validateAndFilterPermissions(t,e,i);let s=this.currentValidationToken,a=[...e];return s&&this.validatePermissionsInBackground(t,e,i,s),a})}validateAndFilterPermissions(t,e,i){return T(this,null,function*(){try{let r=t?.organizationId??i?.clientOrganizationId,n=yield this.userPermissionService?.getUserPermissions({organizationId:r,documentIds:e.map(o=>o.clientDocumentId),folderIds:t?.folderId?[t?.folderId]:[]});if(!n)return e;this.userPermissionService?.setCurrentUserPermissions(n),r&&n?.[i.userId]?.organization?.[r]?.errorCode===ye.PERMISSION_DENIED&&this.loggingService.catch(`User does not have access to organization: ${r}`,void 0,void 0,!0),t?.folderId&&n?.[i.userId]?.folders?.[t?.folderId]?.errorCode===ye.PERMISSION_DENIED&&this.loggingService.catch(`User does not have access to folder: ${t?.folderId}`,void 0,void 0,!0);let s=new Set;Object.entries(n?.[i.userId]?.documents??{}).forEach(([o,c])=>{c?.errorCode===ye.PERMISSION_DENIED&&s.add(o)}),s.size>0&&(this.loggingService.catch(`User does not have access to documents: ${[...s].join(", ")}`,void 0,void 0,!0),this.coreActionsService.triggerAction(S.ERROR,{event:v.Events.Core.SDK_ERROR,sourceMethod:"validateAndFilterPermissions",message:"Access denied to documents in strict validation mode",documentIds:[...s],userId:i.userId,timestamp:new Date().getTime()}));let a=e.filter(o=>!s.has(o.clientDocumentId));return a.length===0&&e.length>0&&this.loggingService.catch("Error in validateAndFilterPermissions: All documents provided are denied"),a}catch(r){return this.loggingService.catch("Error in validateAndFilterPermissions:",r),e}})}validatePermissionsInBackground(t,e,i,r){let n=t?.organizationId??i?.clientOrganizationId;this.userPermissionService?.getUserPermissions({organizationId:n,documentIds:e.map(s=>s.clientDocumentId),folderIds:t?.folderId?[t?.folderId]:[]}).then(s=>{if(this.currentValidationToken===r&&s){this.userPermissionService?.setCurrentUserPermissions(s);let a=[];Object.entries(s?.[i.userId]?.documents??{}).forEach(([o,c])=>{c?.errorCode===ye.PERMISSION_DENIED&&a.push(o)}),n&&s?.[i.userId]?.organization?.[n]?.errorCode===ye.PERMISSION_DENIED&&this.loggingService.catch(`User does not have access to organization: ${n}`,void 0,void 0,!0),t?.folderId&&s?.[i.userId]?.folders?.[t?.folderId]?.errorCode===ye.PERMISSION_DENIED&&this.loggingService.catch(`User does not have access to folder: ${t?.folderId}`,void 0,void 0,!0),a.length>0&&(this.loggingService.catch(`User does not have access to documents: ${a.join(", ")}`,void 0,void 0,!0),this.handleDeniedDocumentAccess(a,i,r))}}).catch(s=>{this.loggingService.catch("Error in background permission validation:",s)})}handleDeniedDocumentAccess(t,e,i){try{if(this.currentValidationToken!==i)return;let r=this.documentPaths$.value;this.coreActionsService.triggerAction(S.ERROR,{event:v.Events.Core.SDK_ERROR,sourceMethod:"handleDeniedDocumentAccess",message:"Access denied to document after optimistic load",documentIds:t,userId:e.userId,timestamp:new Date().getTime()});let n=this.documentIds$.value||[],s=n.filter(a=>!t.includes(a.clientDocumentId));s.length!==n.length&&(s.length>0?this.setDocuments({documents:s.map(a=>({id:a.clientDocumentId})),options:{organizationId:r?.clientOrganizationId},source:"internal",skipPermissionValidation:!0}):(this.loggingService.catch("Error in DocService handleDeniedDocumentAccess: Documents provided are all denied"),this.coreActionsService.triggerAction(S.ERROR,{event:v.Events.Core.SDK_ERROR,sourceMethod:"handleDeniedDocumentAccess",message:"All documents provided are denied",documentIds:t,userId:e.userId,timestamp:new Date().getTime()}),this.unsetDocuments({source:"internal"})))}catch(r){this.loggingService.catch("Error in handleDeniedDocumentAccess:",r)}}reportPortableOrgProfileDenial(t){try{let e=t?.code??"unknown",i=At(t);if(this.loggingService.catch(`Tier B addUserInfoToOrganization denied/failed at the gateway: ${e}${i}`,t,void 0,!0),this.reportedOrgProfileDenials.has(e))return;this.reportedOrgProfileDenials.add(e);let r=`${i}${t?.message?` (${t.message})`:""}`;if(e==="not-found"){console.warn(`Velt [portable backend]: the organization-profile write (addUserInfoToOrganization) was answered 'not-found'${r}, which means the configured backend has no record of this organization. User profile / membership data is NOT being persisted for it, so contacts and mentions will be empty; everything else is unaffected and the call fails soft (hosted parity). Organizations are provisioned out of band on a self-hosted deployment \u2014 identify will issue a token for an organizationId that was never provisioned, so this is expected until yours is.`);return}console.error(`Velt [portable backend]: the organization-profile write (addUserInfoToOrganization) was rejected by the configured backend with '${e}'${r}. User profile / membership data is NOT being persisted for this organization. The call fails soft (hosted parity) \u2014 check that your gateway serves addUserInfoToOrganization and that the caller is permitted to write this user.`)}catch{}}addUserInfoToOrganization(n){return T(this,arguments,function*({organizationId:t,user:e,notificationsConfig:i,currentUserId:r}){try{if(this.adapterSelectorService?.isPortableBackendActive()){let a=yield this.adapterSelectorService.resolveDbAdapter().upsertOrgUserProfile({scope:"org",data:E({organizationId:t,user:this.usersService?.externalUserDataProviderAvailable()?{userId:e?.userId}:e},i&&{notificationsConfig:i})});a?.ok||this.reportPortableOrgProfileDenial(a);return}let s=Ce(this.functions,Oe({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));yield dt({data:E({type:"addUserInfoToOrganization",metadata:{organizationId:t},user:this.usersService?.externalUserDataProviderAvailable()?{userId:e?.userId}:e},i&&{notificationsConfig:i}),getSdkProxy:s,userId:r??e?.userId??""})}catch(s){this.loggingService.warn("Error in DocService addUserInfoToOrganization:",s)}})}setDocumentsImpl(n){return T(this,arguments,function*({documents:t,options:e,source:i,skipPermissionValidation:r=!1}){try{if(this.loggingService.logContext("[CONTEXT] setDocumentsImpl called with documents:",JSON.parse(JSON.stringify(t??"nil")),"options:",JSON.parse(JSON.stringify(e??"nil"))),!this.shouldSetDocumentsAgain(t,ct(e))){i==="external"&&this.loggingService.catch("setDocuments called with previous request");return}let s=p();this.currentValidationToken=s;let a=this.getDocumentIdsFromDocuments({documents:t,setClientDocumentMetadataMap:!0});if(a?.length===0){this.loggingService.warn("Minimum one document must be set in setDocuments");return}let o=this.authService.getUser();if(!o){this.draftDocuments=t,this.draftOptions=e;return}this.pendingDocumentIds=t.map(h=>h.id),this.pendingOptions=this.getEffectiveCompareOptions(e),this.documentPaths$.value?.organizationId&&e?.organizationId&&this.documentPaths$.value?.clientOrganizationId!==e?.organizationId?this.authService.resetServicesCache():this.unsetDocuments({source:"internal",unsetDocumentPaths:!1});let c=e?.organizationId??o?.clientOrganizationId;if(c&&this.addUserInfoToOrganization({organizationId:c,user:o}),a=yield this.filterRelevantDocuments({options:e,documentIds:a,skipPermissionValidation:r}),this.documentIds$.next(a),a?.length){let h=a[0]?.clientDocumentId;e?.rootDocumentId&&a.find(m=>m.clientDocumentId===e?.rootDocumentId)&&(h=e?.rootDocumentId),yield this.debounceSetDocuments({documentId:h,clientOrganizationId:e?.organizationId,options:e})}this.pendingDocumentIds=[],this.pendingOptions={};return}catch(s){this.pendingDocumentIds=[],this.pendingOptions={},this.loggingService.catch("Error in DocService setDocumentsImpl:",s)}})}setDocumentId(r){return T(this,arguments,function*({documentId:t,clientOrganizationId:e,source:i="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentId","color: green;"),i==="internal"&&this.analyticsService.trackEvent(v.Events.Core.SET_DOCUMENTS_TRIGGERED,{payload:{id:t,clientOrganizationId:e,methodName:"setDocumentId",source:i}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.SET_DOCUMENTS_TRIGGERED,methodName:ee.SET_DOCUMENT_ID,source:i,payload:{documentId:t,clientOrganizationId:e}}),yield this.setDocumentsImpl({documents:[{id:t}],options:{organizationId:e},source:i})}catch(n){this.loggingService.catch("Error in setDocumentId:",n);return}})}debounceSetDocuments(r){return T(this,arguments,function*({documentId:t,clientOrganizationId:e,options:i}){try{this.loggingService.log("%c[WB] Calling FUNCTION: debounceSetDocuments","color: green;");let n=i?.debounceTime??this.DEBOUNCE_TIME;this.currentDebounceTime=n;let s=Date.now(),a=s-this.lastSetDocumentIdCallTime,o=s-this.lastSetDocumentIdExecutionTime;if(this.lastSetDocumentIdCallTime=s,this.queueSize>=this.MAX_QUEUE_SIZE){this.loggingService.warn("SetDocumentId queue size exceeded limit");return}if(!this.documentPaths$.value&&!this.isDocumentIdInDebounceQueue||a>n&&o>n){yield this.setDocumentIdImpl(t,e,i),this.lastSetDocumentIdExecutionTime=s;return}this.documentPaths$.next(null),this.isDocumentIdInDebounceQueue=!0,this.draftLocationMap={locations:[],options:void 0},this.queueSize++,this.setDocumentIdSubject.next({documentId:t,clientOrganizationId:e,options:i??void 0});return}catch(n){this.loggingService.catch("Error in debounceSetDocuments:",n)}})}setDocumentIdImpl(t,e,i){return T(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentIdImpl","color: green;");try{let r=this.authService.getUser();if(!r)return;this.currentDocumentId&&this.documentPaths$.value&&(yield this.callPreDocumentIdChangeFunctions(this.documentPaths$.value));let n=this.currentDocumentId;if(this.apiKey){let s=`${$e(t)}`,a=i?.folderId,o=i?.folderId?me(i?.folderId):void 0,c=i?.locationId,h=i?.allDocuments,m=i?.optimisticPermissions,f=r?.organizationId?e?Ke(e):r?.organizationId:void 0,u=p(),g=Ge.SET_DOCUMENTS;this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:u,methodName:B.INIT_DOCUMENTS,moduleName:g,source:"internal",payload:{documentIds:this.documentIds$.value.map(R=>R.clientDocumentId),organizationId:e??r?.clientOrganizationId??""}});let y=p(),D=qe.SET_DOCUMENTS;this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:y,moduleName:D,methodName:M.INIT_DOCUMENTS,source:"internal",payload:{documentIds:this.documentIds$.value.map(R=>R.clientDocumentId),organizationId:e??r?.clientOrganizationId??""}});let U=p(),I=Je.GET_RECORDER_ANNOTATIONS;if(this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:U,moduleName:I,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,source:"internal",payload:{documentIds:this.documentIds$.value.map(R=>R.clientDocumentId),organizationId:e??r?.clientOrganizationId??""}}),yield Promise.allSettled([this.commentResolverService.resolveCommentAnnotations({request:{documentIds:this.documentIds$.value.map(R=>R.clientDocumentId),organizationId:e??r?.clientOrganizationId??""},uniqueId:u,moduleName:g}),this.reactionResolverService.resolveReactionAnnotations({request:{documentIds:this.documentIds$.value.map(R=>R.clientDocumentId),organizationId:e??r?.clientOrganizationId??""},uniqueId:y,moduleName:D}),this.recorderResolverService.resolveRecorderAnnotations({request:{documentIds:this.documentIds$.value.map(R=>R.clientDocumentId),organizationId:e??r?.clientOrganizationId??""},uniqueId:U,moduleName:I})]),this.currentDocumentId!==s||this.documentPaths$.value?.organizationId!==f){this.loggingService.log("setting new docid"),this.currentDocumentId=s;let R=new ai,C=new Tt;R.clientDocumentId=t,C.clientDocumentId=t,R.folderId=a,C.folderId=a,R.locationId=c,C.locationId=c,R.allDocuments=h,R.optimisticPermissions=m,C.allDocuments=h,C.optimisticPermissions=m,R.veltFolderId=o,C.veltFolderId=o,R.documentId=s,C.documentId=s,f&&(R.organizationId=f,R.clientOrganizationId=e??r?.clientOrganizationId,C.organizationId=f,C.clientOrganizationId=e??r?.clientOrganizationId);let N=`${this.apiKey}`,z=`apiKey/${this.apiKey}`;f&&(N=`${N}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${R.organizationId}`,z=`${z}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${R.organizationId}`),C.organization=`apiKey/${this.apiKey}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}`,C.document=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}`,R.presence=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_PRESENCE}/`,R.cursor=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_CURSOR}/`,R.comment=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_COMMENT}/`,C.comment=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_COMMENT}`,R.multiThread=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_MULTI_THREAD}/`,C.multiThread=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_MULTI_THREAD}`,R.tag=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_TAG}/`,R.area=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_AREA}/`,C.area=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_AREA}`,R.arrow=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_ARROW}/`,R.selection=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_SELECTION}/`,R.audioHuddle=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_AUDIO_HUDDLE}/`,R.huddle=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_HUDDLE}/`,R.recorder=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_RECORDER}/`,C.recorder=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_RECORDER}`,R.flock=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_FOLLOW_ALONG}/`,R.syncVideoPlayer=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_SYNC_VIDEO_PLAYER}/`,R.liveState=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_LIVE_STATE}/`,R.liveStateSingleEditorMode=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_LIVE_STATE}/default/singleEditorMode`,R.reaction=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_REACTION}/`,C.reaction=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_REACTION}`,R.crdt=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_CRDT}/`,C.crdt=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_CRDT}`,R.customerMetadata=`${this.apiKey}/${d.FIREBASE_PARTIAL_PATH_CUSTOMER_METADATA}/`,R.views=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_VIEWS}/`,C.notificationViews=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_NOTIFICATION_VIEWS}`,C.documentViews=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS}`,C.locationViews=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS}`,R.notifications=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_NOTIFICATIONS}/`,R.metadata=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_METADATA}/`,R.users=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_USERS}/`,R.documentIam=`${N}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_IAM}/`,R.workspaceIam=`${this.apiKey}/${d.FIREBASE_PARTIAL_PATH_IAM}/`,R.groupContacts=`${N}/${d.FIREBASE_PARTIAL_PATH_CONTACTS}/${d.FIREBASE_PARTIAL_PATH_GROUPS}/`,R.globalContacts=`${N}/${d.FIREBASE_PARTIAL_PATH_CONTACTS}/${d.FIREBASE_PARTIAL_PATH_GLOBAL}/`,R.logins=`${N}/${d.FIREBASE_PARTIAL_PATH_CONTACTS}/${d.FIREBASE_PARTIAL_PATH_LOGINS}/`,R.userFeedback=`${N}/${d.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${d.FIREBASE_PARTIAL_PATH_FEEDBACK}/`,R.userReportBugs=`${N}/${d.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${d.FIREBASE_PARTIAL_PATH_BUGS}/`,R.userContactUs=`${N}/${d.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${d.FIREBASE_PARTIAL_PATH_CONTACT_US}/`,f&&(R.organizationMetadata=`${N}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_METADATA}/`,R.organizationIam=`${N}/${d.FIREBASE_PARTIAL_PATH_IAM}/`,R.organizationGroups=`${N}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_GROUPS}/`,R.organizationNotifications=`${N}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/`,s&&(R.organizationNotificationsWithDocumentId=`${N}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/`,R.heartbeatByDocument=`${N}/${d.FIREBASE_PARTIAL_PATH_HEARTBEAT_BY_DOCUMENT}/${s}/`),R.organizationNotificationsLastNotificationTimestamp=`${N}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${d.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}/${d.FIREBASE_PARTIAL_PATH_DOCS}/`,R.organizationNotificationsUsers=`${N}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${d.FIREBASE_PARTIAL_PATH_USERS}/`,R.heartbeat=`${N}/${d.FIREBASE_PARTIAL_PATH_HEARTBEAT}/`),C.organizationUsers=`${z}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_USERS}`,C.users=`${z}/${d.FIREBASE_PARTIAL_PATH_CENTRAL_USERS}`,C.documentUsers=`${z}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${s}/${d.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS}`,C.notificationDocs=`${z}/${d.FIREBASE_PARTIAL_PATH_NOTIFICATION_DOCS}`,C.notificationUsers=`${z}/${d.FIREBASE_PARTIAL_PATH_NOTIFICATION_USERS}`,this.documentPaths$.next(R),this.firestorePaths$.next(C),R?.clientOrganizationId&&R?.organizationId&&!(R?.clientOrganizationId===this.getOrganizationConfig()?.clientOrganizationId&&R?.organizationId===this.getOrganizationConfig()?.organizationId)&&this.setOrganizationConfig({organizationId:R?.organizationId,clientOrganizationId:R?.clientOrganizationId}),Promise.allSettled([this.updateFolderMetadata(),this.updateDocumentMetadata(),this.fetchLocationMetadata(),this.updateOrganizationMetadata()]),n&&this.location$.value&&this.removeLocation({}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Doc.SET_DOCUMENTS_SUCCESS,payload:{documentId:s,clientDocumentId:t}}),this.analyticsService.trackEvent(v.Events.Doc.SET_DOCUMENTS_SUCCESS,{documentId:s,clientDocumentId:t},!0,this.getUserIdForAnalytics())}}else this.loggingService.catch("Error in setDocumentIdImpl: API key is not provided.")}catch(r){this.loggingService.catch("Error in setDocumentIdImpl: ",r)}})}unsetDocumentId({source:t,unsetDocumentPaths:e}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocumentId","color: green;");try{t==="internal"&&this.analyticsService.trackEvent(v.Events.Core.UNSET_DOCUMENTS_TRIGGERED,{payload:{methodName:"unsetDocumentId",source:t}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Doc.UNSET_DOCUMENTS_TRIGGERED,methodName:ee.UNSET_DOCUMENT_ID,source:t}),this.unsetDocumentImpl({source:t,unsetDocumentPaths:e})}catch(i){this.loggingService.catch("Error in unsetDocumentId: ",i)}}unsetDocumentImpl({source:t,unsetDocumentPaths:e}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocumentImpl","color: green;");try{let i=JSON.parse(JSON.stringify(this.documentIds$.value??[])),r=JSON.parse(JSON.stringify(this.documentPaths$.value?.folderId??"")),n=this.getDocContext();this.currentDocumentId&&this.documentPaths$.value&&this.callPreDocumentIdChangeFunctions(this.documentPaths$.value),e&&(this.documentPaths$.next(null),this.firestorePaths$.next(null)),this.currentDocumentId=null,this.location$.next(null),this.excludedLocationIds$.next([]),this.documentMetadata$.next(null),this.locationMetadata$.next(null),this.locations$.next({}),this.documentIds$.next([]),this.setDocContext(null),this.userPermissionService?.revokeAccessOnDocumentUnset({documentIds:i,folderId:r,context:n}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Doc.UNSET_DOCUMENTS_SUCCESS,source:t}),this.analyticsService.trackEvent(v.Events.Doc.UNSET_DOCUMENTS_SUCCESS,{documentId:this.currentDocumentId,documentMetadata:this.documentMetadata$.value?.[this.currentDocumentId??""],message:t==="external"?"User unset document id":"System unset document id",source:t},!0,this.getUserIdForAnalytics())}catch(i){this.loggingService.catch("Error in unsetDocumentImpl: ",i)}}unsetDocuments({source:t,unsetDocumentPaths:e=!0}){this.loggingService.log("%c[WB] Calling FUNCTION: unsetDocuments","color: green;");try{t==="internal"&&this.analyticsService.trackEvent(v.Events.Core.UNSET_DOCUMENTS_TRIGGERED,{payload:{methodName:"unsetDocuments",source:t}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Doc.UNSET_DOCUMENTS_TRIGGERED,source:t,methodName:ee.UNSET_DOCUMENTS}),this.unsetDocumentImpl({source:t,unsetDocumentPaths:e})}catch(i){this.loggingService.catch("Error in unsetDocuments: ",i)}}addPreDocumentIdChangeFunction(t,e){try{this.loggingService.log("%c[WB] Calling FUNCTION: addPreDocumentIdChangeFunction","color: green;"),this.preDocumentIdChangeFunctions.set(t,e)}catch(i){this.loggingService.catch("Error in addPreDocumentIdChangeFunction: ",i)}}callPreDocumentIdChangeFunctions(t){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling FUNCTION: callPreDocumentIdChangeFunctions","color: green;");for(let[e,i]of this.preDocumentIdChangeFunctions)try{yield i(t)}catch(r){this.loggingService.catch("Error in callPreDocumentIdChangeFunctions: ",r)}}catch(e){this.loggingService.catch("Error in callPreDocumentIdChangeFunctions: ",e)}})}fetchOrganizationMetadata(t){return T(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: fetchOrganizationMetadata","color: green;");try{if(!t&&this.getOrganizationConfig()&&(t=this.getOrganizationConfig()),this.db&&t?.organizationId){let e=t?.organizationId,i=t?.clientOrganizationId,r=this.authService.getUser()?.userId??"",n=yield this.userPermissionService?.getUserPermissionsFromCacheOrFetch({organizationId:i});if(r&&n?.[r]?.organization?.[i]?.errorCode===ye.PERMISSION_DENIED)return;yield this.commonDbService?.getData({feature:"organizationMetadata",properties:{apiKey:this.apiKey??"",organizationId:e,field:"metadata"}}).then(s=>{s&&!s?.errorCode&&this.organizationMetadata$.next(w(E({},this.organizationMetadata$.value),{[e]:s}))}).catch(s=>{this.loggingService.catch("Error in fetchOrganizationMetadata: ",s)})}}catch(e){this.loggingService.catch("Error in fetchOrganizationMetadata: ",e)}})}fetchDocumentMetadata(t){return T(this,null,function*(){try{if(this.db&&this.authService.getUser()){let e=this.documentPaths$.value,i=this.documentMetadata$.value;if(t=t.filter(r=>!i?.[r.documentId]),t?.some(r=>!r?.documentId||!r?.clientDocumentId)||!e)return;if(this.commonDbService?.shouldUseFirestore()){let r=e?.folderId,n=[],s={organizationId:e?.clientOrganizationId,folderId:r},a=[],o=20;for(let h=0;h<t.length;h+=o)a.push(t.slice(h,h+o));a.forEach(h=>{let m=JSON.parse(JSON.stringify(s));m.documentIds=h.map(f=>f.clientDocumentId),n.push(this.fetchDocuments(m))});let c={};n.length>0&&(yield Promise.all(n).then(h=>{h?.forEach(m=>{m?.forEach(f=>{f?.metadata?.documentId&&(c[f.metadata.documentId]=f.metadata)})}),this.setAllDocumentMetadata(E(E({},this.documentMetadata$.value),c))}).catch(h=>{this.loggingService.catch("Error in fetchDocumentMetadata: ",h)}))}else i?.[e?.documentId??t?.[0]?.documentId]||this.commonDbService?.queryData({feature:"allDocuments",properties:{apiKey:this.apiKey??"",organizationId:e?.organizationId,documentId:e?.documentId??t?.[0]?.documentId,skipObjectValues:!0}}).then(r=>{r?.documentId&&this.setDocumentMetadata(r.documentId,r)}).catch(r=>{this.loggingService.catch("Error in fetchDocumentMetadata: ",r)})}}catch(e){this.loggingService.catch("Error in fetchDocumentMetadata: ",e)}})}fetchLocationMetadata(){return T(this,null,function*(){try{if(this.db&&this.authService.getUser()){let t=this.documentPaths$.value,e=this.documentIds$.value,i=t?.folderId,r=t?.allDocuments,n=[],s={organizationId:t?.clientOrganizationId,folderId:i,allDocuments:r},a=[],o=20;for(let h=0;h<e.length;h+=o)a.push(e.slice(h,h+o));a.forEach(h=>{let m=JSON.parse(JSON.stringify(s));m.documentIds=h.map(f=>f.clientDocumentId),n.push(this.fetchLocations(m))});let c=this.locationMetadata$.value??{};n.length>0&&Promise.all(n).then(h=>{h?.forEach(m=>{m?.forEach(f=>{f?.metadata?.documentId&&(c[f.metadata.documentId]=w(E({},c?.[f.metadata.documentId]??{}),{[f.location.id]:f}))})}),Object.keys(c||{}).length>0&&this.locationMetadata$.next(c)}).catch(h=>{this.loggingService.catch("Error in fetchLocationMetadata: ",h)})}}catch(t){this.loggingService.catch("Error in fetchLocationMetadata: ",t)}})}getLocationMetadatas(){return this.locationMetadata$.value}subscribeToCustomerMetadata(){this.loggingService.log("%c[WB] Calling FUNCTION: subscribeToCustomerMetadata","color: green;");try{if(this.customerMetadataSubscription)return;this.db&&this.authService.getUser()&&this.documentPaths$.value&&(this.customerMetadataSubscription=this.commonDbService?.dbListener({feature:"customerMetadata",properties:{skipFirestore:!0}}).pipe(it(e=>P(null))).subscribe(e=>{this.customerMetadata$.next(e?.data)}))}catch(t){this.loggingService.catch("Error in subscribeToCustomerMetadata: ",t)}}getDocumentId(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentId","color: green;"),this.documentPaths$.value?.documentId}getClientDocumentId(){return this.loggingService.log("%c[WB] Calling FUNCTION: getClientDocumentId","color: green;"),this.documentPaths$.value?.clientDocumentId}getDocumentIds$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentIds$","color: green;"),this.documentIds$.asObservable().pipe(G(t=>t?.slice()))}getDocumentIds(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentIds","color: green;"),this.documentIds$.value?.slice()}getLocationMetadata$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocationMetadata$","color: green;"),this.locationMetadata$.asObservable().pipe()}getDocumentPaths$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths$","color: green;"),this.documentPaths$.asObservable()}getFirestorePaths$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirestorePaths$","color: green;"),this.firestorePaths$.asObservable()}getDocumentPaths(){return this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.documentPaths$.value}generateDocumentId(t){try{return`${$e(t)}`}catch(e){return this.loggingService.catch("Error in generateDocumentId: ",e),""}}generateOrganizationId(t){try{return`${Ke(t)}`}catch(e){return this.loggingService.catch("Error in generateOrganizationId: ",e),""}}getFirestorePaths(){return this.loggingService.log("%c[WB] Calling FUNCTION: getFirestorePaths","color: green;"),this.firestorePaths$.value}setLocation(i){return T(this,arguments,function*({location:t,source:e="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocation","color: green;"),e==="internal"&&this.analyticsService.trackEvent(v.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:[t],options:void 0,methodName:"setLocation",source:e}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.SET_LOCATIONS_TRIGGERED,source:e,methodName:ee.SET_LOCATION,payload:{locations:[t],options:void 0}}),this.setLocationsImpl({locations:[t]})}catch(r){this.loggingService.catch("Error in setLocation: ",r)}})}setLocations(r){return T(this,arguments,function*({locations:t,options:e,source:i="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setLocations","color: green;"),i==="internal"&&this.analyticsService.trackEvent(v.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:t,options:e,methodName:"setLocations",source:i}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.SET_LOCATIONS_TRIGGERED,methodName:ee.SET_LOCATIONS,source:i,payload:{locations:t,options:e}}),this.setLocationsImpl({locations:t,options:e})}catch(n){this.loggingService.catch("Error in setLocations: ",n)}})}getValidLocations(t){try{let e=[];return t&&Array.isArray(t)&&t.forEach(i=>{if(i&&typeof i=="object"){let r=!0;i?.version&&(!i?.version?.id||!i?.version?.name)&&(this.loggingService.catch(`Error in setting location for locationId: ${i?.id}, If you're setting version then add id and name fields to version object.`),r=!1),r&&e.push(i)}}),e}catch(e){this.loggingService.catch("Error in getValidLocations: ",e)}return t}setRootLocation(i){return T(this,arguments,function*({location:t,source:e="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: setRootLocation","color: green;"),e==="internal"&&this.analyticsService.trackEvent(v.Events.Core.SET_ROOT_LOCATION_TRIGGERED,{payload:{location:t,methodName:"setRootLocation",source:e}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.SET_ROOT_LOCATION_TRIGGERED,methodName:ee.SET_ROOT_LOCATION,source:e,payload:{location:t}});let r=Object.values(this.locations$.value).map(n=>n.location).filter(n=>String(n.id)!==String(t.id));this.setLocationsImpl({locations:[t,...r],options:{rootLocationId:t.id}})}catch(r){this.loggingService.catch("Error in DocService setRootLocation:",r)}})}setLocationsImpl({locations:t,options:e}){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setLocationsImpl","color: green;"),t.length===0)return;if(!this.authService.getUser()){!e?.appendLocation&&t.length>0&&(this.draftLocationMap.options=w(E(E({},this.draftLocationMap.options??{}),e??{}),{rootLocationId:t[0].id})),this.draftLocationMap.locations=[...this.draftLocationMap.locations,...t],this.draftLocationMap.options=E(E({},this.draftLocationMap.options),e);return}let r=this.getValidLocations(t),n=[],s=[];this.location$.value?.location.id&&s.push(this.location$.value?.location.id),s=[...s,...Object.values(this.locations$.value).map(c=>c.location.id)].filter(c=>c!==void 0);let a;if(e?.rootLocationId&&e?.rootLocationId!==this.location$.value?.location.id&&(a=r.find(c=>c.id===e?.rootLocationId),!a)){this.loggingService.catch(`Error in setting locations, rootLocationId: ${e?.rootLocationId} not found in locations.`);return}if(e?.appendLocation){if(a){let c=ot(a),h=$e(JSON.stringify(c));c.id&&n.push({locationId:h,location:c}),this.location$.next({locationId:h,location:c})}}else{a||(a=r[0]);let c=ot(a),h=$e(JSON.stringify(c));c.id&&n.push({locationId:h,location:c}),this.location$.next({locationId:h,location:c})}let o=[];return r.slice(e?.appendLocation?0:1).forEach(c=>{if(c.id!==this.location$.value?.location.id){let h=E({},c),m=this.locations$.value;c?.id&&Object.keys(m).forEach(y=>{let D=m[y];D.location?.id===c.id&&(h=E(E({},D.location),c),delete m?.[y])});let f=this.genarateLocationId(h),u={locationId:f,location:h};h.id&&n.push({locationId:f,location:h}),o.push(u);let g=w(E({},m),{[f]:u});this.locations$.next(g)}}),this.updateDocumentLocationMetadata(n),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Doc.SET_LOCATIONS_SUCCESS,methodName:ee.SET_LOCATIONS,payload:{locations:r,options:e}}),this.analyticsService.trackEvent(v.Events.Doc.SET_LOCATIONS_SUCCESS,{locations:r,options:e},!0,this.getUserIdForAnalytics()),o}catch(i){this.loggingService.catch("Error in setLocationImpl: ",i);return}}addLocation({location:t,source:e="internal"}){try{return this.loggingService.log("%c[WB] Calling FUNCTION: addLocation","color: green;"),e==="internal"&&this.analyticsService.trackEvent(v.Events.Core.SET_LOCATIONS_TRIGGERED,{payload:{locations:[t],options:{appendLocation:!0},methodName:"addLocation",source:e}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.SET_LOCATIONS_TRIGGERED,methodName:ee.ADD_LOCATION,source:e,payload:{locations:[t],options:{appendLocation:!0}}}),this.setLocationsImpl({locations:[t],options:{appendLocation:!0}})}catch(i){this.loggingService.catch("Error in DocService addLocation:",i);return}}removeLocation({location:t,source:e="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocation","color: green;"),e==="internal"&&this.analyticsService.trackEvent(v.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:[t],methodName:"removeLocation",source:e}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.REMOVE_LOCATIONS_TRIGGERED,source:e,methodName:ee.REMOVE_LOCATION,payload:{locations:[t]}}),t?this.removeLocationsImpl([t],e):e==="external"&&this.removeLocationsImpl(void 0,e)}catch(i){this.loggingService.catch("Error in removeLocation: ",i)}}removeLocations({locations:t,source:e="internal"}){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocations","color: green;"),e==="internal"&&this.analyticsService.trackEvent(v.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:t,methodName:"removeLocations",source:e}}),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.REMOVE_LOCATIONS_TRIGGERED,methodName:ee.REMOVE_LOCATIONS,source:e,payload:{locations:t}}),this.removeLocationsImpl(t,e)}catch(i){this.loggingService.catch("Error in removeLocations: ",i)}}removeLocationsImpl(t,e="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeLocations","color: green;"),e==="internal"&&this.analyticsService.trackEvent(v.Events.Core.REMOVE_LOCATIONS_TRIGGERED,{payload:{locations:t},methodName:"removeLocations",message:"System removed locations",source:e},!0,this.getUserIdForAnalytics()),t?t.forEach(i=>{let r=this.genarateLocationId(i);this.getLocation()?.locationId===r&&(this.location$.next(null),e!=="internal"&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(n=>n.id!==i.id))),this.removeCustomLocation(i)}):(this.location$.next(null),this.locations$.next({}),e!=="internal"&&(this.draftLocationMap.options=void 0,this.draftLocationMap.locations=[])),this.analyticsService.trackEvent(v.Events.Doc.REMOVE_LOCATIONS_SUCCESS,{payload:{locations:t},source:e},!0,this.getUserIdForAnalytics())}catch(i){this.loggingService.catch("Error in removeLocation: ",i)}}unsetLocationIds(t,e="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: unsetLocationIds","color: green;"),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Core.UNSET_LOCATIONS_TRIGGERED,methodName:ee.UNSET_LOCATION_IDS,source:e,payload:{locationIds:t}}),e==="internal"&&this.analyticsService.trackEvent(v.Events.Core.UNSET_LOCATIONS_TRIGGERED,{payload:{locationIds:t},methodName:"unsetLocationIds",message:"System unset location ids",source:e},!0,this.getUserIdForAnalytics()),t?.length?t.forEach(i=>{this.getLocation()?.location.id===i&&(this.location$.next(null),e!=="internal"&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(r=>r.id!==i))),this.removeCustomLocationId(i)}):(this.location$.next(null),this.locations$.next({}),e!=="internal"&&(this.draftLocationMap.options=void 0,this.draftLocationMap.locations=[])),this.coreActionsService.triggerAction(S.INIT_UPDATE,{event:v.Events.Doc.REMOVE_LOCATIONS_SUCCESS,methodName:ee.REMOVE_LOCATIONS_SUCCESS,source:e,payload:{locationIds:t}}),this.analyticsService.trackEvent(v.Events.Doc.REMOVE_LOCATIONS_SUCCESS,{payload:{locationIds:t},source:e},!0,this.getUserIdForAnalytics())}catch(i){this.loggingService.catch("Error in unsetLocationIds: ",i)}}getLocation$(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocation$","color: green;"),this.location$.asObservable()}getLocation(){return this.loggingService.log("%c[WB] Calling FUNCTION: getLocation$","color: green;"),this.location$.value?JSON.parse(JSON.stringify(this.location$.value)):null}excludeLocationIds(t){try{this.excludedLocationIds$.next([...t])}catch(e){this.loggingService.catch("Error in excludeLocationIds: ",e)}}getExcludedLocationIds$(){try{return this.excludedLocationIds$.asObservable()}catch(t){return this.loggingService.catch("Error in getExcludedLocationIds$: ",t),P([])}}updateOrganizationMetadata(t){return T(this,null,function*(){try{!t&&this.getOrganizationConfig()&&(t=this.getOrganizationConfig());let e=t?.organizationId,i=t?.clientOrganizationId,r=this.documentPaths$.value;if(this.db&&e&&r?.documentId){if(this.organizationMetadata$.value?.[e])return;let s=new li;s.apiKey=this.configService?.getApiKey()??"",s.organizationId=e,s.clientOrganizationId=i;let a=this.authService.getUser()?.userId??"",o=i?yield this.userPermissionService?.getUserPermissionsFromCacheOrFetch({organizationId:i}):null;!!(a&&i&&o?.[a]?.organization?.[i]?.errorCode===ye.PERMISSION_DENIED)?this.loggingService.log(`%c[WB] updateOrganizationMetadata skipped \u2014 user does not have access to organization: ${i}`,"color: orange;"):this.userPermissionService?.hasEditAccess({organizationId:e})&&(yield this.commonDbService?.updateData({feature:"organizationMetadata",data:JSON.parse(JSON.stringify(s)),properties:{organizationId:e,documentId:r?.documentId??""}})),yield this.fetchOrganizationMetadata(t)}}catch(e){this.loggingService.catch("Error in updateOrganizationMetadata: ",e)}})}updateFolderMetadata(){return T(this,null,function*(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: updateFolderMetadata","color: green;"),this.db&&this.authService.getUser()&&this.documentPaths$.value?.folderId){let t=this.documentPaths$.value;if(!t?.veltFolderId||!t?.organizationId)return;if(!(yield this.commonDbService?.getData({feature:"folderMetadata",properties:{organizationId:t?.organizationId??"",folderId:t?.veltFolderId??""}}))?.metadata){let i={folderId:this.documentPaths$.value?.folderId,clientOrganizationId:t?.clientOrganizationId,parentFolderId:"root"};if(this.userPermissionService?.hasEditAccess({folderId:this.documentPaths$.value?.veltFolderId??""})){let r=Ce(this.functions,Oe({url:this.endpointsService.getCloudFunctionUrl("sdkProxy"),apiProxyDomain:this.configService?.getApiProxyDomain()}));yield dt({methodName:"createFolder",data:{type:"createFolder",metadata:i},getSdkProxy:r,userId:this.authService.getUser()?.userId??""})}}}}catch(t){this.loggingService.catch("Error in updateFolderMetadata: ",t)}})}updateDocumentMetadata(){return T(this,null,function*(){try{if(this.db&&this.authService.getUser()){let t=this.documentPaths$.value;if(t){let e=this.getDocumentIds();e.find(r=>r.documentId===t.documentId)||e.push({documentId:t.documentId??"",clientDocumentId:t.clientDocumentId??""});let i=e.map(r=>T(this,null,function*(){let n=new si;this.clientDocumentMetadataMap?.[r.clientDocumentId]&&(n=E(E({},this.clientDocumentMetadataMap[r.clientDocumentId]),n)),n.apiKey=this.configService?.getApiKey()??"",n.documentId=r.documentId,n.clientDocumentId=r.clientDocumentId,n.organizationId=t.organizationId,n.clientOrganizationId=t.clientOrganizationId,n.pageInfo=wt(r.clientDocumentId);let s=t?.folderId,a=t?.veltFolderId;n?.pageInfo?.deviceInfo&&delete n?.pageInfo?.deviceInfo;let o=!0,c=this.documentMetadata$.value?.[r.documentId];if(s&&a){let h=this.getDocumentMetadata(r?.documentId??"")??(yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:r?.documentId??"",organizationId:t?.organizationId??"",field:"metadata"}}));h?.clientDocumentId&&!h?.errorCode?h?.folderId&&(h?.folderId!==s||h?.veltFolderId!==a)?(this.loggingService.catch(`Folder id mismatch for document ${r?.clientDocumentId??""}`),o=!1):h?.folderId===s?(s&&(n.folderId=s),a&&(n.veltFolderId=a)):(this.loggingService.catch(`Document ${r?.clientDocumentId??""} is not in the folder ${s??""}`),o=!1):(s&&(n.folderId=s),a&&(n.veltFolderId=a))}if(c){let h={};Object.entries(n).forEach(([m,f])=>{h[m]=f}),le(h,c)&&(o=!1)}o&&this.userPermissionService?.hasEditAccess({documentId:r?.documentId??"",folderId:t?.allDocuments&&t?.veltFolderId?t?.veltFolderId:void 0})&&(yield this.commonDbService?.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(n)),properties:{organizationId:t?.organizationId??"",documentId:r?.documentId??""}}))}));yield Promise.allSettled(i),yield this.fetchDocumentMetadata(e)}}}catch(t){this.loggingService.catch("Error in updateDocumentMetadata: ",t)}})}updateDocumentLocationMetadata(t){return T(this,null,function*(){try{if(this.db&&this.authService.getUser()){let e=this.documentPaths$.value;if(e){let i=this.getDocumentIds();i.find(r=>r.documentId===e.documentId)||i.push({documentId:e.documentId??"",clientDocumentId:e.clientDocumentId??""});for(let r of i){let n=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:r?.documentId??"",organizationId:e?.organizationId??"",field:"metadata"}});n?.errorCode&&(n={});let s=[];for(let a of t){let o=new ci;o.locationId=a?.locationId,o.veltLocationId=Ft(a?.location?.id??""),o.location=a?.location,o.pageInfo=wt(r?.clientDocumentId),o?.pageInfo?.deviceInfo&&delete o?.pageInfo?.deviceInfo;let c=w(E({},n),{[d.FIREBASE_PARTIAL_PATH_LOCATIONS]:w(E({},n[d.FIREBASE_PARTIAL_PATH_LOCATIONS]??{}),{[a?.locationId]:o})});this.commonDbService?.shouldUseFirestore()||s.push(this.commonDbService?.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(c)),properties:{documentId:r?.documentId??"",organizationId:e?.organizationId??""}}));let h=this.locationMetadata$.value;if(h||(h={}),a?.location?.id){let m=h?.[r.documentId],f=m?.[a?.location?.id??""];h&&(m||(h[r.documentId]={}),f||(h[r.documentId][a?.location?.id??""]={}),h[r.documentId][a?.location?.id??""]=w(E({},f),{location:a?.location})),Object.keys(h||{}).length>0&&this.locationMetadata$.next(h)}}yield Promise.allSettled(s)}}}}catch(e){this.loggingService.catch("Error in updateDocumentLocationMetadata: ",e)}})}genarateLocationId(t){try{return t&&typeof t=="object"?$e(JSON.stringify(ot(t))):0}catch(e){return this.loggingService.catch("Error in genarateLocationId: ",e),0}}removeCustomLocation(t,e="internal"){try{let i=this.genarateLocationId(t),r=this.locations$.value;r[i]&&(delete r[i],this.locations$.next(E({},r)),e!=="internal"&&this.isDocumentIdInDebounceQueue&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(n=>n.id!==t.id)))}catch(i){this.loggingService.catch("Error in DocService removeLocation:",i)}}removeCustomLocationId(t,e="internal"){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeCustomLocationId","color: green;");let i=this.locations$.value;Object.entries(i).forEach(([r,n])=>{n.location.id===t&&(delete i[r],this.locations$.next(E({},i)),e!=="internal"&&this.isDocumentIdInDebounceQueue&&(this.draftLocationMap.locations=this.draftLocationMap.locations.filter(s=>s.id!==t)))})}catch(i){this.loggingService.catch("Error in DocService removeCustomLocationId:",i)}}getLocationByClientLocationId(t){try{let e=this.getLocation()?.location;if(e?.id===t)return e;{let i=this.getLocations();Object.keys(i).forEach(r=>{let n=i[r];n.location?.id===t&&(e=n.location)})}return e}catch(e){this.loggingService.catch("Error in DocService getLocationByClientLocationId:",e);return}}removeLocationIfNotInDom(){try{let t=this.locations$.value,e=document.querySelectorAll(`[${d.ATTRIBUTES.VELT_LOCATION}]`),i=[];e.forEach(r=>{let n=r.getAttribute(d.ATTRIBUTES.VELT_LOCATION);if(n){let s=JSON.parse(n),a=this.genarateLocationId(s);i.push(a)}}),Object.keys(t).forEach(r=>{let n=t[r];i.includes(n.locationId)||delete t[r]}),this.locations$.next(E({},t))}catch(t){this.loggingService.catch("Error in DocService removeLocationIfNotInDom:",t)}}getLocations$(){try{return this.locations$.asObservable()}catch(t){return this.loggingService.catch("Error in DocService getLocations$:",t),P({})}}getLocations(){try{return this.locations$.value}catch(t){return this.loggingService.catch("Error in DocService getLocations:",t),{}}}getLocationFromElement(t){try{this.loggingService.log("%c[WB] Calling FUNCTION: getLocationFromElement","color: green;");let e=null;if(t?.getAttribute(d.ATTRIBUTES.VELT_LOCATION)?e=t:e=t.closest(`[${d.ATTRIBUTES.VELT_LOCATION}]`),e){let i=e?.getAttribute(d.ATTRIBUTES.VELT_LOCATION);if(i){let r=JSON.parse(i);return{locationId:this.genarateLocationId(r),location:r}}}return null}catch(e){return this.loggingService.catch("Error in DocService getLocationFromElement:",e),null}}getElementMapWithLocation(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getElementMapWithLocation","color: green;");let t={};return document.querySelectorAll(`[${d.ATTRIBUTES.VELT_LOCATION}], [${d.ATTRIBUTES.VELT_LOCATION_ID}]`).forEach(i=>{if(i.getAttribute(d.ATTRIBUTES.VELT_LOCATION)){let r=this.getLocationFromElement(i);r?.locationId&&(t[r.locationId]={element:i,location:r})}else if(i.getAttribute(d.ATTRIBUTES.VELT_LOCATION_ID)){let r=i.getAttribute(d.ATTRIBUTES.VELT_LOCATION_ID);if(r){let n=this.getLocationByClientLocationId(r);n?.locationId&&(t[n.locationId]={element:i,location:n});let s={id:r},a=this.genarateLocationId(s);t[r]={element:i,location:{locationId:a,location:s}}}}}),t}catch(t){return this.loggingService.catch("Error in DocService getElementMapWithLocation:",t),{}}}getAdditionLocationFromElement(t){try{this.loggingService.log("%c[WB] Calling FUNCTION: getAdditionLocationFromElement","color: green;");let e;if(e=t?.closest(`[${d.ATTRIBUTES.VELT_LOCATION}], [${d.ATTRIBUTES.VELT_LOCATION_ID}]`),e){if(e?.getAttribute(d.ATTRIBUTES.VELT_LOCATION)){let i=e?.getAttribute(d.ATTRIBUTES.VELT_LOCATION);if(i)return JSON.parse(i)}else if(e?.getAttribute(d.ATTRIBUTES.VELT_LOCATION_ID)){let i=e?.getAttribute(d.ATTRIBUTES.VELT_LOCATION_ID);if(i)return{id:i}}}return null}catch(e){return this.loggingService.catch("Error in DocService getAdditionLocationFromElement:",e),null}}getAdditionalDocumentIdFromElement(t){try{return t?.closest(`[${d.ATTRIBUTES.VELT_DOCUMENT_ID}]`)?.getAttribute(d.ATTRIBUTES.VELT_DOCUMENT_ID)||null}catch(e){return this.loggingService.catch("Error in DocService getAdditionalDocumentIdFromElement:",e),null}}getDocumentMetadata(t){try{return t?this.documentMetadata$.value?.[t]||null:this.documentMetadata$.value?.[this.documentPaths$.value?.documentId??""]||null}catch(e){return this.loggingService.catch("Error in DocService getDocumentMetadata:",e),null}}getAllDocumentMetadata$(t){return this.getAllDocumentMetadataMap$().pipe(G(e=>e?.[t??this.documentPaths$.value?.documentId??""]||null),J(Q))}getAllDocumentMetadata(){try{return Object.values(this.documentMetadata$.value||{})}catch(t){return this.loggingService.catch("Error in DocService getAllDocumentMetadata:",t),[]}}getAllDocumentMetadataMap$(){return this.documentMetadata$.asObservable().pipe(G(t=>t||{}),J(Q))}getAllDocumentMetadataMap(){try{return this.documentMetadata$.value||{}}catch(t){return this.loggingService.catch("Error in DocService getAllDocumentMetadata:",t),{}}}getDocumentMetadataOfAvailableDocuments(){try{this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentMetadataOfAvailableDocuments","color: green;");let t=this.documentMetadata$.value||{},e={},i=this.documentPaths$.value?.veltFolderId,r=this.documentPaths$.value?.allDocuments;if(i&&r)Object.values(t).forEach(n=>{n?.documentId&&n?.veltFolderId===i&&(e[n.documentId]=n)});else{let n=this.documentIds$.value;if(n?.length)n.forEach(s=>{let a=t?.[s.documentId];a&&(e[s.documentId]=a)});else if(this.documentPaths$.value?.documentId){let s=t?.[this.documentPaths$.value?.documentId];s&&(e[this.documentPaths$.value?.documentId]=s)}}return Object.values(e)}catch(t){return this.loggingService.catch("Error in DocService getDocumentMetadataOfAvailableDocuments:",t),[]}}getDocumentMetadata$(t){return this.documentMetadata$.asObservable().pipe(G(e=>e?.[t??this.documentPaths$.value?.documentId??""]||null),J(Q))}setDocumentMetadata(t,e){try{this.loggingService.log("%c[WB] Calling FUNCTION: setDocumentMetadata","color: green;");let i=JSON.parse(JSON.stringify(this.documentMetadata$.value??{}));i[t]=e,this.documentMetadata$.next(i)}catch(i){this.loggingService.catch("Error in DocService setDocumentMetadata:",i)}}setAllDocumentMetadata(t){try{this.loggingService.log("%c[WB] Calling FUNCTION: setAllDocumentMetadata","color: green;"),this.documentMetadata$.next(t)}catch(e){this.loggingService.catch("Error in DocService setAllDocumentMetadata:",e)}}getOrganizationMetadata(t){return this.organizationMetadata$.value?.[t]||null}getOrganizationMetadata$(t){return this.organizationMetadata$.asObservable().pipe(G(e=>e?.[t]||null))}getOrganizationMetadataMap$(){return this.organizationMetadata$.asObservable().pipe(G(t=>t||{}),J(Q))}getCustomerMetadata(){return this.customerMetadata$.value}getCustomerMetadata$(){return this.customerMetadata$.asObservable()}getOrganizationConfig$(){return this.organizationConfig$.asObservable().pipe(J(Q))}getOrganizationConfig(){return this.organizationConfig$.value}setOrganizationConfig(t){try{this.loggingService.log("%c[WB] Calling FUNCTION: setOrganizationConfig","color: green;");let e=JSON.parse(JSON.stringify(t));this.organizationConfig$.next(e)}catch(e){return this.loggingService.catch("Error in DocService setOrganizationConfig:",e),!1}return!0}getMetadataFromType(t,e){try{switch(t){case"area":return;case"comment":return e?.multiThreadAnnotationId?this.commentService?.getMultiThreadAnnotationById(e.multiThreadAnnotationId)?.metadata:void 0;case"reaction":case"recorder":return e?.commentAnnotationId?this.commentService?.getAnnotationById(e.commentAnnotationId)?.metadata:void 0;default:return}}catch(i){this.loggingService.catch("Error in DocService getMetadataFromType:",i);return}}getDefaultMetadata({clientDocumentId:t,documentId:e}){try{let i=this.documentPaths$.value;if(!i)return;let r=t||i.clientDocumentId,n=e||i.documentId,s=this.getDocumentMetadata(n),a=n===i.documentId,o=s?.folderId??(a?i.folderId:void 0),c=s?.veltFolderId??(a?i.veltFolderId:void 0);return E(E({apiKey:this.configService.getApiKey()??void 0,clientDocumentId:r,clientOrganizationId:i.clientOrganizationId,documentId:n,organizationId:i.organizationId},o?{folderId:o}:{}),c?{veltFolderId:c}:{})}catch(i){this.loggingService.catch("Error in DocService getDefaultMetadata:",i);return}}getBaseMetadata(t,e){try{let i,r;e?.element?i=this.getAdditionalDocumentIdFromElement(e.element)||void 0:e?.clientDocumentId&&(i=e.clientDocumentId),i&&(r=this.generateDocumentId(i));let n=this.getMetadataFromType(t,e),s=this.getDefaultMetadata({clientDocumentId:i,documentId:r}),a=n||s||{};return a.sdkVersion=Be(),a}catch(i){return this.loggingService.catch("Error in DocService getBaseMetadata:",i),{}}}getServerId({documentId:t,organizationId:e}){try{return t&&(t=this.generateDocumentId(t)),e&&(e=this.generateOrganizationId(e)),{documentId:t,organizationId:e}}catch(i){return this.loggingService.catch("Error in DocService getServerId:",i),null}}fetchDocuments(t){return T(this,null,function*(){try{if(!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),[];let i=[];if(!t?.organizationId)return this.loggingService.catch("Error in fetchDocuments: organizationId is required"),[];if(t?.folderId){let n=me(t?.folderId);i.push(ce("metadata.veltFolderId","==",n))}return t?.documentIds?.length&&!t?.allDocuments&&i.push(ce("metadata.documentId","in",t?.documentIds?.map(n=>this.generateDocumentId(n)).slice(0,30))),yield this.commonDbService?.queryData({feature:"allDocuments",properties:{firestoreQuery:i,apiKey:this.apiKey??"",organizationId:this.generateOrganizationId(t?.organizationId)??this.documentPaths$.value?.organizationId,documentId:this.documentPaths$.value?.documentId}})}catch(e){return this.loggingService.catch("Error in DocService fetchDocuments:",e),[]}})}fetchLocations(t){return T(this,null,function*(){try{if(!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),[];let i=[];if(!t?.organizationId)return this.commonDbService?.shouldUseFirestore()&&this.loggingService.catch("Error in fetchLocations: organizationId is required"),[];if(t?.folderId){let n=me(t?.folderId);i.push(ce("metadata.veltFolderId","==",n))}return t?.documentIds?.length&&!t?.allDocuments&&i.push(ce("metadata.documentId","in",t?.documentIds?.map(n=>this.generateDocumentId(n)).slice(0,30))),yield this.commonDbService?.queryData({feature:"allLocations",properties:{firestoreQuery:i,apiKey:this.apiKey??"",organizationId:this.generateOrganizationId(t?.organizationId)??this.documentPaths$.value?.organizationId,documentId:this.documentPaths$.value?.documentId}})}catch(e){return this.loggingService.catch("Error in DocService fetchLocations:",e),[]}})}updateDocuments(t){return T(this,null,function*(){try{if(typeof t=="object"&&(t=JSON.parse(JSON.stringify(t??{}))),!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),[];let{organizationId:i,documents:r,folderId:n}=t;if(!i&&(i=this.documentPaths$.value?.clientOrganizationId,!i))return this.loggingService.catch("Error in updateDocuments: organizationId is required"),[];let s=Le(i);if(!r||r.length===0)return this.loggingService.catch("Error in updateDocuments: documents is required"),[];let a=[],o=this.documentMetadata$.value??{};for(let c of r)if(c?.documentId){c.organizationId=s,c.clientOrganizationId=i,c.clientDocumentId=c.documentId;let h=De(c.documentId);c.documentId=h,c.apiKey=this.configService.getApiKey()??void 0,(n||this.documentPaths$.value?.folderId)&&(c.folderId=n||this.documentPaths$.value?.folderId,c.veltFolderId=me(n||this.documentPaths$.value?.folderId||""));let m=()=>{if(n&&this.documentPaths$.value?.folderId&&n!==this.documentPaths$.value?.folderId)return;let u=o?.[h];u?o[h]=E(E({},u),c):o[h]=c},f=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:h,organizationId:s,field:"metadata"}});if(f?.errorCode&&(f={}),f&&f.apiKey&&f.folderId&&n&&f.folderId!=c.folderId){this.loggingService.catch(`Error in updateDocuments: document ${c.clientDocumentId} already exists with different folderId: ${f.folderId}`);continue}if(f&&f.apiKey&&!f.folderId&&c.folderId){this.loggingService.catch(`Error in updateDocuments: document ${c.clientDocumentId} already exists, move this document to folder with REST API`);continue}m(),c&&this.commonDbService&&this.userPermissionService?.hasEditAccess({documentId:c?.documentId??""})&&a.push(this.commonDbService.updateData({feature:"documentMetadata",data:JSON.parse(JSON.stringify(c)),properties:{organizationId:s,documentId:h}}))}yield Promise.all(a),this.setAllDocumentMetadata(o)}catch(e){return this.loggingService.catch("Error in DocService updateDocuments:",e),[]}})}updateLocations(t){return T(this,null,function*(){try{if(!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),[];let{organizationId:i,locations:r,documentIds:n}=t;if((!n||n.length===0)&&(n=this.documentIds$.value.map(c=>c.clientDocumentId)??[],n.length===0))return this.loggingService.catch("Error in updateLocations: documentId is required"),[];if(!i&&(i=this.documentPaths$.value?.clientOrganizationId,!i))return this.loggingService.catch("Error in updateLocations: organizationId is required"),[];if(!r||r.length===0)return this.loggingService.catch("Error in updateLocations: locations is required"),[];let s=n.map(c=>De(c)),a=[],o=this.locationMetadata$.value;o||(o={}),s.forEach(c=>{r.forEach(h=>{let m=this.location$.value;if(h?.id===m?.location?.id&&this.location$.next({locationId:m?.locationId,location:h}),h?.id){delete h?.metadata;let f=Ft(h.id),u=o?.[c],g=u?.[h.id];o&&(u||(o[c]={}),g||(o[c][h.id]={}),o[c][h.id]=w(E({},g),{location:h})),h&&this.commonDbService&&a.push(this.commonDbService.updateData({feature:"locationMetadata",data:JSON.parse(JSON.stringify({location:h})),properties:{organizationId:Le(i),documentId:c,id:f}}))}})}),yield Promise.all(a),Object.keys(o||{}).length>0&&this.locationMetadata$.next(o)}catch(e){return this.loggingService.catch("Error in DocService updateLocations:",e),[]}})}fetchFolders(t){return T(this,null,function*(){try{if(!this.authService.getUser())return this.loggingService.catch("User not found. Ensure Identify method is called.",void 0,void 0,!0),[];let i=[];if(!t?.organizationId)return this.loggingService.catch("Error in fetchFolders: organizationId is required"),{data:[],parentFolders:[]};let r=[],n=this.generateOrganizationId(t?.organizationId);if(t?.folderId){let s=me(t?.folderId);i=yield this.commonDbService?.getData({feature:"folder",properties:{folderId:s,apiKey:this.apiKey??"",organizationId:n,documentId:this.documentPaths$.value?.documentId}}),i&&(i=[i]),r=yield this.commonDbService?.queryData({feature:"allFolders",properties:{firestoreQuery:[ce("metadata.veltParentFolderId","==",s)],folderId:s,apiKey:this.apiKey??"",organizationId:n,documentId:this.documentPaths$.value?.documentId}})}else i=yield this.commonDbService?.queryData({feature:"allFolders",properties:{apiKey:this.apiKey??"",organizationId:n,documentId:this.documentPaths$.value?.documentId}});return{data:i,parentFolders:r}}catch(e){return this.loggingService.catch("Error in DocService getFoldersRequest:",e),{data:[],parentFolders:[]}}})}getDocumentIam$(){return this.authService.getUser$().pipe(ie(t=>t?this.documentPaths$.pipe(ie(e=>e?.documentIam?this.commonDbService?.dbListener({feature:"documentIam",properties:{documentId:e.documentId,organizationId:e.organizationId,isCollection:!1}}).pipe(G(i=>i?.data?.docIamConfig??i?.data),J((i,r)=>JSON.stringify(i??{})===JSON.stringify(r??{}))):P(null))):P(null)))}getDocumentAccessType(t){try{return t&&t.features&&t.features.all?t.features.all.restricted?Pe.RESTRICTED:Pe.PUBLIC:t&&t.documentAccessType?t.documentAccessType:Pe.PUBLIC}catch(e){return this.loggingService.catch("Error in DocService getDocumentAccessType:",e),Pe.PUBLIC}}changeDocumentAccessType(t){return T(this,null,function*(){try{let e=this.documentPaths$.value;if(e){let i=yield this.commonDbService?.getData({feature:"documentMetadata",properties:{documentId:e?.documentId??"",organizationId:e?.organizationId??"",field:"docIamConfig"}});if(i?.errorCode)return;switch(delete i.documentAccessType,i.features||(i.features={}),i.features.all||(i.features.all={}),t){case Pe.PUBLIC:i.features.all.restricted=!1;break;case Pe.RESTRICTED:i.features.all.restricted=!0,i.features.all.guestMode=!1;break;default:break}this.commonDbService?.updateData({feature:"documentAccessType",data:JSON.parse(JSON.stringify(i)),properties:{documentId:e?.documentId??"",organizationId:e?.organizationId??""}})}}catch(e){this.loggingService.catch("Error in DocService changeDocumentAccessType:",e)}})}getUserIdForAnalytics(){try{return this.authService?.getAuthUser()?.uid||""}catch(t){return this.loggingService.catch("Error in DocService getUserIdForAnalytics:",t),""}}setUIState(t){try{this.uiState.next(E(E({},this.uiState.value),t))}catch(e){this.loggingService.catch("Error in DocService setUIState:",e)}}getUIState$(){return this.uiState.asObservable()}};l.\u0275fac=function(e){return new(e||l)(A(te),A(ve),A(St),A(yi),A(Ue),A(F),A(fe),A(Se),A(Ne),A(j),A(we),A(pe))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var je={presence:{channelFeature:"presence",materialize:"map"},allPresence:{channelFeature:"presence",materialize:"map"},userNotificationIndex:{channelFeature:"notificationIndex",materialize:"doc",crossOrg:!0},allUserNotifications:{channelFeature:"notification",materialize:"map"},allComments:{channelFeature:"comment",materialize:"map"},allReactions:{channelFeature:"reaction",materialize:"map"},allLastActivityTimestamp:{channelFeature:"lastActivityTimestamp",materialize:"map"},allDocumentViews:{channelFeature:"documentViews",materialize:"map"},allCrdtSyncPresence:{channelFeature:"crdtSyncPresence",materialize:"map"},allCrdtPresence:{channelFeature:"crdtPresence",materialize:"map"},crdtSyncPresence:{channelFeature:"crdtSyncPresence",materialize:"map"},crdtPresence:{channelFeature:"crdtPresence",materialize:"map"}},gn="allComments",mn="allReactions",vn="allLastActivityTimestamp",fn="allDocumentViews",Wt={docNotification:{scope:"doc"},userNotification:{scope:"user"},comment:{scope:"doc"}};function Oi(O){return O in Wt}var kt={userNotificationViews:[{op:"markNotificationRead",scope:"user",verb:"update"}],docNotificationViews:[{op:"updateNotification",scope:"user",verb:"update",payloadFields:["views"]}],userNotification:[{op:"deleteNotification",scope:"user",verb:"delete"}],comment:[{op:"addComment",scope:"doc",verb:"set",formatData:!0,notificationData:!0},{op:"editComment",scope:"doc",verb:"update",formatData:!0},{op:"deleteComment",scope:"doc",verb:"delete"}],reaction:[{op:"addReaction",scope:"doc",verb:"set",formatData:!0},{op:"editReaction",scope:"doc",verb:"update",formatData:!0},{op:"deleteReaction",scope:"doc",verb:"delete"}],documentViews:[{op:"recordDocumentView",scope:"doc",verb:"update"}]},Hi=[...Object.keys(je),...Object.keys(kt)];function Ci(O){return Hi.includes(O)}function Dt(O){return O in je}function Ot(O,l){return kt[O]?.find(Ie=>Ie.verb===l)}function pi(O){return(kt[O]?.length??0)>0}var xi={comment:"comment",reaction:"reaction",documentViews:"documentViews",userNotificationViews:"notification",docNotificationViews:"notification",userNotification:"notification",crdtSyncPresence:"crdtSyncPresence",crdtPresence:"crdtPresence"};function Xe(O){return je[O]?.channelFeature??xi[O]??O}var Gi=new Set(["crdtSyncPresence","allCrdtSyncPresence","crdtPresence","allCrdtPresence"]);function Ht(O){return Gi.has(O)}var qi=new Set(["presence","crdtSyncPresence","crdtPresence"]);function xt(O){return qi.has(O)}function Ui(O,l){let Ie=je[O],t=Xe(O),e=It(t);if(!e||!l.apiKey)return null;let i=String(l.apiKey);switch(e.scope){case"doc":{if(!l.organizationId||!l.documentId)return null;let r=Ht(O);return r&&(l.instanceId===void 0||l.instanceId===null||l.instanceId==="")?null:E({scope:"doc",feature:t,apiKey:i,organizationId:String(l.organizationId),documentId:String(l.documentId)},r?{instanceId:String(l.instanceId)}:{})}case"user":return!l.userIdHash||Ie&&!Ie.crossOrg&&!l.organizationId?null:w(E({scope:"user",feature:t,apiKey:i},!Ie?.crossOrg&&l.organizationId?{organizationId:String(l.organizationId)}:{}),{userIdHash:String(l.userIdHash)});case"org":return l.organizationId?{scope:"org",feature:t,apiKey:i,organizationId:String(l.organizationId)}:null;default:return null}}var x=(()=>{let l=class l{constructor(t,e,i,r,n){this.analyticsService=t,this.authService=e,this.coreActionsService=i,this.docService=r,this.loggingService=n,this.resolveOrganizationUsers=new b(!0),this.resolveFolderUsers=new b(!0),this.resolveDocumentUsers=new b(!0),this.unresolvedUsers=new b([]),this.resolveTimeout=60*1e3,this.resolveAttempts=new Map,this.subscriptions=new qt,this.userDataProvider$=new b(null),this.anonymousUserDataProvider$=new b(null),this.userIdByEmailCache={},this.userById$=new b({}),this.customContactUserById$=new b({}),this.userByIdCalled$=new b({}),this.pendingResolutions=new Set,this.getUserById=s=>{try{let a=this.userById$.value?.[s],o=this.customContactUserById$.value?.[s];return o?a?E(E({},a),o):o:a}catch(a){this.loggingService.catch("Error in UsersService getUserById:",a);return}};try{this.docService.setUsersService(this),this.analyticsService.setUserService(this),this.authService.setUsersService(this),this.docService.getDocumentPaths$().pipe(ge(s=>!!s),ie(()=>this.getUnresolvedUsers$().pipe(ge(s=>s.length>0),Xt(300),_e(20),ie(s=>{let a=this.docService.getOrganizationConfig()?.organizationId;return this.commonDbService?this.commonDbService?.dbListener({feature:"allOrganizationUsers",properties:{organizationId:a,isCollection:!0,useQuery:!0,firestoreQuery:[vt(ce("user.userId","in",s.slice(0,20)))]}}).pipe(G(o=>o?.data),rt(o=>{if(o&&typeof o=="object"){delete o.undefined,delete o.null;let c=Object.values(o??{}),h=c.map(f=>f?.user).filter(f=>!!f&&(!!f.name||!!f.email||!!f.photoUrl));h.length>0&&this.setUserByIds(h);let m=s.filter(f=>!c.some(u=>u.user.userId===f));m.length!==s.length&&this.setUnresolvedUsers(m)}})):P([])})))).subscribe()}catch(s){this.loggingService.catch("Error in UsersService constructor:",s)}}setCommonDbService(t){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setCommonDbService","color: green;"),this.commonDbService=t}catch(e){this.loggingService.catch("Error in UsersService setCommonDbService:",e)}}setContactService(t){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setContactService","color: green;"),this.contactService=t}catch(e){this.loggingService.catch("Error in UsersService setContactService:",e)}}ngOnDestroy(){try{this.subscriptions.unsubscribe(),this.pendingResolutions.clear(),this.resolveAttempts.clear()}catch(t){this.loggingService.catch("Error in UsersService ngOnDestroy:",t)}}isResolverForFeatureDisabled(t){let e=this.userDataProvider$.getValue();try{switch(t){case"allOrganizationUsers":return e?!this.resolveOrganizationUsers.value:!0;case"allFolderUsers":return e?!this.resolveFolderUsers.value:!0;case"allDocumentUsers":return e?!this.resolveDocumentUsers.value:!0;default:return!1}}catch(i){return this.loggingService.catch("Error in UsersService isResolverForFeatureDisabled:",i),!1}}resolveUsers(o){return T(this,arguments,function*({userIds:t,forceResolve:e,feature:i,organizationId:r,skipUserCheck:n=!1,uniqueId:s,moduleName:a}){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: resolveUsers","color: green;");let c=!1;if(i&&(c=this.isResolverForFeatureDisabled(i)),c)return{};{let h={},m=[],f={};if(t?.forEach(u=>{let g=this.getUserById(u);g?h[u]=g:this.userByIdCalled$.getValue()[u]?e&&m.push(u):(m.push(u),this.userByIdCalled$.next(w(E({},this.userByIdCalled$.getValue()),{[u]:!0})))}),m.length>0){let u=s||p();this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.USER_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:u,moduleName:a,methodName:ne.RESOLVE_USERS,source:"internal",payload:{userIds:m,organizationId:r,feature:i,forceResolve:e,skipUserCheck:n,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}});let g={},y=!1,D=new Set;try{let U,I=new Promise((C,N)=>{U=setTimeout(()=>{N(new Error("User resolution timeout"))},this.userDataProvider$.getValue()?.config?.resolveTimeout||this.userDataProvider$.getValue()?.resolveTimeout||this.resolveTimeout)}),R=yield Promise.race([this.getUsersFromDB({userIds:m,organizationId:r,skipUserCheck:n}).finally(()=>{clearTimeout(U)}),I]);R==null?y=!0:g=R,this.analyticsService.trackEvent(v.Events.Resolver.USER_RESOLVER_GET,{sourceMethod:"resolveUsers",source:"sdk",userIds:m}),this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.USER_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:u,methodName:ne.RESOLVE_USERS,moduleName:a,source:"internal",payload:{result:g,userIds:m,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}})}catch(U){y=!0,this.loggingService.catch("Error in UsersService resolveUsers getUsers:",U,{userIds:m}),this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.USER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:u,methodName:ne.RESOLVE_USERS,moduleName:a,source:"internal",payload:{error:U,userIds:m,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}})}finally{let U=this.authService.getProvidedOrCurrentUserId?.();m?.forEach(I=>{if(!g[I]){let R=new Set([...this.getUnresolvedUsers(),I]);if(this.unresolvedUsers.next(Array.from(R)),y&&this.clearUserByIdCalledFlag(I),U&&I===U)return;g[I]={userId:I,name:`User ${I}`},y&&D.add(I)}})}Object.entries(g).forEach(([U,I])=>{I&&(h[U]=g?.[U],D.has(U)||(f[U]=g?.[U]))}),D.size>0&&this.authService.setOptionalPropertiesToUsers(Array.from(D).map(U=>g[U]).filter(Boolean))}return Object.keys(f).length>0&&(this.authService.setOptionalPropertiesToUsers(Object.values(f)),this.mergeUsersIntoStore(Object.values(f)),Object.keys(f).forEach(u=>{let g=this.getUserById(u);g&&(h[u]=g)})),h}}catch(c){this.loggingService.catch("Error in UsersService resolveUsers:",c);let h=s||p();return this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.USER_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:h,methodName:ne.RESOLVE_USERS,moduleName:a,source:"internal",payload:{error:c,userIds:t,externalUserDataProviderAvailable:this.externalUserDataProviderAvailable()}}),{}}})}clearUserByIdCalledFlag(t){try{let e=this.userByIdCalled$.getValue();if(e?.[t]){let i=E({},e);delete i[t],this.userByIdCalled$.next(i)}}catch(e){this.loggingService.catch("Error in UsersService clearUserByIdCalledFlag:",e)}}getUnresolvedUsers$(){return this.unresolvedUsers.asObservable()}getUnresolvedUsers(){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUnresolvedUsers","color: green;");try{return JSON.parse(JSON.stringify(this.unresolvedUsers.getValue()))}catch(t){return this.loggingService.catch("Error in UsersService getUnresolvedUsers:",t),[]}}setUnresolvedUsers(t){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUnresolvedUsers","color: green;");try{if(Array.isArray(t)){let e=JSON.parse(JSON.stringify(t));this.unresolvedUsers.next(e)}}catch(e){this.loggingService.catch("Error in UsersService setUnresolvedUsers:",e)}}getUsersFromDB(r){return T(this,arguments,function*({userIds:t,organizationId:e,skipUserCheck:i=!1}){this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUsersFromDB","color: green;");try{let n=this.userDataProvider$.getValue();if(n){if(n.config?.getConfig?.url){if(e||(e=this.docService.getOrganizationConfig()?.organizationId),!e)return this.loggingService.catch("Error in getUsersFromDB: organizationId is required when using getConfig"),null;let c={organizationId:e,userIds:t},h=yield H(n.config.getConfig.url,n.config.getConfig.headers,c,!0,n.config.getConfig.credentials);return h.statusCode!==200?(this.loggingService.catch(`Error in getUsersFromDB: config-based request failed with statusCode ${h.statusCode}. Message: ${h.message||"Unknown error"}`),null):h.data??{}}let o=yield n.get(t);if(o&&typeof o=="object"&&"success"in o&&"statusCode"in o&&typeof o.success=="boolean"&&typeof o.statusCode=="number"){let c=o;return c.statusCode===200&&c.data?c.data:(this.loggingService.catch(`Error in getUsersFromDB: provider returned error response with statusCode ${c.statusCode}`),null)}return o}if(e||(e=this.docService.getOrganizationConfig()?.organizationId),!e)return null;let s=(yield this.getUsersFromDBWithBatching({userIds:t,organizationId:e,skipUserCheck:i}))??[];this.contactService?.setResolvedUsers(s.flat());let a={};return s.forEach(o=>{o.forEach(c=>{c?.user?.userId&&(a[c.user.userId]=c.user)})}),a}catch(n){return this.loggingService.catch("Error in UsersService getUsersFromDB:",n),null}})}getUsersFromDBWithBatching(r){return T(this,arguments,function*({userIds:t,organizationId:e,skipUserCheck:i=!1}){try{if(!t?.length)return[];let n=[];for(let o=0;o<t.length;o+=30)n.push(t.slice(o,o+30));let s=n.map((o,c)=>T(this,null,function*(){try{return(yield this.commonDbService?.queryData({feature:"allOrganizationUsers",properties:{organizationId:e,useCollectionGroup:!1,isCollection:!0,firestoreQuery:[ce("user.userId","in",o)],skipUserCheck:i}}))||[]}catch(h){return this.loggingService.catch(`Error in batch ${c+1}:`,h),[]}}));return yield Promise.all(s)}catch(n){return this.loggingService.catch("Error in getUsersFromDBWithBatching:",n),[]}})}getTemporaryUsersFromDBWithBatching(r){return T(this,arguments,function*({userIds:t,organizationId:e,resourceIds:i}){try{if(!t?.length||!i?.length)return[];let n=[];for(let u=0;u<t.length;u+=30)n.push(t.slice(u,u+30));let s=[];for(let u=0;u<i.length;u+=30)s.push(i.slice(u,u+30));let a=[],o=0,c=(u,g)=>T(this,null,function*(){try{return((yield this.commonDbService?.queryData({feature:"allPermissionsUsers",properties:{organizationId:e,useCollectionGroup:!1,isCollection:!0,firestoreQuery:[vt(ce("userId","in",u),ce("veltResourceId","in",g))]}}))??[])||[]}catch(y){return this.loggingService.catch(`Error in batch ${o+1}:`,y),[]}});for(let u of n)for(let g of s)a.push(c(u,g)),o++;return(yield Promise.all(a)).flat().filter((u,g,y)=>g===y.findIndex(D=>D.userId===u.userId&&D.resourceId===u.resourceId))}catch(n){return this.loggingService.catch("Error in getTemporaryUsersFromDBWithBatching:",n),[]}})}getResolveOrganizationUsers$(){return this.resolveOrganizationUsers.asObservable()}getResolveFolderUsers$(){return this.resolveFolderUsers.asObservable()}getResolveDocumentUsers$(){return this.resolveDocumentUsers.asObservable()}getUserById$(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: getUserById$","color: green;"),ke([this.userById$,this.customContactUserById$]).pipe(G(([t,e])=>this.applyContactOverlay(t,e)),J(Q))}catch(t){return this.loggingService.catch("Error in UsersService getUserById$:",t),P({})}}applyContactOverlay(t,e){let i=E({},t??{});return Object.entries(e??{}).forEach(([r,n])=>{i[r]=E(E({},i[r]??{}),n)}),i}setUserByIds(t){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUserByIds","color: green;"),this.mergeUsersIntoStore(t)}catch(e){this.loggingService.catch("Error in UsersService setUserByIds:",e)}}setContactListUsers(t){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setContactListUsers","color: green;");let e={};(t??[]).forEach(i=>{let r=i?.userId;r&&(e[r]=JSON.parse(JSON.stringify(i)))}),this.customContactUserById$.next(e)}catch(e){this.loggingService.catch("Error in UsersService setContactListUsers:",e)}}getContactListUser(t){try{return this.customContactUserById$.value?.[t]}catch(e){this.loggingService.catch("Error in UsersService getContactListUser:",e);return}}mergeUsersIntoStore(t){try{let e=JSON.parse(JSON.stringify(this.userById$.getValue()??{}));(t??[]).forEach(i=>{let r=i?.userId;r&&(e[r]=E(E({},e?.[r]??{}),i))}),this.userById$.next(e)}catch(e){this.loggingService.catch("Error in UsersService mergeUsersIntoStore:",e)}}setUserDataProvider(t){try{this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setUserDataProvider","color: green;");let e=t.config?.getConfig?.url,i="get"in t&&typeof t.get=="function";if(!e&&!i){this.loggingService.catch("DataProviders.user is invalid. The get method is missing or is not a function (and no getConfig provided).");return}this.userDataProvider$.next(t),t.config?.resolveUsersConfig?.organization===!1?this.resolveOrganizationUsers.next(!1):this.resolveOrganizationUsers.next(!0),t.config?.resolveUsersConfig?.folder===!1?this.resolveFolderUsers.next(!1):this.resolveFolderUsers.next(!0),t.config?.resolveUsersConfig?.document===!1?this.resolveDocumentUsers.next(!1):this.resolveDocumentUsers.next(!0)}catch(e){this.loggingService.catch("Error in UsersService setUserDataProvider:",e)}}setAnonymousUserDataProvider(t){try{if(this.loggingService.log("%c[WB] Calling UsersService FUNCTION: setAnonymousUserDataProvider","color: green;"),!("resolveUserIdsByEmail"in t)||typeof t.resolveUserIdsByEmail!="function"){this.loggingService.catch("setAnonymousUserDataProvider is invalid. The resolveUserIdsByEmail method is missing or is not a function.");return}this.anonymousUserDataProvider$.next(t)}catch(e){this.loggingService.catch("Error in UsersService setAnonymousUserDataProvider:",e)}}resolveUserIdsByEmail(i){return T(this,arguments,function*({emails:t,uniqueId:e}){try{if(this.loggingService.log("%c[WB] Calling UsersService FUNCTION: resolveUserIdsByEmail","color: green;"),!t?.length)return{};let r=this.anonymousUserDataProvider$.getValue();if(!r||typeof r.resolveUserIdsByEmail!="function")return{};let n=[...new Set(t.filter(I=>!!I))];if(n.length===0)return{};let s={},a=[];if(n.forEach(I=>{let R=this.userIdByEmailCache[I];R?s[I]=R:a.push(I)}),a.length===0)return s;let o=this.docService.getOrganizationConfig()?.clientOrganizationId||"",c=this.docService.getDocumentPaths()?.clientDocumentId||"",h=this.docService.getDocumentPaths()?.folderId||"",m={organizationId:o,documentId:c,folderId:h,emails:a},f=e||p();this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.EMAIL_USER_ID_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:f,methodName:ne.RESOLVE_USER_IDS_BY_EMAIL,source:"internal",payload:{emails:a,organizationId:o,documentId:c,folderId:h}});let u=r.config?.resolveTimeout||this.resolveTimeout,g,y=new Promise((I,R)=>{g=setTimeout(()=>{R(new Error("resolveUserIdsByEmail timeout"))},u)}),D=r.config?.getRetryConfig||{retryCount:0,retryDelay:0},U=T(this,null,function*(){try{let I=yield W(()=>r.resolveUserIdsByEmail(m),"resolveUserIdsByEmail",D);return I?.statusCode===200&&I?.data?I.data:(this.loggingService.catch(`Error in resolveUserIdsByEmail: provider returned statusCode ${I?.statusCode}. Message: ${I?.message||"Unknown error"}`),{})}finally{clearTimeout(g)}});try{let I=yield Promise.race([U,y]);return Object.entries(I).forEach(([R,C])=>{C&&(this.userIdByEmailCache[R]=C,s[R]=C,this.externalUserDataProviderAvailable()||this.docService.addUserInfoToOrganization({organizationId:this.docService.getOrganizationConfig()?.clientOrganizationId??"",user:{userId:C,name:R,email:R},currentUserId:this.authService.getUser()?.userId??""}).catch(N=>{this.loggingService.catch("Error in UsersService resolveUserIdsByEmail addUserInfoToOrganization:",N)}))}),this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.EMAIL_USER_ID_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:f,methodName:ne.RESOLVE_USER_IDS_BY_EMAIL,source:"internal",payload:{result:I,emails:a}}),s}catch(I){return this.loggingService.catch("Error in UsersService resolveUserIdsByEmail (timeout/race):",I),this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.EMAIL_USER_ID_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:f,methodName:ne.RESOLVE_USER_IDS_BY_EMAIL,source:"internal",payload:{error:I,emails:a}}),s}}catch(r){return this.loggingService.catch("Error in UsersService resolveUserIdsByEmail:",r),{}}})}externalUserDataProviderAvailable(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: externalUserDataProviderAvailable","color: green;"),!!this.commonDbService?.shouldUseFirestore()&&!!this.userDataProvider$.getValue()}catch(t){return this.loggingService.catch("Error in UsersService externalUserDataProviderAvailable:",t),!1}}userDataProviderAvailable(){try{return this.loggingService.log("%c[WB] Calling UsersService FUNCTION: userDataProviderAvailable","color: green;"),!!this.commonDbService?.shouldUseFirestore()}catch(t){return this.loggingService.catch("Error in UsersService userDataProviderAvailable:",t),!1}}};l.\u0275fac=function(e){return new(e||l)(A(te),A(ve),A(j),A(ze),A(F))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Ct=(()=>{let l=class l{constructor(t,e,i,r,n,s,a,o){this.loggingService=t,this.usersService=e,this.authService=i,this.functions=r,this.configService=n,this.commentAnnotationsResolverService=s,this.attachmentResolverService=a,this.coreActionsService=o,this.endpointsService=be(Me),this.notificationActionTypeMap={[_.NEWLY_ADDED]:q.COMMENT_ANNOTATION_ADD,[_.ADDED]:q.COMMENT_ADD,[_.UPDATED]:q.COMMENT_UPDATE,[_.DELETED]:q.COMMENT_DELETE},this.additionalEventTypeMap={[_.STATUS_CHANGED]:re.STATUS_CHANGE,[_.PRIORITY_CHANGED]:re.PRIORITY_CHANGE,[_.ASSIGNED]:re.ASSIGN,[_.ACCESS_MODE_CHANGED]:re.ACCESS_MODE_CHANGE,[_.CUSTOM_LIST_CHANGED]:re.CUSTOM_LIST_CHANGE,[_.APPROVED]:re.APPROVE,[_.ACCEPTED]:re.ACCEPT,[_.REJECTED]:re.REJECT,[_.SUGGESTION_ACCEPTED]:re.SUGGESTION_ACCEPT,[_.SUGGESTION_REJECTED]:re.SUGGESTION_REJECT,[_.REACTION_ADDED]:re.REACTION_ADD,[_.REACTION_DELETED]:re.REACTION_DELETE,[_.SUBSCRIBED]:re.SUBSCRIBE,[_.UNSUBSCRIBED]:re.UNSUBSCRIBE}}setNotificationService(t){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: setNotificationService","color: green;"),this.notificationService=t}catch(e){this.loggingService.catch("Error in CommentUtilsService setNotificationService: ",e)}}setUserPermissionService(t){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: setUserPermissionService","color: green;"),this.userPermissionService=t}catch(e){this.loggingService.catch("Error in CommentUtilsService setUserPermissionService: ",e)}}getUserIdsToResolveFromComments(t){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: getUserIdsToResolveFromComments","color: green;");let e=new Set;for(let i of t){if(i?.from?.userId&&e.add(i?.from?.userId),i?.comments)for(let r of i?.comments){if(r?.from?.userId&&e.add(r?.from?.userId),r?.to)for(let n of r?.to)n?.userId&&e.add(n?.userId);if(r?.taggedUserContacts)for(let n of r?.taggedUserContacts)n?.userId&&e.add(n?.userId)}if(i?.assignedTo?.userId&&e.add(i?.assignedTo?.userId),i?.resolvedByUserId&&e.add(i?.resolvedByUserId),i?.suggestion?.resolvedBy?.userId&&e.add(i?.suggestion?.resolvedBy?.userId),i?.subscribedUsers)for(let r of Object.values(i?.subscribedUsers))r.user.userId&&e.add(r.user.userId);if(i?.unsubscribedUsers)for(let r of Object.values(i?.unsubscribedUsers))r.user.userId&&e.add(r.user.userId)}return Array.from(e)}catch(e){return this.loggingService.catch("Error in CommentUtilsService getUserIdsToResolveFromComments:",e),[]}}mergeCommentWithUser(t){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeCommentWithUser","color: green;"),t?.from?.userId){let e=this.usersService.getUserById(t?.from?.userId);e&&(t.from=e)}if(t?.suggestion?.resolvedBy?.userId){let e=this.usersService.getUserById(t?.suggestion?.resolvedBy?.userId);e&&(t.suggestion.resolvedBy=e)}if(t?.comments)for(let e of t?.comments){if(e?.from?.userId){let r=this.usersService.getUserById(e?.from?.userId);r&&(e.from=r)}e?.to&&(e.to=e?.to?.map(r=>{if(r?.userId){let n=this.usersService.getUserById(r?.userId);if(n)return E(E({},r),n)}return r})),e?.taggedUserContacts&&(e.taggedUserContacts=e?.taggedUserContacts?.map(r=>{if(r?.contact){let n=this.usersService.getUserById(r?.contact?.userId);n&&(r.contact=n,(n?.name||n?.email)&&(r.text=`@${n?.name||n?.email}`))}return r}));let i=e?.taggedUserContacts?.filter((r,n,s)=>s.findIndex(a=>a.text===r.text)===n)||[];i.sort((r,n)=>(n.text?.length||0)-(r.text?.length||0)),i.forEach(r=>{if(r?.text){let n=new RegExp(Qe(`{{${r.userId}}}`),"g");e.commentText?.includes(`@User ${r.userId}`)&&(n=new RegExp(Qe(`@User ${r.userId}`),"g")),e.commentText=e.commentText?.replaceAll(n,r.text),e.commentHtml=e.commentHtml?.replaceAll(n,r.text)}})}if(t?.assignedTo?.userId){let e=this.usersService.getUserById(t?.assignedTo?.userId);e&&(t.assignedTo=e)}if(t?.resolvedByUserId){let e=this.usersService.getUserById(t?.resolvedByUserId);e&&(t.resolvedByUser=e)}if(t?.subscribedUsers)for(let e of Object.values(t?.subscribedUsers)){let i=this.usersService.getUserById(e.user.userId);i&&t?.subscribedUsers?.id?.user&&(t.subscribedUsers.id.user=i)}if(t?.unsubscribedUsers)for(let e of Object.values(t?.unsubscribedUsers)){let i=this.usersService.getUserById(e.user.userId);i&&t?.unsubscribedUsers?.id?.user&&(t.unsubscribedUsers.id.user=i)}return t}catch(e){return this.loggingService.catch("Error in CommentUtilsService mergeCommentWithUser:",e),t}}formatCommentData(t){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: formatCommentData","color: green;"),t?.comments?.forEach(e=>{e?.commentText&&e?.commentText?.length>0&&(e.isCommentTextAvailable=!0)}),t?.viewedBy&&delete t.viewedBy,t?.unread!==void 0&&delete t.unread,t?.resolvedByUser!==void 0&&delete t.resolvedByUser,t?.comments&&t.comments.forEach(e=>{e?.reactionAnnotations&&delete e.reactionAnnotations}),this.usersService.userDataProviderAvailable()){if(t?.from?.userId&&(t.from={userId:t.from.userId}),t?.assignedTo?.userId&&(t.assignedTo={userId:t.assignedTo.userId}),t?.subscribedUsers)for(let e of Object.keys(t?.subscribedUsers))t.subscribedUsers[e].user={userId:t?.subscribedUsers[e].user.userId};if(t?.unsubscribedUsers)for(let e of Object.keys(t?.unsubscribedUsers))t.unsubscribedUsers[e].user={userId:t?.unsubscribedUsers[e].user.userId};t?.suggestion?.resolvedBy?.userId&&(t.suggestion.resolvedBy={userId:t.suggestion.resolvedBy.userId})}return t?.comments&&(t.comments=t?.comments?.map(e=>this.formatCommentThreadData(e))),t}catch(e){return this.loggingService.catch("Error in CommentUtilsService formatCommentData:",e),t}}mergeStrippedDataWithCommentAnnotations(t){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeStrippedDataWithCommentAnnotations","color: green;"),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return t;let e=this.commentAnnotationsResolverService.getAnnotationById(t?.annotationId),i=this.attachmentResolverService.attachmentDataProviderAvailable(),r=this.commentAnnotationsResolverService.getFieldsToRemove();return e&&(t?.comments?.forEach(n=>{let s=e?.comments?.[n?.commentId];if(s){n.commentHtml=s?.commentHtml,n.commentText=s?.commentText;let a=s?.attachments;i&&a&&n.attachments?.forEach(o=>{let c=o?.attachmentId;a?.[c]&&(o.name=a?.[c]?.name,o.url=a?.[c]?.url)})}}),e?.targetTextRange?.text&&t?.targetTextRange&&(t.targetTextRange.text=e?.targetTextRange?.text),r?.length>0&&r.forEach(n=>{e?.[n]&&(t[n]=e[n])})),t}catch(e){return this.loggingService.catch("Error in CommentUtilsService mergeStrippedDataWithCommentAnnotations:",e),t}}mergeLocationWithCommentAnnotations(t,e){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: mergeLocationWithCommentAnnotations","color: green;");let i=t?.location?.id,r=t?.metadata?.documentId;if(!i||!r)return t;let n=e?.[r]?.[i];return n&&(t.location=n?.location),t}catch(i){return this.loggingService.catch("Error in CommentUtilsService mergeLocationWithCommentAnnotations:",i),t}}isCommentsDataChanged(t,e){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: isCommentsDataChanged","color: green;");let i=this.commentAnnotationsResolverService.getCommentAnnotationById(e);return i?!le(t,i):!0}catch(i){return this.loggingService.catch("Error in CommentUtilsService isCommentsDataChanged:",i),!0}}stripCommentsFromAnnotationData({comment:t}){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: stripCommentsFromAnnotationData","color: green;");let e=this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable();if(!e)return t;let i=this.attachmentResolverService.attachmentDataProviderAvailable(),r=new ri;if(Object.assign(r,t),r.isCommentResolverUsed=e,i){let n=r.attachments?.map(s=>(s.isAttachmentResolverUsed=!0,delete s?.name,delete s?.url,s));r.attachments=n}return delete r?.commentHtml,delete r?.commentText,r}catch(e){return this.loggingService.catch("Error in CommentUtilsService stripCommentsFromAnnotationData:",e),t}}resolveTaggedUserEmails(t){return T(this,null,function*(){try{let e=new Set;if(t.comments?.forEach(i=>{i.taggedUserContacts?.forEach(r=>{r?.contact?.email&&!r?.userId&&e.add(r.contact.email)}),i.to?.forEach(r=>{r?.email&&!r?.userId&&e.add(r.email)})}),e.size>0){let i=p();this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.EMAIL_USER_ID_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:i,methodName:ne.RESOLVE_USER_IDS_BY_EMAIL,source:"internal",payload:{emails:Array.from(e)}});let r=yield this.usersService.resolveUserIdsByEmail({emails:Array.from(e),uniqueId:i});Object.keys(r).length>0&&t.comments?.forEach(n=>{n.taggedUserContacts?.forEach(s=>{if(s?.contact?.email&&!s?.userId){let a=r[s.contact.email];if(a){let o=s.text;if(o){let c=Qe(o),h=new RegExp(c,"g");n.commentText&&(n.commentText=n.commentText.replace(h,`{{${a}}}`)),n.commentHtml&&(n.commentHtml=n.commentHtml.replace(h,`{{${a}}}`))}s.userId=a,s.contact.userId=a,delete s.contact?.email,delete s.contact?.visibility,s.text=""}}}),n.to=n.to?.map(s=>{if(s?.email&&!s?.userId){let a=r[s.email];if(a)return delete s?.email,delete s?.visibility,w(E({},s),{userId:a})}return s})})}return t}catch(e){return this.loggingService.catch("Error in CommentUtilsService resolveTaggedUserEmails:",e),t}})}stripCommentAnnotationData(r){return T(this,arguments,function*({data:t,actionType:e,commentId:i}){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: stripCommentAnnotationData","color: green;"),t=yield this.resolveTaggedUserEmails(t),!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return{originalData:t,strippedData:null};let n=this.attachmentResolverService.attachmentDataProviderAvailable(),s=this.commentAnnotationsResolverService.getFieldsToRemove(),a=this.commentAnnotationsResolverService.getAdditionalFields(),o,c;e&&(o=this.notificationActionTypeMap?.[e],c=this.additionalEventTypeMap?.[e]);let h=this.commentAnnotationsResolverService.getAdditionalSaveEvents(),m=Array.isArray(h)?h:[],f={},u=null,g=!1;if(t&&t.annotationId){let I=t.annotationId;if(f[I]=E(E(E(E({annotationId:I,metadata:Z(t.metadata??{}),comments:{}},t?.from&&{from:t?.from}),t?.assignedTo&&{assignedTo:t?.assignedTo}),t?.resolvedByUserId&&{resolvedByUserId:t?.resolvedByUserId}),t?.targetTextRange?.text&&{targetTextRange:{text:t?.targetTextRange?.text}}),delete t?.targetTextRange?.text,s?.length>0&&s.forEach(C=>{t?.[C]&&(f[I][C]=t[C],delete t[C])}),a?.length)for(let C of a)t?.[C]!==void 0&&(f[I][C]=JSON.parse(JSON.stringify(t[C])));t.comments?.forEach(C=>{if(C.commentId){let N;n&&(N={},C.attachments?.forEach(z=>{N[z.attachmentId]={attachmentId:z.attachmentId,name:z.name,url:z.url}})),f[I].comments[C.commentId]=E(E(E(E(E(E({commentId:C.commentId},C?.commentHtml&&{commentHtml:C?.commentHtml}),C?.commentText&&{commentText:C?.commentText}),N&&{attachments:N}),C?.from&&{from:C?.from}),C?.to&&{to:C?.to}),C?.taggedUserContacts&&{taggedUserContacts:C?.taggedUserContacts})}}),g=this.isCommentsDataChanged(f[I],I);let R=new ii;Object.assign(R,t),s?.length>0&&s.forEach(C=>{C in t||delete R[C]}),R.comments=t.comments?.map(C=>this.stripCommentsFromAnnotationData({comment:C}))||[],u=R}let y=u?.comments?.find(I=>I.commentId===i);y?.isDraft&&(o=u?.comments?.length&&u?.comments?.length>0?q.COMMENT_ADD:q.COMMENT_ANNOTATION_ADD);let D=!!e&&!!this.notificationActionTypeMap?.[e],U=!!c&&!!u&&!D&&!y?.isDraft&&m.includes(c);return U&&(o=c),{strippedData:g&&(e&&this.notificationActionTypeMap?.[e]||y?.isDraft)||U?f:null,originalData:u,eventType:o}}catch(n){return this.loggingService.catch("Error in CommentAnnotationsResolverService stripCommentAnnotationData:",n),{strippedData:null,originalData:null}}})}formatCommentThreadData(t){try{if(this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: formatCommentThreadData","color: green;"),this.usersService.userDataProviderAvailable()){t?.from?.userId&&(t.from={userId:t.from.userId}),t?.to&&(t.to=t?.to?.map(i=>i?.userId?{userId:i.userId}:i)),t?.taggedUserContacts&&(t.taggedUserContacts=t?.taggedUserContacts?.map(i=>i?.contact?.userId?w(E({},i),{contact:{userId:i.contact.userId}}):i));let e=t?.taggedUserContacts?.filter((i,r,n)=>n.findIndex(s=>s.text===i.text)===r)||[];e.sort((i,r)=>(r.text?.length||0)-(i.text?.length||0)),e.forEach(i=>{if(i?.text&&i?.contact?.userId){let r=new RegExp(Qe(i.text),"g");t.commentText=t.commentText?.replaceAll(r,n=>`{{${i.userId}}}`),t.commentHtml=t.commentHtml?.replaceAll(r,n=>`{{${i.userId}}}`)}}),e.forEach(i=>{i?.text&&i?.contact?.userId&&(i.text="")})}return t}catch(e){return this.loggingService.catch("Error in CommentUtilsService formatCommentThreadData:",e),t}}applyNotificationVisibility({annotation:t,extraData:e,deniedForYouUsers:i}){try{let r=di(t);if(!r)return i??[];e&&typeof e=="object"&&(e.visibility=r);let n=Object.values(e?.annotationData?.subscribedUsers||{}).map(a=>a?.user?.userId).filter(a=>!!a),s=hi(t,n);return[...new Set([...i??[],...s])]}catch(r){return this.loggingService.catch("Error in CommentUtilsService applyNotificationVisibility:",r),i??[]}}getDeniedForYouUsers(e){return T(this,arguments,function*({extraData:t}){try{let i=Object.values(t?.annotationData?.subscribedUsers||{}).map(n=>n.user.userId)??[],r=[];if(this.userPermissionService?.isPermissionProviderAvailable()&&i.length){let n=t?.metadata?.clientDocumentId,s=t?.annotationData?.context?.access&&this.userPermissionService?.getIsContextEnabled()?t?.annotationData?.context?.access:null,a=[],o=t?.metadata?.folderId;i.forEach(m=>{if(a.push({userId:m,resource:E({id:n,type:Te.DOCUMENT,source:se.SET_NOTIFICATIONS,organizationId:t?.metadata?.clientOrganizationId??"",context:s?{access:s}:void 0},o&&{parentFolderId:o})}),s){let f=JSON.stringify(s);a.push({userId:m,resource:{id:f,type:Te.CONTEXT,source:se.SET_NOTIFICATIONS,organizationId:t?.metadata?.clientOrganizationId??"",context:{access:s}}})}});let c=p();this.coreActionsService.triggerAction(S.PERMISSION_PROVIDER,{event:v.Events.PermissionProvider.RESOURCE_ACCESS_REQUEST_FORMED,methodName:se.SET_NOTIFICATIONS,uniqueId:c,timestamp:new Date().getTime(),source:"internal",payload:{requests:a}});let h=yield this.userPermissionService?.onResourceAccessRequired({requests:a,uniqueId:c,methodName:se.SET_NOTIFICATIONS});h?.success&&h?.data?.length&&h.data.forEach(m=>{m.hasAccess||r.push(m.userId)})}return r}catch(i){return this.loggingService.catch("Error in CommentUtilsService getDeniedForYouUsers:",i),[]}})}prepareCommentNotificationData(i){return T(this,arguments,function*({data:t,extraData:e}){if(!e)return;e=this.notificationService?.processNotificationData(e),e.annotationData=t;let r=e?.targetAnnotationData?.commentId;if(r){let n=t?.comments?.find(s=>s?.commentId===r);n&&(e.targetAnnotationData=n)}try{let n=yield this.stripCommentAnnotationData({data:e.annotationData,actionType:e?.actionType??_.NEWLY_ADDED});n?.originalData&&(e.annotationData=this.formatCommentData(n.originalData)),e?.targetAnnotationData&&(e.targetAnnotationData=this.formatCommentThreadData(this.stripCommentsFromAnnotationData({comment:e.targetAnnotationData})))}catch(n){this.loggingService.warn("Error in CommentUtilsService prepareCommentNotificationData:",n)}return e})}handleCommentEncryption(s){return T(this,arguments,function*({data:t,firestorePath:e,extraData:i,eventType:r,metadata:n}){try{this.loggingService.log("%c[WB] Calling CommentUtilsService FUNCTION: handleCommentEncryption","color: green;");let a=at(this.authService.getFirebaseConfig()?.firebaseOptions),o=Ce(this.functions,Oe({url:this.endpointsService.getSetEncryptedDataUrl(a),apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3}),c={from:t?.from,visibilityConfig:t?.visibilityConfig,context:{accessFields:t?.context?.accessFields}};i=yield this.prepareCommentNotificationData({data:t,extraData:i});let h=ft.getFirestoreProdDbName(this.configService.getApiKey()??"",this.authService.getFirebaseConfig()?.firebaseOptions),m=yield this.getDeniedForYouUsers({extraData:i});m=this.applyNotificationVisibility({annotation:c,extraData:i,deniedForYouUsers:m});let f={path:e??"",data:t??{},dbId:h??"",notificationData:i||void 0,notificationURL:this.endpointsService.getNotificationsDbUrl(),feature:"comment",eventType:r??"PATCH",sdkVersion:Be(),deniedForYouUsers:m,isPermissionProviderUsed:this.userPermissionService?.isPermissionProviderAvailable(),isCommentResolverUsed:this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable(),isSettingsConfigByOrganization:this.notificationService?.getSettingsConfigByOrganization(),isCrossOrganizationEnabled:this.notificationService?.getCrossOrganizationConfig()?.enabled,metadata:n},u=yield st(f,this.authService.getUser()?.userId??"");yield o({veltData:u})}catch(a){this.loggingService.catch("Error in CommentUtilsService handleCommentEncryption:",a)}})}};l.\u0275fac=function(e){return new(e||l)(A(F),A(x),A(ve),A(we),A(Ue),A(fe),A(Ve),A(j))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var pt=(()=>{let l=class l{constructor(t,e,i){this.coreActionsService=t,this.loggingService=e,this.analyticsService=i,this.resolveTimeout=60*1e3,this.retrySaveConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.activityDataProvider$=new b(null),this.activityById$=new b({}),this.fieldsToRemove=[],this.getActivityById=r=>{try{return this.activityDataProviderAvailable()?this.activityById$.value?.[r]:void 0}catch(n){this.loggingService.catch("Error in ActivityResolverService getActivityById:",n);return}};try{this.loggingService.log("ActivityResolverService initialized"),this.activityDataProvider$.subscribe(r=>{r&&(r.config?.resolveTimeout&&(this.resolveTimeout=r.config.resolveTimeout),r.config?.saveRetryConfig&&(this.retrySaveConfig=r.config.saveRetryConfig),r.config?.getRetryConfig&&(this.retryGetConfig=r.config.getRetryConfig),r.config?.fieldsToRemove&&(this.fieldsToRemove=r.config.fieldsToRemove))})}catch(r){this.loggingService.catch("Error in ActivityResolverService constructor:",r)}}getProvider(){try{let t=this.activityDataProvider$.getValue();return t||void 0}catch(t){this.loggingService.catch("Error in ActivityResolverService getProvider:",t);return}}ngOnDestroy(){try{this.activityById$.next({})}catch(t){this.loggingService.catch("Error in ActivityResolverService ngOnDestroy:",t)}}resolveActivities(r){return T(this,arguments,function*({request:t,uniqueId:e,moduleName:i}){try{if(this.loggingService.log("%c[WB] Calling ActivityResolverService FUNCTION: resolveActivities","color: green;"),!this.activityDataProviderAvailable())return{};let n,s=!1,a=!1,o=()=>{n&&(clearTimeout(n),n=void 0,a=!0)};return new Promise((c,h)=>{n=setTimeout(()=>{if(!a){s=!0,o();let D=e||p();this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:D,methodName:oe.RESOLVE_ACTIVITIES,moduleName:i,source:"internal",payload:{error:new Error("Activity resolution timeout"),request:t}}),h(new Error("Activity resolution timeout"))}},this.activityDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let m=this.getProvider();if(!m)return o(),c({});let f={},u=[...new Set(t.activityIds||[])],g=w(E({},t),{activityIds:u});T(this,null,function*(){try{if(u.length>0||t.documentIds?.length){let D=e||p();this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:D,methodName:oe.RESOLVE_ACTIVITIES,moduleName:i,source:"internal",payload:{request:g}});let U=W(()=>m?.config?.getConfig?.url?H(m.config.getConfig.url,m.config.getConfig.headers,g,!0,m.config.getConfig.credentials):m?.get?.(g)||Promise.resolve(void 0),"resolveActivities",this.retryGetConfig).then(I=>s?{}:(o(),I&&I.statusCode!==200?(this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:D,methodName:oe.RESOLVE_ACTIVITIES,moduleName:i,source:"internal",payload:{result:I,request:g}}),this.loggingService.catch(I?.message??"Error in ActivityResolverService resolveActivities:"),{}):I?.data)).catch(I=>{throw o(),I});try{f=(yield U)||{},this.analyticsService.trackEvent(v.Events.Resolver.ACTIVITY_RESOLVER_GET,{sourceMethod:"resolveActivities",source:"sdk",activityIds:u});let I={};Object.entries(f).forEach(([R,C])=>{let N=this.activityById$.value?.[R];N?N&&JSON.stringify(N)!==JSON.stringify(C)&&(I[R]=C):I[R]=C}),Object.keys(I).length>0&&this.activityById$.next(E(E({},this.activityById$.getValue()),I)),this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:D,methodName:oe.RESOLVE_ACTIVITIES,moduleName:i,source:"internal",payload:{result:I,request:g}}),c(I)}catch(I){let R=e||p();this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:R,methodName:oe.RESOLVE_ACTIVITIES,moduleName:i,source:"internal",payload:{error:I,request:g}}),s||h(I),c(f)}}else o(),c({})}catch(D){o();let U=e||p();this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:U,methodName:oe.RESOLVE_ACTIVITIES,moduleName:i,source:"internal",payload:{error:D,request:g}}),h(D)}})})}catch(n){this.loggingService.catch("Error in ActivityResolverService resolveActivities:",n);let s=e||p();return this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:oe.RESOLVE_ACTIVITIES,moduleName:i,source:"internal",payload:{error:n,request:t}}),{}}})}saveActivity(t,e){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling ActivityResolverService FUNCTION: saveActivity","color: green;");let i=this.getProvider();if(!this.activityDataProviderAvailable())throw new Error("Activity save data provider not available");let r=e||p();this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_SAVE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:r,methodName:oe.SAVE_ACTIVITY,source:"internal",payload:{request:t}});let n=JSON.parse(JSON.stringify(this.activityById$.getValue()));this.activityById$._value=E(E({},n),t.activity);let s=yield W(()=>{if(i?.config?.saveConfig?.url){let a={activity:t.activity,event:t.event,metadata:Object.values(t.activity??{})?.[0]?.metadata};return H(i.config.saveConfig.url,i.config.saveConfig.headers,a,!1,i.config.saveConfig.credentials)}return i?.save?.({activity:t.activity,event:t.event,metadata:Object.values(t.activity??{})?.[0]?.metadata})||Promise.resolve(void 0)},"saveActivity",this.retrySaveConfig);return s&&s.statusCode!==200?(this.retrySaveConfig.revertOnFailure&&(this.activityById$._value=n),this.loggingService.catch(s?.message??"Error in ActivityResolverService saveActivity:"),this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:r,methodName:oe.SAVE_ACTIVITY,source:"internal",payload:{error:s,request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.ACTIVITY_RESOLVER_SAVE,{sourceMethod:"saveActivity",source:"sdk",activityIds:Object.keys(t.activity),event:t.event}),this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_SAVE_RESULT,timestamp:new Date().getTime(),uniqueId:r,methodName:oe.SAVE_ACTIVITY,source:"internal",payload:{result:{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0},request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!0})}catch(i){this.loggingService.warn("Error in ActivityResolverService saveActivity:",i);let r=e||p();return this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_SAVE_ERROR,timestamp:new Date().getTime(),uniqueId:r,methodName:oe.SAVE_ACTIVITY,source:"internal",payload:{error:i,request:t}}),{revertOnFailure:this.retrySaveConfig.revertOnFailure,isSuccess:!1}}})}getActivitiesById$(){try{return this.activityDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling ActivityResolverService FUNCTION: getActivitiesById$","color: green;"),this.activityById$.asObservable()):P(void 0)}catch(t){return this.loggingService.catch("Error in ActivityResolverService getActivitiesById$:",t),P(void 0)}}getFieldsToRemove(){try{return this.fieldsToRemove}catch(t){return this.loggingService.catch("Error in ActivityResolverService getFieldsToRemove:",t),this.fieldsToRemove}}setActivityDataProvider(t){try{if(t){this.loggingService.log("Setting activity data provider");let e=t.config,i=[{method:"get",configKey:"getConfig"},{method:"save",configKey:"saveConfig"}],r=[];if(i.forEach(({method:n,configKey:s})=>{let a=e?.[s]?.url,o=n in t&&typeof t[n]=="function";!a&&!o&&r.push(n)}),r.length>0){let n=`DataProviders.activity is invalid. The following methods are missing or are not functions (and no corresponding config provided): ${r.join(", ")}.`;this.loggingService.catch(n);return}else this.activityDataProvider$.next(t)}}catch(e){this.loggingService.catch("Error in ActivityResolverService setActivityDataProvider:",e)}}activityDataProviderAvailable(){try{return!!this.activityDataProvider$.getValue()}catch(t){return this.loggingService.catch("Error in ActivityResolverService activityDataProviderAvailable:",t),!1}}};l.\u0275fac=function(e){return new(e||l)(A(j),A(F),A(te))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Ut=(()=>{let l=class l{constructor(t,e,i,r,n,s){this.loggingService=t,this.usersService=e,this.authService=i,this.functions=r,this.configService=n,this.reactionAnnotationsResolverService=s,this.endpointsService=be(Me)}getUserIdsToResolveFromReactions(t){try{let e=new Set;for(let i of t)if(i?.from?.userId&&e.add(i?.from?.userId),i?.reactions?.length)for(let r of i?.reactions)r?.from?.userId&&e.add(r?.from?.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in ReactionUtilsService getUserIdsToResolveFromRecorders:",e),[]}}handleReactionEncryption(r){return T(this,arguments,function*({data:t,firestorePath:e,eventType:i}){try{let n=at(this.authService.getFirebaseConfig()?.firebaseOptions),s=Ce(this.functions,Oe({url:this.endpointsService.getSetEncryptedDataUrl(n),apiProxyDomain:this.configService?.getApiProxyDomain()}),{timeout:1200*1e3}),a=ft.getFirestoreProdDbName(this.configService.getApiKey()??"",this.authService.getFirebaseConfig()?.firebaseOptions),o=this.authService.getUser()?.userId??"",c={path:e??"",data:t??{},dbId:a??"",feature:"reaction",eventType:i??"PATCH",sdkVersion:Be()},h=yield st(c,o);yield s({veltData:h})}catch(n){this.loggingService.catch("Error in handleReactionEncryption:",n)}})}mergeReactionWithUser(t){try{if(this.usersService.userDataProviderAvailable()){if(t?.from?.userId){let e=this.usersService.getUserById(t?.from?.userId);e&&(t.from=e)}if(t?.reactions?.length){for(let e of t?.reactions)if(e?.from?.userId){let i=this.usersService.getUserById(e?.from?.userId);i&&(e.from=i)}}}return t}catch(e){return this.loggingService.catch("Error in ReactionUtilsService mergeReactionWithUser:",e),t}}formatReactionData(t){try{return this.usersService.userDataProviderAvailable()&&t?.from?.userId&&(t.from={userId:t.from.userId}),t.reactions=t?.reactions?.map(e=>(this.usersService.userDataProviderAvailable()&&e?.from?.userId&&(e.from={userId:e.from.userId}),e)),t}catch(e){return this.loggingService.catch("Error in ReactionUtilsService formatReactionData:",e),t}}isReactionDataChanged(t,e){try{this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: isReactionDataChanged","color: green;");let i=this.reactionAnnotationsResolverService.getReactionAnnotationById(e);return i?!le(t,i):!0}catch(i){return this.loggingService.catch("Error in ReactionUtilsService isReactionDataChanged:",i),!0}}stripReactionAnnotationData(t){try{if(this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: stripReactionAnnotationData","color: green;"),!this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())return{originalData:t,strippedData:null};let e={},i=this.reactionAnnotationsResolverService.getFieldsToRemove();if(t&&t.annotationId){let r=t.annotationId;if(e[r]=E({annotationId:r,metadata:Z(t.metadata??{}),icon:t.icon},t?.from&&{from:t?.from}),i?.length>0)for(let s of i)t?.[s]!==void 0&&(e[r][s]=t[s],delete t[s]);if(!this.isReactionDataChanged(e[r],r))return{strippedData:null,originalData:t};delete t?.icon,t.isReactionResolverUsed=!0}return{strippedData:e,originalData:t}}catch(e){return this.loggingService.catch("Error in ReactionUtilsService stripReactionAnnotationData:",e),{strippedData:null,originalData:null}}}mergeStrippedDataWithReactionAnnotations(t){try{if(this.loggingService.log("%c[WB] Calling ReactionUtilsService FUNCTION: mergeStrippedDataWithReactionAnnotations","color: green;"),!this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())return t;let e=this.reactionAnnotationsResolverService.getReactionAnnotationById(t?.annotationId);if(e){e.icon&&(t.icon=e.icon);let i=this.reactionAnnotationsResolverService.getFieldsToRemove();if(i?.length>0)for(let r of i)e?.[r]!==void 0&&(t[r]=e[r])}return t}catch(e){return this.loggingService.catch("Error in ReactionUtilsService mergeStrippedDataWithReactionAnnotations:",e),t}}};l.\u0275fac=function(e){return new(e||l)(A(F),A(x),A(ve),A(we),A(Ue),A(Se))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Nt=(()=>{let l=class l{constructor(t,e,i,r,n,s,a,o,c){this.loggingService=t,this.usersService=e,this.commentUtilsService=i,this.reactionUtilsService=r,this.commentAnnotationsResolverService=n,this.reactionAnnotationsResolverService=s,this.recorderAnnotationsResolverService=a,this.activityResolverService=o,this.serviceBook=c}getActivityDisplayMessage(t){try{switch(t.featureType){case"comment":return this.getCommentDisplayMessage(t);case"recorder":return this.getRecorderDisplayMessage(t);case"reaction":return this.getReactionDisplayMessage(t);case"crdt":return this.getCrdtDisplayMessage(t);case"custom":return t.displayMessageTemplate&&t.displayMessageTemplateData?this.resolveTemplate(t.displayMessageTemplate,t.displayMessageTemplateData):"";default:return""}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService getActivityDisplayMessage:",e),""}}resolveTemplate(t,e){try{return t.replace(/\{\{([\w.]+)\}\}/g,(i,r)=>{let n=r.split(".").reduce((s,a)=>{if(s!=null&&typeof s=="object")return s[a]},e);return n!=null?String(n):""})}catch(i){return this.loggingService.catch("Error in ActivityUtilsService resolveTemplate:",i),t}}buildActivityDataFromExtraData(t){try{let{feature:e,extraData:i}=t;if(!i?.actionType)return null;switch(e){case"comment":return this.buildCommentActivityData({commentAnnotation:i.annotationData,targetComment:i.targetAnnotationData,actionType:i.actionType,otherFields:i});case"recorder":return this.buildRecorderActivityData(i);case"reaction":return this.buildReactionActivityData(i);default:return null}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService buildActivityDataFromExtraData:",e),null}}stripActivityPII(t){return T(this,null,function*(){try{let e=JSON.parse(JSON.stringify(t));if(delete e.displayMessage,!this.usersService.userDataProviderAvailable())return{strippedActivity:e};e.actionUser?.userId&&(e.actionUser={userId:e.actionUser.userId}),e.changes&&this.stripUsersFromChanges(e.changes),e.displayMessageTemplateData&&this.stripUsersFromTemplateData(e.displayMessageTemplateData);let i=this.extractCommentChangesForResolver(e),r=this.extractFeatureEntityDataForResolver(e);yield this.stripFeatureSpecificPII(e);let n=this.extractActivityResolverData(e);return i&&(n?n.changes=E(E({},n.changes),i.changes):n=i),r&&(n?(r.entityData!==void 0&&(n.entityData=r.entityData),r.entityTargetData!==void 0&&(n.entityTargetData=r.entityTargetData)):n=r),n&&(e.isActivityResolverUsed=!0),{strippedActivity:e,activityResolverData:n}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService stripActivityPII:",e),{strippedActivity:t}}})}mergeActivityWithUser(t){try{if(!this.usersService.userDataProviderAvailable())return t;if(t=JSON.parse(JSON.stringify(t)),t.actionUser?.userId){let e=this.usersService.getUserById(t.actionUser.userId);e&&(t.actionUser=e)}return t.changes&&this.rehydrateUsersInChanges(t.changes),t.displayMessageTemplateData&&this.rehydrateUsersInTemplateData(t.displayMessageTemplateData),this.rehydrateFeatureSpecificUserData(t),t}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mergeActivityWithUser:",e),t}}mergeActivityWithFeatureData(t){try{switch(t.featureType){case"comment":return this.mergeActivityWithCommentAnnotationData(t);case"reaction":return this.mergeActivityWithReactionData(t);case"recorder":return this.mergeActivityWithRecorderData(t);default:return t}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mergeActivityWithFeatureData:",e),t}}getUserIdsToResolveFromActivities(t){try{let e=new Set;for(let i of t){if(i.actionUser?.userId&&e.add(i.actionUser.userId),i.changes)for(let r of Object.values(i.changes))r&&(this.extractUserIdFromValue(r.from,e),this.extractUserIdFromValue(r.to,e));if(i.displayMessageTemplateData)for(let r of Object.values(i.displayMessageTemplateData))this.extractUserIdFromValue(r,e);this.extractFeatureSpecificUserIds(i,e)}return Array.from(e)}catch(e){return this.loggingService.catch("Error in ActivityUtilsService getUserIdsToResolveFromActivities:",e),[]}}getEntityIdsToResolveFromActivities(t,e){try{let i=new Set;for(let r of t)if(!(e&&r.featureType!==e))switch(r.featureType){case"comment":case"reaction":case"recorder":r.targetEntityId&&i.add(r.targetEntityId);break}return Array.from(i)}catch(i){return this.loggingService.catch("Error in ActivityUtilsService getEntityIdsToResolveFromActivities:",i),[]}}stripFeatureSpecificPII(t){return T(this,null,function*(){try{switch(t.featureType){case"comment":yield this.stripCommentPII(t);break;case"reaction":this.stripReactionPII(t);break;case"recorder":this.stripRecorderPII(t);break}}catch(e){this.loggingService.catch("Error in ActivityUtilsService stripFeatureSpecificPII:",e)}})}extractActivityResolverData(t){try{if(!this.activityResolverService.activityDataProviderAvailable())return;let e={id:t.id},i=!1,r=this.activityResolverService.getFieldsToRemove();for(let n of r)n in t&&t[n]!==void 0&&(e[n]=t[n],delete t[n],i=!0);return t.metadata&&(e.metadata=Z(t.metadata)),i?e:void 0}catch(e){this.loggingService.catch("Error in ActivityUtilsService extractActivityResolverData:",e);return}}extractCommentChangesForResolver(t){try{return!this.activityResolverService.activityDataProviderAvailable()||t.featureType!=="comment"||!t.changes?.commentText?void 0:{id:t.id,changes:{commentText:t.changes.commentText},metadata:t.metadata?Z(t.metadata):void 0}}catch(e){this.loggingService.catch("Error in ActivityUtilsService extractCommentChangesForResolver:",e);return}}extractFeatureEntityDataForResolver(t){try{if(!this.activityResolverService.activityDataProviderAvailable()||!t.entityData)return;let e=t.featureType==="recorder"&&this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable(),i=t.featureType==="reaction"&&this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable();if(!e&&!i)return;let r={id:t.id,metadata:t.metadata?Z(t.metadata):void 0},n=JSON.parse(JSON.stringify(t.entityData));if(e){let s=this.serviceBook.get(ae)?.stripRecorderAnnotationData({data:n});if(s?.strippedData){let a=Object.keys(s.strippedData)[0];a&&(r.entityData=s.strippedData[a])}}if(i){let s=this.reactionUtilsService.stripReactionAnnotationData(n);if(s?.strippedData){let a=Object.keys(s.strippedData)[0];a&&(r.entityData=s.strippedData[a])}}return r.entityData?r:void 0}catch(e){this.loggingService.catch("Error in ActivityUtilsService extractFeatureEntityDataForResolver:",e);return}}mergeActivityWithResolverData(t){try{if(!this.activityResolverService.activityDataProviderAvailable())return t;let e=this.activityResolverService.getActivityById(t.id);if(!e)return t;e.changes&&(t.changes||(t.changes={}),Object.assign(t.changes,e.changes)),e.entityData!==void 0&&(t.entityData=e.entityData),e.entityTargetData!==void 0&&(t.entityTargetData=e.entityTargetData),e.displayMessageTemplateData&&(t.displayMessageTemplateData||(t.displayMessageTemplateData={}),Object.assign(t.displayMessageTemplateData,e.displayMessageTemplateData));let i=new Set(["id","metadata","changes","entityData","entityTargetData","displayMessageTemplateData"]);for(let[r,n]of Object.entries(e))!i.has(r)&&n!==void 0&&(t[r]=n);return t}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mergeActivityWithResolverData:",e),t}}rehydrateFeatureSpecificUserData(t){try{switch(t.featureType){case"comment":this.rehydrateCommentUserData(t);break;case"reaction":this.rehydrateReactionUserData(t);break;case"recorder":this.rehydrateRecorderUserData(t);break}}catch(e){this.loggingService.catch("Error in ActivityUtilsService rehydrateFeatureSpecificUserData:",e)}}getCommentDisplayMessage(t){try{let e=t.actionUser?.name??"Someone";switch(t.actionType){case L.ANNOTATION_ADD:return`${e} added a comment`;case L.COMMENT_ADD:return`${e} replied to a comment`;case L.COMMENT_UPDATE:return`${e} edited a comment`;case L.COMMENT_DELETE:return`${e} deleted a comment`;case L.ANNOTATION_DELETE:return`${e} deleted a comment thread`;case L.STATUS_CHANGE:{let i=t.changes?.status,r=i?.from?.name,n=i?.to?.name;return r&&n?`${e} changed status from ${r} to ${n}`:`${e} changed the status`}case L.PRIORITY_CHANGE:{let i=t.changes?.priority,r=i?.to;if(!r)return`${e} removed the priority`;let n=typeof r=="object"?r?.name:String(r),s=i?.from,a=s&&typeof s=="object"?s?.name:s?String(s):null;return a&&n?`${e} changed priority from ${a} to ${n}`:`${e} changed priority to ${n}`}case L.ASSIGN:{let r=t.changes?.assignedTo?.to;return r&&typeof r=="object"&&r.name?`${e} assigned to ${r.name}`:`${e} assigned the comment`}case L.ACCESS_MODE_CHANGE:{let r=t.changes?.accessMode?.to;return r?`${e} changed access to ${r}`:`${e} changed the access mode`}case L.CUSTOM_LIST_CHANGE:return`${e} changed the custom list`;case L.APPROVE:return`${e} approved the comment`;case L.ACCEPT:case L.SUGGESTION_ACCEPT:return`${e} accepted a suggestion`;case L.REJECT:case L.SUGGESTION_REJECT:return`${e} rejected a suggestion`;case L.REACTION_ADD:return`${e} reacted to a comment`;case L.REACTION_DELETE:return`${e} removed a reaction`;case L.SUBSCRIBE:return`${e} subscribed to the thread`;case L.UNSUBSCRIBE:return`${e} unsubscribed from the thread`;default:return""}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService getCommentDisplayMessage:",e),""}}getRecorderDisplayMessage(t){try{let e=t.actionUser?.name??"Someone";switch(t.actionType){case He.RECORDING_ADD:return`${e} added a recording`;case He.RECORDING_DELETE:return`${e} deleted a recording`;default:return""}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService getRecorderDisplayMessage:",e),""}}getReactionDisplayMessage(t){try{let e=t.actionUser?.name??"Someone";switch(t.actionType){case xe.REACTION_ADD:return`${e} added a reaction`;case xe.REACTION_DELETE:return`${e} removed a reaction`;default:return""}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService getReactionDisplayMessage:",e),""}}getCrdtDisplayMessage(t){try{let e=t.actionUser?.name??"Someone",r=t.entityData?.editCount??0,n=t.targetEntityId??"unknown";return`${e} made ${r} edit${r!==1?"s":""} to editor ${n}`}catch(e){return this.loggingService.catch("Error in ActivityUtilsService getCrdtDisplayMessage:",e),""}}stripCommentPII(t){return T(this,null,function*(){try{let e=yield this.commentUtilsService.stripCommentAnnotationData({data:t.entityData,actionType:t.eventType??_.NEWLY_ADDED});e?.originalData&&(t.entityData=this.commentUtilsService.formatCommentData(e.originalData)),t.entityTargetData&&(t.entityTargetData=this.commentUtilsService.formatCommentThreadData(this.commentUtilsService.stripCommentsFromAnnotationData({comment:t.entityTargetData}))),this.activityResolverService.activityDataProviderAvailable()&&t.changes?.commentText&&delete t.changes.commentText}catch(e){this.loggingService.catch("Error in ActivityUtilsService stripCommentPII:",e)}})}rehydrateCommentUserData(t){try{t.entityData&&this.commentUtilsService.mergeCommentWithUser(t.entityData),t.entityTargetData&&(this.rehydrateUserInObject(t.entityTargetData,"from"),this.rehydrateUsersInArray(t.entityTargetData,"to"),this.rehydrateUsersInArray(t.entityTargetData,"taggedUserContacts"))}catch(e){this.loggingService.catch("Error in ActivityUtilsService rehydrateCommentUserData:",e)}}stripReactionPII(t){try{if(!t.entityData)return;this.activityResolverService.activityDataProviderAvailable()&&this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable()&&this.reactionUtilsService.stripReactionAnnotationData(t.entityData),t.entityData=this.reactionUtilsService.formatReactionData(t.entityData)}catch(e){this.loggingService.catch("Error in ActivityUtilsService stripReactionPII:",e)}}rehydrateReactionUserData(t){try{if(!t.entityData)return;this.reactionUtilsService.mergeReactionWithUser(t.entityData)}catch(e){this.loggingService.catch("Error in ActivityUtilsService rehydrateReactionUserData:",e)}}stripRecorderPII(t){try{if(!t.entityData)return;if(this.activityResolverService.activityDataProviderAvailable()&&this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()){this.serviceBook.get(ae)?.stripRecorderAnnotationData({data:t.entityData});return}let e=t.entityData;if(this.usersService.userDataProviderAvailable()){e.from&&typeof e.from=="object"&&"userId"in e.from&&(e.from={userId:e.from.userId});let i=e.transcription;i?.from&&typeof i.from=="object"&&"userId"in i.from&&(i.from={userId:i.from.userId})}}catch(e){this.loggingService.catch("Error in ActivityUtilsService stripRecorderPII:",e)}}rehydrateRecorderUserData(t){try{if(!t.entityData)return;this.serviceBook.get(ae)?.mergeRecorderWithUser(t.entityData)}catch(e){this.loggingService.catch("Error in ActivityUtilsService rehydrateRecorderUserData:",e)}}mergeActivityWithCommentAnnotationData(t){try{if(!this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())return t;let e=this.commentAnnotationsResolverService.getAnnotationById(t.targetEntityId);if(!e)return t;let i=t.entityData?.comments;if(Array.isArray(i))for(let r of i){let n=r?.commentId;if(n==null)continue;let s=e.comments?.[String(n)];s&&(s.commentText&&(r.commentText=s.commentText),s.commentHtml&&(r.commentHtml=s.commentHtml))}if(t.targetSubEntityId&&t.entityTargetData){let r=e.comments?.[t.targetSubEntityId];if(r){let n=t.entityTargetData;r.commentText&&(n.commentText=r.commentText),r.commentHtml&&(n.commentHtml=r.commentHtml)}}return t}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mergeActivityWithCommentAnnotationData:",e),t}}mergeActivityWithReactionData(t){try{return!this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable()||!t.targetEntityId||!t.entityData||this.reactionUtilsService.mergeStrippedDataWithReactionAnnotations(t.entityData),t}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mergeActivityWithReactionData:",e),t}}mergeActivityWithRecorderData(t){try{return!this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()||!t.targetEntityId||!t.entityData||this.serviceBook.get(ae)?.mergeStrippedDataWithRecorderAnnotation(t.entityData),t}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mergeActivityWithRecorderData:",e),t}}buildCommentActivityData(t){try{let{commentAnnotation:e,targetComment:i,actionType:r,otherFields:n}=t,s=e,a=i,o=r===_.DELETED&&n?.isAnnotationDelete?L.ANNOTATION_DELETE:this.mapCommentStatusToActionType(r);if(!o)return null;let c=s?.annotationId;if(!c)return null;let h=a?.commentId,m=this.buildCommentChanges(r,a,n);return{featureType:"comment",actionType:o,targetEntityId:c,eventType:r,targetSubEntityId:h??null,changes:Object.keys(m).length>0?m:void 0,entityData:e,entityTargetData:i??void 0}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService buildCommentActivityData:",e),null}}mapCommentStatusToActionType(t){try{switch(t){case _.NEWLY_ADDED:return L.ANNOTATION_ADD;case _.ADDED:return L.COMMENT_ADD;case _.UPDATED:return L.COMMENT_UPDATE;case _.DELETED:return L.COMMENT_DELETE;case _.STATUS_CHANGED:return L.STATUS_CHANGE;case _.PRIORITY_CHANGED:return L.PRIORITY_CHANGE;case _.ASSIGNED:return L.ASSIGN;case _.ACCESS_MODE_CHANGED:return L.ACCESS_MODE_CHANGE;case _.CUSTOM_LIST_CHANGED:return L.CUSTOM_LIST_CHANGE;case _.APPROVED:return L.APPROVE;case _.ACCEPTED:return L.ACCEPT;case _.REJECTED:return L.REJECT;case _.SUGGESTION_ACCEPTED:return L.SUGGESTION_ACCEPT;case _.SUGGESTION_REJECTED:return L.SUGGESTION_REJECT;case _.REACTION_ADDED:return L.REACTION_ADD;case _.REACTION_DELETED:return L.REACTION_DELETE;case _.SUBSCRIBED:return L.SUBSCRIBE;case _.UNSUBSCRIBED:return L.UNSUBSCRIBE;default:return null}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mapCommentStatusToActionType:",e),null}}buildRecorderActivityData(t){try{let e=t.annotationData,i=t.actionType,r=this.mapRecorderStatusToActionType(i);if(!r)return null;let n=e?.annotationId;return n?{featureType:"recorder",actionType:r,targetEntityId:n,entityData:e}:null}catch(e){return this.loggingService.catch("Error in ActivityUtilsService buildRecorderActivityData:",e),null}}mapRecorderStatusToActionType(t){try{switch(t){case Lt.ADDED:return He.RECORDING_ADD;case Lt.DELETED:return He.RECORDING_DELETE;default:return null}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mapRecorderStatusToActionType:",e),null}}buildReactionActivityData(t){try{let e=t.annotationData,i=t.actionType,r=this.mapReactionActionType(i);if(!r)return null;let n=e?.annotationId;return n?{featureType:"reaction",actionType:r,targetEntityId:n,entityData:e}:null}catch(e){return this.loggingService.catch("Error in ActivityUtilsService buildReactionActivityData:",e),null}}mapReactionActionType(t){try{switch(t){case"add":return xe.REACTION_ADD;case"delete":return xe.REACTION_DELETE;default:return null}}catch(e){return this.loggingService.catch("Error in ActivityUtilsService mapReactionActionType:",e),null}}buildCommentChanges(t,e,i){try{let r={};switch(t){case _.NEWLY_ADDED:case _.ADDED:r.commentText={from:null,to:e?.commentText??null};break;case _.UPDATED:r.commentText={from:i?.oldCommentText??null,to:e?.commentText??null};break;case _.DELETED:r.commentText={from:e?.commentText??null,to:null};break;case _.STATUS_CHANGED:r.status={from:i?.oldStatus??null,to:i?.newStatus??null};break;case _.PRIORITY_CHANGED:r.priority={from:i?.oldPriority??null,to:i?.newPriority??null};break;case _.ASSIGNED:{r.assignedTo={from:i?.oldAssignedTo??null,to:i?.newAssignedTo??null};break}case _.ACCESS_MODE_CHANGED:r.accessMode={from:i?.oldAccessMode??null,to:i?.newAccessMode??null};break;case _.CUSTOM_LIST_CHANGED:r.customList={from:i?.oldCustomList??null,to:i?.newCustomList??null};break}return r}catch(r){return this.loggingService.catch("Error in ActivityUtilsService buildCommentChanges:",r),{}}}extractFeatureSpecificUserIds(t,e){try{switch(t.featureType){case"comment":this.extractCommentActivityUserIds(t,e);break;case"reaction":this.extractReactionActivityUserIds(t,e);break;case"recorder":this.extractRecorderActivityUserIds(t,e);break}}catch(i){this.loggingService.catch("Error in ActivityUtilsService extractFeatureSpecificUserIds:",i)}}extractCommentActivityUserIds(t,e){try{if(t.entityData){let i=this.commentUtilsService.getUserIdsToResolveFromComments([t.entityData]);for(let r of i)e.add(r)}if(t.entityTargetData){let i=t.entityTargetData;if(this.extractUserIdFromValue(i.from,e),Array.isArray(i.to))for(let r of i.to)this.extractUserIdFromValue(r,e);if(Array.isArray(i.taggedUserContacts))for(let r of i.taggedUserContacts)this.extractUserIdFromValue(r,e)}}catch(i){this.loggingService.catch("Error in ActivityUtilsService extractCommentActivityUserIds:",i)}}extractReactionActivityUserIds(t,e){try{if(!t.entityData)return;let i=this.reactionUtilsService.getUserIdsToResolveFromReactions([t.entityData]);for(let r of i)e.add(r)}catch(i){this.loggingService.catch("Error in ActivityUtilsService extractReactionActivityUserIds:",i)}}extractRecorderActivityUserIds(t,e){try{if(!t.entityData)return;let i=this.serviceBook.get(ae)?.getUserIdsToResolveFromRecorders([t.entityData])??[];for(let r of i)e.add(r)}catch(i){this.loggingService.catch("Error in ActivityUtilsService extractRecorderActivityUserIds:",i)}}stripUsersFromChanges(t){try{for(let e of Object.keys(t)){let i=t[e];i&&(i.from=this.stripUserIfPresent(i.from),i.to=this.stripUserIfPresent(i.to))}}catch(e){this.loggingService.catch("Error in ActivityUtilsService stripUsersFromChanges:",e)}}stripUserIfPresent(t){try{return t&&typeof t=="object"&&"userId"in t?{userId:t.userId}:t}catch(e){return this.loggingService.catch("Error in ActivityUtilsService stripUserIfPresent:",e),t}}stripUsersFromTemplateData(t){try{for(let e of Object.keys(t)){let i=t[e];i&&typeof i=="object"&&"userId"in i&&(t[e]={userId:i.userId})}}catch(e){this.loggingService.catch("Error in ActivityUtilsService stripUsersFromTemplateData:",e)}}rehydrateUsersInChanges(t){try{for(let e of Object.values(t))e&&(e.from=this.rehydrateIfUser(e.from),e.to=this.rehydrateIfUser(e.to))}catch(e){this.loggingService.catch("Error in ActivityUtilsService rehydrateUsersInChanges:",e)}}rehydrateIfUser(t){try{if(t&&typeof t=="object"&&"userId"in t){let e=t.userId;return this.usersService.getUserById(e)??t}return t}catch(e){return this.loggingService.catch("Error in ActivityUtilsService rehydrateIfUser:",e),t}}rehydrateUsersInTemplateData(t){try{for(let e of Object.keys(t))t[e]=this.rehydrateIfUser(t[e])}catch(e){this.loggingService.catch("Error in ActivityUtilsService rehydrateUsersInTemplateData:",e)}}rehydrateUserInObject(t,e){try{let i=t[e];if(i&&typeof i=="object"&&"userId"in i){let r=i.userId,n=this.usersService.getUserById(r);n&&(t[e]=n)}}catch(i){this.loggingService.catch("Error in ActivityUtilsService rehydrateUserInObject:",i)}}rehydrateUsersInArray(t,e){try{let i=t[e];Array.isArray(i)&&(t[e]=i.map(r=>this.rehydrateIfUser(r)))}catch(i){this.loggingService.catch("Error in ActivityUtilsService rehydrateUsersInArray:",i)}}extractUserIdFromValue(t,e){try{if(t&&typeof t=="object"&&"userId"in t){let i=t.userId;typeof i=="string"&&e.add(i)}}catch(i){this.loggingService.catch("Error in ActivityUtilsService extractUserIdFromValue:",i)}}};l.\u0275fac=function(e){return new(e||l)(A(F),A(x),A(Ct),A(Ut),A(fe),A(Se),A(Ne),A(pt),A(pe))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var _t=class{constructor({apiKey:l,documentId:Ie,organizationId:t,folderId:e,veltFolderId:i,clientDocumentId:r,clientOrganizationId:n}){this.paths={},this.apiKey=l,this.documentId=Ie,this.organizationId=t,this.folderId=e,this.veltFolderId=i,this.clientDocumentId=r,this.clientOrganizationId=n,r&&(this.documentId=De(r)),n&&(this.organizationId=Le(n)),e&&(this.folderId=e,this.veltFolderId=me(e)),this.generateDocumentPaths()}generateDocumentPaths(){try{if(this.paths.clientDocumentId=this.clientDocumentId,this.paths.documentId=this.documentId,this.organizationId&&(this.paths.organizationId=this.organizationId,this.paths.clientOrganizationId=this.clientOrganizationId),this.veltFolderId&&(this.paths.folderId=this.folderId,this.paths.veltFolderId=this.veltFolderId),this.apiKey){let l=`${this.apiKey}`;this.organizationId&&(l=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.paths.organizationId}`),this.documentId&&(this.paths.docs=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/`,this.paths.folder=`${l}/${d.FIREBASE_PARTIAL_PATH_FOLDERS}/`,this.paths.presence=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_PRESENCE}/`,this.paths.cursor=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_CURSOR}/`,this.paths.comment=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_COMMENT}/`,this.paths.multiThread=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_MULTI_THREAD}/`,this.paths.tag=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_TAG}/`,this.paths.area=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_AREA}/`,this.paths.arrow=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_ARROW}/`,this.paths.selection=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_SELECTION}/`,this.paths.audioHuddle=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_AUDIO_HUDDLE}/`,this.paths.huddle=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_HUDDLE}/`,this.paths.recorder=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_RECORDER}/`,this.paths.flock=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_FOLLOW_ALONG}/`,this.paths.syncVideoPlayer=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_SYNC_VIDEO_PLAYER}/`,this.paths.liveState=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_LIVE_STATE}/`,this.paths.liveStateSingleEditorMode=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_LIVE_STATE}/default/singleEditorMode`,this.paths.reaction=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_REACTION}/`,this.paths.crdt=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_CRDT}/`,this.paths.views=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_VIEWS}/`,this.paths.notifications=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_NOTIFICATIONS}/`,this.paths.metadata=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_METADATA}/`,this.paths.users=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_USERS}/`,this.paths.documentIam=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_IAM}/`,this.paths.userConfig=`${l}/${d.FIREBASE_PARTIAL_PATH_USERS}`),this.paths.customerMetadata=`${l}/${d.FIREBASE_PARTIAL_PATH_CUSTOMER_METADATA}/`,this.paths.groupContacts=`${l}/${d.FIREBASE_PARTIAL_PATH_CONTACTS}/${d.FIREBASE_PARTIAL_PATH_GROUPS}/`,this.paths.globalContacts=`${l}/${d.FIREBASE_PARTIAL_PATH_CONTACTS}/${d.FIREBASE_PARTIAL_PATH_GLOBAL}/`,this.paths.logins=`${l}/${d.FIREBASE_PARTIAL_PATH_CONTACTS}/${d.FIREBASE_PARTIAL_PATH_LOGINS}/`,this.paths.userFeedback=`${l}/${d.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${d.FIREBASE_PARTIAL_PATH_FEEDBACK}/`,this.paths.userReportBugs=`${l}/${d.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${d.FIREBASE_PARTIAL_PATH_BUGS}/`,this.paths.userContactUs=`${l}/${d.FIREBASE_PARTIAL_PATH_USER_REQUESTS}/${d.FIREBASE_PARTIAL_PATH_CONTACT_US}/`,this.organizationId&&(this.paths.organizationMetadata=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_METADATA}/`,this.paths.organizationIam=`${l}/${d.FIREBASE_PARTIAL_PATH_IAM}/`,this.paths.organizationGroups=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_GROUPS}/`,this.paths.organizationNotifications=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/`,this.documentId&&(this.paths.organizationNotificationsWithDocumentId=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/`,this.paths.heartbeatByDocument=`${l}/${d.FIREBASE_PARTIAL_PATH_HEARTBEAT_BY_DOCUMENT}/${this.documentId}/`),this.paths.organizationNotificationsLastNotificationTimestamp=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${d.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}/${d.FIREBASE_PARTIAL_PATH_DOCS}/`,this.paths.organizationNotificationsUsers=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_NOTIFICATIONS}/${d.FIREBASE_PARTIAL_PATH_USERS}/`,this.paths.heartbeat=`${l}/${d.FIREBASE_PARTIAL_PATH_HEARTBEAT}/`),this.paths.workspaceIam=`${this.apiKey}/${d.FIREBASE_PARTIAL_PATH_IAM}/`}}catch{}}get folder(){return this.paths.folder?this.paths.folder:this.throwError("Folder path is not available.")}get userConfig(){return this.paths.userConfig?this.paths.userConfig:this.throwError("User config path is not available.")}get workspaceIam(){return this.paths.workspaceIam?this.paths.workspaceIam:this.throwError("Workspace IAM path is not available.")}get docs(){return this.paths.docs?this.paths.docs:this.throwError("Docs path is not available.")}get presence(){return this.paths.presence?this.paths.presence:this.throwError("Presence path is not available.")}get cursor(){return this.paths.cursor?this.paths.cursor:this.throwError("Cursor path is not available.")}get area(){return this.paths.area?this.paths.area:this.throwError("Area path is not available.")}get arrow(){return this.paths.arrow?this.paths.arrow:this.throwError("Arrow path is not available.")}get comment(){return this.paths.comment?this.paths.comment:this.throwError("Comment path is not available.")}get multiThread(){return this.paths.multiThread?this.paths.multiThread:this.throwError("Multi thread path is not available.")}get tag(){return this.paths.tag?this.paths.tag:this.throwError("Tag path is not available.")}get selection(){return this.paths.selection?this.paths.selection:this.throwError("Selection path is not available.")}get audioHuddle(){return this.paths.audioHuddle?this.paths.audioHuddle:this.throwError("Audio huddle path is not available.")}get huddle(){return this.paths.huddle?this.paths.huddle:this.throwError("Huddle path is not available.")}get recorder(){return this.paths.recorder?this.paths.recorder:this.throwError("Recorder path is not available.")}get flock(){return this.paths.flock?this.paths.flock:this.throwError("Flock path is not available.")}get syncVideoPlayer(){return this.paths.syncVideoPlayer?this.paths.syncVideoPlayer:this.throwError("Sync video player path is not available.")}get liveState(){return this.paths.liveState?this.paths.liveState:this.throwError("Live state path is not available.")}get liveStateSingleEditorMode(){return this.paths.liveStateSingleEditorMode?this.paths.liveStateSingleEditorMode:this.throwError("Live state single editor mode path is not available.")}get reaction(){return this.paths.reaction?this.paths.reaction:this.throwError("Reaction path is not available.")}get crdt(){return this.paths.crdt?this.paths.crdt:this.throwError("CRDT path is not available.")}get views(){return this.paths.views?this.paths.views:this.throwError("Views path is not available.")}get notifications(){return this.paths.notifications?this.paths.notifications:this.throwError("Notifications path is not available.")}get metadata(){return this.paths.metadata?this.paths.metadata:this.throwError("Metadata path is not available.")}get users(){return this.paths.users?this.paths.users:this.throwError("Users path is not available.")}get documentIam(){return this.paths.documentIam?this.paths.documentIam:this.throwError("Document IAM path is not available.")}get organizationMetadata(){return this.paths.organizationMetadata?this.paths.organizationMetadata:this.throwError("Organization metadata path is not available.")}get organizationIam(){return this.paths.organizationIam?this.paths.organizationIam:this.throwError("Organization IAM path is not available.")}get customerMetadata(){return this.paths.customerMetadata?this.paths.customerMetadata:this.throwError("Customer metadata path is not available.")}get groupContacts(){return this.paths.groupContacts?this.paths.groupContacts:this.throwError("Group contacts path is not available.")}get globalContacts(){return this.paths.globalContacts?this.paths.globalContacts:this.throwError("Global contacts path is not available.")}get logins(){return this.paths.logins?this.paths.logins:this.throwError("Logins path is not available.")}get userFeedback(){return this.paths.userFeedback?this.paths.userFeedback:this.throwError("User feedback path is not available.")}get userReportBugs(){return this.paths.userReportBugs?this.paths.userReportBugs:this.throwError("User report bugs path is not available.")}get userContactUs(){return this.paths.userContactUs?this.paths.userContactUs:this.throwError("User contact us path is not available.")}get organizationGroups(){return this.paths.organizationGroups?this.paths.organizationGroups:this.throwError("Organization groups path is not available.")}get heartbeat(){return this.paths.heartbeat?this.paths.heartbeat:this.throwError("Heartbeat path is not available.")}get heartbeatByDocument(){return this.paths.heartbeatByDocument?this.paths.heartbeatByDocument:this.throwError("Heartbeat by document path is not available.")}get organizationNotifications(){return this.paths.organizationNotifications?this.paths.organizationNotifications:this.throwError("Organization notifications path is not available.")}get organizationNotificationsWithDocumentId(){return this.paths.organizationNotificationsWithDocumentId?this.paths.organizationNotificationsWithDocumentId:this.throwError("Organization notifications with document id path is not available.")}get organizationNotificationsUsers(){return this.paths.organizationNotificationsUsers?this.paths.organizationNotificationsUsers:this.throwError("Organization notifications users path is not available.")}get organizationNotificationsLastNotificationTimestamp(){return this.paths.organizationNotificationsLastNotificationTimestamp?this.paths.organizationNotificationsLastNotificationTimestamp:this.throwError("Organization notifications last notification timestamp path is not available.")}throwError(l){throw{type:"DocumentPaths",message:l,metadata:{apiKey:this.apiKey,documentId:this.documentId,organizationId:this.organizationId}}}};var $i=(()=>{let l=class l{constructor(t,e,i){this.coreActionsService=t,this.loggingService=e,this.usersService=i}getUserIdsToResolveFromLiveStateCustom(t){try{let e=new Set;return t?.updatedBy&&e.add(t?.updatedBy?.userId),Array.from(e)}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateCustom:",e),[]}}mergeLiveStateCustomWithUser(t){try{if(t?.updatedBy?.userId){let e=this.usersService.getUserById(t?.updatedBy?.userId);e&&(t.updatedBy=e)}return t}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService mergeLiveStateCustomWithUser:",e),t}}formatLiveStateCustomData(t){try{return this.usersService.userDataProviderAvailable()&&t?.updatedBy&&(t.updatedBy={userId:t.updatedBy.userId}),t}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService formatLiveStateCustomData:",e),t}}getUserIdsToResolveFromLiveStateCustoms(t){try{let e=new Set;for(let i of t)i?.updatedBy?.userId&&e.add(i?.updatedBy?.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateCustoms:",e),[]}}getUserIdsToResolveFromLiveStates(t){try{let e=new Set;return t?.default?.singleEditorMode?.editor?.userId&&e.add(t?.default?.singleEditorMode?.editor?.userId),Array.from(e)}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStates:",e),[]}}getUserIdsToResolveFromLiveStateSingleEditorMode(t){try{let e=new Set;return t?.editor?.userId&&e.add(t?.editor?.userId),t?.requestEditorAccess?.user?.userId&&e.add(t?.requestEditorAccess?.user?.userId),Array.from(e)}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService getUserIdsToResolveFromLiveStateSingleEditorMode:",e),[]}}mergeLiveStateWithUser(t){try{if(t?.default?.singleEditorMode?.editor?.userId){let e=this.usersService.getUserById(t?.default?.singleEditorMode?.editor?.userId);e&&(t.default.singleEditorMode.editor=e)}if(t?.default?.singleEditorMode?.requestEditorAccess?.user?.userId){let e=this.usersService.getUserById(t?.default?.singleEditorMode?.requestEditorAccess?.user?.userId);e&&(t.default.singleEditorMode.requestEditorAccess.user=e)}return t}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService mergeLiveStateWithUser:",e),t}}mergeSingleEditorLiveStateDataWithUser(t){try{if(t?.editor?.userId){let e=this.usersService.getUserById(t?.editor?.userId);e&&(t.editor=e)}if(t?.requestEditorAccess?.user?.userId){let e=this.usersService.getUserById(t?.requestEditorAccess?.user?.userId);e&&(t.requestEditorAccess.user=e)}return t}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService mergeSingleEditorLiveStateDataWithUser:",e),t}}resolveAndMergeSingleEditorLiveStateDataWithUser(t){return T(this,null,function*(){try{let e=this.getUserIdsToResolveFromLiveStates({default:{singleEditorMode:t}});if(e.length){let i=p(),r=nt.GET_SINGLE_EDITOR_USERS;return this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:i,methodName:ne.RESOLVE_AND_MERGE_SINGLE_EDITOR_LIVE_STATE_DATA_WITH_USER,moduleName:r,source:"internal",payload:{userIds:e}}),yield this.usersService.resolveUsers({userIds:e,uniqueId:i,moduleName:r}),this.mergeSingleEditorLiveStateDataWithUser(t)}return t}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService resolveAndMergeSingleEditorLiveStateDataWithUser:",e),t}})}formatLiveStateSingleEditorModeData(t){try{return this.usersService.userDataProviderAvailable()&&(t?.editor?.userId&&(t.editor={userId:t.editor.userId}),t?.requestEditorAccess?.user?.userId&&(t.requestEditorAccess.user={userId:t.requestEditorAccess.user.userId})),t}catch(e){return this.loggingService.catch("Error in LiveStateUtilsService formatLiveStateSingleEditorModeData:",e),t}}mergeLiveStateCustomsWithUsers(t){try{for(let e of t)if(e?.updatedBy?.userId){let i=this.usersService.getUserById(e?.updatedBy?.userId);i&&(e.updatedBy=i)}return t}catch(e){return this.loggingService.catch("Error in mergeLiveStateCustomsWithUsers:",e),t}}};l.\u0275fac=function(e){return new(e||l)(A(j),A(F),A(x))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var bt=(()=>{let l=class l{constructor(t,e,i){this.coreActionsService=t,this.loggingService=e,this.analyticsService=i,this.resolveTimeout=60*1e3,this.retryDeleteConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.retryGetConfig={retryCount:0,retryDelay:0,revertOnFailure:!1},this.notificationDataProvider$=new b(null),this.notificationById$=new b({}),this.inFlightRequests=new Map,this.getNotificationById=r=>{try{return this.notificationDataProviderAvailable()?this.notificationById$.value?.[r]:void 0}catch(n){this.loggingService.catch("Error in NotificationResolverService getNotificationById:",n);return}};try{this.loggingService.log("NotificationResolverService initialized"),this.notificationDataProvider$.subscribe(r=>{r&&(r.config?.resolveTimeout&&(this.resolveTimeout=r.config.resolveTimeout),r.config?.deleteRetryConfig&&(this.retryDeleteConfig=r.config.deleteRetryConfig),r.config?.getRetryConfig&&(this.retryGetConfig=r.config.getRetryConfig))})}catch(r){this.loggingService.catch("Error in NotificationResolverService constructor:",r)}}getProvider(){try{let t=this.notificationDataProvider$.getValue();return t||void 0}catch(t){this.loggingService.catch("Error in NotificationResolverService getProvider:",t);return}}ngOnDestroy(){try{this.notificationById$.next({})}catch(t){this.loggingService.catch("Error in NotificationResolverService ngOnDestroy:",t)}}resolveNotifications(r){return T(this,arguments,function*({request:t,uniqueId:e,moduleName:i}){try{if(this.loggingService.log("%c[WB] Calling NotificationResolverService FUNCTION: resolveNotifications","color: green;"),!this.notificationDataProviderAvailable())return{};let n,s=!1,a=!1,o=()=>{n&&(clearTimeout(n),n=void 0,a=!0)};return new Promise((c,h)=>{n=setTimeout(()=>{if(!a){s=!0,o();let C=e||p();this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:C,methodName:X.RESOLVE_NOTIFICATIONS,moduleName:i,source:"internal",payload:{error:new Error("Notification resolution timeout"),request:t}}),h(new Error("Notification resolution timeout"))}},this.notificationDataProvider$.value?.config?.resolveTimeout||this.resolveTimeout);let m=this.getProvider();if(!m)return o(),c({});let f={},u=this.notificationById$.getValue()||{},g=[...new Set(t.notificationIds||[])],y=[],D=[],U=[];for(let C of g)u[C]||(this.inFlightRequests.has(C)?(y.push(this.inFlightRequests.get(C)),D.push(C)):U.push(C));let I=w(E({},t),{notificationIds:U});T(this,null,function*(){try{if(y.length>0&&(yield Promise.allSettled(y)),U.length>0){let C=e||p();this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_RESOLUTION_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:C,methodName:X.RESOLVE_NOTIFICATIONS,moduleName:i,source:"internal",payload:{request:I}});let N,z=new Promise(k=>{N=k});for(let k of U)this.inFlightRequests.set(k,z.then(Ee=>Ee?.[k]));let Wi=W(()=>m?.config?.getConfig?.url?H(m.config.getConfig.url,m.config.getConfig.headers,I,!0,m.config.getConfig.credentials):m?.get?.(I)||Promise.resolve(void 0),"getNotifications",this.retryGetConfig).then(k=>s?{}:(o(),k&&k.statusCode!==200?(this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:C,methodName:X.RESOLVE_NOTIFICATIONS,moduleName:i,source:"internal",payload:{result:k,request:I}}),this.loggingService.catch(k?.message??"Error in NotificationResolverService resolveNotifications:"),{}):k?.data)).catch(k=>{throw o(),k});try{f=(yield Wi)||{},N(f);for(let Ee of U)this.inFlightRequests.delete(Ee);this.analyticsService.trackEvent(v.Events.Resolver.NOTIFICATION_RESOLVER_GET,{sourceMethod:"resolveNotifications",source:"sdk",notificationIds:U});let k={};Object.entries(f).forEach(([Ee,We])=>{let Pt=this.notificationById$.value?.[Ee];Pt?Pt&&JSON.stringify(Pt)!==JSON.stringify(We)&&(k[Ee]=We):k[Ee]=We}),Object.keys(k).length>0&&this.notificationById$.next(E(E({},this.notificationById$.getValue()),k)),this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_RESOLUTION_RESULT,timestamp:new Date().getTime(),uniqueId:C,methodName:X.RESOLVE_NOTIFICATIONS,moduleName:i,source:"internal",payload:{result:k,request:I}}),c(k)}catch(k){N({});for(let We of U)this.inFlightRequests.delete(We);let Ee=e||p();this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:Ee,methodName:X.RESOLVE_NOTIFICATIONS,moduleName:i,source:"internal",payload:{error:k,request:I}}),s||h(k),c(f)}}else o(),c({})}catch(C){o();let N=e||p();this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:N,methodName:X.RESOLVE_NOTIFICATIONS,moduleName:i,source:"internal",payload:{error:C,request:I}}),h(C)}})})}catch(n){this.loggingService.catch("Error in NotificationResolverService resolveNotifications:",n);let s=e||p();return this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_RESOLUTION_ERROR,timestamp:new Date().getTime(),uniqueId:s,methodName:X.RESOLVE_NOTIFICATIONS,moduleName:i,source:"internal",payload:{error:n,request:t}}),{}}})}deleteNotification(t,e,i){return T(this,null,function*(){try{this.loggingService.log("%c[WB] Calling NotificationResolverService FUNCTION: deleteNotification","color: green;");let r=this.getProvider();if(!this.notificationDataProviderAvailable())throw new Error("Notification delete data provider not available");let n=i||p();this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_DELETE_REQUEST_TRIGGERED,timestamp:new Date().getTime(),uniqueId:n,methodName:X.DELETE_NOTIFICATION,source:"internal",payload:{notificationId:t,organizationId:e}});let s=this.notificationById$.getValue(),a=E({},s);delete a?.[t],this.notificationById$._value=a;let o={notificationId:t,organizationId:e},c=yield W(()=>r?.config?.deleteConfig?.url?H(r.config.deleteConfig.url,r.config.deleteConfig.headers,o,!1,r.config.deleteConfig.credentials):r?.delete?.(o)||Promise.resolve(void 0),"deleteNotification",this.retryDeleteConfig);return c&&c.statusCode!==200?(this.retryDeleteConfig.revertOnFailure&&(this.notificationById$._value=s),this.loggingService.catch(c?.message??"Error in NotificationResolverService deleteNotification:"),this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:n,methodName:X.DELETE_NOTIFICATION,source:"internal",payload:{error:c,notificationId:t,organizationId:e}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!1}):(this.analyticsService.trackEvent(v.Events.Resolver.NOTIFICATION_RESOLVER_DELETE,{sourceMethod:"deleteNotification",source:"sdk",notificationId:t}),this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_DELETE_RESULT,timestamp:new Date().getTime(),uniqueId:n,methodName:X.DELETE_NOTIFICATION,source:"internal",payload:{result:{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0},notificationId:t,organizationId:e}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0})}catch(r){this.loggingService.warn("Error in NotificationResolverService deleteNotification:",r);let n=i||p();return this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_DELETE_ERROR,timestamp:new Date().getTime(),uniqueId:n,methodName:X.DELETE_NOTIFICATION,source:"internal",payload:{error:r,notificationId:t,organizationId:e}}),{revertOnFailure:this.retryDeleteConfig.revertOnFailure,isSuccess:!0}}})}getNotificationsById$(){try{return this.notificationDataProviderAvailable()?(this.loggingService.log("%c[WB] Calling NotificationResolverService FUNCTION: getNotificationsById$","color: green;"),this.notificationById$.asObservable()):P(void 0)}catch(t){return this.loggingService.catch("Error in NotificationResolverService getNotificationsById$:",t),P(void 0)}}setNotificationDataProvider(t){try{if(t){this.loggingService.log("Setting notification data provider");let e=t.config,i=[{method:"get",configKey:"getConfig"},{method:"delete",configKey:"deleteConfig"}],r=[];if(i.forEach(({method:n,configKey:s})=>{let a=e?.[s]?.url,o=n in t&&typeof t[n]=="function";!a&&!o&&r.push(n)}),r.length>0){let n=`DataProviders.notification is invalid. The following methods are missing or are not functions (and no corresponding config provided): ${r.join(", ")}.`;this.loggingService.catch(n);return}else this.notificationDataProvider$.next(t)}}catch(e){this.loggingService.catch("Error in NotificationResolverService setNotificationDataProvider:",e)}}notificationDataProviderAvailable(){try{return!!this.notificationDataProvider$.getValue()}catch(t){return this.loggingService.catch("Error in NotificationResolverService notificationDataProviderAvailable:",t),!1}}};l.\u0275fac=function(e){return new(e||l)(A(j),A(F),A(te))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var et=class{constructor({apiKey:l,documentId:Ie,organizationId:t,clientDocumentId:e,clientOrganizationId:i,folderId:r,veltFolderId:n}){this.paths={},this.apiKey=l,this.documentId=Ie,this.organizationId=t,this.veltFolderId=n,e&&(this.documentId=De(e)),i&&(this.organizationId=Le(i)),r&&(this.folderId=r,this.veltFolderId=me(r)),this.generateDocumentPaths()}generateDocumentPaths(){try{if(this.paths.clientDocumentId=this.clientDocumentId,this.paths.documentId=this.documentId,this.organizationId&&(this.paths.organizationId=this.organizationId,this.paths.clientOrganizationId=this.clientOrganizationId),this.veltFolderId&&(this.paths.folderId=this.folderId,this.paths.veltFolderId=this.veltFolderId),this.apiKey){let l=`apiKey/${this.apiKey}`;this.paths.activities=`${l}/${d.FIREBASE_PARTIAL_PATH_ACTIVITIES}`,this.paths.userNotificationIndex=`${l}/${d.FIREBASE_PARTIAL_PATH_USER_NOTIFICATION_INDEX}`,this.organizationId&&(l=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATIONS}/${this.paths.organizationId}`,this.paths.organization=l,this.paths.folder=`${l}/${d.FIREBASE_PARTIAL_PATH_FOLDERS}`,this.paths.organizationUsers=`${l}/${d.FIREBASE_PARTIAL_PATH_ORGANIZATION_USERS}`,this.paths.users=`${l}/${d.FIREBASE_PARTIAL_PATH_CENTRAL_USERS}`,this.paths.notificationDocs=`${l}/${d.FIREBASE_PARTIAL_PATH_NOTIFICATION_DOCS}`,this.paths.notificationUsers=`${l}/${d.FIREBASE_PARTIAL_PATH_NOTIFICATION_USERS}`,this.paths.organizationGroups=`${l}/${d.FIREBASE_PARTIAL_PATH_GROUPS}`,this.paths.lastNotificationTimestamp=`${l}/${d.FIREBASE_PARTIAL_PATH_LAST_NOTIFICATION_TIMESTAMP}`,this.paths.lastActivityTimestamp=`${l}/${d.FIREBASE_PARTIAL_PATH_LAST_ACTIVITY_TIMESTAMP}`,this.paths.userConfig=`${l}/${d.FIREBASE_PARTIAL_PATH_USERS}`,this.paths.permissionsUsers=`${l}/${d.FIREBASE_PARTIAL_PATH_PERMISSIONS_USERS}`),this.veltFolderId&&(this.paths.folderUsers=`${l}/${d.FIREBASE_PARTIAL_PATH_FOLDERS}/${this.veltFolderId}/${d.FIREBASE_PARTIAL_PATH_FOLDER_USERS}`),this.documentId&&(this.paths.document=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}`,this.paths.comment=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_COMMENT}`,this.paths.location=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_LOCATION}`,this.paths.multiThread=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_MULTI_THREAD}`,this.paths.area=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_AREA}`,this.paths.recorder=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_RECORDER}`,this.paths.reaction=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_REACTION}`,this.paths.crdt=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_CRDT}`,this.paths.notificationViews=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_NOTIFICATION_VIEWS}`,this.paths.documentViews=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS}`,this.paths.locationViews=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS}`,this.paths.documentUsers=`${l}/${d.FIREBASE_PARTIAL_PATH_DOCS}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS}`,this.paths.docNotification=`${this.paths.notificationDocs}/${this.documentId}/${d.FIREBASE_PARTIAL_PATH_DOC_NOTIFICATION}`)}}catch{}}get userNotificationIndex(){return this.paths.userNotificationIndex}get permissionsUsers(){return this.paths.permissionsUsers?this.paths.permissionsUsers:this.throwError("PermissionsUsers path is not available.")}get users(){return this.paths.users?this.paths.users:this.throwError("Users path is not available.")}get userConfig(){return this.paths.userConfig?this.paths.userConfig:this.throwError("UserConfig path is not available.")}get folder(){return this.paths.folder?this.paths.folder:this.throwError("Folder path is not available.")}get lastNotificationTimestamp(){return this.paths.lastNotificationTimestamp?this.paths.lastNotificationTimestamp:this.throwError("LastNotificationTimestamp path is not available.")}get organizationGroups(){return this.paths.organizationGroups?this.paths.organizationGroups:this.throwError("organizationGroups path is not available.")}get docNotification(){return this.paths.docNotification?this.paths.docNotification:this.throwError("DocNotification path is not available.")}get organization(){return this.paths.organization?this.paths.organization:this.throwError("Organization path is not available.")}get document(){return this.paths.document?this.paths.document:this.throwError("Document path is not available.")}get location(){return this.paths.location?this.paths.location:this.throwError("Location path is not available.")}get area(){return this.paths.area?this.paths.area:this.throwError("Area path is not available.")}get comment(){return this.paths.comment?this.paths.comment:this.throwError("Comment path is not available.")}get documentViews(){return this.paths.documentViews?this.paths.documentViews:this.throwError("DocumentViews path is not available.")}get locationViews(){return this.paths.locationViews?this.paths.locationViews:this.throwError("LocationViews path is not available.")}get notificationViews(){return this.paths.notificationViews?this.paths.notificationViews:this.throwError("NotificationViews path is not available.")}get documentUsers(){return this.paths.documentUsers?this.paths.documentUsers:this.throwError("DocumentUsers path is not available.")}get folderUsers(){return this.paths.folderUsers?this.paths.folderUsers:this.throwError("FolderUsers path is not available.")}get organizationUsers(){return this.paths.organizationUsers?this.paths.organizationUsers:this.throwError("OrganizationUsers path is not available.")}get notificationDocs(){return this.paths.notificationDocs?this.paths.notificationDocs:this.throwError("NotificationDocs path is not available.")}get notificationUsers(){return this.paths.notificationUsers?this.paths.notificationUsers:this.throwError("NotificationUsers path is not available.")}get multiThread(){return this.paths.multiThread?this.paths.multiThread:this.throwError("Multi thread path is not available.")}get recorder(){return this.paths.recorder?this.paths.recorder:this.throwError("Recorder path is not available.")}get reaction(){return this.paths.reaction?this.paths.reaction:this.throwError("Reaction path is not available.")}get crdt(){return this.paths.crdt?this.paths.crdt:this.throwError("CRDT path is not available.")}get activities(){return this.paths.activities?this.paths.activities:this.throwError("Activities path is not available.")}get lastActivityTimestamp(){return this.paths.lastActivityTimestamp?this.paths.lastActivityTimestamp:this.throwError("LastActivityTimestamp path is not available.")}throwError(l){throw{type:"DocumentPaths",message:l,metadata:{apiKey:this.apiKey,documentId:this.documentId,organizationId:this.organizationId}}}};var Fi=(()=>{let l=class l{constructor(t,e){this.loggingService=t,this.usersService=e}getUserIdsToResolveFromAreaAnnotations(t){try{this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: getUserIdsToResolveFromAreaAnnotations","color: green;");let e=new Set;for(let i of t)i?.from?.userId&&e.add(i?.from?.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in AreaUtilsService getUserIdsToResolveFromAreaAnnotations:",e),[]}}mergeAreaWithUser(t){try{if(this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: mergeAreaWithUser","color: green;"),t?.from?.userId){let e=this.usersService.getUserById(t?.from?.userId);e&&(t.from=e)}return t}catch(e){return this.loggingService.catch("Error in AreaUtilsService mergeAreaWithUser:",e),t}}formatAreaData(t){try{return this.loggingService.log("%c[WB] Calling AreaUtilsService FUNCTION: formatAreaData","color: green;"),this.usersService.userDataProviderAvailable()&&t?.from?.userId&&(t.from={userId:t.from.userId}),t}catch(e){return this.loggingService.catch("Error in AreaUtilsService formatAreaData:",e),t}}};l.\u0275fac=function(e){return new(e||l)(A(F),A(x))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var wi=(()=>{let l=class l{constructor(t,e){this.loggingService=t,this.usersService=e}getUserIdsToResolveFromUserIamData(t){try{this.loggingService.log("%c[WB] Calling ContactUtilsService FUNCTION: getUserIdsToResolveFromUserIamData","color: green;");let e=new Set;if(t?.length)for(let i of t)i?.user?.userId&&e.add(i?.user?.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in ContactUtilsService getUserIdsToResolveFromUserIamData: ",e),[]}}mergeUserIamWithUser(t){try{if(this.loggingService.log("%c[WB] Calling ContactUtilsService FUNCTION: mergeUserIamWithUser","color: green;"),t?.user?.userId){let e=this.usersService.getUserById(t?.user?.userId);if(e){let i=e;t?.user&&typeof t.user=="object"&&(i=E(E({},i),t.user));let r=this.usersService.getContactListUser(t.user.userId);r&&(i=E(E({},i),r)),t=w(E({},t),{user:i})}}return t}catch(e){return this.loggingService.catch("Error in ContactUtilsService mergeUserIamWithUser: ",e),t}}};l.\u0275fac=function(e){return new(e||l)(A(F),A(x))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Bi=(()=>{let l=class l{constructor(t,e){this.loggingService=t,this.usersService=e}getUserIdsToResolveFromMultiThreads(t){try{let e=new Set;for(let i of t)i?.from?.userId&&e.add(i?.from?.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in MultiThreadUtilsService getUserIdsToResolveFromMultiThreads:",e),[]}}mergeMultiThreadWithUser(t){try{if(t?.from?.userId){let e=this.usersService.getUserById(t?.from?.userId);e&&(t.from=e)}return t}catch(e){return this.loggingService.catch("Error in MultiThreadUtilsService mergeMultiThreadWithUser:",e),t}}formatMultiThreadData(t){try{return this.usersService.userDataProviderAvailable()&&(t?.from?.userId&&(t.from={userId:t.from.userId}),t?.commentAnnotationsMap&&(t.commentAnnotationsMap=null)),t}catch(e){return this.loggingService.catch("Error in MultiThreadUtilsService formatMultiThreadData:",e),t}}};l.\u0275fac=function(e){return new(e||l)(A(F),A(x))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Mi=(()=>{let l=class l{constructor(t,e){this.loggingService=t,this.usersService=e}getUserIdsToResolveFromSelections(t){try{let e=new Set;for(let i of t)i?.user?.userId&&e.add(i.user.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in SelectionUtilsService getUserIdsToResolveFromSelections:",e),[]}}mergeSelectionWithUser(t){try{if(t?.user?.userId){let e=this.usersService.getUserById(t?.user?.userId);e&&(t.user=e)}return t}catch(e){return this.loggingService.catch("Error in SelectionUtilsService mergeSelectionWithUser:",e),t}}formatSelectionData(t){try{return this.usersService.userDataProviderAvailable()&&t?.user?.userId&&(t.user={userId:t.user.userId}),t}catch(e){return this.loggingService.catch("Error in SelectionUtilsService formatSelectionData:",e),t}}};l.\u0275fac=function(e){return new(e||l)(A(F),A(x))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var Vi=(()=>{let l=class l{constructor(t,e){this.loggingService=t,this.usersService=e}getUserIdsToResolveFromTags(t){try{let e=new Set;for(let i of t)if(i?.from?.userId&&e.add(i.from.userId),i?.to?.length)for(let r of i.to)r?.userId&&e.add(r.userId);return Array.from(e)}catch(e){return this.loggingService.catch("Error in TagUtilsService getUserIdsToResolveFromTags:",e),[]}}mergeTagWithUser(t){try{if(t?.from?.userId){let e=this.usersService.getUserById(t?.from?.userId);e&&(t.from=e)}return t?.to?.length&&(t.to=t.to.map(e=>{if(e?.userId){let i=this.usersService.getUserById(e?.userId);i&&(e=i)}return e})),t}catch(e){return this.loggingService.catch("Error in TagUtilsService mergeTagWithUser:",e),t}}formatTagData(t){try{return this.usersService.userDataProviderAvailable()&&(t?.from?.userId&&(t.from={userId:t.from.userId}),t?.to?.length&&(t.to=t.to.map(e=>(e?.userId&&(e={userId:e.userId}),e)))),t}catch(e){return this.loggingService.catch("Error in TagUtilsService formatTagData:",e),t}}};l.\u0275fac=function(e){return new(e||l)(A(F),A(x))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var zi=(()=>{let l=class l{constructor(t,e,i,r,n,s,a,o,c,h,m,f,u,g,y,D,U,I,R,C){this.activityUtilsService=t,this.areaUtilsService=e,this.commentUtilsService=i,this.contactUtilsService=r,this.coreActionsService=n,this.liveStateUtilsService=s,this.loggingService=a,this.multiThreadUtilsService=o,this.reactionUtilsService=c,this.selectionUtilsService=h,this.tagUtilsService=m,this.usersService=f,this.docService=u,this.commentAnnotationsResolverService=g,this.reactionAnnotationsResolverService=y,this.recorderAnnotationsResolverService=D,this.notificationResolverService=U,this.activityResolverService=I,this.serviceBook=R,this.attachmentResolverService=C}getErrorForGetRequests({feature:t,error:e}){try{switch(t){case"apiKeyMetadata":case"organizationMetadata":case"documentMetadata":case"folderMetadata":return(e?.message??"")?.includes("Missing or insufficient permissions.")?{errorCode:"PERMISSION_DENIED"}:null;default:return null}}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService getErrorForGetRequests:",i),null}}getFirestorePath({feature:t,properties:e,documentPaths:i,apiKey:r}){try{if(!r)return;if(t==="userNotificationIndex"){if(!e?.id)return;let c=new et({apiKey:r});return c?.userNotificationIndex?`${c.userNotificationIndex}/${e.id}`:void 0}let{documentId:n,organizationId:s,folderId:a}=e;if(!s&&(s=i?.organizationId,!s))return;let o=new et({apiKey:r,documentId:n?`${n}`:"",organizationId:s?`${s}`:"",veltFolderId:a?`${a}`:void 0});switch(t){case"userConfig":return e?.userId&&o?.userConfig?`${o?.userConfig}/${e?.userId}${e?.documentId?`/${d.FIREBASE_PARTIAL_PATH_DOCUMENT_CONFIGURATIONS}/${e?.documentId}`:""}`:void 0;case"allPermissionsUsers":return o?.permissionsUsers?`${o?.permissionsUsers}`:void 0;case"comment":return e?.documentId&&e?.id&&o?.comment?`${o?.comment}/${e?.id}`:void 0;case"allComments":return e?.documentId&&o?.comment?`${o?.comment}`:void 0;case"multiThread":return e?.documentId&&e?.id&&o?.multiThread?`${o?.multiThread}/${e?.id}`:void 0;case"allMultiThreads":return e?.documentId&&o?.multiThread?`${o?.multiThread}`:void 0;case"crdt":return e?.documentId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}`:void 0;case"allLastNotificationTimestamp":return o?.lastNotificationTimestamp?`${o?.lastNotificationTimestamp}`:void 0;case"lastNotificationTimestamp":return e?.id&&o?.lastNotificationTimestamp?`${o?.lastNotificationTimestamp}/${e?.id}`:void 0;case"activity":return e?.id&&o?.activities?`${o?.activities}/${e?.id}`:void 0;case"allActivities":return o?.activities?`${o?.activities}`:void 0;case"allLastActivityTimestamp":return o?.lastActivityTimestamp?`${o?.lastActivityTimestamp}`:void 0;case"lastActivityTimestamp":return e?.id&&o?.lastActivityTimestamp?`${o?.lastActivityTimestamp}/${e?.id}`:void 0;case"area":return e?.documentId&&e?.id&&o?.area?`${o?.area}/${e?.id}`:void 0;case"allAreas":return e?.documentId&&o?.area?`${o?.area}`:void 0;case"allDocuments":return o?.document?`${o?.document}`:void 0;case"allLocations":return o?.location?`${o?.location}`:void 0;case"allFolders":return o?.folder?`${o?.folder}`:void 0;case"folder":return o?.folder&&e.folderId?`${o?.folder}/${e.folderId}`:void 0;case"documentUserAccess":return e?.documentId&&e?.id&&o?.documentUsers?`${o?.documentUsers}/${e?.id}`:void 0;case"reaction":return e?.documentId&&e?.id&&o?.reaction?`${o?.reaction}/${e?.id}`:void 0;case"allReactions":return e?.documentId&&o?.reaction?`${o?.reaction}`:void 0;case"recorder":return e?.documentId&&e?.id&&o?.recorder?`${o?.recorder}/${e?.id}`:void 0;case"allRecorders":return e?.documentId&&o?.recorder?`${o?.recorder}`:void 0;case"recorderTrackEvent":return e?.documentId&&e?.id&&o?.recorder?`${o?.recorder}/${e?.id}/trackRecorderEvent`:void 0;case"documentAccessType":return e?.documentId&&o?.document?`${o?.document}/${e?.documentId}`:void 0;case"apiKeyMetadata":return r?`apiKey/${r}`:void 0;case"organizationMetadata":return o?.organization?`${o?.organization}`:void 0;case"documentIam":case"documentMetadata":return e?.documentId&&o?.document?`${o?.document}/${e?.documentId}`:void 0;case"folderMetadata":return e?.folderId&&o?.folder?`${o?.folder}/${e?.folderId}`:void 0;case"locationMetadata":return e?.documentId&&o?.location&&e?.id?`${o?.location}/${e?.id}`:void 0;case"documentUser":return e?.documentId&&e?.id&&o?.documentUsers?`${o?.documentUsers}/${e?.id}`:void 0;case"allDocumentUsers":return o?.users?`${o?.users}`:void 0;case"allFolderUsers":return o?.users?`${o?.users}`:void 0;case"allOrganizationGroups":return o?.organizationGroups?`${o?.organizationGroups}`:void 0;case"allOrganizationUsers":return o?.users?`${o?.users}`:void 0;case"notificationViewsTimestamp":return e?.documentId&&e?.id&&o?.notificationViews?`${o?.notificationViews}/${e?.id}`:void 0;case"allDocumentViews":return e?.documentId&&o?.documentViews?`${o?.documentViews}`:void 0;case"documentViews":case"documentMetadataViews":case"documentDayViews":case"documentUsersViews":return e?.documentId&&e?.id&&o?.documentViews?`${o?.documentViews}/${e?.id}`:void 0;case"locationDayViews":case"locationUsersViews":case"locationViews":case"locationMetadataViews":case"location":return e?.documentId&&e?.id&&o?.locationViews?`${o?.locationViews}/${e?.id}`:void 0;case"allLocationViews":return e?.documentId&&o?.locationViews?`${o?.locationViews}`:void 0;case"allDocNotifications":return e?.documentId&&o?.docNotification?`${o?.docNotification}`:void 0;case"docNotificationViews":case"docNotification":return e?.documentId&&e?.id&&o?.docNotification?`${o?.docNotification}/${e?.id}`:void 0;case"userNotificationViews":case"userNotification":return e?.userId&&e?.id&&o?.notificationUsers?`${o?.notificationUsers}/${e?.userId}/${d.FIREBASE_PARTIAL_PATH_USER_NOTIFICATION}/${e?.id}`:void 0;case"allUserNotifications":return e?.userId&&o?.notificationUsers?`${o?.notificationUsers}/${e?.userId}/${d.FIREBASE_PARTIAL_PATH_USER_NOTIFICATION}`:void 0;default:throw new Error(`Unknown feature: ${t}`)}}catch(n){this.loggingService.catch("Error in CommonDbUtilsService getFirestorePath:",n);return}}getFirestoreCollectionGroupPath(t){try{switch(t){case"allComments":return d.FIREBASE_PARTIAL_PATH_COMMENT;case"allDocuments":return d.FIREBASE_PARTIAL_PATH_DOCS;case"allLocations":return d.FIREBASE_PARTIAL_PATH_LOCATION;case"allMultiThreads":return d.FIREBASE_PARTIAL_PATH_MULTI_THREAD;case"allAreas":return d.FIREBASE_PARTIAL_PATH_AREA;case"allReactions":return d.FIREBASE_PARTIAL_PATH_REACTION;case"allRecorders":return d.FIREBASE_PARTIAL_PATH_RECORDER;case"allDocumentViews":return d.FIREBASE_PARTIAL_PATH_DOCUMENT_VIEWS;case"allLocationViews":return d.FIREBASE_PARTIAL_PATH_LOCATION_VIEWS;case"allDocumentUsers":return d.FIREBASE_PARTIAL_PATH_DOCUMENT_USERS;case"allFolderUsers":return d.FIREBASE_PARTIAL_PATH_FOLDER_USERS;default:throw new Error(`Unknown feature: ${t}`)}}catch(e){this.loggingService.catch("Error in CommonDbUtilsService getFirestoreCollectionGroupPath:",e);return}}getDocumentPath({feature:t,properties:e,defaultDocumentPaths:i,apiKey:r,useFirestore:n}){try{if(!r)return;let{documentId:s,organizationId:a}=e;a||(a=i?.organizationId);let o=new _t({apiKey:r,documentId:s?`${s}`:"",organizationId:a?`${a}`:""});switch(t){case"userConfig":return e?.userId&&e?.documentId&&o?.userConfig?`${o?.userConfig}/${e?.userId}/${d.FIREBASE_PARTIAL_PATH_DOCUMENT_CONFIGURATIONS}/${e?.documentId}`:void 0;case"allComments":return!n&&e?.documentId&&o?.comment?`${o?.comment}`:void 0;case"allGlobalContacts":return e?.documentId&&o?.globalContacts?`${o?.globalContacts}`:void 0;case"globalContacts":return e?.documentId&&e?.userId&&o?.globalContacts?`${o?.globalContacts}${e?.userId}`:void 0;case"groupContacts":return e?.documentId&&e?.groupId&&o?.groupContacts?`${o?.groupContacts}${e?.groupId}`:void 0;case"groupContactsUser":return e?.documentId&&e?.groupId&&e?.userId&&o?.groupContacts?`${o?.groupContacts}${e?.groupId}/${e?.userId}`:void 0;case"allLoginContacts":return e?.documentId&&e?.userId&&o?.logins?`${o?.logins}${e?.userId}/contacts`:void 0;case"allLogins":return e?.documentId&&o?.logins?`${o?.logins}`:void 0;case"logins":return e?.documentId&&e?.userId&&o?.logins?`${o?.logins}${e?.userId}`:void 0;case"customerMetadata":return o?.customerMetadata?`${o?.customerMetadata}`:void 0;case"allArrows":return e?.documentId&&o?.arrow?`${o?.arrow}`:void 0;case"arrow":return e?.documentId&&o?.arrow&&e.id?`${o?.arrow}${e.id}`:void 0;case"allCursors":return e?.documentId&&o?.cursor?`${o?.cursor}`:void 0;case"cursor":return e?.documentId&&o?.cursor&&e.id?`${o?.cursor}${e.id}`:void 0;case"flockUser":return e?.documentId&&o?.flock&&e.id?`${o?.flock}users/${e.id}`:void 0;case"flockSession":return e?.documentId&&o?.flock&&e.id?`${o?.flock}sessions/${e.id}`:void 0;case"allHuddleAttendees":return e?.documentId&&o?.huddle?`${o?.huddle}attendees`:void 0;case"huddleAttendee":return e?.documentId&&o?.huddle&&e.id?`${o?.huddle}attendees/${e.id}`:void 0;case"huddleAttendeeState":return e?.documentId&&o?.huddle&&e.id?`${o?.huddle}attendees/${e.id}/state`:void 0;case"allHuddleInvitees":return e?.documentId&&o?.huddle?`${o?.huddle}invitees`:void 0;case"huddleConnection":return e?.documentId&&o?.huddle&&e.id?`${o?.huddle}connections/${e.id}`:void 0;case"huddleIceCandidate":return e?.documentId&&o?.huddle&&e.id?`${o?.huddle}iceCandidates/${e.id}`:void 0;case"allHuddleIceCandidates":return e?.documentId&&o?.huddle?`${o?.huddle}iceCandidates`:void 0;case"allHuddleMessages":return e?.documentId&&o?.huddle?`${o?.huddle}messages`:void 0;case"huddleMessage":return e?.documentId&&o?.huddle&&e.id?`${o?.huddle}messages/${e.id}`:void 0;case"allLiveStates":return e?.documentId&&o?.liveState?`${o?.liveState}`:void 0;case"allLiveStateCustoms":return e?.documentId&&o?.liveState?`${o?.liveState}custom`:void 0;case"liveStateCustom":return e?.documentId&&o?.liveState&&e?.id?`${o?.liveState}custom/${e.id}`:void 0;case"liveStateSingleEditorMode":return e?.documentId&&o?.liveStateSingleEditorMode?`${o?.liveStateSingleEditorMode}`:void 0;case"liveStateAutoSyncState":return e?.documentId&&o?.liveState?`${o?.liveState}default/autoSyncState`:void 0;case"liveStateAutoSyncStateCurrent":return e?.documentId&&o?.liveState?`${o?.liveState}default/autoSyncState/current`:void 0;case"liveStateAutoSyncStateHistoryId":return e?.documentId&&o?.liveState&&e?.id?`${o?.liveState}default/autoSyncState/history/${e.id}`:void 0;case"presence":return e?.documentId&&o?.presence&&e?.userId?`${o?.presence}${e?.userId}`:void 0;case"allPresence":return e?.documentId&&o?.presence?`${o?.presence}`:void 0;case"workspaceIam":return o?.workspaceIam?`${o?.workspaceIam}`:void 0;case"selection":return e?.documentId&&o?.selection&&e?.userId?`${o?.selection}${e?.userId}`:void 0;case"allSelections":return e?.documentId&&o?.selection?`${o?.selection}`:void 0;case"syncVideoPlayer":return e?.documentId&&o?.syncVideoPlayer?`${o?.syncVideoPlayer}`:void 0;case"allTags":return e?.documentId&&o?.tag?`${o?.tag}`:void 0;case"tag":return e?.documentId&&o?.tag&&e?.id?`${o?.tag}${e?.id}`:void 0;case"userContactUs":return e?.documentId&&o?.userContactUs?`${o?.userContactUs}`:void 0;case"userFeedback":return e?.documentId&&o?.userFeedback?`${o?.userFeedback}`:void 0;case"userReportBug":return e?.documentId&&o?.userReportBugs?`${o?.userReportBugs}`:void 0;case"comment":return!n&&e?.documentId&&e?.id&&o?.comment?`${o?.comment}${e?.id}`:void 0;case"allMultiThreads":return!n&&e?.documentId&&o?.multiThread?`${o?.multiThread}`:void 0;case"crdt":return!n&&e?.documentId&&o?.crdt?`${o?.crdt}`:void 0;case"crdtData":return e?.documentId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/data`:void 0;case"crdtSyncState":return e?.documentId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/sync/state`:void 0;case"crdtSyncPresence":return e?.documentId&&e.userId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/sync/presence/${e.userId}`:void 0;case"allCrdtSyncPresence":return e?.documentId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/sync/presence`:void 0;case"crdtPresence":return e?.documentId&&e.userId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/presence/${e.userId}`:void 0;case"allCrdtPresence":return e?.documentId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/presence`:void 0;case"crdtVersion":return e?.documentId&&o?.crdt&&e?.id&&e?.versionId?`${o?.crdt}/${e?.id}/versions/${e?.versionId}`:void 0;case"crdtVersions":return e?.documentId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/versions`:void 0;case"crdtMessages":return e?.documentId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/messages`:void 0;case"crdtMessage":return e?.documentId&&o?.crdt&&e?.id&&e?.messageId?`${o?.crdt}/${e?.id}/messages/${e?.messageId}`:void 0;case"crdtSnapshot":return e?.documentId&&o?.crdt&&e?.id?`${o?.crdt}/${e?.id}/snapshot`:void 0;case"multiThread":return!n&&e?.documentId&&e?.id&&o?.multiThread?`${o?.multiThread}${e?.id}`:void 0;case"allLastNotificationTimestamp":return!n&&o?.organizationNotificationsLastNotificationTimestamp?`${o?.organizationNotificationsLastNotificationTimestamp}`:void 0;case"lastNotificationTimestamp":return!n&&e?.id&&o?.organizationNotificationsLastNotificationTimestamp?`${o?.organizationNotificationsLastNotificationTimestamp}${e?.id}`:void 0;case"documentIam":return!n&&e?.documentId&&o?.documentIam?`${o?.documentIam}`:void 0;case"allDocuments":return!n&&o?.docs&&e?.documentId?`${o?.docs}/${e?.documentId}/${d.FIREBASE_PARTIAL_PATH_METADATA}`:void 0;case"allAreas":return!n&&e?.documentId&&o?.area?`${o?.area}`:void 0;case"area":return!n&&e?.id&&o?.area?`${o?.area}${e?.id}`:void 0;case"folder":return!n&&e?.folderId&&o?.folder?`${o?.folder}${e?.folderId}`:void 0;case"documentUserAccess":return!n&&e?.id&&o?.documentIam?`${o?.documentIam}users/${e?.id}`:void 0;case"documentUser":return!n&&e?.documentId&&e?.id&&o?.documentIam?`${o?.documentIam}users/${e?.id}`:void 0;case"allDocumentUsers":return!n&&e?.documentId&&o?.documentIam?`${o?.documentIam}users/`:void 0;case"allOrganizationGroups":return!n&&o?.organizationGroups?`${o?.organizationGroups}`:void 0;case"allOrganizationUsers":return!n&&o?.organizationIam?`${o?.organizationIam}users/`:void 0;case"reaction":return!n&&e?.id&&o?.reaction?`${o?.reaction}${e?.id}`:void 0;case"allReactions":return!n&&e?.documentId&&o?.reaction?`${o?.reaction}`:void 0;case"recorder":return!n&&e?.documentId&&e?.id&&o?.recorder?`${o?.recorder}${e?.id}`:void 0;case"allRecorders":return!n&&e?.documentId&&o?.recorder?`${o?.recorder}`:void 0;case"organizationMetadata":return!n&&o?.organizationMetadata?`${o?.organizationMetadata}`:void 0;case"heartbeat":return e?.id&&o?.heartbeat?`${o?.heartbeat}${e?.id}`:void 0;case"allHeartbeats":return o?.heartbeat?`${o?.heartbeat}`:void 0;case"heartbeatByDocument":return e?.id&&o?.heartbeatByDocument?`${o?.heartbeatByDocument}${e?.id}`:void 0;case"allHeartbeatsByDocument":return o?.heartbeatByDocument?`${o?.heartbeatByDocument}`:void 0;case"documentAccessType":return!n&&o?.documentIam?`${o?.documentIam}`:void 0;case"documentMetadata":return!n&&e?.documentId&&o?.metadata?`${o?.metadata}`:void 0;case"allDocumentViews":return!n&&e?.documentId&&o?.views?`${o?.views}documentViews/`:void 0;case"documentViews":return!n&&e?.documentId&&e?.id&&o?.views?`${o?.views}documentViews/${e?.id}`:void 0;case"allLocationViews":return!n&&e?.documentId&&o?.views?`${o?.views}locationViews/`:void 0;case"notificationViewsTimestamp":return!n&&e?.id&&e?.user&&o?.views?`${o?.views}notification/${e?.id}/views/${e?.user}`:void 0;case"documentUsersViews":return!n&&e?.id&&e?.user&&e?.date&&o?.views?`${o?.views}documentViews/${e?.id}/users/${e?.user}/${e?.date}`:void 0;case"documentMetadataViews":return!n&&e?.id&&o?.views?`${o?.views}documentViews/${e?.id}/metadata`:void 0;case"documentDayViews":return!n&&e?.id&&e?.date&&e?.user&&o?.views?`${o?.views}documentViews/${e?.id}/day/${e?.date}/${e?.user}`:void 0;case"locationViews":return!n&&e?.id&&o?.views?`${o?.views}locationViews/${e?.id}/location`:void 0;case"location":return!n&&e?.id&&o?.views?`${o?.views}locationViews/${e?.id}`:void 0;case"locationUsersViews":return!n&&e?.id&&e?.user&&e?.date&&o?.views?`${o?.views}locationViews/${e?.id}/users/${e?.user}/${e?.date}`:void 0;case"locationMetadataViews":return!n&&e?.id&&o?.views?`${o?.views}locationViews/${e?.id}/metadata`:void 0;case"locationDayViews":return!n&&e?.id&&e?.date&&e?.user&&o?.views?`${o?.views}locationViews/${e?.id}/day/${e?.date}/${e?.user}`:void 0;case"docNotificationViews":case"docNotification":return e?.documentId&&e?.id&&o?.organizationNotificationsWithDocumentId?`${o?.organizationNotificationsWithDocumentId}${e?.id}`:void 0;case"allDocNotifications":return e?.documentId&&o?.organizationNotificationsWithDocumentId?`${o?.organizationNotificationsWithDocumentId}`:void 0;case"allUserNotifications":return e?.userId&&o?.organizationNotificationsUsers?`${o?.organizationNotificationsUsers}${e?.userId}`:void 0;case"userNotificationViews":case"userNotification":return e?.userId&&e?.id&&o?.organizationNotificationsUsers?`${o?.organizationNotificationsUsers}${e?.userId}/${e?.id}`:void 0;case"locationMetadata":return;case"allLocations":return;case"folderMetadata":return;case"allPermissionsUsers":return;default:throw new Error(`Unknown feature: ${t}`)}}catch(s){this.loggingService.catch("Error in CommonDbUtilsService getDocumentPath:",s);return}}resolveAnnotations(i){return T(this,arguments,function*({data:t,feature:e}){try{if(t&&t?.length>0)switch(e){case"allComments":{if(this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable()){let r=p(),n=Ge.GET_COMMENT_ANNOTATIONS;this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:B.RESOLVE_COMMENT_ANNOTATIONS,moduleName:n,source:"internal",payload:{commentAnnotationIds:t,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""}}),this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:t,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:r,moduleName:n})}break}case"allReactions":{if(this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable()){let r=p(),n=qe.GET_REACTION_ANNOTATIONS;this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:n,source:"internal",payload:{reactionAnnotationIds:t,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""}}),this.reactionAnnotationsResolverService.resolveReactionAnnotations({request:{reactionAnnotationIds:t,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:r,moduleName:n})}break}case"allRecorders":{if(this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()){let r=p(),n=Je.GET_RECORDER_ANNOTATIONS;this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:r,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:n,source:"internal",payload:{recorderAnnotationIds:t,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""}}),this.recorderAnnotationsResolverService.resolveRecorderAnnotations({request:{recorderAnnotationIds:t,organizationId:this.docService.getDocumentPaths()?.clientOrganizationId??""},uniqueId:r,moduleName:n})}break}default:break}}catch(r){this.loggingService.catch(`Error in CommonDbUtilsService resolveAnnotations: ${e}`,r)}})}formatResponse(m){return T(this,arguments,function*({feature:t,data:e,organizationId:i,shouldAwait:r=!1,forceResolve:n=!1,shouldCommentAnnotationsResolverAwait:s=!1,shouldNotificationResolverAwait:a=!1,shouldActivityResolverAwait:o=!1,shouldReactionResolverAwait:c=!1,shouldRecorderResolverAwait:h=!1}){try{let f=i??this.docService.getDocumentPaths()?.clientOrganizationId??this.docService.getOrganizationConfig()?.clientOrganizationId??"";if(this.usersService.userDataProviderAvailable()){let u=[];switch(t){case"allAreas":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.areaUtilsService.getUserIdsToResolveFromAreaAnnotations(Object.values(e)));break}case"allArrows":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.serviceBook.get(ht)?.getUserIdsToResolveFromArrowAnnotations(Object.values(e))??[]);break}case"allCursors":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.serviceBook.get(ut)?.getUserIdsToResolveFromCursorUsers(Object.values(e))??[]);break}case"allComments":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.commentUtilsService.getUserIdsToResolveFromComments(Object.values(e)));break}case"allDocumentUsers":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(e)));break}case"allFolderUsers":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(e)));break}case"allOrganizationUsers":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.contactUtilsService.getUserIdsToResolveFromUserIamData(Object.values(e)));break}case"allMultiThreads":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.multiThreadUtilsService.getUserIdsToResolveFromMultiThreads(Object.values(e)));break}case"allDocNotifications":{e&&typeof e=="object"&&(u=this.serviceBook.get(de)?.getUserIdsToResolveFromNotifications(Array.isArray(e)?e:Object.values(e))??[]);break}case"allUserNotifications":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.serviceBook.get(de)?.getUserIdsToResolveFromNotifications(Object.values(e))??[]);break}case"allPresence":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.serviceBook.get(gt)?.getUserIdsToResolveFromPresenceUsers(Object.values(e))??[]);break}case"allRecorders":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.serviceBook.get(ae)?.getUserIdsToResolveFromRecorders(Object.values(e))??[]);break}case"allReactions":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.reactionUtilsService.getUserIdsToResolveFromReactions(Object.values(e)));break}case"allTags":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.tagUtilsService.getUserIdsToResolveFromTags(Object.values(e)));break}case"allHuddleAttendees":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.serviceBook.get(mt)?.getUserIdsToResolveFromHuddleAttendees(Object.values(e))??[]);break}case"liveStateCustom":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateCustom(e));break}case"allLiveStateCustoms":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateCustoms(Object.values(e)));break}case"allLiveStates":{e&&typeof e=="object"&&(u=this.liveStateUtilsService.getUserIdsToResolveFromLiveStates(e));break}case"liveStateSingleEditorMode":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.liveStateUtilsService.getUserIdsToResolveFromLiveStateSingleEditorMode(e));break}case"allSelections":{e&&typeof e=="object"&&!Array.isArray(e)&&(u=this.selectionUtilsService.getUserIdsToResolveFromSelections(Object.values(e)));break}case"allActivities":{e&&typeof e=="object"&&(u=this.activityUtilsService.getUserIdsToResolveFromActivities(Array.isArray(e)?e:Object.values(e)));break}default:u=[]}if(u?.length){let g=p(),y=nt.GET_USERS;this.coreActionsService.triggerAction(S.USER_RESOLVER,{event:v.Events.Resolver.USER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:ne.FORMAT_RESPONSE,source:"internal",moduleName:y,payload:{userIds:u,feature:t,forceResolve:n}}),r?yield this.usersService.resolveUsers({userIds:u,forceResolve:n,feature:t,organizationId:i,uniqueId:g,moduleName:y}):this.usersService.resolveUsers({userIds:u,forceResolve:n,feature:t,organizationId:i,uniqueId:g,moduleName:y})}}if(this.notificationResolverService.notificationDataProviderAvailable()){let u=[];switch(t){case"allDocNotifications":case"allUserNotifications":{e&&typeof e=="object"&&(u=this.serviceBook.get(de)?.getCustomNotificationIdsToResolve(e)??[],u=u.filter(y=>!this.notificationResolverService.getNotificationById(y)));break}default:u=[]}if(u?.length){let g=p(),y=ni.GET_NOTIFICATIONS;this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:X.FORMAT_RESPONSE,moduleName:y,source:"internal",payload:{notificationIds:u,organizationId:f,shouldNotificationResolverAwait:a}}),a?yield this.notificationResolverService.resolveNotifications({request:{notificationIds:u,organizationId:f},uniqueId:g,moduleName:y}):this.notificationResolverService.resolveNotifications({request:{notificationIds:u,organizationId:f},uniqueId:g,moduleName:y})}}if(this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable()){let u=[];switch(t){case"allDocNotifications":{if(e&&typeof e=="object"){let y=this.serviceBook.get(de)?.getTargetAnnotationIdsFromNotifications(e)??[];u=[...u,...y],u=u.filter(D=>!this.commentAnnotationsResolverService.getCommentAnnotationById(D))}break}case"allUserNotifications":{if(e&&typeof e=="object"&&!Array.isArray(e)){let y=this.serviceBook.get(de)?.getTargetAnnotationIdsFromNotifications(e)??[];u=[...u,...y],u=u.filter(D=>!this.commentAnnotationsResolverService.getCommentAnnotationById(D))}break}case"allActivities":{if(e&&typeof e=="object"){let g=Array.isArray(e)?e:Object.values(e),y=this.activityUtilsService.getEntityIdsToResolveFromActivities(g,"comment");u=[...u,...y],u=u.filter(D=>!this.commentAnnotationsResolverService.getCommentAnnotationById(D))}break}default:u=[]}if(u?.length){let g=p(),y=Ge.GET_NOTIFICATIONS;this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:B.FORMAT_RESPONSE,moduleName:y,source:"internal",payload:{commentAnnotationIds:u,organizationId:f,shouldCommentAnnotationsResolverAwait:s}}),s?yield this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:u,organizationId:f},uniqueId:g,moduleName:y}):this.commentAnnotationsResolverService.resolveCommentAnnotations({request:{commentAnnotationIds:u,organizationId:f},uniqueId:g,moduleName:y})}}if(t==="allActivities"&&e&&typeof e=="object"){let u=Array.isArray(e)?e:Object.values(e),g=this.docService.getDocumentPaths()?.clientOrganizationId??"";if(this.activityResolverService.activityDataProviderAvailable()){let y=[];for(let D of u)D?.id&&!this.activityResolverService.getActivityById(D.id)&&y.push(D.id);if(y.length){let D=p(),U=oi.GET_ACTIVITIES;this.coreActionsService.triggerAction(S.ACTIVITY_RESOLVER,{event:v.Events.Resolver.ACTIVITY_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:D,methodName:oe.FORMAT_RESPONSE,moduleName:U,source:"internal",payload:{activityIds:y,organizationId:g,shouldActivityResolverAwait:o}}),o?yield this.activityResolverService.resolveActivities({request:{activityIds:y,organizationId:g},uniqueId:D,moduleName:U}):this.activityResolverService.resolveActivities({request:{activityIds:y,organizationId:g},uniqueId:D,moduleName:U})}}if(this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable()){let y=this.activityUtilsService.getEntityIdsToResolveFromActivities(u,"reaction");if(y=y.filter(D=>!this.reactionAnnotationsResolverService.getAnnotationById(D)),y.length){let D=p(),U=qe.GET_REACTION_ANNOTATIONS;this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:D,methodName:M.RESOLVE_REACTION_ANNOTATIONS,moduleName:U,source:"internal",payload:{reactionAnnotationIds:y,organizationId:g,shouldReactionResolverAwait:c}}),c?yield this.reactionAnnotationsResolverService.resolveReactionAnnotations({request:{reactionAnnotationIds:y,organizationId:g},uniqueId:D,moduleName:U}):this.reactionAnnotationsResolverService.resolveReactionAnnotations({request:{reactionAnnotationIds:y,organizationId:g},uniqueId:D,moduleName:U})}}if(this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()){let y=this.activityUtilsService.getEntityIdsToResolveFromActivities(u,"recorder");if(y=y.filter(D=>!this.recorderAnnotationsResolverService.getAnnotationById(D)),y.length){let D=p(),U=Je.GET_RECORDER_ANNOTATIONS;this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_RESOLUTION_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:D,methodName:V.RESOLVE_RECORDER_ANNOTATIONS,moduleName:U,source:"internal",payload:{recorderAnnotationIds:y,organizationId:g,shouldRecorderResolverAwait:h}}),h?yield this.recorderAnnotationsResolverService.resolveRecorderAnnotations({request:{recorderAnnotationIds:y,organizationId:g},uniqueId:D,moduleName:U}):this.recorderAnnotationsResolverService.resolveRecorderAnnotations({request:{recorderAnnotationIds:y,organizationId:g},uniqueId:D,moduleName:U})}}}return e}catch(f){return this.loggingService.catch("Error in CommonDbUtilsService formatResponse:",f),e}})}mergeCommentAnnotationsWithData({data:t,feature:e}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeCommentAnnotationsWithData","color: green;"),this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable())switch(e){case"allComments":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((i,[r,n])=>(i[r]=this.commentUtilsService.mergeStrippedDataWithCommentAnnotations(n),i),{}):t;case"allDocNotifications":case"allUserNotifications":if(t&&typeof t=="object"&&!Array.isArray(t)){let i=this.serviceBook.get(de);return Object.entries(t).reduce((r,[n,s])=>(r[n]=i?i.mergeStrippedDataWithNotification(s):s,r),{})}else return t;case"allActivities":return this.mergeActivitiesWithFeatureData(t);default:return t}return t}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService mergeCommentAnnotationsWithData:",i),t}}mergeActivityResolverWithData({data:t,feature:e}){try{return this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeActivityResolverWithData","color: green;"),this.activityResolverService.activityDataProviderAvailable()&&e==="allActivities"&&Array.isArray(t)?t.map(i=>this.activityUtilsService.mergeActivityWithResolverData(i)):t}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService mergeActivityResolverWithData:",i),t}}mergeNotificationsWithResolvedData({data:t,feature:e}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeNotificationsWithResolvedData","color: green;"),this.notificationResolverService.notificationDataProviderAvailable())switch(e){case"allDocNotifications":case"allUserNotifications":{let i=this.serviceBook.get(de);return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[n,s])=>(r[n]=i?i.mergeResolvedNotificationData(s):s,r),{}):Array.isArray(t)?t.map(r=>i?i.mergeResolvedNotificationData(r):r):t}default:return t}return t}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService mergeNotificationsWithResolvedData:",i),t}}mergeNotificationsWithResolvedData$({data:t,feature:e}){try{return this.notificationResolverService.getNotificationsById$().pipe(G(()=>{let i=this.mergeNotificationsWithResolvedData({data:t?.data??{},feature:e}),r=this.mergeUsersWithData({feature:e,data:i??{}});return typeof r=="object"?{data:JSON.parse(JSON.stringify(r)),operation:t?.operation??null}:{data:r,operation:t?.operation??null}}),J(Q))}catch(i){return this.loggingService.catch("Error in mergeNotificationsWithResolvedData$:",i),P(t)}}mergeReactionAnnotationsWithData({data:t,feature:e}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeReactionAnnotationsWithData","color: green;"),this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable())switch(e){case"allReactions":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((i,[r,n])=>(i[r]=this.reactionUtilsService.mergeStrippedDataWithReactionAnnotations(n),i),{}):t;case"allActivities":return this.mergeActivitiesWithFeatureData(t);default:return t}return t}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService mergeReactionAnnotationsWithData:",i),t}}mergeRecorderAnnotationsWithData({data:t,feature:e}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeRecorderAnnotationsWithData","color: green;"),this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable())switch(e){case"allRecorders":if(t&&typeof t=="object"&&!Array.isArray(t)){let i=this.serviceBook.get(ae);return Object.entries(t).reduce((r,[n,s])=>(r[n]=i?i.mergeStrippedDataWithRecorderAnnotation(s):s,r),{})}else return t;case"allActivities":return this.mergeActivitiesWithFeatureData(t);default:return t}return t}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService mergeRecorderAnnotationsWithData:",i),t}}mergeActivitiesWithFeatureData(t){return Array.isArray(t)?t.map(e=>this.activityUtilsService.mergeActivityWithFeatureData(e)):t}mergeLocationMetadataWithData({data:t,feature:e,locationMetadata:i}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeLocationMetadataWithData","color: green;"),i&&typeof i=="object"&&!Array.isArray(i))switch(e){case"allComments":return t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((r,[n,s])=>(r[n]=this.commentUtilsService.mergeLocationWithCommentAnnotations(s,i),r),{}):t;case"allDocNotifications":case"allUserNotifications":if(t&&typeof t=="object"&&!Array.isArray(t)){let r=this.serviceBook.get(de);return Object.entries(t).reduce((n,[s,a])=>(n[s]=r?r.mergeLocationWithNotification(a,i):a,n),{})}else return t;default:return t}return t}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService mergeLocationMetadataWithData:",r),t}}mergeUsersWithData({feature:t,data:e}){try{if(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: mergeUsersWithData","color: green;"),this.usersService.userDataProviderAvailable())switch(t){case"allAreas":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.areaUtilsService.mergeAreaWithUser(n),i),{}):e;case"allArrows":if(e&&typeof e=="object"&&!Array.isArray(e)){let i=this.serviceBook.get(ht);return Object.entries(e).reduce((r,[n,s])=>(r[n]=i?i.mergeArrowWithUser(s):s,r),{})}else return e;case"allCursors":if(e&&typeof e=="object"&&!Array.isArray(e)){let i=this.serviceBook.get(ut);return Object.entries(e).reduce((r,[n,s])=>(r[n]=i?i.mergeCursorUserWithUser(s):s,r),{})}else return e;case"allComments":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.commentUtilsService.mergeCommentWithUser(n),i),{}):e;case"allDocumentUsers":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.contactUtilsService.mergeUserIamWithUser(n),i),{}):e;case"allFolderUsers":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.contactUtilsService.mergeUserIamWithUser(n),i),{}):e;case"allOrganizationUsers":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.contactUtilsService.mergeUserIamWithUser(n),i),{}):e;case"allMultiThreads":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.multiThreadUtilsService.mergeMultiThreadWithUser(n),i),{}):e;case"allDocNotifications":if(e&&typeof e=="object"){let i=this.serviceBook.get(de);return e?.map(r=>i?i.mergeNotificationWithUser(r):r)}else return e;case"allUserNotifications":if(e&&typeof e=="object"&&!Array.isArray(e)){let i=this.serviceBook.get(de);return Object.entries(e).reduce((r,[n,s])=>(r[n]=i?i.mergeNotificationWithUser(s):s,r),{})}else return e;case"allPresence":if(e&&typeof e=="object"&&!Array.isArray(e)){let i=this.serviceBook.get(gt);return Object.entries(e).reduce((r,[n,s])=>(r[n]=i?i.mergePresenceUserWithUser(s):s,r),{})}else return e;case"allRecorders":if(e&&typeof e=="object"&&!Array.isArray(e)){let i=this.serviceBook.get(ae);return Object.entries(e).reduce((r,[n,s])=>(r[n]=i?i.mergeRecorderWithUser(s):s,r),{})}else return e;case"allReactions":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.reactionUtilsService.mergeReactionWithUser(n),i),{}):e;case"allTags":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.tagUtilsService.mergeTagWithUser(n),i),{}):e;case"allHuddleAttendees":if(e&&typeof e=="object"&&!Array.isArray(e)){let i=this.serviceBook.get(mt);return Object.entries(e).reduce((r,[n,s])=>(r[n]=i?.mergeHuddleAttendeeWithUser(s)??s,r),{})}else return e;case"liveStateCustom":return e&&typeof e=="object"&&!Array.isArray(e)?this.liveStateUtilsService.mergeLiveStateCustomWithUser(e):e;case"allLiveStateCustoms":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.liveStateUtilsService.mergeLiveStateCustomWithUser(n),i),{}):e;case"allLiveStates":return e&&typeof e=="object"?this.liveStateUtilsService.mergeLiveStateWithUser(e):e;case"liveStateSingleEditorMode":return e&&typeof e=="object"&&!Array.isArray(e)?this.liveStateUtilsService.mergeSingleEditorLiveStateDataWithUser(e):e;case"allSelections":return e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e).reduce((i,[r,n])=>(i[r]=this.selectionUtilsService.mergeSelectionWithUser(n),i),{}):e;case"allActivities":return Array.isArray(e)?e.map(i=>this.activityUtilsService.mergeActivityWithUser(i)):e;default:return e}return e}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService mergeUsersWithData:",i),e}}mergeCommentAnnotationsWithData$({data:t,feature:e}){try{return this.commentAnnotationsResolverService.getCommentAnnotationsById$().pipe(G(()=>{let i=this.mergeCommentAnnotationsWithData({data:t?.data??{},feature:e}),r=this.mergeUsersWithData({feature:e,data:i??{}});return typeof r=="object"?{data:JSON.parse(JSON.stringify(r)),operation:t?.operation??null}:{data:r,operation:t?.operation??null}}),J(Q))}catch(i){return this.loggingService.catch("Error in mergeCommentAnnotationsWithData:",i),P(t)}}mergeReactionAnnotationsWithData$({data:t,feature:e}){try{return this.reactionAnnotationsResolverService.getReactionAnnotationsById$().pipe(G(()=>{let i=this.mergeReactionAnnotationsWithData({data:t?.data??{},feature:e}),r=this.mergeUsersWithData({feature:e,data:i??{}});return typeof r=="object"?{data:JSON.parse(JSON.stringify(r)),operation:t?.operation??null}:{data:r,operation:t?.operation??null}}),J(Q))}catch(i){return this.loggingService.catch("Error in mergeReactionAnnotationsWithData:",i),P(t)}}mergeRecorderAnnotationsWithData$({data:t,feature:e}){try{return this.recorderAnnotationsResolverService.getRecorderAnnotationsById$().pipe(G(()=>{let i=this.mergeRecorderAnnotationsWithData({data:t?.data??{},feature:e}),r=this.mergeUsersWithData({feature:e,data:i??{}});return typeof r=="object"?{data:JSON.parse(JSON.stringify(r)),operation:t?.operation??null}:{data:r,operation:t?.operation??null}}),J(Q))}catch(i){return this.loggingService.catch("Error in mergeRecorderAnnotationsWithData:",i),P(t)}}mergeUsersWithData$({feature:t,data:e}){try{return this.usersService.getUserById$().pipe(G(()=>{let i=this.mergeUsersWithData({feature:t,data:e?.data??{}});return typeof i=="object"?{data:JSON.parse(JSON.stringify(i)),operation:e?.operation??null}:{data:i,operation:e?.operation??null}}),J(Q))}catch(i){return this.loggingService.catch(`Error in mergeUsersWithData for ${t}:`,i),P(e)}}mergeLocationMetadataWithData$({data:t,feature:e}){try{return this.docService.getLocationMetadata$().pipe(G(i=>{let r=this.mergeLocationMetadataWithData({data:t?.data??{},feature:e,locationMetadata:i});return typeof r=="object"?{data:JSON.parse(JSON.stringify(r)),operation:t?.operation??null}:{data:r,operation:t?.operation??null}}),J(Q))}catch(i){return this.loggingService.catch(`Error in mergeLocationMetadataWithData for ${e}:`,i),P(t)}}handleDataStripping(n){return T(this,arguments,function*({feature:t,data:e,actionType:i,commentId:r}){try{switch(this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: handleDataStripping","color: green;"),t){case"comment":{let s=yield this.commentUtilsService.stripCommentAnnotationData({data:e,actionType:i,commentId:r});return this.filterOriginalDataForVeltDb({feature:t,result:s,providerAvailable:this.commentAnnotationsResolverService.commentAnnotationDataProviderAvailable()})}case"reaction":{let s=this.reactionUtilsService.stripReactionAnnotationData(e);return this.filterOriginalDataForVeltDb({feature:t,result:s,providerAvailable:this.reactionAnnotationsResolverService.reactionAnnotationDataProviderAvailable()})}case"recorder":{let s=this.serviceBook.get(ae)?.stripRecorderAnnotationData({data:e,actionType:i})??{originalData:e,strippedData:null};return this.filterOriginalDataForVeltDb({feature:t,result:s,providerAvailable:this.recorderAnnotationsResolverService.recorderAnnotationDataProviderAvailable()})}default:return{originalData:e,strippedData:null}}}catch(s){return this.loggingService.catch("Error in CommonDbUtilsService handleDataStripping:",s),{originalData:e,strippedData:null}}})}filterOriginalDataForVeltDb({feature:t,result:e,providerAvailable:i}){try{return!i||!e||e.originalData===null||e.originalData===void 0?e:w(E({},e),{originalData:this.applyVeltDbFieldFilter(t,e.originalData)})}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService filterOriginalDataForVeltDb:",r),e}}applyVeltDbFieldFilter(t,e){switch(t){case"comment":return vi(e,{stripAttachmentFiles:this.attachmentResolverService.attachmentDataProviderAvailable()});case"reaction":return fi(e);case"recorder":return Si(e);default:return e}}formatData({feature:t,data:e,properties:i,offset:r,isRealtimeDb:n}){try{this.loggingService.log("%c[WB] Calling CommonDbUtilsService FUNCTION: formatData","color: green;"),typeof e=="object"&&(e=JSON.parse(JSON.stringify(e)));let s=new Date().getTime()+r;switch(t){case"documentAccessType":return delete e?.users,{docIamConfig:e};case"organizationMetadata":case"documentMetadata":return n?e:{metadata:e};case"documentCommentMetadata":return e;case"cursor":{let a=this.serviceBook.get(ut);return a?a.formatCursorUserData(e):e}case"comment":return this.commentUtilsService.formatCommentData(e);case"area":return this.areaUtilsService.formatAreaData(e);case"arrow":{let a=this.serviceBook.get(ht);return a?a.formatArrowData(e):e}case"liveStateCustom":return this.liveStateUtilsService.formatLiveStateCustomData(e);case"liveStateSingleEditorMode":return this.liveStateUtilsService.formatLiveStateSingleEditorModeData(e);case"multiThread":return this.multiThreadUtilsService.formatMultiThreadData(e);case"reaction":return this.reactionUtilsService.formatReactionData(e);case"recorder":return this.serviceBook.get(ae)?.formatRecorderData(e,s)??e;case"notificationViewsTimestamp":return{views:{[i.user??""]:e}};case"documentUsersViews":return n?e:{users:{[i.user??""]:{[i.date??""]:e}}};case"documentDayViews":return n?e:{day:{[i.date??""]:{[i.user??""]:e}}};case"documentMetadataViews":return n?e:{metadata:e};case"huddleMessage":return this.serviceBook.get(mt)?.formatHuddleMessageData(e)??e;case"locationMetadataViews":return n?e:{metadata:e};case"locationUsersViews":return n?e:{users:{[i.user??""]:{[i.date??""]:e}}};case"locationDayViews":return n?e:{day:{[i.date??""]:{[i.user??""]:e}}};case"locationViews":return n?e:{location:e};case"docNotificationViews":return n?e:{views:e.views};case"userNotificationViews":return n?e:{views:e.views};case"presence":{let a=this.serviceBook.get(gt);return a?a.formatPresenceUserData(e):e}case"selection":return this.selectionUtilsService.formatSelectionData(e);case"tag":return this.tagUtilsService.formatTagData(e);default:return e}}catch(s){return this.loggingService.catch("Error in CommonDbUtilsService formatData:",s),e}}modifyAndSetData(n){return T(this,arguments,function*({feature:t,data:e,subscriber:i,operation:r=null}){try{let s=yield this.modifyData({feature:t,data:e});i.next({data:s,operation:r})}catch(s){this.loggingService.catch("Error in CommonDbUtilsService modifyAndSetData:",s)}})}isDataAlreadyProcessedInLocalCache({feature:t,change:e,cache:i}){try{if(t==="allReactions"||t==="allComments"){if(e.type==="removed")return!Object.keys(i??{}).includes(e.doc.id);if(i?.[e.doc.id]){let r=e.doc.data(),n=i?.[e.doc.id];return r?.lastUpdated===n?.lastUpdated}}return!1}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService isDataAlreadyProcessedInLocalCache:",r),!1}}modifyData(i){return T(this,arguments,function*({feature:t,data:e}){try{return yield this.formatResponse({feature:t,data:e})}catch(r){return this.loggingService.catch("Error in CommonDbUtilsService modifyData:",r),e}})}addMetadata(t,e){try{return t&&typeof t=="object"&&!Array.isArray(t)?w(E({},t),{metadata:t?.metadata??{documentId:e?.documentId,organizationId:e?.organizationId,apiKey:e?.apiKey}}):t}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService addMetadata:",i),t}}setDataInLocal(a){return T(this,arguments,function*({feature:t,data:e,observablesCache:i,eventType:r,id:n,operation:s=null}){try{let c={comment:"allComments",reaction:"allReactions"}[t];if(!c)return null;let h=e?.metadata?.documentId,m=e?.metadata?.veltFolderId;return Object.keys(i).filter(f=>f.includes(c)&&(!h||f.includes(h)||m&&f.includes(m))).forEach(f=>{let u=i[f]?.subject?.getValue()??{};r==="DELETE"?n&&u?.data?.[n]&&(delete u?.data?.[n],i[f]?.subject&&i[f].subject.next({data:u?.data,operation:s})):i[f]?.subject?.next({data:w(E({},u?.data),{[e?.annotationId]:e}),operation:s})}),null}catch(o){return this.loggingService.catch("Error in CommonDbUtilsService setDataInLocal:",o),null}})}handleCommentEncryption(s){return T(this,arguments,function*({data:t,firestorePath:e,extraData:i,eventType:r,metadata:n}){try{return yield this.commentUtilsService.handleCommentEncryption({data:t,firestorePath:e,extraData:i,eventType:r,metadata:n})}catch(a){return this.loggingService.catch("Error in CommonDbUtilsService handleCommentEncryption:",a),t}})}prepareCommentNotificationData({data:t,extraData:e}){return this.commentUtilsService.prepareCommentNotificationData({data:t,extraData:e})}handleReactionEncryption(r){return T(this,arguments,function*({data:t,firestorePath:e,eventType:i}){try{return yield this.reactionUtilsService.handleReactionEncryption({data:t,firestorePath:e,eventType:i})}catch(n){return this.loggingService.catch("Error in CommonDbUtilsService handleReactionEncryption:",n),t}})}rtdbDefaultTransactionCallback(t,e){try{let i=E({},t||{});return Object.entries(e).forEach(([r,n])=>{n==null?delete i[r]:i[r]=n}),i}catch(i){return this.loggingService.catch("Error in CommonDbUtilsService rtdbDefaultTransactionCallback:",i),t}}};l.\u0275fac=function(e){return new(e||l)(A(Nt),A(Fi),A(Ct),A(wi),A(j),A($i),A(F),A(Bi),A(Ut),A(Mi),A(Vi),A(x),A(ze),A(fe),A(Se),A(Ne),A(bt),A(pt),A(pe),A(Ve))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var ji=(()=>{let l=class l{allow(){return Promise.resolve({allow:!0})}canRead(t){return T(this,null,function*(){return this.allow()})}canWrite(t){return T(this,null,function*(){return this.allow()})}};l.\u0275fac=function(e){return new(e||l)},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();var ir=new Set(["unimplemented","invalid-argument"]),rr=new Set(["failed-precondition"]),nr=new Set(["docNotificationViews"]),or=new Set(["comment","reaction","documentViews","userNotificationViews","userNotification"]),sr={crdtData:"the crdt message-log api (pushMessage / onMessage / getMessages)",crdtSyncState:"the crdt message-log api (saveSnapshot / getSnapshot)"},Mo=(()=>{let l=class l{constructor(t,e,i,r,n,s,a,o,c,h,m,f,u,g,y,D,U,I,R){this.activityUtilsService=t,this.authService=e,this.commonDbUtilsService=i,this.coreActionsService=r,this.loggingService=n,this.firestoreService=s,this.databaseService=a,this.configService=o,this.docService=c,this.usersService=h,this.commentAnnotationsResolverService=m,this.reactionAnnotationsResolverService=f,this.recorderAnnotationsResolverService=u,this.notificationResolverService=g,this.serviceBook=y,this.realtimeAdapter=D,this.dbAdapter=U,this.authzAdapter=I,this.adapterSelectorService=R,this.offset=0,this.db=null,this.firestore=null,this.subscriptions=[],this.offsetListener=null,this.serverTimeOffsetUnsub=null,this.observablesCache={},this.reportedPortableRacedWrites=new Set,this.reportedPortableWriteDenials=new Set,this.reportedPortableUnservedReads=new Set,this.reportedDocChannelIdentityMismatches=new Set,this.firestoreSubscriptions={},this.rtdbSubscriptions={},this.loggingService.log("%c[WB] Creating CLASS: CommonDbService","color: blue;"),this.serviceBook.observe(Ei).subscribe(C=>{this.activityService=C??void 0}),this.docService.setCommonDbService(this),this.authService.setCommonDbService(this),this.usersService.setCommonDbService(this),this.subscriptions.push(this.databaseService.getDb().subscribe(C=>{C&&(this.db=C)})),this.serverTimeOffsetUnsub=this.realtimeAdapter.onServerTimeOffset(C=>{this.offset=C}),this.subscriptions.push(this.firestoreService.getFirestore().subscribe(C=>{C&&(this.firestore=C)}))}unsubscribeFromObservables(){try{Object.values(this.firestoreSubscriptions??{}).forEach(t=>{t?.unsubscribe()}),Object.values(this.rtdbSubscriptions??{}).forEach(t=>{t?.unsubscribe()}),Object.entries(this.observablesCache??{}).forEach(([t,e])=>{e?.subject?.complete(),e?.subject?.unsubscribe()}),this.observablesCache={},this.firestoreSubscriptions={},this.rtdbSubscriptions={}}catch(t){this.loggingService.catch("Error in unsubscribeFromObservables:",t)}}ngOnDestroy(){this.subscriptions.forEach(t=>t.unsubscribe()),this.offsetListener&&this.offsetListener(),this.serverTimeOffsetUnsub&&(this.serverTimeOffsetUnsub(),this.serverTimeOffsetUnsub=null),this.unsubscribeFromObservables()}setupOnDisconnect(t,e,i,r){return T(this,null,function*(){try{if(i&&this.isPortableChannelFeature(i)&&xt(Xe(i))){let n=this.buildPortableChannelKey(i,r);n?yield this.adapterSelectorService.resolveRealtimeAdapter().onDisconnect(n,e):this.loggingService.catch(`Velt [portable backend]: could not build a channel key for the '${i}' disconnect intent \u2014 no cleanup was registered. A path-scoped presence feature needs its instance id in properties.id.`,void 0,void 0,!0);return}if(this.db){let n=this.realtimeAdapter.rtdbRef(this.db,t);return this.realtimeAdapter.rtdbOnDisconnectUpdate(i??"commondb",n,e)}return Promise.resolve()}catch(n){return this.loggingService.catch("Error in setupOnDisconnect:",n),Promise.resolve()}})}getOffset(){return this.offset}getServerTimestamp(){return new Date().getTime()+this.getOffset()}subscribeToServices(t){ke([this.databaseService.getDb(),this.firestoreService.getFirestore()]).pipe(ge(([e,i])=>!!e),_e(1),rt(([e,i])=>{t({db:e,firestore:i})})).subscribe({error:e=>{this.loggingService.catch("Error in CommonDbService subscription: ",e)}})}performDatabaseOperation(t,e,i,r,n,s){return T(this,null,function*(){try{if(!e){this.loggingService.warn(`%c[WB] No properties found for ${t}`,"color: red;");return}if(this.isPortableUnservedWrite(t)){this.reportPortableUnservedWrite(t),n?.({ok:!1,code:"unimplemented",message:`'${t}' has no portable backend surface`});return}let a=!1,o=null;return this.isPortableBackendActive()||(o=Bt(()=>{try{if(o?.(),o=null,a)return;if(this.isPortableUnservedWrite(t)){a=!0,this.reportPortableUnservedWrite(t),n?.({ok:!1,code:"unimplemented",message:`'${t}' has no portable backend surface`});return}a=!0,this.reportedPortableRacedWrites.has(t)||(this.reportedPortableRacedWrites.add(t),this.loggingService.catch(`Velt [portable backend]: the write for '${t}' was issued before the portable transport registered and cannot be re-dispatched from this junction, so it was NOT persisted. This is a client-side ordering fault, not a backend denial.`,void 0,void 0,!0)),n?.({ok:!1,code:"failed-precondition",message:`'${t}' write raced portable activation and was not sent`})}catch(c){this.loggingService.catch(`Error in portable activation watch for ${t}: `,c)}})),this.subscribeToServices(m=>T(this,[m],function*({db:c,firestore:h}){if(a)return;a=!0,o?.(),o=null;let f;e?.skipFirestore||(f=this.commonDbUtilsService.getFirestorePath({feature:t,properties:e,documentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey()}));let u=this.commonDbUtilsService.getDocumentPath({feature:t,properties:e,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey(),useFirestore:this.shouldUseFirestore()});if(!c){this.loggingService.warn(`%c[WB] No database or firestore found for ${t}`,"color: red;");return}try{let g,y;try{u&&(g=this.realtimeAdapter.rtdbRef(c,`${u}`))}catch{this.loggingService.catch("Error in dbRef")}try{f?.includes("/organizations")&&h&&f&&(y=this.dbAdapter.firestoreDoc(h,`${f}`))}catch{this.loggingService.catch("Error in docRef")}if(!this.authService.getUser())return;yield i({dbRef:g,firestoreRef:y,data:r,firestorePath:f}),s&&s({firestoreAvailable:!!h})}catch(g){this.loggingService.catch(`Error in ${t} operation: `,g),n&&n(g)}}))}catch(a){this.loggingService.catch("Error in performDatabaseOperation:",a)}})}setData(a){return T(this,arguments,function*({feature:t,data:e,properties:i,callback:r,errorCallback:n,extraData:s}){try{if(this.loggingService.log(`%c[WB] Calling FUNCTION: setData for ${t}`,"color: green;"),this.shouldUseFirestore()&&e?.metadata&&!e?.metadata?.apiKey)return;if(this.commonDbUtilsService.setDataInLocal({feature:t,data:e,observablesCache:this.observablesCache,operation:null}),this.createActivityFromExtraData(t,s),this.isPortableChannelFeature(t)){let o=Ot(t,"set");return o?this.invokePortableDbWriteOp(o,t,e,i,r,n,s):this.publishPortableChannelState(t,e,i,r,n)}return this.performDatabaseOperation(t,i,o=>T(this,null,function*(){if(o.dbRef){let c=this.commonDbUtilsService.formatData({feature:t,data:o.data,properties:i,offset:this.getOffset(),isRealtimeDb:!0});i?.rtdbTransaction?yield this.realtimeAdapter.rtdbRunTransaction(t,o.dbRef,()=>JSON.parse(JSON.stringify(c))):yield this.realtimeAdapter.rtdbSet(t,o.dbRef,JSON.parse(JSON.stringify(c)))}try{if(o.firestoreRef&&o.data&&!i?.skipFirestore){let c=this.commonDbUtilsService.formatData({feature:t,data:o.data,properties:i,offset:this.getOffset()});typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)));let{strippedData:h,originalData:m,eventType:f}=yield this.commonDbUtilsService.handleDataStripping({feature:t,data:c,actionType:s?.actionType,commentId:s?.targetAnnotationData?.commentId??i?.targetCommentId});if(t==="comment"){let u=null,g=p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:B.SET_DATA,source:"internal",payload:{strippedData:h,originalData:m,eventType:f,commentId:s?.targetAnnotationData?.commentId}}),h&&(u=yield this.commentAnnotationsResolverService.saveCommentAnnotation({commentAnnotation:h,eventType:f,commentId:s?.targetAnnotationData?.commentId},g)),m&&(u?.isSuccess||u===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({data:m,firestorePath:o.firestorePath??"",extraData:s,metadata:i?.metadata}))}else if(t==="reaction"){let u=null,g=p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:M.SET_DATA,source:"internal",payload:{strippedData:h,originalData:m}}),h&&(u=yield this.reactionAnnotationsResolverService.saveReactionAnnotation(h,g)),m&&(u?.isSuccess||u===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({data:m,firestorePath:o.firestorePath??""}))}else if(t==="recorder"){let u=null,g=p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:V.SET_DATA,source:"internal",payload:{strippedData:h,originalData:m}}),h&&(u=yield this.recorderAnnotationsResolverService.saveRecorderAnnotation({recorderAnnotation:h,eventType:f},g)),m&&(u?.isSuccess||u===null)&&this.firestore&&(yield this.dbAdapter.firestoreRunTransaction(this.firestore,y=>T(this,null,function*(){y.set(o.firestoreRef,JSON.parse(JSON.stringify(m)))})))}else yield this.dbAdapter.firestoreSetDoc(o.firestoreRef,c)}}catch(c){this.authService.getUser()&&this.loggingService.catch(`Error in setData for ${t}`,c)}}),e,n,r)}catch(o){this.loggingService.catch(`Error in setData for ${t}`,o)}})}updateData(a){return T(this,arguments,function*({feature:t,data:e,properties:i,callback:r,errorCallback:n,extraData:s}){try{if(this.loggingService.log(`%c[WB] Calling FUNCTION: updateData for ${t}`,"color: green;"),this.shouldUseFirestore()&&e?.metadata&&!e?.metadata?.apiKey)return;if(this.commonDbUtilsService.setDataInLocal({feature:t,data:e,observablesCache:this.observablesCache,operation:null}),this.createActivityFromExtraData(t,s),this.isPortableChannelFeature(t)){let o=Ot(t,"update");return o?this.invokePortableDbWriteOp(o,t,e,i,r,n,s):this.publishPortableChannelState(t,e,i,r,n)}return this.performDatabaseOperation(t,i,o=>T(this,null,function*(){if(o.dbRef&&!i?.skipRtdb){let c=this.commonDbUtilsService.formatData({feature:t,data:o.data,properties:i,offset:this.getOffset(),isRealtimeDb:!0});i?.rtdbTransaction?yield this.realtimeAdapter.rtdbRunTransaction(t,o.dbRef,h=>{let m;return i?.rtdbTransactionCallback?m=i.rtdbTransactionCallback(h,c):m=this.commonDbUtilsService.rtdbDefaultTransactionCallback(h,c),JSON.parse(JSON.stringify(m))}):yield this.realtimeAdapter.rtdbUpdate(t,o.dbRef,JSON.parse(JSON.stringify(c)))}try{if(o.firestoreRef&&o.data&&!i?.skipFirestore){let c=this.commonDbUtilsService.formatData({feature:t,data:o.data,properties:i,offset:this.getOffset()});typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)));let{strippedData:h,originalData:m,eventType:f}=yield this.commonDbUtilsService.handleDataStripping({feature:t,data:c,actionType:s?.actionType,commentId:s?.targetAnnotationData?.commentId});if(t==="comment"){let u=null,g=p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:B.UPDATE_DATA,source:"internal",payload:{strippedData:h,originalData:m,eventType:f,commentId:s?.targetAnnotationData?.commentId}}),h&&(u=yield this.commentAnnotationsResolverService.saveCommentAnnotation({commentAnnotation:h,eventType:f,commentId:s?.targetAnnotationData?.commentId},g)),m&&(u?.isSuccess||u===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({data:m,firestorePath:o.firestorePath??"",extraData:s,metadata:i?.metadata}))}else if(t==="reaction"){let u=null,g=p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:M.UPDATE_DATA,source:"internal",payload:{strippedData:h,originalData:m}}),h&&(u=yield this.reactionAnnotationsResolverService.saveReactionAnnotation(h,g)),m&&(u?.isSuccess||u===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({data:m,firestorePath:o.firestorePath??""}))}else if(t==="recorder"){let u=null,g=p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_SAVE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:g,methodName:V.UPDATE_DATA,source:"internal",payload:{strippedData:h,originalData:m}}),h&&(u=yield this.recorderAnnotationsResolverService.saveRecorderAnnotation({recorderAnnotation:h,eventType:f},g)),m&&(u?.isSuccess||u===null)&&this.firestore&&(yield this.dbAdapter.firestoreRunTransaction(this.firestore,y=>T(this,null,function*(){y.set(o.firestoreRef,JSON.parse(JSON.stringify(m)))})))}else yield this.dbAdapter.firestoreSetDoc(o.firestoreRef,c,{merge:!0})}}catch(c){this.authService.getUser()&&this.loggingService.catch(`Error in updateDoc for ${t}`,c)}}),e,n,r)}catch(o){this.loggingService.catch(`Error in updateData for ${t}`,o)}})}createActivityFromExtraData(t,e){try{if(!e?.actionType||!this.activityService)return;let i=this.activityUtilsService.buildActivityDataFromExtraData({feature:t,extraData:e});i&&this.activityService.createActivity(i)}catch(i){this.loggingService.catch("Error in CommonDbService createActivityFromExtraData:",i)}}deleteData(s){return T(this,arguments,function*({feature:t,properties:e,callback:i,errorCallback:r,extraData:n}){try{if(this.loggingService.log(`%c[WB] Calling FUNCTION: deleteData for ${t}`,"color: green;"),this.commonDbUtilsService.setDataInLocal({feature:t,observablesCache:this.observablesCache,eventType:"DELETE",id:e?.id,operation:{type:"removed",ids:[e?.id]}}),this.createActivityFromExtraData(t,n),this.isPortableChannelFeature(t)){let a=Ot(t,"delete");if(a)return this.invokePortableDbWriteOp(a,t,void 0,e,i,r);if(pi(t)){this.loggingService.warn(`[WB] No portable delete op mapped for ${t}`),r?.({ok:!1,code:"unimplemented"});return}return this.publishPortableChannelState(t,{userId:e?.userId,userSnippylyId:e?.userId,onlineStatus:d.PRESENCE_STATUS_OFFLINE,timestamp:this.getServerTimestamp()},e,i,r)}return this.performDatabaseOperation(t,e,a=>T(this,null,function*(){a.dbRef&&(yield this.realtimeAdapter.rtdbRemove(t,a.dbRef));try{if(a.firestoreRef&&!e?.skipFirestore)if(t==="comment"){let o=null,c=p();this.coreActionsService.triggerAction(S.COMMENT_RESOLVER,{event:v.Events.Resolver.COMMENT_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:c,methodName:B.DELETE_DATA,source:"internal",payload:{commentAnnotationId:e?.id??"",metadata:e?.metadata}}),o=yield this.commentAnnotationsResolverService.deleteCommentAnnotation(e?.id??"",e?.metadata,c),(o?.isSuccess||o===null)&&(yield this.commonDbUtilsService.handleCommentEncryption({firestorePath:a.firestorePath??"",eventType:"DELETE",metadata:e?.metadata}))}else if(t==="reaction"){let o=null,c=p();this.coreActionsService.triggerAction(S.REACTION_RESOLVER,{event:v.Events.Resolver.REACTION_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:c,methodName:M.DELETE_DATA,source:"internal",payload:{reactionAnnotationId:e?.id??"",metadata:e?.metadata}}),o=yield this.reactionAnnotationsResolverService.deleteReactionAnnotation(e?.id??"",e?.metadata,c),(o?.isSuccess||o===null)&&(yield this.commonDbUtilsService.handleReactionEncryption({firestorePath:a.firestorePath??"",eventType:"DELETE"}))}else if(t==="recorder"){let o=null,c=p();this.coreActionsService.triggerAction(S.RECORDER_RESOLVER,{event:v.Events.Resolver.RECORDER_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:c,methodName:V.DELETE_DATA,source:"internal",payload:{recorderAnnotationId:e?.id??"",metadata:e?.metadata}}),o=yield this.recorderAnnotationsResolverService.deleteRecorderAnnotation(e?.id??"",e?.metadata,c),(o?.isSuccess||o===null)&&(yield this.dbAdapter.firestoreDeleteDoc(a.firestoreRef))}else if(t==="userNotification"){let o=null,c=p();this.coreActionsService.triggerAction(S.NOTIFICATION_RESOLVER,{event:v.Events.Resolver.NOTIFICATION_DELETE_REQUEST_FORMED,timestamp:new Date().getTime(),uniqueId:c,methodName:X.DELETE_DATA,source:"internal",payload:{notificationId:e?.id??"",organizationId:e?.organizationId??""}}),o=yield this.notificationResolverService.deleteNotification(String(e?.id??""),this.docService.getDocumentPaths()?.clientOrganizationId??"",c),(o?.isSuccess||o===null)&&(yield this.dbAdapter.firestoreDeleteDoc(a.firestoreRef))}else yield this.dbAdapter.firestoreDeleteDoc(a.firestoreRef)}catch(o){this.authService.getUser()&&this.loggingService.catch(`Error in deleteData for ${t}`,o)}}),void 0,r,i)}catch(a){this.loggingService.catch(`Error in deleteData for ${t}`,a)}})}shouldUseFirestore(){try{return this.authService.getAdvancedQueriesEnabled()}catch(t){return this.loggingService.catch("Error in shouldUseFirestore:",t),!1}}generateDocumentId(){try{let t=this.firestoreService.generateFirestoreDocumentId();return t||(t=p()),t||"noDocumentId"}catch(t){return this.loggingService.catch("Error in generateFirestoreDocumentId:",t),p()||"noDocumentId"}}queryData(i){return T(this,arguments,function*({feature:t,properties:e}){try{let r=this.shouldUseFirestore();return!t||!e?(this.loggingService.warn("[WB] Missing required parameters in queryData"),[]):r?yield this.handleFirestoreQuery(t,e):yield this.handleRtdbQuery(t,e)}catch(r){return this.loggingService.catch(`Error in queryData for ${t}`,r),[]}})}handleFirestoreQuery(t,e){return T(this,null,function*(){try{if(!this.firestore)return this.loggingService.warn("[WB] Firestore not initialized"),[];let i=e?.useCollectionGroup?this.commonDbUtilsService.getFirestoreCollectionGroupPath(t):this.commonDbUtilsService.getFirestorePath({feature:t,properties:e,documentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey()});if(!i)return this.loggingService.warn(`[WB] No firestore path found for ${t}`),[];try{let r=this.dbAdapter.firestoreCollection(this.firestore,i);e?.useCollectionGroup&&(r=this.dbAdapter.firestoreCollectionGroup(this.firestore,i));let n=e?.firestoreQuery??[],s=this.dbAdapter.firestoreQuery(r,...n);if(!this.authService.getUser()&&!e?.skipUserCheck)return[];if(e?.getCount)try{let a=yield this.dbAdapter.firestoreGetCountFromServer(s).catch(o=>(this.authService.getUser()&&this.loggingService.catch(`Error in getCountFromServer for ${t}`,o),null));return a?a.data().count:0}catch(a){return this.authService.getUser()&&this.loggingService.catch(`Error in getCountFromServer for ${t}`,a),0}else try{let a=yield this.dbAdapter.firestoreGetDocs(s).catch(c=>(this.authService.getUser()&&this.loggingService.catch(`Error in getDocs for ${t}`,c),null));if(!a)return[];let o=a.docs.map(c=>c.data());try{return yield this.commonDbUtilsService.modifyData({feature:t,data:o})}catch(c){return this.loggingService.catch(`Error in modifyData for ${t}`,c),o}}catch(a){return this.authService.getUser()&&this.loggingService.catch(`Error in getDocs for ${t}`,a),[]}}catch(r){return this.loggingService.catch(`Error in Firestore query for ${t}:`,r),[]}}catch(i){return this.loggingService.catch(`Error in Firestore query for ${t}:`,i),[]}})}handleRtdbQuery(t,e){return T(this,null,function*(){if(!this.db)return this.loggingService.warn("[WB] Realtime Database not initialized"),[];let i=this.commonDbUtilsService.getDocumentPath({feature:t,properties:e,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey()});if(!i)return this.loggingService.warn(`[WB] No database path found for ${t}`),[];try{let r=this.realtimeAdapter.rtdbRef(this.db,i),n=e?.rtdbQuery??[],s=this.realtimeAdapter.rtdbQueryRef(r,...n);if(!this.authService.getUser()&&!e?.skipUserCheck)return[];let a=yield this.realtimeAdapter.rtdbGet(s).catch(c=>(this.authService.getUser()&&this.loggingService.catch(`Error in get for ${t}`,c),null));if(!a)return[];let o=a.val();return o?e?.skipObjectValues?o:Object.values(o??{}):[]}catch(r){return this.loggingService.catch(`Error in RTDB query for ${t}:`,r),[]}})}buildAuthzRequest(t,e){return{feature:t,scope:"doc",resourceId:e?.id!=null?String(e.id):void 0,apiKey:e?.apiKey??this.configService.getApiKey()??void 0,organizationId:e?.organizationId!=null?String(e.organizationId):void 0,documentId:e?.documentId!=null?String(e.documentId):void 0}}getData(i){return T(this,arguments,function*({feature:t,properties:e}){try{let r=this.shouldUseFirestore();if(e?.skipFirestore&&(r=!1),!t||!e)return this.loggingService.warn("[WB] Missing required parameters in getData"),{};try{if(Oi(t)&&this.isPortableBackendActive())return yield this.invokePortableDbRead(t,e)}catch(n){return this.loggingService.catch(`Error in getData portable branch for ${t}: `,n),{}}if(r&&this.firestore){let n=this.commonDbUtilsService.getFirestorePath({feature:t,properties:e,documentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey()});if(!n)return this.loggingService.warn(`[WB] No firestore path found for ${t}`),{};try{if(!this.authService.getUser())return this.loggingService.catch("User not set. [source: getData]",void 0,void 0,!0),{};if(!(yield this.authzAdapter.canRead(this.buildAuthzRequest(t,e))).allow)return{};let a=yield this.dbAdapter.read({feature:t,scope:"doc",location:n,store:"firestore",field:e?.field,suppressError:e?.suppressError}).catch(c=>(this.authService.getUser()&&!e?.suppressError&&this.loggingService.catch(`Error in getDoc for ${t}`,c),this.commonDbUtilsService.getErrorForGetRequests({feature:t,error:c})));if(a){if(a?.errorCode)return a}else return this.loggingService.warn(`[WB] No document found at ${n}`),{};let o=a.data;return e?.field?o?.[e.field]??{}:o??{}}catch(s){return this.loggingService.catch(`Error fetching Firestore data for ${t}:`,s),{}}}if(this.db){let n=this.commonDbUtilsService.getDocumentPath({feature:t,properties:e,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey()});if(!n)return this.loggingService.warn(`[WB] No database path found for ${t}`),{};try{if(!this.authService.getUser())return{};if(!(yield this.authzAdapter.canRead(this.buildAuthzRequest(t,e))).allow)return{};let a=yield this.dbAdapter.read({feature:t,scope:"doc",location:n,store:"rtdb",field:e?.field,suppressError:e?.suppressError}).catch(c=>(this.authService.getUser()&&this.loggingService.catch(`Error in get for ${t}`,c),this.commonDbUtilsService.getErrorForGetRequests({feature:t,error:c})));if(a){if(a?.errorCode)return a}else return this.loggingService.warn(`[WB] No data found at ${n}`),{};let o=a.data;return e?.field?o?.[e.field]??{}:o??{}}catch(s){return this.loggingService.catch(`Error fetching RTDB data for ${t}:`,s),{}}}return this.loggingService.warn("[WB] No database connection available"),{}}catch(r){return this.loggingService.catch("Unexpected error in getData:",r),{}}})}dbListener({feature:t,properties:e}){try{if(Dt(t)&&this.isPortableBackendActive())return this.getPortableChannelObservable(t,e)}catch(n){this.loggingService.catch(`Error in dbListener portable branch for ${t}: `,n)}let i=this.shouldUseFirestore();e?.skipFirestore&&(i=!1);let r=`${t}-${JSON.stringify(e)}`;return Yt(this.portableUnservedRead$(t),ke([this.databaseService.getDb(),this.firestoreService.getFirestore(),this.authService.getUser$().pipe(ge(n=>!!n))]).pipe(ge(([n,s])=>n?i&&!s?(this.loggingService.warn(`[WB] Firestore requested but not available for ${t}`),!1):!0:(this.loggingService.warn(`[WB] No database found for ${t}`),!1)),ie(([n,s])=>{try{if(i&&s){if(!!!this.observablesCache[r]){this.observablesCache[r]={subject:new b({}),count:0};let c=this.handleFirestoreListener(t,e,s).subscribe(h=>{this.observablesCache[r]?.subject?.next(h)},h=>this.observablesCache[r]?.subject?.error(h));this.firestoreSubscriptions[r]=c}return new Ae(o=>{let c=this.observablesCache[r]?.subject?.subscribe(h=>o.next(h),h=>o.error(h),()=>o.complete());return this.observablesCache[r].count+=1,()=>{c?.unsubscribe(),this.observablesCache[r]&&(this.observablesCache[r].count-=1,this.observablesCache[r].count<=0&&(this.firestoreSubscriptions[r]?.unsubscribe(),delete this.firestoreSubscriptions[r],this.observablesCache[r]?.subject?.complete(),delete this.observablesCache[r]))}})}else if(n){if(!!!this.observablesCache[r]){this.observablesCache[r]={subject:new b({}),count:0};let c=this.handleRealtimeDbListener(t,e,n).subscribe(h=>{this.observablesCache[r]?.subject?.next(h)},h=>this.observablesCache[r]?.subject?.error(h));this.rtdbSubscriptions[r]=c}return new Ae(o=>{let c=this.observablesCache[r]?.subject?.subscribe(h=>o.next(h),h=>o.error(h),()=>o.complete());return this.observablesCache[r].count+=1,()=>{c?.unsubscribe(),this.observablesCache[r]&&(this.observablesCache[r].count-=1,this.observablesCache[r].count<=0&&(this.rtdbSubscriptions[r]?.unsubscribe(),delete this.rtdbSubscriptions?.[r],this.observablesCache[r]?.subject?.complete(),delete this.observablesCache?.[r]))}})}return P({})}catch(a){return this.loggingService.catch(`Error setting up listener for ${t}:`,a),P({})}}),ei(()=>{this.loggingService.log(`[WB] Cleaning up listener for ${t} and key ${r}`)})))}handleFirestoreListener(t,e,i){let r=e?.useCollectionGroup?this.commonDbUtilsService.getFirestoreCollectionGroupPath(t):this.commonDbUtilsService.getFirestorePath({feature:t,properties:e,documentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey()}),n=`${t}-${JSON.stringify(e)}`;return r?new Ae(s=>{let a=e.isCollection?this.setupCollectionListener(i,r,t,s,e):this.setupDocumentListener(i,r,t,s,e);return()=>{s.complete(),s.unsubscribe(),a(),this.observablesCache[n]?.subject?.complete(),this.observablesCache[n]?.subject?.unsubscribe(),delete this.observablesCache[n]}}).pipe(ie(s=>this.commonDbUtilsService.mergeUsersWithData$({feature:t,data:s})),ie(s=>["allComments","allUserNotifications"].includes(t)?this.commonDbUtilsService.mergeCommentAnnotationsWithData$({data:s,feature:t}):P(s)),ie(s=>["allReactions"].includes(t)?this.commonDbUtilsService.mergeReactionAnnotationsWithData$({data:s,feature:t}):P(s)),ie(s=>["allRecorders"].includes(t)?this.commonDbUtilsService.mergeRecorderAnnotationsWithData$({data:s,feature:t}):P(s)),J(Q)):(this.loggingService.warn(`[WB] No firestore path found for ${t} and key ${n}`),P({}))}setupCollectionListener(t,e,i,r,n){let s=`${i}-${JSON.stringify(n)}`,a=this.dbAdapter.firestoreCollection(t,e);if(n?.useCollectionGroup&&(a=this.dbAdapter.firestoreCollectionGroup(t,e)),n?.useQuery&&n?.firestoreQuery){let h=n?.firestoreQuery??[];a=this.dbAdapter.firestoreQuery(a,...h)}let o=!0,c=[];return i==="allComments"&&this.loggingService.logContext("[CONTEXT] setupCollectionListener called with path:",e,"feature:",i,"properties:",JSON.stringify(n??"nil")),this.dbAdapter.firestoreOnSnapshot(a,h=>{try{let m=JSON.parse(JSON.stringify(this.observablesCache[s]?.subject?.getValue()?.data??{})),f=null,u=!1;h?.docChanges()?.length?h.docChanges().forEach(g=>{["allComments","allReactions","allRecorders"].includes(i)&&!o&&g.type!=="removed"&&c.push(g.doc.id),this.commonDbUtilsService.isDataAlreadyProcessedInLocalCache({feature:i,change:g,cache:this.observablesCache[s]?.subject?.getValue()?.data??{}})||(u=!0,Object.assign(m,this.handleCollectionChange(g,m)),g.type==="removed"&&(f||(f={type:g.type,ids:[]}),f.ids.push(g.doc.id)))}):u=!0,u&&(["allComments","allReactions","allRecorders"].includes(i)&&c?.length&&(this.commonDbUtilsService.resolveAnnotations({data:c,feature:i}),c=[]),this.commonDbUtilsService.modifyAndSetData({feature:i,data:m,subscriber:r,operation:f})),o=!1}catch(m){this.loggingService.logContext(`[ERROR] Firestore listener error for feature ${i}:`,m),this.loggingService.logContext(`[ERROR] Firestore listener error for properties ${JSON.stringify(n??"nil")}:`),this.loggingService.logContext(`[ERROR] Firestore listener error for user ${JSON.stringify(this.authService.getUser()??"nil")}:`),this.handleListenerError(m,i,r)}},h=>{this.loggingService.logContext(`[ERROR] Firestore listener error for feature ${i}:`,h),this.loggingService.logContext(`[ERROR] Firestore listener error for properties ${JSON.stringify(n??"nil")}:`),this.loggingService.logContext(`[ERROR] Firestore listener error for user ${JSON.stringify(this.authService.getUser()??"nil")}:`),this.handleListenerError(h,i,r)})}handleCollectionChange(t,e){switch(t.type){case"added":case"modified":e[t.doc.id]=t.doc.data();break;case"removed":delete e?.[t.doc.id];break}return e}setupDocumentListener(t,e,i,r,n){let s=this.dbAdapter.firestoreDoc(t,e);return this.dbAdapter.firestoreOnSnapshot(s,a=>{try{let o=a.data()||{};n?.field&&(o=o?.[n?.field]??{}),this.commonDbUtilsService.modifyAndSetData({feature:i,data:o,subscriber:r,operation:null})}catch(o){this.handleListenerError(o,i,r)}},a=>this.handleListenerError(a,i,r))}handleListenerError(t,e,i){this.loggingService.catch(`Firestore listener error for ${e}:`,t)}portableUnservedRead$(t){return Kt(()=>{try{return this.isPortableBackendActive()?Dt(t)?tt:this.databaseService.getDbValue()||this.firestoreService.getFirestoreValue()?tt:(this.reportPortableUnservedRead(t),P({data:{},operation:null})):new Ae(e=>Bt(()=>{e.next(null),e.complete()})).pipe(ie(()=>this.portableUnservedRead$(t)))}catch(e){return this.loggingService.catch(`Error in portable unserved-read fallback for ${t}: `,e),tt}})}isPortableUnservedWrite(t){try{return!this.isPortableBackendActive()||this.isPortableChannelFeature(t)?!1:!this.databaseService.getDbValue()&&!this.firestoreService.getFirestoreValue()}catch(e){return this.loggingService.catch("Error in isPortableUnservedWrite: ",e),!1}}reportPortableUnservedWrite(t){try{let e=`unserved-write:${t}`;if(this.reportedPortableWriteDenials.has(e))return;this.reportedPortableWriteDenials.add(e);let i=sr[t];this.loggingService.catch(i?`Velt [portable backend]: '${t}' writes have no portable surface and were NOT sent. This api is SUPERSEDED on the self-hosted backend \u2014 use ${i} instead. This is an integration fix, not a deployment limitation.`:`Velt [portable backend]: '${t}' writes have no portable surface on this deployment and were NOT sent. This feature is not part of the self-hosted backend's operation catalogue \u2014 the write was dropped rather than silently queued forever. There is no alternative api: this is a deployment capability gap, NOT a misconfigured integration.`,void 0,void 0,!0)}catch{}}reportPortableUnservedRead(t){try{if(this.reportedPortableUnservedReads.has(t))return;this.reportedPortableUnservedReads.add(t),this.loggingService.log(`%c[WB] Portable backend serves no read channel for '${t}' \u2014 emitting an empty result so consumers render an empty state instead of loading forever.`,"color: orange;")}catch(e){this.loggingService.catch("Error in reportPortableUnservedRead: ",e)}}isPortableBackendActive(){try{return this.adapterSelectorService?.isPortableBackendActive()===!0}catch(t){return this.loggingService.catch("Error in isPortableBackendActive: ",t),!1}}isPortableChannelFeature(t){return Ci(t)&&this.isPortableBackendActive()}usesPortableChannelFeed(t){return Dt(t)&&this.isPortableBackendActive()}whenPortableRealtimeReady(){return T(this,null,function*(){try{if(!this.isPortableBackendActive())return;yield this.adapterSelectorService?.resolveRealtimeAdapter()?.whenReady?.()}catch(t){this.loggingService.catch("Error in CommonDbService whenPortableRealtimeReady:",t)}})}reportPortableUnsupportedWrite(t,e){try{this.loggingService.catch(`Portable write '${e}' (${t}) is not supported on the portable backend \u2014 not sent.`,void 0,void 0,!0);let i=`unsupported:${t}`;if(this.reportedPortableWriteDenials.has(i))return;this.reportedPortableWriteDenials.add(i),console.error(`Velt [portable backend]: '${t}' writes are NOT SUPPORTED on the portable backend and were not sent. Document-level notification read markers have no portable surface (the ratified surface is the user-scoped notification feed only), so doc-level "seen" state will read stale. Per-user read state is unaffected and works normally.`)}catch{}}clearReportedDenialsForOp(t){let e=`${t}:`;for(let i of Array.from(this.reportedPortableWriteDenials))i.startsWith(e)&&this.reportedPortableWriteDenials.delete(i)}currentUserIdHash(){try{let t=this.authService?.getUser()?.userId;return t?Ke(t):void 0}catch(t){this.loggingService.catch("Error in CommonDbService currentUserIdHash: ",t);return}}buildPortableChannelKey(t,e,i){let r=this.docService.getDocumentPaths(),n=i??e?.userIdHash??e?.userId??e?.id;return Ui(t,{apiKey:e?.apiKey??this.configService.getApiKey(),organizationId:e?.organizationId??r?.organizationId,documentId:e?.documentId??r?.documentId,userIdHash:n!=null?String(n):void 0,instanceId:Ht(t)&&e?.id!=null?String(e.id):void 0})}publishPortableChannelState(t,e,i,r,n){return T(this,null,function*(){try{if(!xt(Xe(t))){this.loggingService.warn(`[WB] No portable write op mapped for ${t} (verb mismatch or unmapped)`),n?.({ok:!1,code:"unimplemented"});return}let s=this.buildPortableChannelKey(t,i);if(!s){this.loggingService.warn(`[WB] No portable channel key resolvable for ${t}`),n?.({ok:!1,code:"failed-precondition"});return}let a=yield this.adapterSelectorService.resolveRealtimeAdapter().presence(s,e);a.ok?r?.():n?.(a)}catch(s){this.loggingService.catch(`Error in publishPortableChannelState for ${t}: `,s),n?.(s)}})}invokePortableDbWriteOp(t,e,i,r,n,s,a){return T(this,null,function*(){try{if(nr.has(e)){this.reportPortableUnsupportedWrite(e,t.op),s?.({ok:!1,code:"unimplemented",message:`'${e}' is not supported on the portable backend`});return}t.formatData&&i!==void 0&&(i=this.commonDbUtilsService.formatData({feature:e,data:i,properties:r,offset:this.getOffset()}));let o=i;if(t.payloadFields?.length){if(o={},i!==void 0)for(let y of t.payloadFields)i[y]!==void 0&&(o[y]=i[y])}else(t.op==="markNotificationRead"||t.op==="deleteNotification"||t.op==="deleteComment")&&(o=void 0);let c;if(t.notificationData&&a)try{let y=i!==void 0?JSON.parse(JSON.stringify(i)):i;c=yield this.commonDbUtilsService.prepareCommentNotificationData({data:y,extraData:a})}catch(y){this.loggingService.catch(`Error preparing notificationData for portable ${t.op} (${e}) \u2014 op ships without it: `,y)}let h=r?.userIdHash??r?.userId??this.currentUserIdHash(),m=or.has(e)?this.buildPortableChannelKey(e,r,h?String(h):void 0):null,f=E(E(E({scope:t.scope,resourceId:r?.id!==void 0&&r?.id!==null?String(r.id):void 0},o!==void 0?{data:o}:{}),c!==void 0?{notificationData:c}:{}),m?{channel:m}:{}),g=yield this.adapterSelectorService.resolveDbAdapter()[t.op](f);g.ok?(this.clearReportedDenialsForOp(t.op),n?.({firestoreAvailable:!0})):(this.reportPortableWriteDenial(t.op,e,g),s?.(g))}catch(o){this.loggingService.catch(`Error in invokePortableDbWriteOp (${t.op}) for ${e}: `,o),s?.(o)}})}reportPortableWriteDenial(t,e,i){try{let r=i?.code??"unknown",n=At(i),s=`Portable write op '${t}' (${e}) was denied by the backend: ${r}${n}`;this.loggingService.log(s),this.loggingService.catch(s,i,void 0,!0);let a=rr.has(r);if(!a&&!ir.has(r))return;let o=`${t}:${r}`;if(this.reportedPortableWriteDenials.has(o))return;this.reportedPortableWriteDenials.add(o),console.error(a?`Velt [portable backend]: the operation '${t}' was NOT SENT${i?.message?` (${i.message})`:""}. The write for '${e}' was not persisted and is NOT retried. This is a client-side precondition \u2014 usually the realtime connection was not open (handshake or reconnect window), or the channel could not be resolved.`:`Velt [portable backend]: the operation '${t}' was rejected by the configured backend with '${r}'${n}${i?.message?` (${i.message})`:""}. Writes for '${e}' are NOT being persisted. This usually means the gateway does not expose this operation \u2014 check that the deployed backend implements the full operation catalogue for the features you have enabled.`)}catch{}}invokePortableDbRead(t,e){return T(this,null,function*(){let i=Wt[t];if(!i)return{};let r=e?.id!==void 0&&e?.id!==null?String(e.id):"",n={feature:t,scope:i.scope,location:r,field:e?.field,suppressError:e?.suppressError,resourceId:r||void 0,apiKey:e?.apiKey??this.configService.getApiKey()??void 0,organizationId:e?.organizationId!==void 0&&e?.organizationId!==null?String(e.organizationId):void 0,documentId:e?.documentId!==void 0&&e?.documentId!==null?String(e.documentId):void 0,metadata:e?.userId?{userIdHash:String(e.userId)}:void 0},s=yield this.adapterSelectorService.resolveDbAdapter().read(n);if(s?.errorCode)return{};let a=s?.data;return a==null?{}:e?.field?a?.[e.field]??{}:a})}getPortableChannelObservable(t,e){let i=`portable-${t}-${JSON.stringify(e)}`;if(!this.observablesCache[i]){this.observablesCache[i]={subject:new b({}),count:0};let r=this.applyDbListenerPostProcessing(t,this.handlePortableChannelListener(t,e));this.firestoreSubscriptions[i]=r.subscribe(n=>this.observablesCache[i]?.subject?.next(n),n=>{this.loggingService.catch(`Portable channel feed error for ${t}: `,n),this.observablesCache[i]?.subject?.next({data:{},operation:null})})}return new Ae(r=>{let n=this.observablesCache[i]?.subject?.subscribe(s=>r.next(s),s=>r.error(s),()=>r.complete());return this.observablesCache[i].count+=1,()=>{n?.unsubscribe(),this.observablesCache[i]&&(this.observablesCache[i].count-=1,this.observablesCache[i].count<=0&&(this.firestoreSubscriptions[i]?.unsubscribe(),delete this.firestoreSubscriptions[i],this.observablesCache[i]?.subject?.complete(),delete this.observablesCache[i]))}})}handlePortableChannelListener(t,e){return new Ae(i=>{try{let r=je[t]?.materialize??"map",n=r==="map"&&e?.documentIds?.length?e.documentIds:void 0,s=(n?n.map(D=>this.buildPortableChannelKey(t,w(E({},e),{documentId:D}))):[this.buildPortableChannelKey(t,e)]).filter(D=>!!D),a=new Set,o=s.filter(D=>{let U=JSON.stringify(D);return a.has(U)?!1:(a.add(U),!0)});if(!o.length)return this.loggingService.warn(`[WB] No portable channel key resolvable for ${t}`),i.next({}),()=>{};let c=this.adapterSelectorService.resolveRealtimeAdapter(),h=It(Xe(t))?.mode??"ephemeral",m=o.map(()=>({})),f=o.map(()=>!1),u={},g=()=>{i.next(Object.assign({},...m))},y=o.map((D,U)=>c.subscribe(D,h,I=>{try{if(f[U])return;if(r==="doc"){u=I.type==="removed"?{}:I.data??{},i.next(E({},u));return}I.type==="removed"?delete m[U][I.id]:m[U][I.id]=this.stampDocChannelIdentity(this.commonDbUtilsService.addMetadata(I.data,this.channelScopedProperties(e,D)),D),g()}catch(R){this.loggingService.catch(`Error in portable channel delta for ${t}: `,R)}},{onSnapshotComplete:()=>{try{if(r==="doc"){i.next(E({},u));return}g()}catch(I){this.loggingService.catch(`Error in portable snapshot-complete emit for ${t}: `,I)}},onError:I=>{f[U]=!0,u={};for(let R of Object.keys(m[U]))delete m[U][R];this.loggingService.catch(`Portable channel denied for ${t}: `,{ok:!1,code:I}),g()}}));return()=>y.forEach(D=>D.unsubscribe())}catch(r){return this.loggingService.catch(`Error in handlePortableChannelListener for ${t}: `,r),i.next({}),()=>{}}})}channelScopedProperties(t,e){try{if(e?.scope==="doc"&&e?.documentId!==void 0&&e?.documentId!==null&&(t?.documentId===void 0||t?.documentId===null))return w(E({},t),{documentId:e.documentId})}catch(i){this.loggingService.catch("Error in CommonDbService channelScopedProperties: ",i)}return t}stampDocChannelIdentity(t,e){try{if(e?.scope!=="doc"||e?.documentId===void 0||e?.documentId===null||!t||typeof t!="object"||Array.isArray(t))return t;let i=t.metadata;return!i||typeof i!="object"||Array.isArray(i)?t:i.documentId!==void 0&&i.documentId!==null&&i.documentId!==""?(this.reportDocChannelIdentityMismatch(i,e),t):w(E({},t),{metadata:E(w(E({},i),{documentId:e.documentId}),i.organizationId===void 0&&e.organizationId!==void 0?{organizationId:e.organizationId}:{})})}catch(i){return this.loggingService.catch("Error in CommonDbService stampDocChannelIdentity: ",i),t}}reportDocChannelIdentityMismatch(t,e){try{let i=String(t?.documentId)!==String(e?.documentId),r=t?.organizationId!==void 0&&e?.organizationId!==void 0&&String(t.organizationId)!==String(e.organizationId);if(!i&&!r)return;this.loggingService.log(`[WB] Portable doc-channel identity mismatch: row body claims document '${t?.documentId}'${r?` / organization '${t?.organizationId}'`:""} but arrived on the channel for document '${e?.documentId}'${r?` / organization '${e?.organizationId}'`:""}.`);let n=`${e?.documentId}>${t?.documentId}:${e?.organizationId}>${t?.organizationId}`;if(this.reportedDocChannelIdentityMismatches.has(n))return;this.reportedDocChannelIdentityMismatches.add(n),console.error(`Velt [portable backend]: a row delivered on the channel for document '${e?.documentId}' carries metadata naming document '${t?.documentId}'${r?` and organization '${t?.organizationId}' (channel organization is '${e?.organizationId}')`:""}. The row body is used as-is, so this row is being filed under the document/organization it names, NOT the channel it arrived on. If that is not intended, the gateway is routing rows to the wrong channel.`)}catch{}}handleRealtimeDbListener(t,e,i){let r=this.commonDbUtilsService.getDocumentPath({feature:t,properties:e,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey()});if(!r)return this.loggingService.warn(`[WB] No database path found for ${t}`),P({});let n=this.realtimeAdapter.rtdbRef(i,r);if(e?.useQuery&&e?.rtdbQuery){let s=e?.rtdbQuery??[];n=this.realtimeAdapter.rtdbQueryRef(n,...s)}return this.objectValFromChildEvents(n,t).pipe(it(s=>(this.loggingService.catch(`RTDB listener error for ${t}:`,s),P({}))),G(s=>(s===null&&(s={}),s&&typeof s=="object"?Object.entries(s??{}).reduce((o,[c,h])=>(o[c]=this.commonDbUtilsService.addMetadata(h,e),o),{}):this.commonDbUtilsService.addMetadata(s,e))),s=>this.applyDbListenerPostProcessing(t,s))}applyDbListenerPostProcessing(t,e){return e.pipe(ie(i=>this.commonDbUtilsService.modifyData({feature:t,data:i})),ie(i=>this.usersService.getUserById$().pipe(G(()=>({data:this.commonDbUtilsService.mergeUsersWithData({feature:t,data:i}),operation:null})))))}pushData(r){return T(this,arguments,function*({feature:t,properties:e,data:i}){try{return this.loggingService.log(`%c[WB] Calling FUNCTION: pushData for ${t}`,"color: green;"),this.performDatabaseOperation(t,e,n=>T(this,null,function*(){if(n.dbRef){let s=this.realtimeAdapter.rtdbPush(t,n.dbRef);yield this.realtimeAdapter.rtdbSet(t,s,JSON.parse(JSON.stringify(n.data)))}}),i)}catch(n){this.loggingService.catch(`Error in pushData for ${t}`,n)}})}streamChildAdded({feature:t,properties:e,afterTs:i}){try{return this.loggingService.log(`%c[WB] Calling FUNCTION: streamChildAdded for ${t}`,"color: green;"),new Ae(r=>{let n=null,s=!1,a=({db:o})=>{if(!o||s||!this.authService.getUser())return;let c=this.commonDbUtilsService.getDocumentPath({feature:t,properties:e,defaultDocumentPaths:this.docService.getDocumentPaths(),apiKey:e.apiKey??this.configService.getApiKey(),useFirestore:!1});if(!c)return;let m=this.realtimeAdapter.rtdbRef(o,c),f=!1,u=D=>{try{let U=D.val();if(f){if(i!=null&&U?.timestamp!=null&&U.timestamp<=i)return;r.next(U)}}catch(U){this.loggingService.catch(`streamChildAdded onChildAdded callback error for ${t}:`,U)}},g=D=>{try{this.loggingService.catch(`streamChildAdded error for ${t}:`,D),r.error(D)}catch(U){this.loggingService.catch(`streamChildAdded onError handler error for ${t}:`,U)}};this.realtimeAdapter.rtdbOnChildAdded(t,m,u,g);let y=this.realtimeAdapter.rtdbOnValue(t,m,()=>{f=!0},g,{onlyOnce:!0});n=()=>{try{y&&typeof y=="function"&&y(),this.realtimeAdapter.rtdbOff(m,"child_added",u)}catch(D){this.loggingService.catch(`streamChildAdded cleanup error for ${t}:`,D)}}};return this.subscribeToServices(a),()=>{s=!0,n&&n()}})}catch(r){return this.loggingService.catch(`Error in streamChildAdded for ${t}`,r),P(null)}}objectValFromChildEvents(t,e){return new Ae(i=>{let r={},n=!1,s=null,a=g=>{try{this.loggingService.catch(`Realtime DB listener error for ${e}:`,g),i.error(g)}catch{}},o=g=>{try{if(!le(g,s)){let y=JSON.parse(JSON.stringify(g));s=y,i.next(y)}}catch{}},c=g=>{try{g.key&&(r[g.key]=g.val(),n&&o(E({},r)))}catch{}},h=g=>{try{g.key&&(r[g.key]=g.val(),n&&o(E({},r)))}catch{}},m=g=>{try{g.key&&(delete r[g.key],n&&o(E({},r)))}catch{}},f=g=>{try{if(!n){let y=r&&typeof r=="object"?JSON.parse(JSON.stringify(r)):{};s=y,i.next(y),n=!0}}catch{}};this.realtimeAdapter.rtdbOnChildAdded(e,t,c,a),this.realtimeAdapter.rtdbOnChildChanged(e,t,h,a),this.realtimeAdapter.rtdbOnChildRemoved(e,t,m,a);let u=this.realtimeAdapter.rtdbOnValue(e,t,f,a,{onlyOnce:!0});return()=>{try{u&&typeof u=="function"&&u(),this.realtimeAdapter.rtdbOff(t,"child_added",c),this.realtimeAdapter.rtdbOff(t,"child_changed",h),this.realtimeAdapter.rtdbOff(t,"child_removed",m)}catch{}}})}};l.\u0275fac=function(e){return new(e||l)(A(Nt),A(ve),A(zi),A(j),A(F),A(Ai),A(St),A(Ue),A(ze),A(x),A(fe),A(Se),A(Ne),A(bt),A(pe),A(Ti),A(Ri),A(ji),A(Et))},l.\u0275prov=$({token:l,factory:l.\u0275fac,providedIn:"root"});let O=l;return O})();export{fe as a,Se as b,Ve as c,Ne as d,ze as e,gn as f,mn as g,vn as h,fn as i,Oi as j,Dt as k,x as l,Ct as m,pt as n,Nt as o,_t as p,$i as q,bt as r,zi as s,Mo as t};
|